diff --git a/firmware/retro_tech_fw/user/ch32v00x_it.c b/firmware/retro_tech_fw/user/ch32v00x_it.c index 00614d5..030fc14 100644 --- a/firmware/retro_tech_fw/user/ch32v00x_it.c +++ b/firmware/retro_tech_fw/user/ch32v00x_it.c @@ -53,26 +53,24 @@ volatile uint32_t uptime; void SysTick_Handler(void) { - if (++ticnt > 0x7ff) { + if (++ticnt > 0x1ff) { ticnt = 0; uptime++; } // send new LEDs (1/128 duty) - if ((ticnt & 0xf) == 3) { + if ((ticnt & 0x3) == 0) { led_send(); } // process buttons (1/512 duty) - if ((ticnt & 0x3) == 0) { - btn_poll(); - } + btn_poll(); // process ADC (1/256 duty) - if ((ticnt & 0x07) == 1) { + if ((ticnt & 0x1) == 0) { adc_convert(); } - if ((ticnt & 0x07) == 2) { + if ((ticnt & 0x1) == 1) { adc_read(); } diff --git a/firmware/retro_tech_fw/user/main.c b/firmware/retro_tech_fw/user/main.c index 7a2175a..e58752c 100644 --- a/firmware/retro_tech_fw/user/main.c +++ b/firmware/retro_tech_fw/user/main.c @@ -30,7 +30,7 @@ void systick_init(void) { - SysTick->CMP = (SystemCoreClock / 2048) - 1; // we want a 2048Hz interrupt + SysTick->CMP = (SystemCoreClock / 512) - 1; // we want a 512Hz interrupt SysTick->CNT = 0; // clear counter SysTick->CTLR = 0xF; // start counter in /1 mode, enable interrupts, auto-reset counter SysTick->SR = 0; // clear count comparison flag @@ -82,13 +82,6 @@ void gpio_init() GPIO_Init(GPIOC, &gpio); } -/********************************************************************* - * @fn main - * - * @brief Main program. - * - * @return none - */ int main(void) { // configure core @@ -126,10 +119,10 @@ int main(void) while(1) { __WFI(); - // after sending LEDs, run our program + // after sending LEDs, run LED render program // to update the LED buffer for next time // we have approx 7ms to render... plenty of time - if ((ticnt & 0xf) == 3) { + if ((ticnt & 0x3) == 0) { ui_render(); } }