Progress on the menu

- Debounced the interlocks
- Created a specified screen for pre-compliance tests

ADCs must be averaged
menu handling of screens is not OK
destructing tasks is not OK

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@257 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-18 15:26:05 +00:00
parent 97a42de2ea
commit 51ffde94d7
20 changed files with 649 additions and 215 deletions

View File

@@ -34,6 +34,10 @@
#include <stdbool.h>
#include "stm32f10x.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "platform.h"
#include "gpio.h"
@@ -66,6 +70,9 @@ struct Interlock
struct InterlockElement NC;
bool initialized;
T_INTERLOCK_ID ID;
TaskHandle_t taskHandle;
SemaphoreHandle_t semaphore;
int waitToDebounce_ms;
};
// -----------------------------------------------------------------------------
@@ -88,7 +95,7 @@ struct Interlock
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus Interlock_construct(struct Interlock* self, T_INTERLOCK_ID ID, struct Gpio* NO, EXTI_InitTypeDef NOEXTI, struct Gpio* NC, EXTI_InitTypeDef NCEXTI);
extern ErrorStatus Interlock_construct(struct Interlock* self, T_INTERLOCK_ID ID, struct Gpio* NO, EXTI_InitTypeDef NOEXTI, struct Gpio* NC, EXTI_InitTypeDef NCEXTI, int waitToDebounce_ms);
/** ----------------------------------------------------------------------------

View File

@@ -25,8 +25,14 @@
// Include files
// -----------------------------------------------------------------------------
#include "stm32f10x.h"
#include "Error.h"
#include "Logger.h"
#include "Interlock.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
@@ -48,23 +54,39 @@
// Function declarations
// -----------------------------------------------------------------------------
static void InterlockTask (void* parameters);
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus Interlock_construct(struct Interlock* self, T_INTERLOCK_ID ID, struct Gpio* NO, EXTI_InitTypeDef NOEXTI, struct Gpio* NC, EXTI_InitTypeDef NCEXTI)
ErrorStatus Interlock_construct(struct Interlock* self, T_INTERLOCK_ID ID, struct Gpio* NO, EXTI_InitTypeDef NOEXTI, struct Gpio* NC, EXTI_InitTypeDef NCEXTI, int waitToDebounce_ms)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
self->ID = ID;
self->NO.io = NO;
self->NO.ioEXTI = NOEXTI;
self->NC.io = NC;
self->NC.ioEXTI = NCEXTI;
self->initialized = true;
vSemaphoreCreateBinary(self->semaphore);
xSemaphoreTake(self->semaphore, 0);
BaseType_t rv = xTaskCreate(InterlockTask, (const char*)"InterlockIO", 300, self, 1, &self->taskHandle);
if (rv != pdTRUE)
{
returnValue = ERROR;
LOGGER_ERROR(mainLog, "FAILED to start Interlock ID %d with code %d", ID, (int)rv);
}
else
{
self->ID = ID;
self->NO.io = NO;
self->NO.ioEXTI = NOEXTI;
self->NC.io = NC;
self->NC.ioEXTI = NCEXTI;
self->waitToDebounce_ms = waitToDebounce_ms;
self->initialized = true;
LOGGER_INFO(mainLog, "Interlock ID %d started", self->ID);
}
}
else
{
@@ -115,3 +137,24 @@ void Interlock_setEXTI(struct Interlock* self, FunctionalState command)
self->NC.ioEXTI.EXTI_LineCmd = command;
EXTI_Init(&self->NC.ioEXTI);
}
static void InterlockTask (void* parameters)
{
struct Interlock* self = (struct Interlock*)parameters;
while(1)
{
xSemaphoreTake(self->semaphore, portMAX_DELAY);
vTaskDelay(self->waitToDebounce_ms);
if (self->ID == COMMON_INTERLOCK)
{
Error_postError(INTERLOCK_COMMON_FAIL);
}
else if (self->ID == TESLA_INTERLOCK)
{
Error_postError(INTERLOCK_TESLA_FAIL);
}
}
}

View File

@@ -341,7 +341,9 @@ ErrorStatus NHD0420_sendCommand(const struct NHD0420* self, char command)
ErrorStatus returnValue = SUCCESS;
if (self->initialized)
{
char buffer[NHD0420_CMD_LENGTH] = {NHD0420_CMD_PREFIX, command};
char buffer[NHD0420_CMD_LENGTH];
buffer[0] = NHD0420_CMD_PREFIX;
buffer[1] = command;
returnValue = IODevice_write(self->device, buffer, NHD0420_CMD_LENGTH);
}