logger interrupt

This commit is contained in:
Wolfgang Hottgenroth 2020-11-10 16:30:26 +01:00
parent fa66527d9c
commit bf5d9b4bae
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
3 changed files with 22 additions and 0 deletions

View File

@ -1,8 +1,10 @@
#ifndef _LOGGER_H_
#define _LOGGER_H_
#include <main.h>
#define LOGGER_INTERRUPT
typedef enum {
LOG_HIGH,
@ -32,4 +34,9 @@ int coloredMsg(const t_logColor color, const char *format, ...);
// 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_

View File

@ -35,6 +35,12 @@ void logFree() {
ringbufferFree(&logBuffer);
}
#ifdef LOGGER_INTERRUPT
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart) {
logExec();
}
#endif
int logExec() {
int c = -1;
#ifndef TEST
@ -45,7 +51,11 @@ int logExec() {
#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

View File

@ -233,6 +233,11 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
if (huart == &mbusUart) {
mbusCommTxCpltCallback(huart);
}
#ifdef LOGGER_INTERRUPT
else if (huart == &debugUart) {
debugTxCpltCallback(huart);
}
#endif
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {