main comment cleanup

This commit is contained in:
true 2025-07-25 20:36:27 -07:00
parent efaeb803a5
commit 5267625e30

View File

@ -36,6 +36,7 @@
/*
void systick_init(void) void systick_init(void)
{ {
SysTick->CMP = (SystemCoreClock / 512) - 1; // we want a 512Hz interrupt SysTick->CMP = (SystemCoreClock / 512) - 1; // we want a 512Hz interrupt
@ -45,9 +46,12 @@ void systick_init(void)
NVIC_EnableIRQ(SysTicK_IRQn); // enable interrupt NVIC_EnableIRQ(SysTicK_IRQn); // enable interrupt
} }
*/
void awu_init(void) void awu_init(void)
{ {
// these magic numbers set a ~498.6Hz update rate
// 48000000 (HSI) / 1024 / Prescale / Window
AWU_SetPrescaler(AWU_Prescaler_2); AWU_SetPrescaler(AWU_Prescaler_2);
AWU_SetWindowValue(47); AWU_SetWindowValue(47);
AutoWakeUpCmd(ENABLE); AutoWakeUpCmd(ENABLE);
@ -64,10 +68,10 @@ void gpio_init()
{ {
GPIO_InitTypeDef gpio = {0}; 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; 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_Mode = GPIO_Mode_IPU;
gpio.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6; gpio.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
GPIO_Init(GPIOA, &gpio); GPIO_Init(GPIOA, &gpio);
@ -78,19 +82,19 @@ void gpio_init()
GPIOA->BCR = GPIO_Pin_7; GPIOA->BCR = GPIO_Pin_7;
GPIO_Init(GPIOA, &gpio); GPIO_Init(GPIOA, &gpio);
// potentiometer (PB1, A9) // potentiometer (PB1; A9)
gpio.GPIO_Pin = GPIO_Pin_1; gpio.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOB, &gpio); GPIO_Init(GPIOB, &gpio);
// lightsense LED anode // lightsense LED anode (PB7)
gpio.GPIO_Mode = GPIO_Mode_Out_PP; gpio.GPIO_Mode = GPIO_Mode_Out_PP;
gpio.GPIO_Pin = GPIO_Pin_7; gpio.GPIO_Pin = GPIO_Pin_7;
GPIOB->BCR = GPIO_Pin_7; GPIOB->BCR = GPIO_Pin_7;
GPIO_Init(GPIOB, &gpio); 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) // EEP_WP EEPROM write protect (PA9) (active high)
// IS_SDB IS31FL3729 shutdown pin (PC3) (active low) // IS_SDB IS31FL3729 shutdown pin (PC3) (active low)
@ -102,23 +106,25 @@ void gpio_init()
gpio.GPIO_Pin = GPIO_Pin_3; gpio.GPIO_Pin = GPIO_Pin_3;
GPIO_Init(GPIOC, &gpio); 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_Mode = GPIO_Mode_AF_PP;
gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
GPIO_Init(GPIOA, &gpio); 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; gpio.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIOA->BCR = GPIO_Pin_0 | GPIO_Pin_1; GPIOA->BCR = GPIO_Pin_0 | GPIO_Pin_1;
gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_Init(GPIOA, &gpio); 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_Mode = GPIO_Mode_IPU;
gpio.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; gpio.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_Init(GPIOA, &gpio); GPIO_Init(GPIOA, &gpio);
} }
// here we go
int main(void) int main(void)
{ {
// configure core // configure core
@ -130,7 +136,7 @@ int main(void)
RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC |
RCC_APB2Periph_ADC1 | RCC_APB2Periph_TIM1, ENABLE); 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(); gpio_init();
// get saved settings, or reset if BTN1 is pushed // get saved settings, or reset if BTN1 is pushed
@ -148,7 +154,7 @@ int main(void)
// configure UI // configure UI
ui_init(); ui_init();
// configure auto-wakeup to run at 498Hz // configure auto-wakeup to run at ~498Hz
awu_init(); awu_init();
// set up LEDs initially // set up LEDs initially