update for SWO - hw validation menu integrated

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@239 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-06 07:46:54 +00:00
parent ab3301889c
commit 5105d55089
12 changed files with 143 additions and 84 deletions

View File

@@ -39,6 +39,8 @@
#include <string.h> #include <string.h>
#include "uart.h" #include "uart.h"
#include "stm32f10x_rtc.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Constant and macro definitions // Constant and macro definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -269,14 +271,16 @@ static void loggerTask(void* parameters)
} }
#endif #endif
uint32_t seconds = RTC_GetCounter();
#if defined(ENABLE_SERIAL_LOGGING) #if defined(ENABLE_SERIAL_LOGGING)
// Formatted print // Formatted print
snprintf(str, sizeof(str) / sizeof(str[0]), "%s[%s] %s, %s, %d: %s%s\n", snprintf(str, sizeof(str) / sizeof(str[0]), "%s[%s] %09d %s, %s, %d: %s%s\n",
vt100Prefix, vt100Prefix,
(logQueueItem.logType == LOGTYPE_DEBUG) ? "DBG" : (logQueueItem.logType == LOGTYPE_DEBUG) ? "DBG" :
(logQueueItem.logType == LOGTYPE_INFO) ? "INF" : (logQueueItem.logType == LOGTYPE_INFO) ? "INF" :
(logQueueItem.logType == LOGTYPE_WARNING) ? "WRN" : "ERR", (logQueueItem.logType == LOGTYPE_WARNING) ? "WRN" : "ERR",
seconds,
logQueueItem.fileName, logQueueItem.fileName,
logQueueItem.functionName, logQueueItem.functionName,
logQueueItem.lineNumber, logQueueItem.lineNumber,
@@ -288,12 +292,6 @@ static void loggerTask(void* parameters)
IODevice_write(self->loggingDevice, str, strlen(str)); IODevice_write(self->loggingDevice, str, strlen(str));
#endif #endif
char buffer[5] = {0,};
size_t actualLength = 0;
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(self->loggingDevice, str, strlen(str));
} }
} }

View File

@@ -32,6 +32,8 @@
// Include files // Include files
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <stdbool.h>
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "semphr.h" #include "semphr.h"
#include "task.h" #include "task.h"
@@ -76,14 +78,14 @@ struct Keypad
struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS]; struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS];
Keypad_KeyState lastState[KEYPAD_NUMBER_OF_ROWS][KEYPAD_NUMBER_OF_COLUMNS]; Keypad_KeyState lastState[KEYPAD_NUMBER_OF_ROWS][KEYPAD_NUMBER_OF_COLUMNS];
xTaskHandle taskHandle; xTaskHandle taskHandle;
int taskPriority;
uint16_t stackSize;
SemaphoreHandle_t scanSemaphore; SemaphoreHandle_t scanSemaphore;
xQueueHandle rxQueue; xQueueHandle rxQueue;
size_t rxQueueSize;
bool initialized;
int waitToDebounce_ms; int waitToDebounce_ms;
};
struct KeypadParameters
{
int rxQueueSize;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -95,8 +97,9 @@ struct KeypadParameters
* contructor for the Keypad driver * contructor for the Keypad driver
* *
* @param self Keypad object to initialize * @param self Keypad object to initialize
* @param parameters Parameters to use for initialisation
* @param debounceTime debounce time for the keypad to use * @param debounceTime debounce time for the keypad to use
* @param taskPriority Priority of the keypad task
* @param stackSize Stacksize for the task
* *
* @return ErrorStatus SUCCESS if initialisation was successful * @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise * ERROR otherwise
@@ -104,7 +107,7 @@ struct KeypadParameters
* @todo * @todo
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
extern ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* parameters, int debounceTime); extern ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize);
/** ---------------------------------------------------------------------------- /** ----------------------------------------------------------------------------
@@ -121,21 +124,6 @@ extern ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters
*/ */
extern void Keypad_destruct (const struct Keypad* self); extern void Keypad_destruct (const struct Keypad* self);
/** ----------------------------------------------------------------------------
* Keypad_getDefaultParameters
* Returns default parameters for a keypad
*
* @param parameters Keypad parameters struct that will be
* filled with default values
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus Keypad_getDefaultParameters(struct KeypadParameters* parameters);
#endif /* KEYPAD_INC_KEYPADMATRIX_H_ */ #endif /* KEYPAD_INC_KEYPADMATRIX_H_ */

