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

@@ -32,7 +32,6 @@
// -----------------------------------------------------------------------------
#include "FreeRTOS.h"
#include "semphr.h"
#include "stm32f10x.h"
@@ -48,9 +47,15 @@
// Type definitions.
// -----------------------------------------------------------------------------
struct Time
{
int hours;
int minutes;
int seconds;
};
struct Rtc
{
SemaphoreHandle_t secondSync;
struct Observable observable;
};

View File

@@ -81,6 +81,9 @@
#define KEYPAD_STACK_SIZE (128)
#define KEYPAD_TASK_PRIORITY (3)
#define KEYPAD_DEF_QUEUESIZE (32)
// Interlock settings
#define INTERLOCK_DEBOUNCE_TIME_MS (50)
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
@@ -602,7 +605,7 @@ static ErrorStatus initPeriphery(void)
/* --------------------------------------------------------------------*/
/* RTC */
/* --------------------------------------------------------------------*/
IRQ_setInterruptProperties(RTC_IRQn, 12, 12, ENABLE);
IRQ_setInterruptProperties(RTC_IRQn, 13, 0, ENABLE);
RTC_construct(rtc);
/* --------------------------------------------------------------------*/
@@ -702,6 +705,8 @@ static ErrorStatus initPeriphery(void)
GPIO_construct(ledOrange, OUTPUT, ledOrange->gpio);
// 6V5 Power Enable
GPIO_construct(power6v5Enable, OUTPUT, power6v5Enable->gpio);
// powerEnable is inverted. Set to HIGH/TRUE to switch OFF
GPIO_setValue(power6v5Enable, true);
IRQ_setInterruptProperties(EXTI0_IRQn, 12, 0, ENABLE);
IRQ_setInterruptProperties(EXTI1_IRQn, 12, 0, ENABLE);
@@ -712,7 +717,7 @@ static ErrorStatus initPeriphery(void)
EXTI_InitTypeDef intNCEXTI = configureEXTI(EXTI_Line1, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
GPIO_construct(interlockNC, INPUT, interlockNC->gpio);
Interlock_construct(interlock, COMMON_INTERLOCK, interlockNO, intNOEXTI, interlockNC, intNCEXTI);
Interlock_construct(interlock, COMMON_INTERLOCK, interlockNO, intNOEXTI, interlockNC, intNCEXTI, INTERLOCK_DEBOUNCE_TIME_MS);
// Solenoid
GPIO_construct(solenoid, OUTPUT, solenoid->gpio);
@@ -742,7 +747,7 @@ static ErrorStatus initPeriphery(void)
EXTI_InitTypeDef teslaNCEXTI = configureEXTI(EXTI_Line10, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
GPIO_construct(teslaNC, INPUT, teslaNC->gpio);
Interlock_construct(teslalock, TESLA_INTERLOCK, teslaNO, teslaNOEXTI, teslaNC, teslaNCEXTI);
Interlock_construct(teslalock, TESLA_INTERLOCK, teslaNO, teslaNOEXTI, teslaNC, teslaNCEXTI, INTERLOCK_DEBOUNCE_TIME_MS);
}
return returnValue;

View File

@@ -31,6 +31,7 @@
#include "rtc.h"
#include "stm32f10x_rtc.h"
#include "Logger.h"
#include "Observable.h"
// -----------------------------------------------------------------------------
@@ -64,15 +65,6 @@ ErrorStatus RTC_construct(struct Rtc* self)
{
ErrorStatus returnValue = SUCCESS;
//! Create semaphore to synchronize with RTC interrupt handler
vSemaphoreCreateBinary(self->secondSync);
// Take semaphore
if (xSemaphoreTake(self->secondSync, 0) == pdFALSE)
{
//! An error has occurred
returnValue = ERROR;
}
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
@@ -105,3 +97,31 @@ struct Observable* RTC_getObservable(struct Rtc* self)
{
return &self->observable;
}
void RTC_IRQHandler(void)
{
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
{
/* Clear the RTC Second interrupt */
RTC_ClearITPendingBit(RTC_IT_SEC);
Observable_notifyObservers(RTC_getObservable(rtc), NULL);
/* Wait until last write operation on RTC registers has finished */
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);
}