change button gpio init to be like other programs, as part of gpio_init()

This commit is contained in:
true 2024-08-08 03:32:59 -07:00
parent 340cdcad89
commit 3a48cd8f06
2 changed files with 15 additions and 7 deletions

View File

@ -3,7 +3,8 @@
* GAT Addon Firmware * GAT Addon Firmware
* by true * by true
* *
* version 0.0.2 * version 0.0.3
* Last Update 20240808
* *
* code was made for different random addons I designed for dc32, * code was made for different random addons I designed for dc32,
* then adapted to each one. so things might be a mess. * then adapted to each one. so things might be a mess.
@ -85,7 +86,14 @@ void gpio_init()
gpio.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; gpio.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6;
GPIO_Init(GPIOC, &gpio); GPIO_Init(GPIOC, &gpio);
// BTN1, BTN2 will be handled by button handler // BTN1 (PC5) pull up, BTN2 (PC4) pull down
gpio.GPIO_Pin = GPIO_Pin_4;
gpio.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOC, &gpio);
gpio.GPIO_Pin = GPIO_Pin_5;
gpio.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOC, &gpio);
} }
int main(void) int main(void)
@ -102,7 +110,6 @@ int main(void)
// configure gpio pins, hard buttons (used for settings reset) // configure gpio pins, hard buttons (used for settings reset)
gpio_init(); gpio_init();
btn_init();
// get saved settings, or reset if BTN1 is pushed // get saved settings, or reset if BTN1 is pushed
i2c_init(); i2c_init();
@ -110,6 +117,7 @@ int main(void)
// configure hardware // configure hardware
adc_init(); adc_init();
btn_init();
led_init(); led_init();
// configure random // configure random

View File

@ -18,10 +18,10 @@ void btn_init()
{ {
uint8_t i; uint8_t i;
// configure GPIO // configure GPIO (now handled as part of main GPIO init function)
BTN_PORT->BSHR = (BTN1_PUPD << BTN1_PIN) | (BTN2_PUPD << BTN2_PIN); // BTN_PORT->BSHR = (BTN1_PUPD << BTN1_PIN) | (BTN2_PUPD << BTN2_PIN);
BTN_PORT->CFGLR &= ~((0xf << (BTN1_PIN*4)) | ((0xf << (BTN2_PIN*4)))); // BTN_PORT->CFGLR &= ~((0xf << (BTN1_PIN*4)) | ((0xf << (BTN2_PIN*4))));
BTN_PORT->CFGLR |= (0x8 << (BTN1_PIN*4)) | (0x8 << (BTN2_PIN*4)); // BTN_PORT->CFGLR |= (0x8 << (BTN1_PIN*4)) | (0x8 << (BTN2_PIN*4));
// configure default setup // configure default setup
for (i = 0; i < BTN_COUNT; i++) { for (i = 0; i < BTN_COUNT; i++) {