View File

@@ -40,9 +40,6 @@
// Constant and macro definitions // Constant and macro definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define KEYPAD_STACK_SIZE (512)
#define KEYPAD_TASK_PRIORITY (3)
#define KEYPAD_DEF_QUEUESIZE (32)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Type definitions // Type definitions
@@ -67,13 +64,13 @@ static void KeypadTask(void* parameters);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* parameters, int debounceTime) ErrorStatus Keypad_construct(struct Keypad* self, int debounceTime, int taskPriority, uint16_t stackSize, size_t rxQueueSize)
{ {
int rowCounter = 0; int rowCounter = 0;
int colCounter = 0; int colCounter = 0;
ErrorStatus returnValue = SUCCESS; ErrorStatus returnValue = SUCCESS;
if(keypad != NULL) if(!self->initialized)
{ {
IODevice_construct(&self->device, read, NULL); IODevice_construct(&self->device, read, NULL);
@@ -84,6 +81,9 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
} }
self->waitToDebounce_ms = debounceTime; self->waitToDebounce_ms = debounceTime;
self->rxQueueSize = rxQueueSize;
self->stackSize = stackSize;
self->taskPriority = taskPriority;
// Initialize memory to keep track of state changes per key // Initialize memory to keep track of state changes per key
for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++) for (rowCounter = 0; rowCounter < KEYPAD_NUMBER_OF_ROWS; rowCounter++)
@@ -95,7 +95,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
} }
//! Create a new FREERTOS queue to handle data from Keypad input to app //! Create a new FREERTOS queue to handle data from Keypad input to app
self->rxQueue = xQueueCreate(parameters->rxQueueSize, sizeof(struct KeypadQueueItem)); self->rxQueue = xQueueCreate(self->rxQueueSize, sizeof(struct KeypadQueueItem));
if (self->rxQueue == 0) if (self->rxQueue == 0)
{ {
//! Queue identifier is 0 -> error //! Queue identifier is 0 -> error
@@ -104,7 +104,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
if(returnValue == SUCCESS) if(returnValue == SUCCESS)
{ {
xTaskCreate(KeypadTask, (const char*)"keypadTask", KEYPAD_STACK_SIZE, keypad, KEYPAD_TASK_PRIORITY, self->taskHandle); xTaskCreate(KeypadTask, (const char*)"keypadTask", self->stackSize, keypad, self->taskPriority, &self->taskHandle);
} }
if(returnValue == SUCCESS) if(returnValue == SUCCESS)
@@ -120,12 +120,17 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param
if(returnValue == SUCCESS) if(returnValue == SUCCESS)
{ {
LOGGER_INFO(mainLog, "Keypad task started"); LOGGER_INFO(mainLog, "Keypad task started");
self->initialized = true;
} }
else else
{ {
LOGGER_ERROR(mainLog, "Keypad task FAILED"); LOGGER_ERROR(mainLog, "Keypad task FAILED");
} }
} }
else
{
returnValue = ERROR;
}
return returnValue; return returnValue;
} }
@@ -138,22 +143,22 @@ void Keypad_Destruct (const struct Keypad* self)
} }
ErrorStatus Keypad_getDefaultParameters(struct KeypadParameters* parameters)
{
ErrorStatus errorStatus = SUCCESS;
parameters->rxQueueSize = KEYPAD_DEF_QUEUESIZE;
return errorStatus;
}
static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength) static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length, size_t* actualLength)
{ {
ErrorStatus errorStatus = SUCCESS; ErrorStatus returnValue = SUCCESS;
const struct Keypad* keypad = (const struct Keypad*)self;
if (keypad->initialized)
{
*actualLength = 1; *actualLength = 1;
}
else
{
returnValue = ERROR;
}
return errorStatus; return returnValue;
} }

View File

