- added IODevice support
- fixed some issues with the logger and stack sizes git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@216 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -19,7 +19,7 @@ system_stm32f10x.o \
|
||||
sysmem.o \
|
||||
startup_stm32f10x_cl.o \
|
||||
\
|
||||
freeRTOSFixes.o \
|
||||
FreeRTOSFixes.o \
|
||||
Logger.o \
|
||||
\
|
||||
heap_2.o\
|
||||
@@ -81,7 +81,7 @@ 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 $(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$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lDisplay -lMisc -lSTM_StdPeriph
|
||||
OLI_STM32_H107: export LDARCHIVES := -L. -L$(STM32_STDPERIPH_ROOT) -L$(HAL_DIR) -lhsb_mrts_OLI_STM32_H107 -lPlatform -lKeypad -lDisplay -lMisc -lSTM_StdPeriph
|
||||
OLI_STM32_H107: export ARFLAGS := ru
|
||||
OLI_STM32_H107: export OBJCOPYFLAGS := -O binary
|
||||
OLI_STM32_H107: export OBJDUMPFLAGS := -x --syms -S
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 8000000 )
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||
#define configMAX_PRIORITIES ( 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 512 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 30 * 1024 ) )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0x8000 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
@@ -65,20 +65,21 @@
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
|
||||
|
||||
/* Software timer related definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY (4)
|
||||
#define configTIMER_QUEUE_LENGTH (10)
|
||||
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY (4)
|
||||
#define configTIMER_QUEUE_LENGTH (10)
|
||||
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
|
||||
/* Define to trap errors during development. */
|
||||
#define configASSERT( x ) if( ( x ) == 0 ) for(;;)
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: 167 $
|
||||
/// $Author: mmi $
|
||||
/// $Date: 2017-09-12 13:09:10 +0200 (di, 12 sep 2017) $
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "IODevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -83,20 +86,6 @@ typedef enum
|
||||
LOGTYPE_ERROR /**< Unrecoverable fault */
|
||||
} LogType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FATALCODE_STACKOVERFLOW = 0x11,
|
||||
FATALCODE_MALLOCFAILED = 0x12,
|
||||
FATALCODE_USBCOMQUEUE = 0x13,
|
||||
FATALCODE_LOGGERINITFAILED = 0x14,
|
||||
FATALCODE_LOGGERQUEUEFAILED = 0x15,
|
||||
FATALCODE_ADCOVERFLOW = 0x16,
|
||||
FATALCODE_HIDQUEUETIMEOUT = 0x17,
|
||||
FATALCODE_OUTPUTACTIONSQUEUETIMEOUT = 0x18,
|
||||
FATALCODE_RNETQUEUEFAILED = 0x19,
|
||||
FATALCODE_TEST2 = 0xFE,
|
||||
FATALCODE_TEST = 0xFF
|
||||
} FatalCode;
|
||||
|
||||
struct LogQueueItem
|
||||
{
|
||||
@@ -112,12 +101,12 @@ struct LogQueueItem
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void Logger_initialize(void* const interface);
|
||||
ErrorStatus Logger_construct(struct IODevice* const device);
|
||||
void Logger_terminate(void);
|
||||
|
||||
void Logger_logISR(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
|
||||
void Logger_fatal(FatalCode code);
|
||||
ErrorStatus Logger_addCommandHandlers(void);
|
||||
ErrorStatus Logger_logModuleInfo(void);
|
||||
extern ErrorStatus Logger_logModuleInfo(void);
|
||||
|
||||
/**
|
||||
* Logs a string.
|
||||
|
||||
@@ -54,5 +54,4 @@
|
||||
|
||||
void OS_logTaskInfo(xTaskHandle taskHandle);
|
||||
|
||||
|
||||
#endif /* FREERTOSFIXES_H_ */
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
|
||||
void SysTick_Handler(void);
|
||||
|
||||
|
||||
extern void IRQ_setInterruptProperties(uint8_t irqChannel, uint8_t preemptionPriority, uint8_t subPriority, FunctionalState command);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: 167 $
|
||||
/// $Author: mmi $
|
||||
/// $Date: 2017-09-12 13:09:10 +0200 (di, 12 sep 2017) $
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <FreeRTOSFixes.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "Logger.h"
|
||||
#include "semphr.h"
|
||||
@@ -42,9 +43,9 @@
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define LOGQUEUE_SIZE (64)
|
||||
#define LOGQUEUE_SIZE (16)
|
||||
#define LOGGER_STACK_SIZE (512)
|
||||
#define LOGGER_TASK_PRIORITY (1)
|
||||
#define LOGGER_TASK_PRIORITY (2)
|
||||
|
||||
// Makefile compile options:
|
||||
// ENABLE_SERIAL_LOGGING: Use the serial port for logging.
|
||||
@@ -64,7 +65,7 @@
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct Uart* loggerInterface;
|
||||
static struct IODevice* loggerDevice;
|
||||
|
||||
static xQueueHandle logQueue;
|
||||
|
||||
@@ -90,34 +91,35 @@ static void loggerTask(void* parameters);
|
||||
* ---------------------*
|
||||
*/
|
||||
|
||||
void Logger_initialize(void* const interface)
|
||||
ErrorStatus Logger_construct(struct IODevice* const device)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if(!initialized)
|
||||
{
|
||||
ErrorStatus errorStatus = SUCCESS;
|
||||
|
||||
///TODO This is currently hardcoded into the UART - there must be a way for more generic usage
|
||||
loggerInterface = (struct Uart* const) interface;
|
||||
loggerDevice = device;
|
||||
|
||||
if(errorStatus == SUCCESS)
|
||||
if(returnValue == SUCCESS)
|
||||
{
|
||||
logQueue = xQueueCreate(LOGQUEUE_SIZE, sizeof(struct LogQueueItem));
|
||||
|
||||
if(logQueue == 0)
|
||||
{
|
||||
errorStatus = ERROR;
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if(errorStatus == SUCCESS)
|
||||
if(returnValue == SUCCESS)
|
||||
{
|
||||
if(xTaskCreate(loggerTask, (const char*)"loggerTask", LOGGER_STACK_SIZE, NULL, LOGGER_TASK_PRIORITY, &loggerTaskHandle) != pdPASS)
|
||||
{
|
||||
errorStatus = ERROR;
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if(errorStatus == SUCCESS)
|
||||
if(returnValue == SUCCESS)
|
||||
{
|
||||
initialized = true;
|
||||
LOGGER_INFO("Logger started");
|
||||
@@ -127,6 +129,11 @@ void Logger_initialize(void* const interface)
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void Logger_terminate(void)
|
||||
@@ -135,6 +142,15 @@ void Logger_terminate(void)
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus Logger_logModuleInfo(void)
|
||||
{
|
||||
ErrorStatus errorStatus = SUCCESS;
|
||||
|
||||
OS_logTaskInfo(loggerTaskHandle);
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
|
||||
{
|
||||
if(initialized)
|
||||
@@ -174,7 +190,7 @@ void Logger_log(const char* fileName, const char* functionName, int lineNumber,
|
||||
vsnprintf(str, sizeof(str) / sizeof(str[0]), format, ap);
|
||||
va_end(ap);
|
||||
|
||||
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, logType, str);
|
||||
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, str);
|
||||
(void)xQueueSend(logQueue, &logQueueItem, 0);
|
||||
}
|
||||
else
|
||||
@@ -254,7 +270,7 @@ static void loggerTask(void* parameters)
|
||||
{
|
||||
// Raw print
|
||||
#if defined(ENABLE_SERIAL_LOGGING)
|
||||
Uart_Write(loggerInterface, (const uint8_t*)logQueueItem.context, strlen(logQueueItem.context));
|
||||
IODevice_write(loggerDevice, logQueueItem.context, strlen(logQueueItem.context));
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -310,7 +326,7 @@ static void loggerTask(void* parameters)
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SERIAL_LOGGING)
|
||||
Uart_Write(loggerInterface, (const uint8_t*)str, strlen(str));
|
||||
IODevice_write(loggerDevice, str, strlen(str));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <FreeRTOSFixes.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "freeRTOSFixes.h"
|
||||
#include "Logger.h"
|
||||
#include "led.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
@@ -65,12 +67,12 @@ void OS_logTaskInfo(xTaskHandle taskHandle)
|
||||
unsigned portBASE_TYPE highWaterMark;
|
||||
char text[128];
|
||||
|
||||
snprintf(text, sizeof(text), "Task %s\n", pcTaskGetTaskName(taskHandle));
|
||||
// Shell_sendString(text);
|
||||
snprintf(text, sizeof(text), "***** Task %s", pcTaskGetTaskName(taskHandle));
|
||||
LOGGER_INFO(text);
|
||||
|
||||
highWaterMark = uxTaskGetStackHighWaterMark(taskHandle);
|
||||
snprintf(text, sizeof(text), "Stack high water mark : %lu long words\n", highWaterMark);
|
||||
// Shell_sendString(text);
|
||||
snprintf(text, sizeof(text), "***** Stack high water mark : %lu long words", highWaterMark);
|
||||
LOGGER_INFO(text);
|
||||
}
|
||||
|
||||
// Implementation for libc, needed for printf related functions.
|
||||
@@ -93,7 +95,8 @@ caddr_t _sbrk(int incr)
|
||||
// Stack overflow hook
|
||||
void vApplicationStackOverflowHook(xTaskHandle xTask, signed portCHAR* pcTaskName)
|
||||
{
|
||||
// Logger_fatal(FATALCODE_STACKOVERFLOW);
|
||||
LED_turnOn(ledGreen);
|
||||
LOGGER_ERROR("STACK OVERFLOW IN TASK %s", pcTaskName);
|
||||
}
|
||||
|
||||
// Malloc failed hook
|
||||
|
||||
@@ -25,16 +25,19 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <FreeRTOSFixes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// FreeRTOS includes
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "freeRTOSFixes.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include "misc.h"
|
||||
#include "stm32f10x_rcc.h"
|
||||
|
||||
#include "nhd0420.h"
|
||||
#include "keypadMatrix.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "led.h"
|
||||
@@ -69,11 +72,13 @@ unsigned long ulRunTimeStatsClock = 0UL;
|
||||
static struct LedTaskArguments ledTaskArguments;
|
||||
static xTaskHandle initTaskHandle;
|
||||
static xTaskHandle ledTaskHandle;
|
||||
static xTaskHandle sysTaskHandle;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus systeminfoCommandHandler(void);
|
||||
static void initTask(void* parameters);
|
||||
static void ledBlinkTask(void* parameters);
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -91,10 +96,7 @@ int main (void)
|
||||
ledTaskArguments.led = ledOrange;
|
||||
ledTaskArguments.frequency = 2;
|
||||
|
||||
xTaskCreate(initTask, (const char* const)"initTask", 1024, NULL, 0, &initTaskHandle);
|
||||
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 1024, &ledTaskArguments, 0, &ledTaskHandle);
|
||||
|
||||
LOGGER_INFO("Starting the scheduler");
|
||||
xTaskCreate(initTask, (const char* const)"initTask", 1024, NULL, 5, &initTaskHandle);
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
@@ -113,11 +115,44 @@ void vApplicationTickHook ()
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void printSystemInfoTask(void* parameters)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
systeminfoCommandHandler();
|
||||
vTaskDelay(60000);
|
||||
}
|
||||
}
|
||||
|
||||
static ErrorStatus systeminfoCommandHandler(void)
|
||||
{
|
||||
ErrorStatus errorStatus = SUCCESS;
|
||||
size_t freeMemory;
|
||||
char text[128];
|
||||
|
||||
freeMemory = xPortGetFreeHeapSize();
|
||||
snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory);
|
||||
LOGGER_INFO(text);
|
||||
|
||||
errorStatus &= Logger_logModuleInfo();
|
||||
vTaskDelay(100);
|
||||
errorStatus &= Keypad_logModuleInfo();
|
||||
vTaskDelay(100);
|
||||
OS_logTaskInfo(ledTaskHandle);
|
||||
vTaskDelay(100);
|
||||
OS_logTaskInfo(sysTaskHandle);
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
static void initTask(void* parameters)
|
||||
{
|
||||
initPlatform();
|
||||
|
||||
Logger_initialize(uart1);
|
||||
Logger_construct(&uart1->device);
|
||||
|
||||
Keypad_construct();
|
||||
|
||||
NHD0420_construct(spiDisplay);
|
||||
|
||||
@@ -133,10 +168,13 @@ static void initTask(void* parameters)
|
||||
vTaskDelay(1000);
|
||||
NHD0420_setCursorToHome();
|
||||
vTaskDelay(1000);
|
||||
NHD0420_sendData("Hallo Welt", 10);
|
||||
vTaskDelay(1);
|
||||
NHD0420_setCursorToPosition(4, 5);
|
||||
NHD0420_sendData("Koetjeboe", 9);
|
||||
|
||||
|
||||
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 40, &ledTaskArguments, 0, &ledTaskHandle);
|
||||
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 1, &sysTaskHandle);
|
||||
|
||||
// Delete this init task
|
||||
vTaskDelete(NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#include "semphr.h"
|
||||
|
||||
#include "stm32f10x_it.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include "stm32f10x_exti.h"
|
||||
|
||||
#include "led.h"
|
||||
#include "platform.h"
|
||||
@@ -264,3 +267,48 @@ void SPI3_IRQHandler (void)
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI4_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
LOGGER_INFO_ISR("EXT4 ISR");
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line4);
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
void EXTI9_5_IRQHandler (void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if (EXTI_GetITStatus(EXTI_Line5) != RESET)
|
||||
{
|
||||
LOGGER_INFO_ISR("EXT5 ISR");
|
||||
EXTI_ClearITPendingBit(EXTI_Line5);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line6) != RESET)
|
||||
{
|
||||
LOGGER_INFO_ISR("EXT6 ISR");
|
||||
EXTI_ClearITPendingBit(EXTI_Line6);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line7) != RESET)
|
||||
{
|
||||
LOGGER_INFO_ISR("EXT7 ISR");
|
||||
EXTI_ClearITPendingBit(EXTI_Line7);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user