107 lines
2.0 KiB
C
Raw Normal View History

2020-10-18 22:02:17 +02:00
#include <string.h>
#include <stdint.h>
2020-10-24 19:34:30 +02:00
#include <stdbool.h>
2020-10-18 22:02:17 +02:00
#include <stdlib.h>
2020-10-29 15:44:13 +01:00
2020-10-18 22:02:17 +02:00
#include <main.h>
#include <usart.h>
2020-10-31 21:25:49 +01:00
#include <adc.h>
2020-11-05 14:38:10 +01:00
#include <spi.h>
2020-10-18 22:02:17 +02:00
2020-10-29 15:44:13 +01:00
#include <PontCoopScheduler.h>
2020-11-03 10:05:45 +01:00
#include <show.h>
2020-10-27 15:12:19 +01:00
#include <loopCtrl.h>
2020-10-28 19:40:08 +01:00
#include <mbusComm.h>
2020-10-29 15:44:13 +01:00
#include <logger.h>
2020-10-31 21:25:49 +01:00
#include <frontend.h>
2020-11-05 14:38:10 +01:00
#include <eeprom.h>
2020-11-08 15:56:14 +01:00
#include <wizHelper.h>
2020-11-14 21:15:33 +01:00
#include <mqttComm.h>
2020-11-15 23:51:48 +01:00
#include <cmdHandler.h>
2020-11-19 19:09:22 +01:00
#include <oled.h>
2020-11-15 23:51:48 +01:00
2020-11-10 15:56:07 +01:00
2020-10-18 22:02:17 +02:00
void my_setup_1() {
2020-10-27 15:12:19 +01:00
schInit();
2020-10-29 15:44:13 +01:00
logInit();
2020-11-17 15:04:34 +01:00
showInit();
2020-10-18 22:02:17 +02:00
}
void my_errorHandler() {
2020-11-03 10:05:45 +01:00
show(LED_RED, ON);
2020-10-18 22:02:17 +02:00
}
2020-11-03 14:31:59 +01:00
2020-10-18 22:02:17 +02:00
void my_setup_2() {
2020-11-03 10:05:45 +01:00
show(LED_RED, OFF);
2020-11-17 15:04:34 +01:00
show(LED_GREEN, BLINK);
2020-11-17 12:01:15 +01:00
logMsg("Application starting");
2020-10-27 15:12:19 +01:00
2020-11-19 19:09:22 +01:00
oledInit();
2020-11-20 17:22:49 +01:00
oledClearAllScreens();
2020-11-20 12:20:30 +01:00
oledSetActiveScreen(OLED_SCREEN0);
oledPrint(OLED_SCREEN0, "App starting");
2020-11-19 19:09:22 +01:00
2020-11-05 14:38:10 +01:00
eepromInit();
2020-11-20 12:20:30 +01:00
oledPrint(OLED_SCREEN0, "eeprom init");
2020-11-05 14:38:10 +01:00
2020-11-08 15:56:14 +01:00
wizInit();
2020-11-20 12:20:30 +01:00
oledPrint(OLED_SCREEN0, "network init");
2020-11-16 14:56:05 +01:00
mqttCommInit();
2020-11-20 12:20:30 +01:00
oledPrint(OLED_SCREEN0, "mqtt init");
2020-11-15 23:51:48 +01:00
cmdHandlerInit();
2020-11-20 12:20:30 +01:00
oledPrint(OLED_SCREEN0, "cmdhandler init");
2020-11-10 15:56:07 +01:00
2020-11-16 14:56:05 +01:00
frontendInit();
frontendSetThreshold(240);
2020-11-20 12:20:30 +01:00
oledPrint(OLED_SCREEN0, "frontend init");
2020-11-08 15:56:14 +01:00
2020-11-17 15:38:11 +01:00
mbusCommInit();
2020-11-20 12:20:30 +01:00
oledPrint(OLED_SCREEN0, "Meterbus init");
oledPrint(OLED_SCREEN0, "App running");
2020-10-18 22:02:17 +02:00
}
void my_loop() {
2020-11-24 14:13:51 +01:00
show(DEBUG_2, TOGGLE);
2020-10-27 15:12:19 +01:00
schExec();
2020-11-17 15:15:28 +01:00
#ifndef LOGGER_OUTPUT_BY_INTERRUPT
logExec();
#endif //LOGGER_OUTPUT_BY_INTERRUPT
2020-11-23 19:30:57 +01:00
mbusCommExec();
2020-10-18 22:02:17 +02:00
}
void SYSTICK_Callback() {
2020-10-27 15:12:19 +01:00
schUpdate();
2020-10-18 22:02:17 +02:00
}
2020-10-27 22:28:03 +01:00
void HAL_GPIO_EXTI_Callback(uint16_t pin) {
if (pin == Loop_Status_Pin) {
loopStatusCallback();
}
2020-10-29 15:44:13 +01:00
}
2020-10-31 21:25:49 +01:00
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
if (hadc == &frontendAdc) {
frontendAdcCallback(hadc);
}
}
2020-11-02 15:02:39 +01:00
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
2020-11-17 15:15:28 +01:00
#ifdef LOGGER_OUTPUT_BY_INTERRUPT
2020-11-24 13:18:18 +01:00
if (huart == &debugUart) {
2020-11-10 16:30:26 +01:00
debugTxCpltCallback(huart);
2020-11-02 15:02:39 +01:00
}
2020-11-17 15:15:28 +01:00
#endif //LOGGER_OUTPUT_BY_INTERRUPT
2020-11-02 15:41:07 +01:00
}
2020-11-05 14:38:10 +01:00
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) {
if (hspi == &eepromSpi) {
eepromSpiTxCpltCallback(hspi);
}
}