@@ -62,7 +62,7 @@
#define UART_LOG_TX_QUEUE (256) #define UART_LOG_TX_QUEUE (256)
// UART3 Settings (Developer terminal) // UART3 Settings (Developer terminal)
#define UART_TER_BAUDRATE (115200) #define UART_TER_BAUDRATE (57600)
#define UART_TER_TX_QUEUE (512) #define UART_TER_TX_QUEUE (512)
// SPI1 settings // SPI1 settings
@@ -74,6 +74,9 @@
// Keypad Settings // Keypad Settings
#define KEYPAD_DEBOUNCE_TIME_MS (20) #define KEYPAD_DEBOUNCE_TIME_MS (20)
#define KEYPAD_STACK_SIZE (128)
#define KEYPAD_TASK_PRIORITY (3)
#define KEYPAD_DEF_QUEUESIZE (32)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Type definitions // Type definitions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -120,7 +123,6 @@ static struct SpiDevice _spiEEPROM;
// Keypad // Keypad
static struct Keypad _keypad; static struct Keypad _keypad;
static struct KeypadParameters _keypadParameters;
// The following pointers are for export (see platform.h) and external use. // The following pointers are for export (see platform.h) and external use.
@@ -153,7 +155,6 @@ struct SpiDevice* const spiEEPROM = &_spiEEPROM;
struct SpiParameters* const spiEEPROMParam = &_spi3EEPROMParameters; struct SpiParameters* const spiEEPROMParam = &_spi3EEPROMParameters;
struct Keypad* const keypad = &_keypad; struct Keypad* const keypad = &_keypad;
struct KeypadParameters* const keypadParam = &_keypadParameters;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Function declarations // Function declarations
@@ -350,8 +351,7 @@ ErrorStatus initPlatform(void)
IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE); IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE);
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE); IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
Keypad_getDefaultParameters(keypadParam); Keypad_construct(keypad, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE);
Keypad_construct(keypad, keypadParam, KEYPAD_DEBOUNCE_TIME_MS);
} }
return returnValue; return returnValue;

View File

@@ -91,6 +91,10 @@ ErrorStatus RTC_construct(struct Rtc* self)
/* Wait until last write operation on RTC registers has finished */ /* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask(); RTC_WaitForLastTask();
// Reset the counter
RTC_SetCounter(0x00);
return returnValue; return returnValue;
} }

View File

@@ -15,6 +15,7 @@ startup_stm32f10x_cl.o \
Display.o \ Display.o \
FreeRTOSFixes.o \ FreeRTOSFixes.o \
hwValidationMenu.o \ hwValidationMenu.o \
repairProcess.o \
\ \
heap_2.o\ heap_2.o\
list.o \ list.o \

View File

@@ -62,6 +62,7 @@
#define configQUEUE_REGISTRY_SIZE (10) #define configQUEUE_REGISTRY_SIZE (10)
#define configGENERATE_RUN_TIME_STATS 1 #define configGENERATE_RUN_TIME_STATS 1
/* Set the following definitions to 1 to include the API function, or zero /* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */ to exclude the API function. */

View File

@@ -76,12 +76,13 @@ struct HwValidationMenuItems
struct HwValidationMenu struct HwValidationMenu
{ {
TaskHandle_t taskHandle; TaskHandle_t taskHandle;
int TaskPriority; int taskPriority;
uint16_t stackSize; uint16_t stackSize;
bool runTask; bool runTask;
struct HwValidationMenuItems* testItems; struct HwValidationMenuItems* testItems;
int menuItemSelected; int menuItemSelected;
struct IODevice* ioDevice; struct IODevice* ioDevice;
bool initialized;
}; };
@@ -104,7 +105,7 @@ struct HwValidationMenu
* @todo * @todo
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
extern ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IODevice* ioDevice, struct HwValidationMenuItems testItems); extern ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IODevice* ioDevice, struct HwValidationMenuItems* testItems, int taskPriority, uint16_t stackSize);
#endif /* INC_HWVALIDATIONMENU_H_ */ #endif /* INC_HWVALIDATIONMENU_H_ */

View File

