diff --git a/firmware/retro_tech_fw/user/main.c b/firmware/retro_tech_fw/user/main.c index 156a888..ab8db61 100644 --- a/firmware/retro_tech_fw/user/main.c +++ b/firmware/retro_tech_fw/user/main.c @@ -3,7 +3,8 @@ * GAT Addon Firmware * by true * - * version 0.0.2 + * version 0.0.3 + * Last Update 20240808 * * code was made for different random addons I designed for dc32, * 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_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) @@ -102,7 +110,6 @@ int main(void) // configure gpio pins, hard buttons (used for settings reset) gpio_init(); - btn_init(); // get saved settings, or reset if BTN1 is pushed i2c_init(); @@ -110,6 +117,7 @@ int main(void) // configure hardware adc_init(); + btn_init(); led_init(); // configure random diff --git a/firmware/retro_tech_fw/user/src/btn.c b/firmware/retro_tech_fw/user/src/btn.c index 86b3470..f6023e3 100644 --- a/firmware/retro_tech_fw/user/src/btn.c +++ b/firmware/retro_tech_fw/user/src/btn.c @@ -18,10 +18,10 @@ void btn_init() { uint8_t i; - // configure GPIO - 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 |= (0x8 << (BTN1_PIN*4)) | (0x8 << (BTN2_PIN*4)); + // configure GPIO (now handled as part of main GPIO init function) + // 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 |= (0x8 << (BTN1_PIN*4)) | (0x8 << (BTN2_PIN*4)); // configure default setup for (i = 0; i < BTN_COUNT; i++) {