Add pin_shutdown()

Portions of pin_setup() that establish a safe, low-power state are moved
into the new pin_shutdown(). Use pin_shutdown() to prepare for sleep or
reset or prior to calling pin_setup().
This commit is contained in:
Michael Ossmann
2025-12-16 21:52:53 -05:00
parent 44db1674d7
commit 6f862a1349
4 changed files with 23 additions and 16 deletions

View File

@@ -1021,7 +1021,7 @@ void ssp1_set_mode_ice40(void)
}
#endif
void pin_setup(void)
void pin_shutdown(void)
{
/* Configure all GPIO as Input (safe state) */
gpio_init();
@@ -1068,20 +1068,6 @@ void pin_setup(void)
scu_pinmux(SCU_PINMUX_USB_LED1, SCU_CONF_FUNCTION3);
#endif
led_off(0);
led_off(1);
led_off(2);
#ifdef RAD1O
led_off(3);
#endif
gpio_output(&gpio_led[0]);
gpio_output(&gpio_led[1]);
gpio_output(&gpio_led[2]);
#if (defined RAD1O || defined PRALINE)
gpio_output(&gpio_led[3]);
#endif
#ifdef PRALINE
disable_1v2_power();
disable_3v3aux_power();
@@ -1129,7 +1115,6 @@ void pin_setup(void)
scu_pinmux(SCU_PINMUX_GPIO3_10, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
scu_pinmux(SCU_PINMUX_GPIO3_11, SCU_GPIO_PDN | SCU_CONF_FUNCTION0);
#endif
#ifdef PRALINE
@@ -1171,6 +1156,24 @@ void pin_setup(void)
/* enable input on SCL and SDA pins */
SCU_SFSI2C0 = SCU_I2C0_NOMINAL;
}
/* Run after pin_shutdown() and prior to enabling power supplies. */
void pin_setup(void)
{
led_off(0);
led_off(1);
led_off(2);
#ifdef RAD1O
led_off(3);
#endif
gpio_output(&gpio_led[0]);
gpio_output(&gpio_led[1]);
gpio_output(&gpio_led[2]);
#if (defined RAD1O || defined PRALINE)
gpio_output(&gpio_led[3]);
#endif
ssp1_set_mode_max283x();

View File

@@ -421,6 +421,7 @@ void ssp1_set_mode_max2831(void);
void ssp1_set_mode_ice40(void);
#endif
void pin_shutdown(void);
void pin_setup(void);
#ifdef PRALINE

View File

@@ -262,6 +262,8 @@ int main(void)
selftest.report.pass = true;
detect_hardware_platform();
pin_shutdown();
delay_us_at_mhz(10000, 96);
pin_setup();
#ifndef PRALINE
enable_1v8_power();

View File

@@ -130,6 +130,7 @@ usb_request_status_t usb_vendor_request_reset(
const usb_transfer_stage_t stage)
{
if (stage == USB_TRANSFER_STAGE_SETUP) {
pin_shutdown();
#ifdef HACKRF_ONE
/*
* Set boot pins as inputs so that the bootloader reads them