Skip to content

Commit 128396a

Browse files
committed
some review fixes
1 parent 5dd0e1b commit 128396a

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

src/rp2_common/hardware_clocks/clocks.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,7 @@ void clock_gpio_init_int_frac16(uint gpio, uint src, uint32_t div_int, uint16_t
245245
invalid_params_if(HARDWARE_CLOCKS, true);
246246
}
247247

248-
#if !PICO_RP2040 // assert currently broken on RP2040, but we know that hardware has 16-bit integer part
249-
static_assert(CLOCKS_CLK_GPOUT0_DIV_INT_MSB - CLOCKS_CLK_GPOUT0_DIV_INT_LSB == 15, "");
250-
#endif
251-
invalid_params_if(HARDWARE_CLOCKS, div_int >> 16);
248+
invalid_params_if(HARDWARE_CLOCKS, div_int >> (CLOCKS_CLK_GPOUT0_DIV_INT_MSB - CLOCKS_CLK_GPOUT0_DIV_INT_LSB + 1));
252249
// Set up the gpclk generator
253250
clocks_hw->clk[gpclk].ctrl = (src << CLOCKS_CLK_GPOUT0_CTRL_AUXSRC_LSB) |
254251
CLOCKS_CLK_GPOUT0_CTRL_ENABLE_BITS;

src/rp2_common/hardware_clocks/include/hardware/clocks.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ void clocks_enable_resus(resus_callback_t resus_callback);
353353
*
354354
* \param gpio The GPIO pin to output the clock to. Valid GPIOs are: 21, 23, 24, 25. These GPIOs are connected to the GPOUT0-3 clock generators.
355355
* \param src The source clock. See the register field CLOCKS_CLK_GPOUT0_CTRL_AUXSRC for a full list. The list is the same for each GPOUT clock generator.
356-
* \param div_int The integer part of the value to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock. this is in range of 1..2^24-1.
356+
* \param div_int The integer part of the value to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock. This is in range of 1..2^24-1 on RP2040
357+
* and 1..2^16-1 on RP2350
357358
* \param div_frac16 The fractional part of the value to divide the source clock by. This is in range of 0..65536 (/65536).
358359
*/
359360
void clock_gpio_init_int_frac16(uint gpio, uint src, uint32_t div_int, uint16_t div_frac16);
@@ -363,8 +364,8 @@ void clock_gpio_init_int_frac16(uint gpio, uint src, uint32_t div_int, uint16_t
363364
*
364365
* \param gpio The GPIO pin to output the clock to. Valid GPIOs are: 21, 23, 24, 25. These GPIOs are connected to the GPOUT0-3 clock generators.
365366
* \param src The source clock. See the register field CLOCKS_CLK_GPOUT0_CTRL_AUXSRC for a full list. The list is the same for each GPOUT clock generator.
366-
* \param div_int The integer part of the value to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock. this is in range of 1..2^24-1.
367-
* \param div_frac8 The fractional part of the value to divide the source clock by. This is in range of 0..255 (/256).
367+
* \param div_int The integer part of the value to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock. This is in range of 1..2^24-1 on RP2040
368+
* and 1..2^16-1 on RP2350
368369
*/
369370
static inline void clock_gpio_init_int_frac8(uint gpio, uint src, uint32_t div_int, uint8_t div_frac8) {
370371
return clock_gpio_init_int_frac16(gpio, src, div_int, (uint16_t)(div_frac8 << 8u));

src/rp2_common/hardware_pio/include/hardware/pio.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,9 +1691,9 @@ static inline void pio_sm_set_clkdiv(PIO pio, uint sm, float div) {
16911691
check_pio_param(pio);
16921692
check_sm_param(sm);
16931693
uint32_t div_int;
1694-
uint8_t div_frac;
1695-
pio_calculate_clkdiv8_from_float(div, &div_int, &div_frac);
1696-
pio_sm_set_clkdiv_int_frac8(pio, sm, div_int, div_frac);
1694+
uint8_t div_frac8;
1695+
pio_calculate_clkdiv8_from_float(div, &div_int, &div_frac8);
1696+
pio_sm_set_clkdiv_int_frac8(pio, sm, div_int, div_frac8);
16971697
}
16981698

16991699
/*! \brief Clear a state machine's TX and RX FIFOs

src/rp2_common/hardware_pwm/include/hardware/pwm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static inline void pwm_config_set_clkdiv_int_frac(pwm_config *c, uint8_t div_int
186186
* \ingroup hardware_pwm
187187
*
188188
* \param c PWM configuration struct to modify
189-
* \param div_int Integer value to reduce counting rate by. Must be greater than or equal to 1 annd less than 256.
189+
* \param div_int Integer value to reduce counting rate by. Must be greater than or equal to 1 and less than 256.
190190
*
191191
* If the divide mode is free-running, the PWM counter runs at clk_sys / div.
192192
* Otherwise, the divider reduces the rate of events seen on the B pin input (level or edge)

src/rp2_common/pico_cyw43_driver/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ if (EXISTS ${PICO_CYW43_DRIVER_PATH}/${CYW43_DRIVER_TEST_FILE})
8484
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_INT, integer component of pio clock divider used for cyw43 comms, type=int, default=2, group=pico_cyw43_driver
8585
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_INT=${CYW43_PIO_CLOCK_DIV_INT})
8686
endif()
87-
if (CYW43_PIO_CLOCK_DIV_FRAC)
88-
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_FRAC, fractional component of pio clock divider used for cyw43 comms, type=int, default=0, group=pico_cyw43_driver
89-
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_FRAC=${CYW43_PIO_CLOCK_DIV_FRAC})
87+
if (CYW43_PIO_CLOCK_DIV_FRAC8)
88+
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_FRAC, fractional component of pio clock divider used for cyw43 comms in range 0-255, type=int, default=0, group=pico_cyw43_driver
89+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_FRAC8=${CYW43_PIO_CLOCK_DIV_FRAC8})
9090
endif()
9191
if (CYW43_PIO_CLOCK_DIV_DYNAMIC)
9292
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_DYNAMIC, flag used to enable dynamic pio clock divider API, type=bool, default=false, group=pico_cyw43_driver

0 commit comments

Comments
 (0)