From 5267625e30e1630525a919636365927343cc0924 Mon Sep 17 00:00:00 2001 From: true Date: Fri, 25 Jul 2025 20:36:27 -0700 Subject: [PATCH] main comment cleanup --- firmware/retro_tech_fw/code/main.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/firmware/retro_tech_fw/code/main.c b/firmware/retro_tech_fw/code/main.c index 7589d05..5acbaba 100644 --- a/firmware/retro_tech_fw/code/main.c +++ b/firmware/retro_tech_fw/code/main.c @@ -36,6 +36,7 @@ +/* void systick_init(void) { SysTick->CMP = (SystemCoreClock / 512) - 1; // we want a 512Hz interrupt @@ -45,9 +46,12 @@ void systick_init(void) NVIC_EnableIRQ(SysTicK_IRQn); // enable interrupt } +*/ void awu_init(void) { + // these magic numbers set a ~498.6Hz update rate + // 48000000 (HSI) / 1024 / Prescale / Window AWU_SetPrescaler(AWU_Prescaler_2); AWU_SetWindowValue(47); AutoWakeUpCmd(ENABLE); @@ -64,10 +68,10 @@ void gpio_init() { GPIO_InitTypeDef gpio = {0}; - // only one GPIO speed on this bad boy + // only one GPIO speed on this bad boy, and it must be defined gpio.GPIO_Speed = GPIO_Speed_50MHz; - // jogwheel digital inputs, active low (PA4-PA6) + // jogwheel digital inputs (PA4-PA6) (active low) gpio.GPIO_Mode = GPIO_Mode_IPU; gpio.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6; GPIO_Init(GPIOA, &gpio); @@ -78,19 +82,19 @@ void gpio_init() GPIOA->BCR = GPIO_Pin_7; GPIO_Init(GPIOA, &gpio); - // potentiometer (PB1, A9) + // potentiometer (PB1; A9) gpio.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIOB, &gpio); - // lightsense LED anode + // lightsense LED anode (PB7) gpio.GPIO_Mode = GPIO_Mode_Out_PP; gpio.GPIO_Pin = GPIO_Pin_7; GPIOB->BCR = GPIO_Pin_7; GPIO_Init(GPIOB, &gpio); - // USB (unused in application) - PC16, PC17 + // USB (unused in application...for now) (PC16, PC17) - // debug (not changed in application) - PC18, PC19 + // debug (not changed in application) (PC18, PC19) // EEP_WP EEPROM write protect (PA9) (active high) // IS_SDB IS31FL3729 shutdown pin (PC3) (active low) @@ -102,23 +106,25 @@ void gpio_init() gpio.GPIO_Pin = GPIO_Pin_3; GPIO_Init(GPIOC, &gpio); - // I2C SCL, SCA for addon header + // I2C SDA, SCL for addon header (PA10, PA11) gpio.GPIO_Mode = GPIO_Mode_AF_PP; gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; GPIO_Init(GPIOA, &gpio); - // software I2C, SCL for on-board devices + // software I2C SDA, SCL for on-board devices (PA0, PA1) gpio.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIOA->BCR = GPIO_Pin_0 | GPIO_Pin_1; gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_Init(GPIOA, &gpio); - // UART RX/TX on addon header; not currently used + // UART RX/TX on addon header (not currently used) (PA2, PA3) gpio.GPIO_Mode = GPIO_Mode_IPU; gpio.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; GPIO_Init(GPIOA, &gpio); } + +// here we go int main(void) { // configure core @@ -130,7 +136,7 @@ int main(void) RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_ADC1 | RCC_APB2Periph_TIM1, ENABLE); - // configure gpio pins, hard buttons (used for settings reset) + // configure gpio pins, including buttons (need button for settings reset) gpio_init(); // get saved settings, or reset if BTN1 is pushed @@ -148,7 +154,7 @@ int main(void) // configure UI ui_init(); - // configure auto-wakeup to run at 498Hz + // configure auto-wakeup to run at ~498Hz awu_init(); // set up LEDs initially