@@ -98,7 +98,7 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa
if(returnValue == SUCCESS) if(returnValue == SUCCESS)
{ {
if (xTaskCreate(DisplayTask, (const char*)"DisplayTask", self->stackSize, self, self->TaskPriority, self->taskHandle) != pdTRUE) if (xTaskCreate(DisplayTask, (const char*)"DisplayTask", self->stackSize, self, self->TaskPriority, &self->taskHandle) != pdTRUE)
{ {
returnValue = ERROR; returnValue = ERROR;
LOGGER_ERROR(mainLog, "Starting display task failed"); LOGGER_ERROR(mainLog, "Starting display task failed");

View File

@@ -314,19 +314,21 @@ static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IODevice* ioDevice, struct HwValidationMenuItems testItems) ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IODevice* ioDevice, struct HwValidationMenuItems* testItems, int taskPriority, uint16_t stackSize)
{ {
ErrorStatus returnValue = SUCCESS; ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
self->ioDevice = ioDevice; self->ioDevice = ioDevice;
self->TaskPriority = 0; self->taskPriority = taskPriority;
self->stackSize = 1024; self->stackSize = stackSize;
self->menuItemSelected = 0; self->menuItemSelected = 0;
if (xTaskCreate(hwValidationMenuTask, (const char*)"HwValidationMenu", self->stackSize, self, self->TaskPriority, self->taskHandle) != pdTRUE) if (xTaskCreate(hwValidationMenuTask, (const char*)"HwValidationMenu", self->stackSize, self, self->taskPriority, &self->taskHandle) != pdTRUE)
{ {
returnValue = ERROR; returnValue = ERROR;
LOGGER_ERROR(mainLog, "Starting hw validation menu task failed"); LOGGER_ERROR(mainLog, "Starting hw validation menu task failed");
@@ -335,6 +337,11 @@ ErrorStatus HwValidationMenu_construct(struct HwValidationMenu* self, struct IOD
{ {
LOGGER_INFO(mainLog, "hw validation menu task started"); LOGGER_INFO(mainLog, "hw validation menu task started");
} }
}
else
{
returnValue = ERROR;
}
return returnValue; return returnValue;
} }
@@ -346,7 +353,7 @@ static void hwValidationMenuTask(void *parameters)
while(1) while(1)
{ {
hwValidationMenuUpdate(self); hwValidationMenuUpdate(self);
vTaskDelay(1); vTaskDelay(100);
} }
} }

View File

@@ -34,7 +34,8 @@
#include "task.h" #include "task.h"
#include "Display.h" #include "Display.h"
#include "Logger.h" #include "hwValidationMenu.h"
#include "repairProcess.h"
#include "misc.h" #include "misc.h"
#include "stm32f10x_rcc.h" #include "stm32f10x_rcc.h"
@@ -48,6 +49,7 @@
#include "gpio.h" #include "gpio.h"
#include "IODevice.h" #include "IODevice.h"
#include "keypadMatrix.h" #include "keypadMatrix.h"
#include "Logger.h"
#include "PCBA.h" #include "PCBA.h"
#include "uart.h" #include "uart.h"
#include "spi.h" #include "spi.h"
@@ -88,8 +90,14 @@ static xTaskHandle sysTaskHandle;
static struct Display _display; static struct Display _display;
struct Display* display = &_display; struct Display* display = &_display;
static struct NHD0420 nhd0420; static struct NHD0420 nhd0420 = {.initialized = false};
static struct MAX5715 max5715 = {.initialized = false}; static struct MAX5715 max5715 = {.initialized = false};
static struct RepairProcess _rp = {.initialized = false};
static struct HwValidationMenu _hwValidation = {.initialized = false};
static struct HwValidationMenuItems hwTestItems;
struct RepairProcess* rp = &_rp;
struct HwValidationMenu* hwValidation = &_hwValidation;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Function declarations // Function declarations
@@ -139,7 +147,7 @@ static void printSystemInfoTask(void* parameters)
{ {
LOGGER_INFO(mainLog, "---------------------------------------"); LOGGER_INFO(mainLog, "---------------------------------------");
systeminfoCommandHandler(); systeminfoCommandHandler();
vTaskDelay(60000); vTaskDelay(20000);
} }
} }
@@ -153,12 +161,20 @@ static ErrorStatus systeminfoCommandHandler(void)
snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory); snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory);
LOGGER_INFO(mainLog, text); LOGGER_INFO(mainLog, text);
OS_logTaskInfo(display->taskHandle); vTaskDelay(10);
vTaskDelay(100);
OS_logTaskInfo(ledTaskHandle); OS_logTaskInfo(ledTaskHandle);
vTaskDelay(100); vTaskDelay(10);
OS_logTaskInfo(sysTaskHandle); OS_logTaskInfo(sysTaskHandle);
vTaskDelay(100); vTaskDelay(10);
OS_logTaskInfo(display->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(mainLog->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(keypad->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(rp->taskHandle);
vTaskDelay(10);
OS_logTaskInfo(hwValidation->taskHandle);
return errorStatus; return errorStatus;
} }
@@ -167,18 +183,20 @@ static void initTask(void* parameters)
{ {
initPlatform(); initPlatform();
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 50, &ledTaskArguments, 0, &ledTaskHandle); xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 100, &ledTaskArguments, 0, &ledTaskHandle);
Logger_construct(mainLog, &uart1->device, 2, 512); Logger_construct(mainLog, &uart3->device, 2, 512);
IODevice_write(&uart1->device, pcba->name, strlen(pcba->name));
NHD0420_construct(&nhd0420, &spiDisplay->device); NHD0420_construct(&nhd0420, &spiDisplay->device);
Display_construct(display, &nhd0420.displayDevice, 0, 1024, 10, 1000, 5000); Display_construct(display, &nhd0420.displayDevice, 0, 256, 10, 1000, 5000);
Display_clearScreen(display); Display_clearScreen(display);
Display_setBrightness(display, 6);
Display_setContrast(display, 40);
Display_write(display, pcba->name, strlen(pcba->name), 1, 1); Display_write(display, pcba->name, strlen(pcba->name), 1, 1);
char buffer[20]; char buffer[20];
@@ -188,11 +206,31 @@ static void initTask(void* parameters)
Version_getInstance()->patch); Version_getInstance()->patch);
Display_write(display, buffer, strlen(buffer), 3, 4); Display_write(display, buffer, strlen(buffer), 3, 4);
hwTestItems.display = &nhd0420.displayDevice;
hwTestItems.internalADC = adc1;
hwTestItems.externalDAC = &max5715;
hwTestItems.power6v5Enable = NULL;
hwTestItems.interlock1 = NULL;
hwTestItems.interlock2 = NULL;
hwTestItems.solenoid = NULL;
hwTestItems.mcp0Relay = NULL;
hwTestItems.mcp1Relay = NULL;
hwTestItems.mcp2Relay = NULL;
hwTestItems.cat0Relay = NULL;
hwTestItems.cat1Relay = NULL;
hwTestItems.cat2Relay = NULL;
hwTestItems.pcba = pcba;
// EEPROM TO BE DONE
HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 2, 1024);
MAX5715_construct(&max5715, &spiDAC->device); MAX5715_construct(&max5715, &spiDAC->device);
MAX5715_writeCODEn(&max5715, (MAX5715_SEL_DACA | MAX5715_SEL_DACC), 0x579B); MAX5715_writeREF_ON_2V5(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
repairProcess_construct(rp, 3, 1024);
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 1, &sysTaskHandle); xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 1, &sysTaskHandle);
// Delete this init task // Delete this init task
vTaskDelete(NULL); vTaskDelete(NULL);
@@ -209,8 +247,10 @@ static void ledBlinkTask (void* parameters)
while (1) while (1)
{ {
IODevice_write(&gpio->device, &high, 1); IODevice_write(&gpio->device, &high, 1);
Display_write(display, pcba->name, 1, 1, 20);
vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
IODevice_write(&gpio->device, &low, 1); IODevice_write(&gpio->device, &low, 1);
Display_write(display, " ", 1, 1, 20);
vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
} }
} }

