debug works in interrupt mode now, needs some refactoring, MBUSYield stops the whole system
This commit is contained in:
parent
15d8afa207
commit
c98c5dd8a5
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
// won't work so far
|
|
||||||
// #define LOGGER_INTERRUPT
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LOG_HIGH,
|
LOG_HIGH,
|
||||||
@ -29,14 +27,7 @@ int errMsg(const char *format, ...);
|
|||||||
|
|
||||||
int coloredMsg(const t_logColor color, const char *format, ...);
|
int coloredMsg(const t_logColor color, const char *format, ...);
|
||||||
|
|
||||||
// reads the ringbuffer and transfers data to output channel
|
void debugTxCpltCallback(UART_HandleTypeDef *huart);
|
||||||
// call this from the idle-loop
|
|
||||||
// return value can be ignored, it is only used in test
|
|
||||||
int logExec();
|
|
||||||
|
|
||||||
#ifdef LOGGER_INTERRUPT
|
|
||||||
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _LOGGER_H_
|
#endif // _LOGGER_H_
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#endif // TEST
|
#endif // TEST
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t singleOctetTXBuffer;
|
||||||
|
|
||||||
static ringbuffer_t logBuffer;
|
static ringbuffer_t logBuffer;
|
||||||
|
|
||||||
void logInit() {
|
void logInit() {
|
||||||
@ -35,35 +37,15 @@ void logFree() {
|
|||||||
ringbufferFree(&logBuffer);
|
ringbufferFree(&logBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOGGER_INTERRUPT
|
void debugTxCpltCallback(UART_HandleTypeDef *huart) {
|
||||||
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart) {
|
int c = ringbufferGetOne(&logBuffer);
|
||||||
logExec();
|
if (c > 0) {
|
||||||
}
|
singleOctetTXBuffer = (uint8_t) c;
|
||||||
#endif
|
HAL_UART_Transmit_IT(&debugUart, &singleOctetTXBuffer, 1);
|
||||||
|
|
||||||
int logExec() {
|
|
||||||
int c = -1;
|
|
||||||
#ifndef TEST
|
|
||||||
if (__HAL_UART_GET_FLAG(&debugUart, UART_FLAG_TXE)) { // is the TX channel free
|
|
||||||
#endif // TEST
|
|
||||||
c = ringbufferGetOne(&logBuffer);
|
|
||||||
if (c > 0) {
|
|
||||||
#ifndef TEST
|
|
||||||
// transfer to TX channel
|
|
||||||
uint8_t cc = (uint8_t) c;
|
|
||||||
#ifndef LOGGER_INTERRUPT
|
|
||||||
HAL_UART_Transmit(&debugUart, &cc, 1, HAL_MAX_DELAY);
|
|
||||||
#else
|
|
||||||
HAL_UART_Transmit_IT(&debugUart, &cc, 1);
|
|
||||||
#endif // LOGGER_INTERRUPT
|
|
||||||
#endif // TEST
|
|
||||||
}
|
|
||||||
#ifndef TEST
|
|
||||||
}
|
}
|
||||||
#endif // TEST
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
static void flashGreenLed(void *handle) {
|
static void flashGreenLed(void *handle) {
|
||||||
show(LED_GREEN, TOGGLE);
|
show(LED_GREEN, TOGGLE);
|
||||||
@ -87,7 +69,12 @@ static int innerLogMsg(const char *pre, const char *post, const char *format, va
|
|||||||
strcat(msgBuffer, post);
|
strcat(msgBuffer, post);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 == (res = ringbufferPut(&logBuffer, (uint8_t*) msgBuffer, strlen(msgBuffer)))) {
|
|
||||||
|
HAL_NVIC_DisableIRQ(UART4_IRQn);
|
||||||
|
res = ringbufferPut(&logBuffer, (uint8_t*) msgBuffer, strlen(msgBuffer));
|
||||||
|
HAL_NVIC_EnableIRQ(UART4_IRQn);
|
||||||
|
|
||||||
|
if (-1 == res) {
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
// blink the green light or so
|
// blink the green light or so
|
||||||
flashGreenLed(NULL);
|
flashGreenLed(NULL);
|
||||||
@ -96,6 +83,7 @@ static int innerLogMsg(const char *pre, const char *post, const char *format, va
|
|||||||
printf("\n*** green blink ***\n");
|
printf("\n*** green blink ***\n");
|
||||||
#endif // TEST
|
#endif // TEST
|
||||||
}
|
}
|
||||||
|
debugTxCpltCallback(NULL);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,6 @@ void my_loop() {
|
|||||||
show(DEBUG_1, TOGGLE);
|
show(DEBUG_1, TOGGLE);
|
||||||
|
|
||||||
schExec();
|
schExec();
|
||||||
logExec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SYSTICK_Callback() {
|
void SYSTICK_Callback() {
|
||||||
@ -214,7 +213,7 @@ void SYSTICK_Callback() {
|
|||||||
schUpdate();
|
schUpdate();
|
||||||
|
|
||||||
// MQTT Interface
|
// MQTT Interface
|
||||||
MilliTimer_Handler();
|
// MilliTimer_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_GPIO_EXTI_Callback(uint16_t pin) {
|
void HAL_GPIO_EXTI_Callback(uint16_t pin) {
|
||||||
@ -232,12 +231,9 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
|
|||||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
||||||
if (huart == &mbusUart) {
|
if (huart == &mbusUart) {
|
||||||
mbusCommTxCpltCallback(huart);
|
mbusCommTxCpltCallback(huart);
|
||||||
}
|
} else if (huart == &debugUart) {
|
||||||
#ifdef LOGGER_INTERRUPT
|
|
||||||
else if (huart == &debugUart) {
|
|
||||||
debugTxCpltCallback(huart);
|
debugTxCpltCallback(huart);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
#include <PontCoopScheduler.h>
|
#include <PontCoopScheduler.h>
|
||||||
#include <wizHelper.h>
|
#include <wizHelper.h>
|
||||||
|
#include <show.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -61,7 +62,10 @@ static void messageArrived(MessageData* md)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mqttHandler(void *handle) {
|
static void mqttHandler(void *handle) {
|
||||||
// MQTTYield(&mqttClient, data.keepAliveInterval);
|
show(DEBUG_2, ON);
|
||||||
|
MQTTYield(&mqttClient, data.keepAliveInterval);
|
||||||
|
show(DEBUG_2, OFF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqttCommInit(void *handle) {
|
void mqttCommInit(void *handle) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user