Default uart fixups #3185

Open
will-v-pi wants to merge 2 commits from default-uart-fixups into develop
will-v-pi commented 2026-09-07 04:35:12 -05:00 (Migrated from github.com)

Add UART_CLK_DEST_PERI() and UART_CLK_DEST_SYS() macros to use in low power

Document the pairing between stdio/stdout/stdin init/deinit functions

Fix and simplify the PICO_DEFAULT_UART_TX_PIN/RX_PIN checks

Fixes #3172 and #3173

Add `UART_CLK_DEST_PERI()` and `UART_CLK_DEST_SYS()` macros to use in low power Document the pairing between `stdio`/`stdout`/`stdin` `init`/`deinit` functions Fix and simplify the `PICO_DEFAULT_UART_TX_PIN`/`RX_PIN` checks Fixes #3172 and #3173
kilograham (Migrated from github.com) reviewed 2026-09-07 04:35:12 -05:00
lurch (Migrated from github.com) reviewed 2026-09-08 06:07:53 -05:00
@ -188,1 +210,4 @@
#define UART_CLK_DEST_SYS(uart) (uart_get_index(uart) ? CLK_DEST_SYS_UART1 : CLK_DEST_SYS_UART0)
#endif
/**
lurch (Migrated from github.com) commented 2026-09-08 06:07:53 -05:00
 * \brief Returns \ref clock_dest_num_t of the clk_sys dest for the given UART instance

?

```suggestion * \brief Returns \ref clock_dest_num_t of the clk_sys dest for the given UART instance ``` ?
lurch (Migrated from github.com) reviewed 2026-09-08 06:10:09 -05:00
@ -188,0 +198,4 @@
#define UART_CLK_DEST_PERI(uart) (uart_get_index(uart) ? CLK_DEST_PERI_UART1 : CLK_DEST_PERI_UART0)
#endif
/**
lurch (Migrated from github.com) commented 2026-09-08 06:10:08 -05:00

I don't know much about how the clocks work, but is "the clk_peri dest for the given UART instance" something that needs a better explanation? 🤷
(Does "dest" mean "destination", or something else?)

I don't know much about how the clocks work, but is "the clk_peri dest for the given UART instance" something that needs a better explanation? :shrug: (Does "dest" mean "destination", or something else?)
lurch (Migrated from github.com) reviewed 2026-09-08 06:12:54 -05:00
lurch (Migrated from github.com) commented 2026-09-08 06:12:53 -05:00

What does "disables for output" / "disables for input" mean? 😉

What does "disables for output" / "disables for input" mean? :wink:
lurch (Migrated from github.com) reviewed 2026-09-08 06:14:08 -05:00
lurch (Migrated from github.com) commented 2026-09-08 06:14:08 -05:00
 * This method disables PICO_DEFAULT_UART_RX_PIN for UART input (if defined), and leaves the pad isolated
```suggestion * This method disables PICO_DEFAULT_UART_RX_PIN for UART input (if defined), and leaves the pad isolated ```
will-v-pi (Migrated from github.com) reviewed 2026-09-08 06:17:03 -05:00
will-v-pi (Migrated from github.com) commented 2026-09-08 06:17:03 -05:00

I’m not sure - that’s pre-existing wording, I was just adding the comma. The only thing it actually does to the pins is isolate them on RP2350.

I’m not sure - that’s pre-existing wording, I was just adding the comma. The only thing it actually does to the pins is isolate them on RP2350.
will-v-pi (Migrated from github.com) reviewed 2026-09-08 06:19:41 -05:00
@ -188,0 +198,4 @@
#define UART_CLK_DEST_PERI(uart) (uart_get_index(uart) ? CLK_DEST_PERI_UART1 : CLK_DEST_PERI_UART0)
#endif
/**
will-v-pi (Migrated from github.com) commented 2026-09-08 06:19:40 -05:00

It means destination, but I used dest to match the abbreviation used in the enum clock_dest_num_t

It means destination, but I used dest to match the abbreviation used in the enum `clock_dest_num_t`
lurch (Migrated from github.com) reviewed 2026-09-08 06:22:22 -05:00
@ -25,3 +26,3 @@
#ifdef PICO_DEFAULT_UART_TX_PIN
#if (PICO_DEFAULT_UART_TX_PIN & 0x1) || (PICO_RP2040 && (PICO_DEFAULT_UART_TX_PIN & 0x2))
#if (PICO_DEFAULT_UART_TX_PIN % 2) || (PICO_RP2040 && (PICO_DEFAULT_UART_TX_PIN % 4))
#error "Specified PICO_DEFAULT_UART_TX_PIN does not support UART TX"
lurch (Migrated from github.com) commented 2026-09-08 06:22:22 -05:00

Is it also worth checking that PICO_DEFAULT_UART_TX_PIN is below a particular value? (e.g. #define PICO_DEFAULT_UART_TX_PIN 100 obviously wouldn't work 🙂 )
I guess it depends how much needs to be checked in the code, and how much can just be assumed to have been already checked by https://github.com/raspberrypi/pico-sdk/blob/develop/tools/check_board_header.py ?

Is it also worth checking that PICO_DEFAULT_UART_TX_PIN is below a particular value? (e.g. `#define PICO_DEFAULT_UART_TX_PIN 100` obviously wouldn't work :slightly_smiling_face: ) I guess it depends how much needs to be checked in the code, and how much can just be assumed to have been already checked by https://github.com/raspberrypi/pico-sdk/blob/develop/tools/check_board_header.py ?
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'default-uart-fixups:default-uart-fixups'
git switch 'default-uart-fixups'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'develop'
git merge --no-ff 'default-uart-fixups'
git switch 'default-uart-fixups'
git rebase 'develop'
git switch 'develop'
git merge --ff-only 'default-uart-fixups'
git switch 'default-uart-fixups'
git rebase 'develop'
git switch 'develop'
git merge --no-ff 'default-uart-fixups'
git switch 'develop'
git merge --squash 'default-uart-fixups'
git switch 'develop'
git merge --ff-only 'default-uart-fixups'
git switch 'develop'
git merge 'default-uart-fixups'
git push origin 'develop'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!3185
No description provided.