#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void my_setup_1() { schInit(); logInit(); showInit(); } void my_errorHandler() { show(LED_RED, ON); } void second_tick(void *handle) { coloredMsg(LOG_GREEN, "Tick"); } void my_setup_2() { show(LED_RED, OFF); show(LED_GREEN, BLINK); logMsg("Application starting"); eepromInit(); configInit(); wizInit(); // cmdHandlerInit(); schAdd(second_tick, NULL, 0, 60*1000); // HAL_TIM_IC_Start_IT(&mainsCnt, TIM_CHANNEL_1); logMsg("Application running"); } void my_loop() { // show(DEBUG_2, TOGGLE); schExec(); #ifndef LOGGER_OUTPUT_BY_INTERRUPT logExec(); #endif //LOGGER_OUTPUT_BY_INTERRUPT } void SYSTICK_Callback() { schUpdate(); } void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) { #ifdef LOGGER_OUTPUT_BY_INTERRUPT if (huart == &debugUart) { debugTxCpltCallback(huart); } #endif //LOGGER_OUTPUT_BY_INTERRUPT } void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) { if (hspi == &eepromSpi) { eepromSpiTxCpltCallback(hspi); } } void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) { static uint8_t state = 0; static uint32_t savedV = 0; if (htim == &mainsCnt) { uint32_t v = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1); if (state == 0) { show(DEBUG_2, ON); savedV = v; state = 1; } else if (state == 1) { show(DEBUG_2, OFF); uint32_t captured = (savedV < v) ? (v - savedV) : ((htim->Init.Period - savedV) + v); double f = 1.0 / ((double)captured) * 1.0e6; logMsg("CCR: %ld, %f", captured, f); state = 0; } else { state = 0; } } }