#include "radio-controller.h" #include "stm32f1xx_hal.h" #include "mcu/arm/semihosting.h" #include "mcu/stm32cube/uart.h" #include "mcu/stm32cube/debug.h" #ifdef HAL_IWDG_MODULE_ENABLED extern IWDG_HandleTypeDef hiwdg; #endif extern TIM_HandleTypeDef htim1; extern UART_HandleTypeDef huart2; mcu::stm32cube::uart::uart_port uart2(&huart2); mcu::stm32cube::debug::dbg<100> dbg(uart2); void main_pre_init() { } void main_post_init() { bool debugger_connected = (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0; if (debugger_connected) { semihosting::enable(); } printf("Radio Controller\n"); HAL_TIM_Base_Start_IT(&htim1); // HAL_TIM_IC_Start_IT(&htim1, 1); uart2.enable(); } static uint32_t tick_next = 0; static bool seen_high = false; void main_loop() { auto now = HAL_GetTick(); if (now >= tick_next) { // puts(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_8) ? "1" : "0"); uint32_t cnt = __HAL_TIM_GET_COUNTER(&htim1); dbg.println("cnt=%lu, now=%lu, seen_high=%d", cnt, now, seen_high); tick_next += 1000; seen_high = false; dbg.println("wat"); } seen_high |= HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_8); #ifdef HAL_IWDG_MODULE_ENABLED HAL_IWDG_Refresh(&hiwdg); #endif } void it_tim1() { ; }