Skip to content

Commit d3420a7

Browse files
committed
update previous fix as 1.0 < clkdiv < 2.0 IS supported on RP2350
1 parent f407f5b commit d3420a7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/rp2_common/hardware_clocks/clocks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ bool clock_configure(clock_handle_t clock, uint32_t src, uint32_t auxsrc, uint32
102102
return false;
103103

104104
uint32_t div = (uint32_t)((((uint64_t) src_freq) << CLOCKS_CLK_GPOUT0_DIV_INT_LSB) / freq);
105-
// only clock divider of 1, or >= 2 are supported
105+
#if PICO_RP2040
106+
// on RP2040 only clock divider of 1, or >= 2 are supported
106107
if (div < (2u << CLOCKS_CLK_GPOUT0_DIV_INT_LSB)) {
107108
div = (1u << CLOCKS_CLK_GPOUT0_DIV_INT_LSB);
108109
}
110+
#endif
109111
uint32_t actual_freq = (uint32_t) ((((uint64_t) src_freq) << CLOCKS_CLK_GPOUT0_DIV_INT_LSB) / div);
110112

111113
clock_configure_internal(clock, src, auxsrc, actual_freq, div);

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,22 @@ typedef clock_num_t clock_handle_t;
269269
* frequency to be specified, and will set the clock divider to achieve the exact or higher frequency
270270
* achievable, with the maximum being the src_freq.
271271
*
272-
* Note: That the clock hardware only support divisors of exactly 1 or 2.0->65535.0
272+
* \if rp2350_specific
273+
* Note: That the RP2350 clock hardware supports divisors from 1.0->65535.0 in steps of 1/65536
273274
*
274-
* See the tables in the description for details on the possible values for clock sources.
275+
* \endif
276+
* \if rp2030_specific
277+
* Note: That the RP2040 clock hardware only support divisors of exactly 1.0 or 2.0->65535.0 in steps of 1/256
278+
* \endif
275279
*
280+
* See the tables in the description for details on the possible values for clock sources.
276281
*
277282
* \param clock The clock to configure
278283
* \param src The main clock source, can be 0.
279284
* \param auxsrc The auxiliary clock source, which depends on which clock is being set. Can be 0
280285
* \param src_freq Frequency of the input clock source
281286
* \param freq Requested frequency
287+
* \return true if the clock is updated, false if freq > src_freq
282288
*/
283289
bool clock_configure(clock_handle_t clock, uint32_t src, uint32_t auxsrc, uint32_t src_freq, uint32_t freq);
284290

0 commit comments

Comments
 (0)