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-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-10-28 19:40:08 +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-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-10-25 15:37:16 +01:00
|
|
|
void helloMeterbus(void *handle) {
|
2020-11-03 14:00:54 +01:00
|
|
|
static t_mbusDevice device = {
|
|
|
|
.deviceName = "Total Power",
|
|
|
|
.address = 80,
|
|
|
|
.consideredField = {
|
|
|
|
{ .label = "energy", .index = 0 },
|
2020-11-03 14:10:09 +01:00
|
|
|
{ .label = "power", .index = 17 },
|
|
|
|
{ .label = "", .index = 0 },
|
|
|
|
{ .label = "", .index = 0 }
|
2020-11-03 14:00:54 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-02 20:59:52 +01:00
|
|
|
static uint32_t cnt = 0;
|
|
|
|
logMsg("*** NEW REQUEST %d ***", cnt);
|
|
|
|
cnt++;
|
2020-11-03 14:00:54 +01:00
|
|
|
mbusCommRequest(&device);
|
2020-10-29 23:16:03 +01:00
|
|
|
// static char msg[] = "Hello";
|
|
|
|
// HAL_UART_Transmit_IT(&mbusUart, &msg, strlen(msg));
|
|
|
|
|
2020-10-24 19:27:40 +02:00
|
|
|
}
|
|
|
|
|
2020-10-24 19:34:30 +02: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);
|
|
|
|
show(LED_GREEN, ON);
|
2020-10-27 15:12:19 +01:00
|
|
|
|
2020-10-31 22:19:48 +01:00
|
|
|
frontendInit();
|
2020-11-01 22:15:04 +01:00
|
|
|
frontendSetThreshold(240);
|
2020-10-31 22:19:48 +01:00
|
|
|
|
2020-11-02 19:26:06 +01:00
|
|
|
schAdd(helloMeterbus, NULL, 0, 10000);
|
2020-10-18 22:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void my_loop() {
|
2020-11-03 10:05:45 +01:00
|
|
|
show(DEBUG_1, TOGGLE);
|
2020-11-01 13:22:57 +01:00
|
|
|
|
2020-10-27 15:12:19 +01:00
|
|
|
schExec();
|
2020-10-29 15:44:13 +01:00
|
|
|
logExec();
|
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) {
|
|
|
|
if (huart == &mbusUart) {
|
|
|
|
mbusCommTxCpltCallback(huart);
|
|
|
|
}
|
2020-11-02 15:41:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
|
|
|
if (huart == &mbusUart) {
|
|
|
|
mbusCommRxCpltCallback(huart);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|