View File

@@ -38,6 +38,8 @@
#include "stm32f10x_usart.h" #include "stm32f10x_usart.h"
#include "Display.h" #include "Display.h"
#include "repairProcess.h"
#include "Logger.h" #include "Logger.h"
#include "platform.h" #include "platform.h"
#include "rtc.h" #include "rtc.h"
@@ -270,6 +272,8 @@ void EXTI9_5_IRQHandler (void)
extern struct Display* display; extern struct Display* display;
extern struct RepairProcess* rp;
void RTC_IRQHandler(void) void RTC_IRQHandler(void)
{ {
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
@@ -281,10 +285,20 @@ void RTC_IRQHandler(void)
xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken); xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken);
Display_feedRefreshCounter(display); Display_feedRefreshCounter(display);
repairProcess_feedSecondsCounterFromISR(rp);
/* Wait until last write operation on RTC registers has finished */ /* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask(); RTC_WaitForLastTask();
}
if (RTC_GetITStatus(RTC_IT_OW))
{
// Counter overflow on next cycle pending - RESET counter to 0
RTC_ClearITPendingBit(RTC_IT_OW);
RTC_SetCounter(0x00);
LOGGER_WARNING_ISR(mainLog, "RTC counter overflow detected - reset system clock counter to 0");
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken); portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
} }