configure unused GPIO, flash lightsense LED during boot for testing
This commit is contained in:
parent
1bc5289f4a
commit
33a42edc7f
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue