Fixed issues with the logger and brought logger to same structure as the rest - now the logger is a independent object

Added testItems to HwValidationMenu for SWo

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@235 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-05 07:49:28 +00:00
parent 955d695720
commit c860b5b3b4
17 changed files with 283 additions and 258 deletions

View File

@@ -25,6 +25,8 @@
<option id="gnu.c.compiler.option.debugging.level.1951365338" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.35161744" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Platform/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/FreeRTOS/Source/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/hsb-mrts/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x}&quot;"/>
@@ -124,4 +126,5 @@
<path value=""/>
</doc-comment-owner>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

View File

@@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-103770239591" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1404919128665" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-103770239591" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1404919128665" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@@ -11,7 +11,7 @@ ROOTDIR = ../
LIBRARY_NAME = libHAL.a
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) \
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(ADDITIONAL_SWITCHES) \
-Iinc \
-I$(ROOTDIR)/Platform/inc \
-I$(ROOTDIR)/hsb-mrts/inc \
@@ -24,6 +24,7 @@ ARFLAGS = rs
OBJECTS = \
DisplayDevice.o \
Logger.o \
MAX5715.o \
nhd0420.o

View File

@@ -32,6 +32,13 @@
#include "stm32f10x.h"
#include <stdbool.h>
#include "FreeRTOS.h"
#include "semphr.h"
#include "queue.h"
#include "task.h"
#include "platform.h"
#include "IODevice.h"
@@ -43,36 +50,38 @@
* Logs an error
* \memberof Logger
*/
#define LOGGER_ERROR(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
#define LOGGER_WARNING(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
#define LOGGER_INFO(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
#define LOGGER_ERROR(a, ...) \
Logger_log(a, __FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
#define LOGGER_DEBUG(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
#define LOGGER_WARNING(a, ...) \
Logger_log(a, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
#define LOGGER_PRINT(...) \
Logger_log("", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
#define LOGGER_ERROR_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
#define LOGGER_WARNING_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
#define LOGGER_INFO_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
#define LOGGER_INFO(a, ...) \
Logger_log(a, __FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
#define LOGGER_DEBUG_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
#define LOGGER_DEBUG(a, ...) \
Logger_log(a, __FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
#define LOGGER_PRINT_ISR(...) \
Logger_logISR("", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
#define LOGGER_PRINT(a, ...) \
Logger_log(a, "", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
#define LOGGER_ERROR_ISR(a, ...) \
Logger_logISR(a, __FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
#define LOGGER_WARNING_ISR(a, ...) \
Logger_logISR(a, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
#define LOGGER_INFO_ISR(a, ...) \
Logger_logISR(a, __FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
#define LOGGER_DEBUG_ISR(a, ...) \
Logger_logISR(a, __FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
#define LOGGER_PRINT_ISR(a, ...) \
Logger_logISR(a, "", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
@@ -96,17 +105,25 @@ struct LogQueueItem
LogType logType;
};
struct Logger
{
struct IODevice* loggingDevice;
TaskHandle_t taskHandle;
int TaskPriority;
uint16_t stackSize;
bool runTask;
QueueHandle_t logQueue;
bool initialized;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
ErrorStatus Logger_construct(struct IODevice* const device);
void Logger_terminate(void);
extern ErrorStatus Logger_construct(struct Logger* self, struct IODevice* const device, int taskPriority, uint16_t stackSize);
extern void Logger_terminate(struct Logger* self);
void Logger_logISR(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
ErrorStatus Logger_addCommandHandlers(void);
extern ErrorStatus Logger_logModuleInfo(void);
void Logger_logISR(struct Logger* self, const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
/**
* Logs a string.
@@ -120,6 +137,6 @@ extern ErrorStatus Logger_logModuleInfo(void);
* \param format printf-type formatting string
* \param ... Variable arguments according to the formatting string
*/
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...) __attribute__((format(printf, 5, 6)));
void Logger_log(struct Logger* self, const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...) __attribute__((format(printf, 6, 7)));
#endif

View File

@@ -44,8 +44,6 @@
// -----------------------------------------------------------------------------
#define LOGQUEUE_SIZE (24)
#define LOGGER_STACK_SIZE (512)
#define LOGGER_TASK_PRIORITY (2)
// Makefile compile options:
// ENABLE_SERIAL_LOGGING: Use the serial port for logging.
@@ -65,107 +63,82 @@
// File-scope variables
// -----------------------------------------------------------------------------
static struct IODevice* loggerDevice;
static xQueueHandle logQueue;
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
static bool initialized = false;
static xTaskHandle loggerTaskHandle = NULL;
static void composeLogQueueItem(struct LogQueueItem* logQueueItem, const char* fileName, const char* functionName,
int lineNumber, LogType logType, const char* context);
static void loggerTask(void* parameters);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
static void composeLogQueueItem(struct LogQueueItem* logQueueItem, const char* fileName, const char* functionName,
int lineNumber, LogType logType, const char* context);
static void loggerTask(void* parameters);
/* ---------------------*
* Function definitions *
* ---------------------*
*/
ErrorStatus Logger_construct(struct IODevice* const device)
ErrorStatus Logger_construct(struct Logger* self, struct IODevice* const device, int taskPriority, uint16_t stackSize)
{
ErrorStatus returnValue = SUCCESS;
if(!initialized)
{
loggerDevice = device;
if (!self->initialized)
{
self->loggingDevice = device;
self->TaskPriority = taskPriority;
self->stackSize = stackSize;
if(returnValue == SUCCESS)
{
logQueue = xQueueCreate(LOGQUEUE_SIZE, sizeof(struct LogQueueItem));
self->logQueue = xQueueCreate(LOGQUEUE_SIZE, sizeof(struct LogQueueItem));
if(logQueue == 0)
if(self->logQueue == 0)
{
returnValue = ERROR;
}
}
if(returnValue == SUCCESS)
{
if(xTaskCreate(loggerTask, (const char*)"loggerTask", LOGGER_STACK_SIZE, NULL, LOGGER_TASK_PRIORITY, &loggerTaskHandle) != pdPASS)
{
returnValue = ERROR;
}
}
if(returnValue == SUCCESS)
{
if(xTaskCreate(loggerTask, (const char*)"loggerTask", self->stackSize, self, self->TaskPriority, &self->taskHandle) != pdPASS)
{
returnValue = ERROR;
}
}
if(returnValue == SUCCESS)
{
initialized = true;
LOGGER_INFO("Logger started");
}
else
{
if(returnValue == SUCCESS)
{
LOGGER_INFO(self, "Logger started");
self->initialized = true;
}
}
}
else
{
returnValue = ERROR;
}
}
return returnValue;
}
void Logger_terminate(void)
void Logger_destruct(struct Logger* self)
{
self->initialized = false;
}
ErrorStatus Logger_logModuleInfo(void)
void Logger_log(struct Logger* self, const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
{
ErrorStatus errorStatus = SUCCESS;
#if defined(ENABLE_LOGGING)
static int nrLostMessages = 0;
static bool overflowRecovery = false;
int nrOfMessages;
struct LogQueueItem logQueueItem;
va_list ap;
OS_logTaskInfo(loggerTaskHandle);
return errorStatus;
}
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
{
if(initialized)
if (self->initialized)
{
static int nrLostMessages = 0;
static bool overflowRecovery = false;
int nrOfMessages;
struct LogQueueItem logQueueItem;
va_list ap;
nrOfMessages = uxQueueMessagesWaiting(&logQueue);
nrOfMessages = uxQueueMessagesWaiting(&self->logQueue);
if((nrOfMessages == LOGQUEUE_SIZE - 1) && !overflowRecovery)
{
// Queue almost full, only one entry left. Log a warning instead
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, "Log queue overflow");
(void)xQueueSend(logQueue, &logQueueItem, 0);
(void)xQueueSend(self->logQueue, &logQueueItem, 0);
overflowRecovery = true;
nrLostMessages = 1;
@@ -176,7 +149,7 @@ void Logger_log(const char* fileName, const char* functionName, int lineNumber,
char str[128];
snprintf(str, sizeof(str) / sizeof(str[0]), "%d messages lost", nrLostMessages);
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, str);
(void)xQueueSend(logQueue, &logQueueItem, 0);
(void)xQueueSend(self->logQueue, &logQueueItem, 0);
overflowRecovery = false;
}
@@ -189,35 +162,35 @@ void Logger_log(const char* fileName, const char* functionName, int lineNumber,
va_end(ap);
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, str);
(void)xQueueSend(logQueue, &logQueueItem, 0);
(void)xQueueSend(self->logQueue, &logQueueItem, 0);
}
else
{
// Count number of lost messages
++nrLostMessages;
}
}
#endif
}
void Logger_logISR(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context)
void Logger_logISR(struct Logger* self, const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context)
{
#if defined(ENABLE_LOGGING)
if(initialized)
{
struct LogQueueItem logQueueItem;
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, context);
if(xQueueSendFromISR(logQueue, &logQueueItem, &higherPriorityTaskWoken) != pdTRUE)
{
// Queue failed
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
#endif
#if defined(ENABLE_LOGGING)
if (self->initialized)
{
struct LogQueueItem logQueueItem;
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, context);
if(xQueueSendFromISR(self->logQueue, &logQueueItem, &higherPriorityTaskWoken) != pdTRUE)
{
// Queue failed
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
#endif
}
@@ -258,17 +231,18 @@ static void composeLogQueueItem(struct LogQueueItem* logQueueItem, const char* f
static void loggerTask(void* parameters)
{
for(;;)
struct Logger* self = (struct Logger*)parameters;
while(self->initialized)
{
struct LogQueueItem logQueueItem;
xQueueReceive(logQueue, &logQueueItem, portMAX_DELAY);
xQueueReceive(self->logQueue, &logQueueItem, portMAX_DELAY);
if(logQueueItem.logType == LOGTYPE_PRINT)
{
// Raw print
#if defined(ENABLE_SERIAL_LOGGING)
IODevice_write(loggerDevice, logQueueItem.context, strlen(logQueueItem.context));
IODevice_write(self->loggingDevice, logQueueItem.context, strlen(logQueueItem.context));
#endif
}
@@ -279,10 +253,6 @@ static void loggerTask(void* parameters)
char* vt100Prefix = "";
const char* vt100Postfix = "\033[0m";
#endif
int hours;
int minutes;
int seconds;
#if defined(ENABLE_SERIAL_LOGGING)
if(logQueueItem.logType == LOGTYPE_INFO)
@@ -299,23 +269,14 @@ static void loggerTask(void* parameters)
}
#endif
///TODO add RTC support
// RTC_getTime(&hours, &minutes, &seconds);
hours = 13;
minutes = 37;
seconds = 10;
#if defined(ENABLE_SERIAL_LOGGING)
// Formatted print
snprintf(str, sizeof(str) / sizeof(str[0]), "%s[%s] %02d:%02d:%02d %s, %s, %d: %s%s\n",
snprintf(str, sizeof(str) / sizeof(str[0]), "%s[%s] %s, %s, %d: %s%s\n",
vt100Prefix,
(logQueueItem.logType == LOGTYPE_DEBUG) ? "DBG" :
(logQueueItem.logType == LOGTYPE_INFO) ? "INF" :
(logQueueItem.logType == LOGTYPE_WARNING) ? "WRN" : "ERR",
///TODO add RTC support
hours,
minutes,
seconds,
logQueueItem.fileName,
logQueueItem.functionName,
logQueueItem.lineNumber,
@@ -324,15 +285,17 @@ static void loggerTask(void* parameters)
#endif
#if defined(ENABLE_SERIAL_LOGGING)
IODevice_write(loggerDevice, str, strlen(str));
IODevice_write(self->loggingDevice, str, strlen(str));
#endif
char buffer[5] = {0,};
size_t actualLength = 0;
IODevice_read(loggerDevice, buffer, 5, &actualLength);
IODevice_read(self->loggingDevice, buffer, 5, &actualLength);
snprintf(str, sizeof(str) / sizeof(str[0]), "%d - %x %x %x %x %x", actualLength, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]);
IODevice_write(loggerDevice, str, strlen(str));
IODevice_write(self->loggingDevice, str, strlen(str));
}
}
vTaskDelete(self->taskHandle);
}

View File

@@ -16,6 +16,9 @@ export RELEASE_DEFINES = \
export PLATFORM = -D$(PLATFORM_OLIMEX_STM32_H107)
export ADDITIONAL_SWITCHES = \
-DENABLE_SERIAL_LOGGING
all:
$(MAKE) pho_hsb_olimex_stm32_h107

View File

@@ -60,6 +60,8 @@ typedef struct
GPIO_InitTypeDef GPIO_InitStruct;
} T_PL_GPIO;
extern struct Logger* mainLog;
// Export of PCBA information
extern struct Pcba* pcba;

View File

@@ -119,11 +119,11 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
if(returnValue == SUCCESS)
{
LOGGER_INFO("Keypad task started");
LOGGER_INFO(mainLog, "Keypad task started");
}
else
{
LOGGER_ERROR("Keypad task FAILED");
LOGGER_ERROR(mainLog, "Keypad task FAILED");
}
}
@@ -190,8 +190,6 @@ static void KeypadTask(void* parameters)
{
self->lastState[rowCounter][colCounter] = RELEASED;
// Key has been released
LOGGER_DEBUG("KEY row%d, column%d released", rowCounter, colCounter);
}
else
{
@@ -204,7 +202,6 @@ static void KeypadTask(void* parameters)
{
self->lastState[rowCounter][colCounter] = PRESSED;
// Key has been pressed
LOGGER_DEBUG("KEY row%d, column%d pressed", rowCounter, colCounter);
}
else
{

View File

@@ -34,6 +34,8 @@
#include "stm32f10x_pwr.h"
#include "stm32f10x_it.h"
#include "Logger.h"
#include "platform.h"
#include "adc.h"
#include "gpio.h"
@@ -84,6 +86,9 @@
// The following static file-scope variables represent the actual storage of
// the IO/Peripheral object
// Logger
static struct Logger _mainLog = {.initialized = false};
// PCBA information
// LEDs
@@ -117,8 +122,12 @@ static struct SpiDevice _spiEEPROM;
static struct Keypad _keypad;
static struct KeypadParameters _keypadParameters;
// The following pointers are for export (see platform.h) and external use.
// Note that the pointer content is marked "const"
struct Logger* mainLog = &_mainLog;
struct Pcba* pcba;
struct Gpio* const ledGreen = &_ledGreen;
@@ -265,6 +274,7 @@ ErrorStatus initPlatform(void)
uartLoggerParam->txQueueSize = UART_LOG_TX_QUEUE;
returnValue = Uart_construct(uart1, uartLoggerParam);
/* --------------------------------------------------------------------*/
/* USART3 */
/* --------------------------------------------------------------------*/

View File

@@ -31,6 +31,8 @@
#include "rtc.h"
#include "stm32f10x_rtc.h"
#include "Observable.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------

View File

@@ -244,3 +244,102 @@ ErrorStatus Uart_read (struct Uart* self, char* buffer, size_t length, size_t* a
return returnValue;
}
/** ----------------------------------------------------------------------------
* @brief Function: USART1_IRQHandler
*
* Dedicated Interrupt Service Routine for USART1
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
void USART1_IRQHandler(void)
{
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
//! Transmission register empty interrupt
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart1->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART1, usartTxItem.byte);
//! check if queue is empty -> all bytes transmit
if(pdTRUE == xQueueIsQueueEmptyFromISR(uart1->txQueue))
{
//! Disable the COMPORT Transmit interrupt and release semaphore
USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
xSemaphoreGiveFromISR(uart1->txSemaphore, &higherPriorityTaskWoken);
}
}
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
//! Read one byte from the receive data register
struct usartQueueItem usartRxItem;
//! Reading from reception register automatically clears the RXNE interrupt
usartRxItem.byte = USART_ReceiveData(USART1);
//! Add the byte to the USART RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart1->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
/** ----------------------------------------------------------------------------
* @brief Function: USART3_IRQHandler
*
* Dedicated Interrupt Service Routine for USART3
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
void USART3_IRQHandler(void)
{
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
//! Transmission register empty interrupt
if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart3->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART3, usartTxItem.byte);
//! check if queue is empty -> all bytes transmit
if(pdTRUE == xQueueIsQueueEmptyFromISR(uart3->txQueue))
{
//! Disable the COMPORT Transmit interrupt and release semaphore
USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
xSemaphoreGiveFromISR(uart3->txSemaphore, &higherPriorityTaskWoken);
}
}
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
{
//! Read one byte from the receive data register
struct usartQueueItem usartRxItem;
//! Reading from reception register automatically clears the RXNE interrupt
usartRxItem.byte = (char)USART_ReceiveData(USART3);
//! Add the byte to the USART RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart3->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}

View File

@@ -14,7 +14,6 @@ startup_stm32f10x_cl.o \
\
Display.o \
FreeRTOSFixes.o \
Logger.o \
\
heap_2.o\
list.o \
@@ -54,7 +53,7 @@ OLI_STM32_H107: export OBJ_DIR := obj_release/
OLI_STM32_H107: export OBJECTS := $(OBJECTS_GEN)
OLI_STM32_H107: export OBJECTS_MAIN := $(OBJECTS_MAIN)
OLI_STM32_H107: export CROSS_COMPILE := arm-none-eabi-
OLI_STM32_H107: export CCFLAGS := -c -O2 -Wall -g -lc -lm -fno-common -mcpu=cortex-m3 -DOLI_STM32_H107 -DENABLE_SERIAL_LOGGING -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(INCLUDES)
OLI_STM32_H107: export CCFLAGS := -c -O2 -Wall -g -lc -lm -fno-common -mcpu=cortex-m3 -mthumb $(PLATFORM) $(RELEASE_DEFINES) $(INCLUDES)
OLI_STM32_H107: export ASFLAGS := -g -mapcs-32
OLI_STM32_H107: export LDFLAGS := -g -nostartfiles -mcpu=cortex-m3 -mthumb -T$(LINKER_SCRIPTS_DIR)/$(LINKER_SCRIPT) -Wl,-Map=hsb_mrts_OLI_STM32_H107.map
OLI_STM32_H107: export LDARCHIVES := -L. -L$(STM32_STDPERIPH_ROOT) -L$(PLATFORM_DIR) -L$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lHAL -lSTM_StdPeriph

View File

@@ -59,6 +59,25 @@ struct HwValidationMenu
bool runTask;
};
struct HwValidationMenuItems
{
struct DisplayDevice* display; // DisplayDevice to talk to
struct Adc* internalADC; // Internal ADC with channel array
struct MAX5715* externalDAC; // External DAC with channel array
struct Gpio* interlock1;
struct Gpio* interlock2;
struct Gpio* solenoid;
struct Gpio* mcp0Relay;
struct Gpio* mcp1Relay;
struct Gpio* mcp2Relay;
struct Gpio* cat0Relay;
struct Gpio* cat0Relay;
struct Gpio* cat0Relay;
struct Pcba* pcba;
// struct Eeprom* eeprom; // Not implemented yet
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
@@ -66,16 +85,19 @@ struct HwValidationMenu
/** ----------------------------------------------------------------------------
* HwValidationMenu_construct
* Description of function
* Constructor for HW validation menu (usually used on a terminal)
*
* @param self
* @param ioDevice
* @return ErrorStatus
* @param self The validation menu object
* @param ioDevice IODevice to communicate with
* @param testItems list of items to test
*
* @return ErrorStatus SUCCESS if construction was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IODevice* ioDevice);
extern ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IODevice* ioDevice, struct HwValidationMenuItems testItems);
#endif /* INC_HWVALIDATIONMENU_H_ */

View File

@@ -30,6 +30,8 @@
#include "nhd0420.h"
#include "platform.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
@@ -99,11 +101,11 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa
if (xTaskCreate(DisplayTask, (const char*)"DisplayTask", self->stackSize, self, self->TaskPriority, self->taskHandle) != pdTRUE)
{
returnValue = ERROR;
LOGGER_ERROR("Starting display task failed");
LOGGER_ERROR(mainLog, "Starting display task failed");
}
else
{
LOGGER_INFO("Display task started");
LOGGER_INFO(mainLog, "Display task started");
}
}

View File

@@ -32,6 +32,7 @@
#include "Logger.h"
#include "platform.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
@@ -67,11 +68,11 @@ void OS_logTaskInfo(xTaskHandle taskHandle)
char text[128];
snprintf(text, sizeof(text), "***** Task %s", pcTaskGetTaskName(taskHandle));
LOGGER_INFO(text);
LOGGER_INFO(mainLog, text);
highWaterMark = uxTaskGetStackHighWaterMark(taskHandle);
snprintf(text, sizeof(text), "***** Stack high water mark : %lu long words", highWaterMark);
LOGGER_INFO(text);
LOGGER_INFO(mainLog, text);
}
// Implementation for libc, needed for printf related functions.
@@ -94,13 +95,13 @@ caddr_t _sbrk(int incr)
// Stack overflow hook
void vApplicationStackOverflowHook(xTaskHandle xTask, signed portCHAR* pcTaskName)
{
LOGGER_ERROR("STACK OVERFLOW IN TASK %s", pcTaskName);
LOGGER_ERROR(mainLog, "STACK OVERFLOW IN TASK %s", pcTaskName);
}
// Malloc failed hook
void vApplicationMallocFailedHook(void)
{
// Logger_fatal(FATALCODE_MALLOCFAILED);
}
// Assert for StdPeriph library

View File

@@ -137,7 +137,7 @@ static void printSystemInfoTask(void* parameters)
{
while (1)
{
LOGGER_INFO("---------------------------------------");
LOGGER_INFO(mainLog, "---------------------------------------");
systeminfoCommandHandler();
vTaskDelay(60000);
}
@@ -151,15 +151,14 @@ static ErrorStatus systeminfoCommandHandler(void)
freeMemory = xPortGetFreeHeapSize();
snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory);
LOGGER_INFO(text);
LOGGER_INFO(mainLog, text);
errorStatus &= Logger_logModuleInfo();
OS_logTaskInfo(display->taskHandle);
vTaskDelay(100);
OS_logTaskInfo(ledTaskHandle);
vTaskDelay(100);
OS_logTaskInfo(sysTaskHandle);
// vTaskDelay(100);
// OS_logTaskInfo(display->taskHandle);
vTaskDelay(100);
return errorStatus;
}
@@ -170,7 +169,9 @@ static void initTask(void* parameters)
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 50, &ledTaskArguments, 0, &ledTaskHandle);
Logger_construct(&uart1->device);
Logger_construct(mainLog, &uart1->device, 2, 512);
IODevice_write(&uart1->device, pcba->name, strlen(pcba->name));
NHD0420_construct(&nhd0420, &spiDisplay->device);

View File

@@ -122,102 +122,7 @@ void IRQ_setKeypadEXTI(struct Keypad* self, FunctionalState command)
// {
// }
/** ----------------------------------------------------------------------------
* @brief Function: USART1_IRQHandler
*
* Dedicated Interrupt Service Routine for USART1
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
void USART1_IRQHandler(void)
{
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
//! Transmission register empty interrupt
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart1->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART1, usartTxItem.byte);
//! check if queue is empty -> all bytes transmit
if(pdTRUE == xQueueIsQueueEmptyFromISR(uart1->txQueue))
{
//! Disable the COMPORT Transmit interrupt and release semaphore
USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
xSemaphoreGiveFromISR(uart1->txSemaphore, &higherPriorityTaskWoken);
}
}
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
//! Read one byte from the receive data register
struct usartQueueItem usartRxItem;
//! Reading from reception register automatically clears the RXNE interrupt
usartRxItem.byte = USART_ReceiveData(USART1);
//! Add the byte to the USART RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart1->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
/** ----------------------------------------------------------------------------
* @brief Function: USART3_IRQHandler
*
* Dedicated Interrupt Service Routine for USART3
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
void USART3_IRQHandler(void)
{
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
//! Transmission register empty interrupt
if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart3->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART3, usartTxItem.byte);
//! check if queue is empty -> all bytes transmit
if(pdTRUE == xQueueIsQueueEmptyFromISR(uart3->txQueue))
{
//! Disable the COMPORT Transmit interrupt and release semaphore
USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
xSemaphoreGiveFromISR(uart3->txSemaphore, &higherPriorityTaskWoken);
}
}
//! Current interrupt is triggered by USART_RXNE (receive register not empty)
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
{
//! Read one byte from the receive data register
struct usartQueueItem usartRxItem;
//! Reading from reception register automatically clears the RXNE interrupt
usartRxItem.byte = (char)USART_ReceiveData(USART3);
//! Add the byte to the USART RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart3->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
/** ----------------------------------------------------------------------------
* @brief Function: SPI1_IRQHandler
@@ -353,12 +258,10 @@ void EXTI9_5_IRQHandler (void)
}
else if (EXTI_GetITStatus(EXTI_Line8) != RESET)
{
LOGGER_INFO_ISR("EXT8 ISR");
EXTI_ClearITPendingBit(EXTI_Line8);
}
else if (EXTI_GetITStatus(EXTI_Line9) != RESET)
{
LOGGER_INFO_ISR("EXT9 ISR");
EXTI_ClearITPendingBit(EXTI_Line9);
}