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

@@ -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");

View File

@@ -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;
}
}

View File

@@ -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));
}
}

View File

@@ -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);
}