diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c index 86b15a1..b860750 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c @@ -39,6 +39,8 @@ #include #include "uart.h" + +#include "stm32f10x_rtc.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -269,14 +271,16 @@ static void loggerTask(void* parameters) } #endif + uint32_t seconds = RTC_GetCounter(); #if defined(ENABLE_SERIAL_LOGGING) // 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, (logQueueItem.logType == LOGTYPE_DEBUG) ? "DBG" : (logQueueItem.logType == LOGTYPE_INFO) ? "INF" : (logQueueItem.logType == LOGTYPE_WARNING) ? "WRN" : "ERR", + seconds, logQueueItem.fileName, logQueueItem.functionName, logQueueItem.lineNumber, @@ -288,12 +292,6 @@ static void loggerTask(void* parameters) IODevice_write(self->loggingDevice, str, strlen(str)); #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)); } } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h index b2deaf6..9180860 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/inc/keypadMatrix.h @@ -32,6 +32,8 @@ // Include files // ----------------------------------------------------------------------------- +#include + #include "FreeRTOS.h" #include "semphr.h" #include "task.h" @@ -76,14 +78,14 @@ struct Keypad struct keypadElement column[KEYPAD_NUMBER_OF_COLUMNS]; Keypad_KeyState lastState[KEYPAD_NUMBER_OF_ROWS][KEYPAD_NUMBER_OF_COLUMNS]; xTaskHandle taskHandle; + int taskPriority; + uint16_t stackSize; SemaphoreHandle_t scanSemaphore; xQueueHandle rxQueue; + size_t rxQueueSize; + bool initialized; int waitToDebounce_ms; -}; -struct KeypadParameters -{ - int rxQueueSize; }; // ----------------------------------------------------------------------------- @@ -95,8 +97,9 @@ struct KeypadParameters * contructor for the Keypad driver * * @param self Keypad object to initialize - * @param parameters Parameters to use for initialisation * @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 * ERROR otherwise @@ -104,7 +107,7 @@ struct KeypadParameters * @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); -/** ---------------------------------------------------------------------------- - * 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_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c index e8e69a7..dfe6589 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/keypadMatrix.c @@ -40,9 +40,6 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- -#define KEYPAD_STACK_SIZE (512) -#define KEYPAD_TASK_PRIORITY (3) -#define KEYPAD_DEF_QUEUESIZE (32) // ----------------------------------------------------------------------------- // 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 colCounter = 0; ErrorStatus returnValue = SUCCESS; - if(keypad != NULL) + if(!self->initialized) { IODevice_construct(&self->device, read, NULL); @@ -84,6 +81,9 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param } self->waitToDebounce_ms = debounceTime; + self->rxQueueSize = rxQueueSize; + self->stackSize = stackSize; + self->taskPriority = taskPriority; // Initialize memory to keep track of state changes per key 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 - self->rxQueue = xQueueCreate(parameters->rxQueueSize, sizeof(struct KeypadQueueItem)); + self->rxQueue = xQueueCreate(self->rxQueueSize, sizeof(struct KeypadQueueItem)); if (self->rxQueue == 0) { //! Queue identifier is 0 -> error @@ -104,7 +104,7 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param 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) @@ -120,12 +120,17 @@ ErrorStatus Keypad_construct(struct Keypad* self, struct KeypadParameters* param if(returnValue == SUCCESS) { LOGGER_INFO(mainLog, "Keypad task started"); + self->initialized = true; } else { LOGGER_ERROR(mainLog, "Keypad task FAILED"); } } + else + { + returnValue = ERROR; + } 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) { - ErrorStatus errorStatus = SUCCESS; + ErrorStatus returnValue = SUCCESS; - *actualLength = 1; + const struct Keypad* keypad = (const struct Keypad*)self; - return errorStatus; + if (keypad->initialized) + { + *actualLength = 1; + } + else + { + returnValue = ERROR; + } + + return returnValue; } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c index 453f5f3..d774030 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/oli_stm32_h107.c @@ -62,7 +62,7 @@ #define UART_LOG_TX_QUEUE (256) // UART3 Settings (Developer terminal) -#define UART_TER_BAUDRATE (115200) +#define UART_TER_BAUDRATE (57600) #define UART_TER_TX_QUEUE (512) // SPI1 settings @@ -74,6 +74,9 @@ // Keypad Settings #define KEYPAD_DEBOUNCE_TIME_MS (20) +#define KEYPAD_STACK_SIZE (128) +#define KEYPAD_TASK_PRIORITY (3) +#define KEYPAD_DEF_QUEUESIZE (32) // ----------------------------------------------------------------------------- // Type definitions // ----------------------------------------------------------------------------- @@ -120,7 +123,6 @@ static struct SpiDevice _spiEEPROM; // Keypad static struct Keypad _keypad; -static struct KeypadParameters _keypadParameters; // 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 Keypad* const keypad = &_keypad; -struct KeypadParameters* const keypadParam = &_keypadParameters; // ----------------------------------------------------------------------------- // Function declarations @@ -350,8 +351,7 @@ ErrorStatus initPlatform(void) IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE); IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE); - Keypad_getDefaultParameters(keypadParam); - Keypad_construct(keypad, keypadParam, KEYPAD_DEBOUNCE_TIME_MS); + Keypad_construct(keypad, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE); } return returnValue; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/rtc.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/rtc.c index 700ddac..1e45289 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/rtc.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/rtc.c @@ -91,6 +91,10 @@ ErrorStatus RTC_construct(struct Rtc* self) /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); + // Reset the counter + RTC_SetCounter(0x00); + + return returnValue; } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile index c094514..aa11eb4 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile @@ -15,6 +15,7 @@ startup_stm32f10x_cl.o \ Display.o \ FreeRTOSFixes.o \ hwValidationMenu.o \ +repairProcess.o \ \ heap_2.o\ list.o \ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h index 6c9c89d..306d82a 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h @@ -62,6 +62,7 @@ #define configQUEUE_REGISTRY_SIZE (10) #define configGENERATE_RUN_TIME_STATS 1 + /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h index 4a0d465..331ac6b 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hwValidationMenu.h @@ -76,12 +76,13 @@ struct HwValidationMenuItems struct HwValidationMenu { TaskHandle_t taskHandle; - int TaskPriority; + int taskPriority; uint16_t stackSize; bool runTask; struct HwValidationMenuItems* testItems; int menuItemSelected; struct IODevice* ioDevice; + bool initialized; }; @@ -104,7 +105,7 @@ struct HwValidationMenu * @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_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c index c421397..78e16df 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c @@ -98,7 +98,7 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa 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; LOGGER_ERROR(mainLog, "Starting display task failed"); diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c index a60b44f..b2cdec4 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/hwValidationMenu.c @@ -314,26 +314,33 @@ 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; - self->ioDevice = ioDevice; - - self->TaskPriority = 0; - self->stackSize = 1024; - - self->menuItemSelected = 0; - - if (xTaskCreate(hwValidationMenuTask, (const char*)"HwValidationMenu", self->stackSize, self, self->TaskPriority, self->taskHandle) != pdTRUE) + if (!self->initialized) { - returnValue = ERROR; - LOGGER_ERROR(mainLog, "Starting hw validation menu task failed"); + self->ioDevice = ioDevice; + + self->taskPriority = taskPriority; + self->stackSize = stackSize; + + self->menuItemSelected = 0; + + if (xTaskCreate(hwValidationMenuTask, (const char*)"HwValidationMenu", self->stackSize, self, self->taskPriority, &self->taskHandle) != pdTRUE) + { + returnValue = ERROR; + LOGGER_ERROR(mainLog, "Starting hw validation menu task failed"); + } + else + { + LOGGER_INFO(mainLog, "hw validation menu task started"); + } } else { - LOGGER_INFO(mainLog, "hw validation menu task started"); + returnValue = ERROR; } return returnValue; @@ -346,7 +353,7 @@ static void hwValidationMenuTask(void *parameters) while(1) { hwValidationMenuUpdate(self); - vTaskDelay(1); + vTaskDelay(100); } } @@ -1237,4 +1244,4 @@ static ErrorStatus hwValidationMenuReceiveMessage(struct HwValidationMenu* self, } return returnValue; -} \ No newline at end of file +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c index 48d9d10..2d47083 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c @@ -34,7 +34,8 @@ #include "task.h" #include "Display.h" -#include "Logger.h" +#include "hwValidationMenu.h" +#include "repairProcess.h" #include "misc.h" #include "stm32f10x_rcc.h" @@ -48,6 +49,7 @@ #include "gpio.h" #include "IODevice.h" #include "keypadMatrix.h" +#include "Logger.h" #include "PCBA.h" #include "uart.h" #include "spi.h" @@ -88,8 +90,14 @@ static xTaskHandle sysTaskHandle; static struct Display _display; struct Display* display = &_display; -static struct NHD0420 nhd0420; +static struct NHD0420 nhd0420 = {.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 @@ -139,7 +147,7 @@ static void printSystemInfoTask(void* parameters) { LOGGER_INFO(mainLog, "---------------------------------------"); systeminfoCommandHandler(); - vTaskDelay(60000); + vTaskDelay(20000); } } @@ -153,12 +161,20 @@ static ErrorStatus systeminfoCommandHandler(void) snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory); LOGGER_INFO(mainLog, text); - OS_logTaskInfo(display->taskHandle); - vTaskDelay(100); + vTaskDelay(10); OS_logTaskInfo(ledTaskHandle); - vTaskDelay(100); + vTaskDelay(10); 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; } @@ -167,18 +183,20 @@ static void initTask(void* parameters) { 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); - - IODevice_write(&uart1->device, pcba->name, strlen(pcba->name)); + Logger_construct(mainLog, &uart3->device, 2, 512); 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_setBrightness(display, 6); + + Display_setContrast(display, 40); + Display_write(display, pcba->name, strlen(pcba->name), 1, 1); char buffer[20]; @@ -188,11 +206,31 @@ static void initTask(void* parameters) Version_getInstance()->patch); 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_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); // Delete this init task vTaskDelete(NULL); @@ -209,8 +247,10 @@ static void ledBlinkTask (void* parameters) while (1) { IODevice_write(&gpio->device, &high, 1); + Display_write(display, pcba->name, 1, 1, 20); vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); IODevice_write(&gpio->device, &low, 1); + Display_write(display, " ", 1, 1, 20); vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); } } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c index f28117c..84c9213 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/stm32f10x_it.c @@ -38,6 +38,8 @@ #include "stm32f10x_usart.h" #include "Display.h" +#include "repairProcess.h" + #include "Logger.h" #include "platform.h" #include "rtc.h" @@ -270,6 +272,8 @@ void EXTI9_5_IRQHandler (void) extern struct Display* display; +extern struct RepairProcess* rp; + void RTC_IRQHandler(void) { static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE; @@ -281,10 +285,20 @@ void RTC_IRQHandler(void) xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken); Display_feedRefreshCounter(display); + repairProcess_feedSecondsCounterFromISR(rp); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); - - portEND_SWITCHING_ISR(higherPriorityTaskWoken); } + + 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); }