diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/radio-controller.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/radio-controller.cpp b/src/radio-controller.cpp index c71aaa5..9795574 100644 --- a/src/radio-controller.cpp +++ b/src/radio-controller.cpp @@ -1,13 +1,18 @@ #include "radio-controller.h" #include "stm32f1xx_hal.h" -#include <cstring> #include "mcu/arm/semihosting.h" +#include "mcu/stm32cubemx/uart.h" +#include "mcu/stm32cubemx/debug.h" #ifdef HAL_IWDG_MODULE_ENABLED extern IWDG_HandleTypeDef hiwdg; #endif extern TIM_HandleTypeDef htim1; +extern UART_HandleTypeDef huart2; + +mcu::stm32cubemx::uart::uart_port uart2(&huart2); +mcu::stm32cubemx::debug::dbg<100> dbg(uart2); void main_pre_init() { } @@ -15,21 +20,33 @@ void main_pre_init() { void main_post_init() { semihosting::enable(); - HAL_TIM_Base_Start(&htim1); + 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() { -// printf("hello world!"); 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); - printf("cnt=%lu, now=%lu\n", cnt, now); + 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 |