Skip to content

Powman fix #2499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions src/rp2_common/hardware_clocks/include/hardware/clocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,18 @@ void clocks_enable_resus(resus_callback_t resus_callback);
/*! \brief Output an optionally divided clock to the specified gpio pin.
* \ingroup hardware_clocks
*
* \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.
* \if rp2040_specific
* On RP2040 valid GPIOs are 21, 23, 24, 25.
* These GPIOs are connected to the GPOUT0-3 clock generators.
* \endif
* \if rp2350_specific
* On RP2350 valid GPIOs are 13, 15, 21, 23, 24, 25.
* GPIOs 13 and 21 are connected to the GPOUT0 clock generator.
* GPIOs 15 and 23 are connected to the GPOUT1 clock generator.
* GPIOs 24 and 25 are connected to the GPOUT2-3 clock generators.
* \endif
*
* \param gpio The GPIO pin to output the clock to.
* \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.
* \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
* and 1..2^16-1 on RP2350
Expand All @@ -410,7 +421,18 @@ void clock_gpio_init_int_frac16(uint gpio, uint src, uint32_t div_int, uint16_t
/*! \brief Output an optionally divided clock to the specified gpio pin.
* \ingroup hardware_clocks
*
* \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.
* * \if rp2040_specific
* On RP2040 valid GPIOs are 21, 23, 24, 25.
* These GPIOs are connected to the GPOUT0-3 clock generators.
* \endif
* \if rp2350_specific
* On RP2350 valid GPIOs are 13, 15, 21, 23, 24, 25.
* GPIOs 13 and 21 are connected to the GPOUT0 clock generator.
* GPIOs 15 and 23 are connected to the GPOUT1 clock generator.
* GPIOs 24 and 25 are connected to the GPOUT2-3 clock generators.
* \endif
*
* \param gpio The GPIO pin to output the clock to.
* \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.
* \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
* and 1..2^16-1 on RP2350
Expand All @@ -428,7 +450,18 @@ static inline void clock_gpio_init_int_frac(uint gpio, uint src, uint32_t div_in
/*! \brief Output an optionally divided clock to the specified gpio pin.
* \ingroup hardware_clocks
*
* \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.
* \if rp2040_specific
* On RP2040 valid GPIOs are 21, 23, 24, 25.
* These GPIOs are connected to the GPOUT0-3 clock generators.
* \endif
* \if rp2350_specific
* On RP2350 valid GPIOs are 13, 15, 21, 23, 24, 25.
* GPIOs 13 and 21 are connected to the GPOUT0 clock generator.
* GPIOs 15 and 23 are connected to the GPOUT1 clock generator.
* GPIOs 24 and 25 are connected to the GPOUT2-3 clock generators.
* \endif
*
* \param gpio The GPIO pin to output the clock to.
* \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.
* \param div The float amount to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock.
*/
Expand Down
10 changes: 9 additions & 1 deletion src/rp2_common/hardware_powman/powman.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ static void powman_timer_use_gpio(uint32_t gpio, uint32_t use, uint32_t using) {
if (was_running) powman_timer_stop();
invalid_params_if(HARDWARE_POWMAN, !((gpio == 12) || (gpio == 14) || (gpio == 20) || (gpio == 22)));
gpio_set_input_enabled(gpio, true);
powman_write(&powman_hw->ext_time_ref, gpio);
uint32_t source = 0; // 12
if (gpio == 20) {
source = 1;
} else if (gpio == 14) {
source = 2;
} else if (gpio == 22) {
source = 3;
}
powman_write(&powman_hw->ext_time_ref, source);
powman_set_bits(&powman_hw->timer, use);
if (was_running) {
powman_timer_start();
Expand Down
Loading