@@ -577,6 +577,42 @@ static inline bool set_sys_clock_khz(uint32_t freq_khz, bool required) {
577
577
return false;
578
578
}
579
579
580
+ #define GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040 (gpio , default_clk_handle ) \
581
+ ((gpio) == 21 ? clk_gpout0 : \
582
+ ((gpio) == 23 ? clk_gpout1 : \
583
+ ((gpio) == 24 ? clk_gpout2 : \
584
+ ((gpio) == 25 ? clk_gpout3 : \
585
+ (default_clk_handle)))))
586
+
587
+ #define GPIO_TO_GPOUT_CLOCK_HANDLE_RP2350 (gpio , default_clk_handle ) \
588
+ ((gpio) == 13 ? clk_gpout0 : \
589
+ ((gpio) == 15 ? clk_gpout1 : \
590
+ (GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040(gpio, default_clk_handle))))
591
+
592
+ /**
593
+ * \def GPIO_TO_GPOUT_CLOCK_HANDLE(gpio, default_clk_handle)
594
+ * \ingroup hardware_clocks
595
+ * \hideinitializer
596
+ * \brief Returns the GPOUT clock number associated with a particular GPIO if there is one, or default_clk_handle otherwise
597
+ *
598
+ * Note this macro is intended to resolve at compile time, and does no parameter checking
599
+ */
600
+ #ifndef GPIO_TO_GPOUT_CLOCK_HANDLE
601
+ #if PICO_RP2040
602
+ #define GPIO_TO_GPOUT_CLOCK_HANDLE GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040
603
+ #else
604
+ #define GPIO_TO_GPOUT_CLOCK_HANDLE GPIO_TO_GPOUT_CLOCK_HANDLE_RP2350
605
+ #endif
606
+ #endif
607
+
608
+ /**
609
+ * \brief return the associated GPOUT clock for a given GPIO if any
610
+ * \ingroup hardware_clocks
611
+ * \return the GPOUT clock number associated with a particular GPIO or default_clk_handle otherwise
612
+ */
613
+ static inline clock_handle_t gpio_to_gpout_clock_handle (uint gpio , clock_handle_t default_clk_handle ) {
614
+ return GPIO_TO_GPOUT_CLOCK_HANDLE (gpio , ({invalid_params_if (HARDWARE_CLOCKS , true); default_clk_handle ;}));
615
+ }
580
616
#ifdef __cplusplus
581
617
}
582
618
#endif
0 commit comments