From 33a42edc7f949c2f87e5d50518200b76521ba0af Mon Sep 17 00:00:00 2001 From: true Date: Mon, 28 Oct 2024 08:05:03 -0700 Subject: [PATCH] configure unused GPIO, flash lightsense LED during boot for testing --- nametag8_CH592/user/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nametag8_CH592/user/main.c b/nametag8_CH592/user/main.c index ce25a60..6453744 100644 --- a/nametag8_CH592/user/main.c +++ b/nametag8_CH592/user/main.c @@ -146,6 +146,21 @@ void systick_init(void) SysTick->CTLR = SysTick_CTLR_STCLK | SysTick_CTLR_STE; // enable counter in /1 mode } +void gpio_init() +{ + // by default pins are floating inputs + + // lightsense pins anode (PA5), cathode (PA14) low outputs + R32_PA_DIR = (1 << 5) | (1 << 14); + + // configure unused as pullup + R8_PA_PU_1 = 0x8f; // unused PA8-11, PA15 + R8_PB_PU_2 = 0x80; // unused PB23 + + // disable input buffer on unused pins + R32_PIN_CONFIG2 = 0x0200cf00; // also PA14, only ever an input +} + static void idle_clear() { @@ -372,6 +387,9 @@ int main() PWR_DCDCCfg(ENABLE); // enable DC-DC converter; brings significant power saving + gpio_init(); // configure default states for GPIO pins + R32_PA_OUT |= (1 << 14); // enable lightsense LED during boot for testing + i2c_init(); // get i2c initialized since most stuff will need it uconf_load(); // read the user config @@ -399,6 +417,8 @@ int main() rtcisr_init(); // configure main program tick interrupt + R32_PA_CLR = (1 << 14); // turn off lightsense LED now + lowprio_task(); // start the low priority task loop }