Going on with structure
Added observer/observable for RTC git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@251 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -24,12 +24,14 @@ ARFLAGS = rs
|
||||
|
||||
OBJECTS = \
|
||||
DisplayDevice.o \
|
||||
hsb-mrts.o \
|
||||
Interlock.o \
|
||||
IODevice.o \
|
||||
KeyboardDevice.o \
|
||||
Logger.o \
|
||||
MAX5715.o \
|
||||
nhd0420.o \
|
||||
Observable.o \
|
||||
PID.o \
|
||||
storm700.o
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Class.h (c) 2013 Micro-Key bv
|
||||
* -----------------------------------------------------------------------------
|
||||
* Micro-Key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* -----------------------------------------------------------------------------
|
||||
* Description: Macro utilities to hide or protect struct members
|
||||
* -----------------------------------------------------------------------------
|
||||
* $Id$
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _CLASS_H_
|
||||
#define _CLASS_H_
|
||||
|
||||
#ifndef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#define PRIVATE(member) DONOTUSE ## member
|
||||
#undef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#else
|
||||
|
||||
#define PRIVATE(member) member
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -82,6 +82,7 @@
|
||||
Logger_logISR(a, "", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Class.h"
|
||||
#include "Observer.h"
|
||||
|
||||
/* -------------------------------*
|
||||
@@ -37,17 +36,14 @@
|
||||
/**
|
||||
* Maximal number of Observers for one Observable.
|
||||
*/
|
||||
#define OBSERVABLE_MAX_OBSERVERS (32)
|
||||
#define OBSERVABLE_MAX_OBSERVERS (10)
|
||||
|
||||
/**
|
||||
* Static initializer for the Observable class.
|
||||
* Typical usage: struct Observable observable = OBSERVABLE_INITIALIZER;
|
||||
*/
|
||||
#ifdef CLASS_INTERNAL_INCLUDE
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
#else
|
||||
#define OBSERVABLE_INITIALIZER { .DONOTUSEnrOfObservers = 0, .DONOTUSEobservers = { 0, } }
|
||||
#endif
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
|
||||
|
||||
/* ------------------*
|
||||
* Type definitions. *
|
||||
@@ -59,8 +55,8 @@
|
||||
*/
|
||||
struct Observable
|
||||
{
|
||||
int PRIVATE(nrOfObservers);
|
||||
Observer PRIVATE(observers)[OBSERVABLE_MAX_OBSERVERS];
|
||||
int nrOfObservers;
|
||||
Observer observers[OBSERVABLE_MAX_OBSERVERS];
|
||||
};
|
||||
|
||||
/* ----------------------*
|
||||
@@ -74,14 +70,14 @@ struct Observable
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_initialize(struct Observable* self);
|
||||
void Observable_construct(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Terminates the Observable class. All Observers are removed.
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_terminate(struct Observable* self);
|
||||
void Observable_destruct(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Adds one Observer to the Observable.
|
||||
|
||||
@@ -47,12 +47,12 @@ static int indexOfObserverInList(const struct Observable* self, const Observer o
|
||||
* ---------------------*
|
||||
*/
|
||||
|
||||
void Observable_initialize(struct Observable* self)
|
||||
void Observable_construct(struct Observable* self)
|
||||
{
|
||||
Observable_deleteObservers(self);
|
||||
}
|
||||
|
||||
void Observable_terminate(struct Observable* self)
|
||||
void Observable_destruct(struct Observable* self)
|
||||
{
|
||||
Observable_deleteObservers(self);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ ErrorStatus Observable_addObserver(struct Observable* self, const Observer obser
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ERROR("No space left to store a new observer");
|
||||
LOGGER_ERROR(mainLog, "No space left to store a new observer");
|
||||
errorStatus = ERROR;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ ErrorStatus Observable_addObserverAtFront(struct Observable* self, const Observe
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ERROR("No space left to store a new observer");
|
||||
LOGGER_ERROR(mainLog, "No space left to store a new observer");
|
||||
errorStatus = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,11 +94,15 @@ ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice* devic
|
||||
ddParameters.brightnessMax = NHD0420_BRIGHTNESS_MAX;
|
||||
ddParameters.contrastMin = NHD0420_CONTRAST_MIN;
|
||||
ddParameters.contrastMax = NHD0420_CONTRAST_MAX;
|
||||
DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, NULL, setBrightness, setContrast, NULL);
|
||||
|
||||
returnValue = DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, NULL, setBrightness, setContrast, NULL);
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
self->initialized = true;
|
||||
NHD0420_sendData(self, "Hallo", 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
|
||||
@@ -50,7 +50,7 @@ static char keyLookupTable[STORM700_NUMBER_OF_ROWS][STORM700_NUMBER_OF_COLUMNS]
|
||||
{ '1', '2', '3', 'X' },
|
||||
{ '4', '5', '6', 'U' },
|
||||
{ '7', '8', '9', 'D' },
|
||||
{ 'L', '0', 'R', '\n'}
|
||||
{ 'L', '0', 'R', 'E' }
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "stm32f10x_spi.h"
|
||||
#include "stm32f10x_usart.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -64,6 +65,7 @@ extern struct Logger* mainLog;
|
||||
|
||||
// Export of PCBA information
|
||||
extern struct Pcba* pcba;
|
||||
extern struct Version* version;
|
||||
// Export of ADCs
|
||||
extern struct Adc* const adc1;
|
||||
// Export of the rtc
|
||||
@@ -79,6 +81,7 @@ extern struct SpiDevice* const spiDisplay;
|
||||
extern struct SpiDevice* const spiEEPROM;
|
||||
// Export of Keypad
|
||||
extern struct Keypad* const keypad;
|
||||
extern struct Storm700* const storm700;
|
||||
// Export of GPIOs
|
||||
extern struct Gpio* const ledGreen;
|
||||
extern struct Gpio* const ledOrange;
|
||||
@@ -94,9 +97,14 @@ extern struct Gpio* const mcp2Relay;
|
||||
extern struct Gpio* const cat0Relay;
|
||||
extern struct Gpio* const cat1Relay;
|
||||
extern struct Gpio* const cat2Relay;
|
||||
|
||||
extern struct Interlock* const interlock;
|
||||
extern struct Interlock* const teslalock;
|
||||
|
||||
extern struct NHD0420* const nhd0420;
|
||||
|
||||
extern struct MAX5715* const max5715;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Observable.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -49,6 +51,7 @@
|
||||
struct Rtc
|
||||
{
|
||||
SemaphoreHandle_t secondSync;
|
||||
struct Observable observable;
|
||||
};
|
||||
|
||||
|
||||
@@ -68,4 +71,18 @@ struct Rtc
|
||||
extern ErrorStatus RTC_construct(struct Rtc* self);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* RTC_getObservable
|
||||
* Description of function
|
||||
*
|
||||
* @param self
|
||||
*
|
||||
* @return struct Observable*
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern struct Observable* RTC_getObservable(struct Rtc* self);
|
||||
|
||||
|
||||
#endif /* INC_RTC_H_ */
|
||||
|
||||
@@ -37,17 +37,20 @@
|
||||
#include "Logger.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "gpio.h"
|
||||
#include "Interlock.h"
|
||||
#include "internalADC.h"
|
||||
#include "gpio.h"
|
||||
#include "keypadMatrix.h"
|
||||
#include "MAX5715.h"
|
||||
#include "nhd0420.h"
|
||||
#include "PCBA.h"
|
||||
#include "rtc.h"
|
||||
#include "spi.h"
|
||||
#include "spiDevice.h"
|
||||
#include "storm700.h"
|
||||
#include "uart.h"
|
||||
#include "keypadMatrix.h"
|
||||
#include "nhd0420.h"
|
||||
#include "MAX5715.h"
|
||||
#include "Version.h"
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -118,6 +121,7 @@ static struct SpiDevice _spiEEPROM = {.initialized = false};
|
||||
|
||||
// Keypad
|
||||
static struct Keypad _keypad = {.initialized = false};
|
||||
static struct Storm700 _storm700 = {.initialized = false};
|
||||
|
||||
// GPIOs
|
||||
static struct Gpio _ledGreen = {.initialized = false};
|
||||
@@ -138,6 +142,10 @@ static struct Gpio _cat2Relay = {.initialized = false};
|
||||
static struct Interlock _interlock = {.initialized = false};
|
||||
static struct Interlock _teslalock = {.initialized = false};
|
||||
|
||||
static struct NHD0420 _nhd0420 = {.initialized = false};
|
||||
|
||||
static struct MAX5715 _max5715 = {.initialized = false};
|
||||
|
||||
|
||||
// The following pointers are for export (see platform.h) and external use.
|
||||
// Note that the pointer content is marked "const"
|
||||
@@ -145,6 +153,7 @@ static struct Interlock _teslalock = {.initialized = false};
|
||||
struct Logger* mainLog = &_mainLog;
|
||||
|
||||
struct Pcba* pcba; // Singleton
|
||||
struct Version* version; // Singleton
|
||||
|
||||
struct Adc* const adc1 = &_adc1;
|
||||
struct AdcParameters* adc1Parameters = &_adc1Parameters;
|
||||
@@ -166,6 +175,7 @@ struct SpiDevice* const spiEEPROM = &_spiEEPROM;
|
||||
struct SpiParameters* const spiEEPROMParam = &_spi3EEPROMParameters;
|
||||
|
||||
struct Keypad* const keypad = &_keypad;
|
||||
struct Storm700* const storm700 = &_storm700;
|
||||
|
||||
struct Gpio* const ledGreen = &_ledGreen;
|
||||
struct Gpio* const ledOrange = &_ledOrange;
|
||||
@@ -174,7 +184,7 @@ struct Gpio* const interlockNO = &_interlockNO;
|
||||
struct Gpio* const interlockNC = &_interlockNC;
|
||||
struct Gpio* const teslaNO = &_teslaNO;
|
||||
struct Gpio* const teslaNC = &_teslaNC;
|
||||
struct Gpio* const solenoid = & _solenoid;
|
||||
struct Gpio* const solenoid = &_solenoid;
|
||||
struct Gpio* const mcp0Relay = &_mcp0Relay;
|
||||
struct Gpio* const mcp1Relay = &_mcp1Relay;
|
||||
struct Gpio* const mcp2Relay = &_mcp2Relay;
|
||||
@@ -185,12 +195,18 @@ struct Gpio* const cat2Relay = &_cat2Relay;
|
||||
struct Interlock* const interlock = &_interlock;
|
||||
struct Interlock* const teslalock = &_teslalock;
|
||||
|
||||
struct NHD0420* const nhd0420 = &_nhd0420;
|
||||
|
||||
struct MAX5715* const max5715 = &_max5715;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus initClocks(void);
|
||||
static ErrorStatus initIO (void);
|
||||
static ErrorStatus initPeriphery(void);
|
||||
static ErrorStatus initPlatformDevices (void);
|
||||
static T_PL_GPIO configureGPIO (GPIO_TypeDef* gpioTypeDef, GPIOMode_TypeDef gpioMode, GPIOSpeed_TypeDef gpioSpeed, uint16_t gpioPin);
|
||||
static EXTI_InitTypeDef configureEXTI (uint32_t line, EXTIMode_TypeDef mode, EXTITrigger_TypeDef trigger, FunctionalState command);
|
||||
|
||||
@@ -198,7 +214,7 @@ static EXTI_InitTypeDef configureEXTI (uint32_t line, EXTIMode_TypeDef mode, EXT
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//#ifdef OLI_STM32_H107
|
||||
#ifdef OLI_STM32_H107
|
||||
|
||||
ErrorStatus initPlatform(void)
|
||||
{
|
||||
@@ -220,222 +236,18 @@ ErrorStatus initPlatform(void)
|
||||
// INITIALIZE AND CONFIGURE ALL REQUIRED IO AND PERIPHERY
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* PCBA */
|
||||
/* --------------------------------------------------------------------*/
|
||||
pcba = PCBA_getInstance();
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* DMA1 - Channel 1 - For use with ADC1 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
DMA_DeInit(DMA1_Channel1);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)adc1->channelValue;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = ADC1_NUMBER_OF_USED_CHANNELS;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
|
||||
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
|
||||
/* Enable DMA1 channel1 */
|
||||
DMA_Cmd(DMA1_Channel1, ENABLE);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* ADC1 - for module feedback */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(ADC1_2_IRQn, 12, 12, DISABLE);
|
||||
adc1Parameters->ADC_Mode = ADC_Mode_Independent;
|
||||
adc1Parameters->ADC_ScanConvMode = ENABLE;
|
||||
adc1Parameters->ADC_ContinuousConvMode = ENABLE;
|
||||
adc1Parameters->ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
adc1Parameters->ADC_DataAlign = ADC_DataAlign_Right;
|
||||
adc1Parameters->ADC_NbrOfChannel = ADC1_NUMBER_OF_USED_CHANNELS;
|
||||
|
||||
adc1->ADCx = ADC1;
|
||||
ADC_construct(adc1, adc1Parameters);
|
||||
|
||||
struct AdcChannelParameters acParameters;
|
||||
acParameters.channel = ADC_Channel_1;
|
||||
acParameters.Rank = 1;
|
||||
acParameters.ADC_SampleTime = ADC_SampleTime_239Cycles5;
|
||||
ADCChannel_construct(&adc1->channel[1], adc1, &acParameters);
|
||||
|
||||
acParameters.channel = ADC_Channel_2;
|
||||
acParameters.Rank = 2;
|
||||
acParameters.ADC_SampleTime = ADC_SampleTime_239Cycles5;
|
||||
ADCChannel_construct(&adc1->channel[2], adc1, &acParameters);
|
||||
|
||||
acParameters.channel = ADC_Channel_0;
|
||||
acParameters.Rank = 3;
|
||||
acParameters.ADC_SampleTime = ADC_SampleTime_239Cycles5;
|
||||
ADCChannel_construct(&adc1->channel[0], adc1, &acParameters);
|
||||
|
||||
ADC_setDMAStatus(adc1, ENABLE);
|
||||
ADC_setStatus(adc1, ENABLE);
|
||||
ADC_performInternalCalibration(adc1);
|
||||
ADC_SoftwareStartConvCmd(adc1->ADCx, ENABLE);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* RTC */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(RTC_IRQn, 12, 12, ENABLE);
|
||||
RTC_construct(rtc);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* USART1 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(USART1_IRQn, 15, 15, ENABLE);
|
||||
uart1->USART_TypeDef = USART1;
|
||||
Uart_getDefaultParameters(uartLoggerParam);
|
||||
// Adjust to higher baudrate for intensive logging
|
||||
uartLoggerParam->baudrate = UART_LOG_BAUDRATE;
|
||||
// Adjust the TX queue size for intensive logging
|
||||
uartLoggerParam->txQueueSize = UART_LOG_TX_QUEUE;
|
||||
returnValue = Uart_construct(uart1, uartLoggerParam);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* USART3 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Initialize the Terminal UART
|
||||
IRQ_setInterruptProperties(USART3_IRQn, 15, 15, ENABLE);
|
||||
uart3->USART_TypeDef = USART3;
|
||||
Uart_getDefaultParameters(uartTerminalParam);
|
||||
// Adjust to higher baudrate for intensive logging
|
||||
uartTerminalParam->baudrate = UART_TER_BAUDRATE;
|
||||
// Adjust the TX queue size for intensive logging
|
||||
uartTerminalParam->txQueueSize = UART_TER_TX_QUEUE;
|
||||
returnValue = Uart_construct(uart3, uartTerminalParam);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* SPI1 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(SPI1_IRQn, 12, 12, ENABLE);
|
||||
spi1->initialized = false;
|
||||
spi1->SPI_TypeDef = SPI1;
|
||||
MAX5715_getSpiParameters(spiDACParam);
|
||||
GPIO_SetBits(spiDAC->SPI_CE.GPIO_Typedef, spiDAC->SPI_CE.GPIO_InitStruct.GPIO_Pin);
|
||||
SpiDevice_construct(spiDAC, spi1, spiDACParam);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* SPI3 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(SPI3_IRQn, 12, 12, ENABLE);
|
||||
spi3->initialized = false;
|
||||
spi3->SPI_TypeDef = SPI3;
|
||||
// Get the SPI parameters from the NHD0420 driver. They are more critical than the parameters from the EEPROM
|
||||
NHD0420_getSpiParameters(spiDisplayParam);
|
||||
// In order to use multiple slaves on this bus (and to increase performance), some parameters are altered
|
||||
// Use full-duples instead of TX only, because the EEPROM is both write- and readable
|
||||
spiDisplayParam->SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||
// Adjust the RX and TX queues for multiple use
|
||||
spiDisplayParam->rxQueueSize = SPI_LCD_EEPROM_RX_QUEUE;
|
||||
spiDisplayParam->txQueueSize = SPI_LCD_EEPROM_TX_QUEUE;
|
||||
///TODO SPI_CE should be initialized individually
|
||||
GPIO_SetBits(spiDisplay->SPI_CE.GPIO_Typedef, spiDisplay->SPI_CE.GPIO_InitStruct.GPIO_Pin);
|
||||
GPIO_SetBits(spiEEPROM->SPI_CE.GPIO_Typedef, spiEEPROM->SPI_CE.GPIO_InitStruct.GPIO_Pin);
|
||||
SpiDevice_construct(spiDisplay, spi3, spiDisplayParam);
|
||||
SpiDevice_construct(spiEEPROM, spi3, spiEEPROMParam);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* KEYPAD COLUMNS */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Set-up the interrupts for the Keypad columns
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_Line = EXTI_Line4;
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[0].EXTI_InitStruct);
|
||||
// Enable the interrupts for the Keypad columns
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_Line = EXTI_Line5;
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[1].EXTI_InitStruct);
|
||||
// Enable the interrupts for the Keypad columns
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_Line = EXTI_Line6;
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[2].EXTI_InitStruct);
|
||||
// Enable the interrupts for the Keypad columns
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_Line = EXTI_Line7;
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[3].EXTI_InitStruct);
|
||||
|
||||
IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
|
||||
|
||||
Keypad_construct(keypad, 4, 4, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* GPIOs */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Green LED
|
||||
GPIO_construct(ledGreen, OUTPUT, ledGreen->gpio);
|
||||
// Orange LED
|
||||
GPIO_construct(ledOrange, OUTPUT, ledOrange->gpio);
|
||||
// 6V5 Power Enable
|
||||
GPIO_construct(power6v5Enable, OUTPUT, power6v5Enable->gpio);
|
||||
|
||||
IRQ_setInterruptProperties(EXTI0_IRQn, 12, 0, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI1_IRQn, 12, 0, ENABLE);
|
||||
// InterlockNO
|
||||
EXTI_InitTypeDef intNOEXTI; // = configureEXTI(EXTI_Line0, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, ENABLE);
|
||||
intNOEXTI.EXTI_Line = EXTI_Line0;
|
||||
intNOEXTI.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
intNOEXTI.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
intNOEXTI.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&intNOEXTI);
|
||||
GPIO_construct(interlockNO, INPUT, interlockNO->gpio);
|
||||
// InterlockNC
|
||||
EXTI_InitTypeDef intNCEXTI = configureEXTI(EXTI_Line1, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, ENABLE);
|
||||
GPIO_construct(interlockNC, INPUT, interlockNC->gpio);
|
||||
|
||||
// Interlock_construct(interlock, interlockNO, intNOEXTI, interlockNC, intNCEXTI);
|
||||
|
||||
// Solenoid
|
||||
GPIO_construct(solenoid, OUTPUT, solenoid->gpio);
|
||||
if (PCBA_getInstance()->pcba == CathodeMCP)
|
||||
{
|
||||
// MCP0Relay
|
||||
GPIO_construct(mcp0Relay, OUTPUT, mcp0Relay->gpio);
|
||||
// MCP1Relay
|
||||
GPIO_construct(mcp1Relay, OUTPUT, mcp1Relay->gpio);
|
||||
// MCP2Relay
|
||||
GPIO_construct(mcp2Relay, OUTPUT, mcp2Relay->gpio);
|
||||
// CAT0Relay
|
||||
GPIO_construct(cat0Relay, OUTPUT, cat0Relay->gpio);
|
||||
// CAT1Relay
|
||||
GPIO_construct(cat1Relay, OUTPUT, cat1Relay->gpio);
|
||||
// CAT2Relay
|
||||
GPIO_construct(cat2Relay, OUTPUT, cat2Relay->gpio);
|
||||
}
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
// Tesla Lock
|
||||
EXTI_InitTypeDef teslaNOEXTI = configureEXTI(EXTI_Line9, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(teslaNO, INPUT, teslaNO->gpio);
|
||||
EXTI_InitTypeDef teslaNCEXTI = configureEXTI(EXTI_Line10, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(teslaNC, INPUT, teslaNC->gpio);
|
||||
|
||||
Interlock_construct(teslalock, teslaNO, teslaNOEXTI, teslaNC, teslaNCEXTI);
|
||||
returnValue = initPeriphery();
|
||||
}
|
||||
|
||||
// Interlock_setEXTI(interlock, ENABLE);
|
||||
|
||||
// INITIALIZE PLATFORM-SPECIFIC APPLICATIONS
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = initPlatformDevices();
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
static ErrorStatus initClocks (void)
|
||||
{
|
||||
@@ -505,80 +317,35 @@ static ErrorStatus initIO (void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
T_PL_GPIO gpio;
|
||||
|
||||
/*PCBA IO initialisation -------------------------------------------------*/
|
||||
// A0
|
||||
T_PL_GPIO A0;
|
||||
A0.GPIO_Typedef = GPIOC;
|
||||
A0.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
|
||||
A0.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
||||
A0.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
|
||||
GPIO_Init(A0.GPIO_Typedef, &A0.GPIO_InitStruct);
|
||||
T_PL_GPIO A0 = configureGPIO(GPIOC, GPIO_Mode_IPD, GPIO_Speed_10MHz, GPIO_Pin_0);
|
||||
// A1
|
||||
T_PL_GPIO A1;
|
||||
A1.GPIO_Typedef = GPIOC;
|
||||
A1.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
|
||||
A1.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
|
||||
A1.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
|
||||
GPIO_Init(A1.GPIO_Typedef, &A1.GPIO_InitStruct);
|
||||
|
||||
T_PL_GPIO A1 = configureGPIO(GPIOC, GPIO_Mode_IPD, GPIO_Speed_10MHz, GPIO_Pin_1);
|
||||
PCBA_setIO(&A0, &A1);
|
||||
|
||||
|
||||
/*LED IO initialisation --------------------------------------------------*/
|
||||
// Init LED Green
|
||||
ledGreen->gpio.GPIO_Typedef = GPIOC;
|
||||
ledGreen->gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
ledGreen->gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
|
||||
ledGreen->gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(ledGreen->gpio.GPIO_Typedef, &ledGreen->gpio.GPIO_InitStruct);
|
||||
ledGreen->gpio = configureGPIO(GPIOC, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_6);
|
||||
|
||||
// Init LED Orange
|
||||
ledOrange->gpio.GPIO_Typedef = GPIOC;
|
||||
ledOrange->gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
ledOrange->gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
|
||||
ledOrange->gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(ledOrange->gpio.GPIO_Typedef, &ledOrange->gpio.GPIO_InitStruct);
|
||||
ledOrange->gpio = configureGPIO(GPIOC, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_7);
|
||||
|
||||
/* ADC1 initialisation ---------------------------------------------------*/
|
||||
// Channel 0 - PA0
|
||||
gpio.GPIO_Typedef = GPIOA;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AIN;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
||||
adc1->channel[ADC_Channel_0].input = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
adc1->channel[ADC_Channel_0].input = configureGPIO(GPIOA, GPIO_Mode_AIN, GPIO_Speed_50MHz, GPIO_Pin_0);
|
||||
// Channel 1 - PA1
|
||||
gpio.GPIO_Typedef = GPIOA;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AIN;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
|
||||
adc1->channel[ADC_Channel_1].input = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
adc1->channel[ADC_Channel_1].input = configureGPIO(GPIOA, GPIO_Mode_AIN, GPIO_Speed_50MHz, GPIO_Pin_1);
|
||||
// Channel 2 - PA2
|
||||
gpio.GPIO_Typedef = GPIOA;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AIN;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
|
||||
adc1->channel[ADC_Channel_2].input = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
adc1->channel[ADC_Channel_2].input = configureGPIO(GPIOA, GPIO_Mode_AIN, GPIO_Speed_50MHz, GPIO_Pin_2);
|
||||
|
||||
|
||||
/* USART1 initialisation -------------------------------------------------*/
|
||||
// Init TX line
|
||||
gpio.GPIO_Typedef = GPIOB;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
|
||||
gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
uart1->USART_TX = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
|
||||
|
||||
uart1->USART_TX = configureGPIO(GPIOB, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_6);
|
||||
// Init RX line
|
||||
gpio.GPIO_Typedef = GPIOB;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
|
||||
uart1->USART_RX = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
|
||||
uart1->USART_RX = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_7);
|
||||
// Apply pin-remapping for UART1 I/Os (alternative I/Os usage)
|
||||
GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE);
|
||||
|
||||
@@ -587,41 +354,16 @@ static ErrorStatus initIO (void)
|
||||
if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP))
|
||||
{
|
||||
// Init TX line
|
||||
gpio.GPIO_Typedef = GPIOB;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10;
|
||||
gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
uart1->USART_TX = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
|
||||
|
||||
uart3->USART_TX = configureGPIO(GPIOB, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_10);
|
||||
// Init RX line
|
||||
gpio.GPIO_Typedef = GPIOB;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
|
||||
uart1->USART_RX = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
GPIO_Init(uart3->USART_RX.GPIO_Typedef, &uart3->USART_RX.GPIO_InitStruct);
|
||||
uart1->USART_RX = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_11);
|
||||
}
|
||||
else if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
// Init TX line
|
||||
gpio.GPIO_Typedef = GPIOD;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8;
|
||||
gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
uart1->USART_TX = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
|
||||
|
||||
uart3->USART_TX = configureGPIO(GPIOD, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_8);
|
||||
// Init RX line
|
||||
gpio.GPIO_Typedef = GPIOD;
|
||||
gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9;
|
||||
uart1->USART_RX = gpio;
|
||||
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||
GPIO_Init(uart3->USART_RX.GPIO_Typedef, &uart3->USART_RX.GPIO_InitStruct);
|
||||
|
||||
uart1->USART_RX = configureGPIO(GPIOD, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_9);
|
||||
GPIO_PinRemapConfig(GPIO_FullRemap_USART3, ENABLE);
|
||||
}
|
||||
|
||||
@@ -788,9 +530,293 @@ static ErrorStatus initIO (void)
|
||||
teslaNC->gpio = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_10);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource10);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus initPeriphery(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* PCBA & Software Version */
|
||||
/* --------------------------------------------------------------------*/
|
||||
pcba = PCBA_getInstance();
|
||||
version = Version_getInstance();
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* DMA1 - Channel 1 - For use with ADC1 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
DMA_DeInit(DMA1_Channel1);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)adc1->channelValue;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = ADC1_NUMBER_OF_USED_CHANNELS;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
|
||||
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
|
||||
/* Enable DMA1 channel1 */
|
||||
DMA_Cmd(DMA1_Channel1, ENABLE);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* ADC1 - for module feedback */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(ADC1_2_IRQn, 12, 12, DISABLE);
|
||||
adc1Parameters->ADC_Mode = ADC_Mode_Independent;
|
||||
adc1Parameters->ADC_ScanConvMode = ENABLE;
|
||||
adc1Parameters->ADC_ContinuousConvMode = ENABLE;
|
||||
adc1Parameters->ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||
adc1Parameters->ADC_DataAlign = ADC_DataAlign_Right;
|
||||
adc1Parameters->ADC_NbrOfChannel = ADC1_NUMBER_OF_USED_CHANNELS;
|
||||
|
||||
adc1->ADCx = ADC1;
|
||||
ADC_construct(adc1, adc1Parameters);
|
||||
|
||||
struct AdcChannelParameters acParameters;
|
||||
acParameters.channel = ADC_Channel_1;
|
||||
acParameters.Rank = 1;
|
||||
acParameters.ADC_SampleTime = ADC_SampleTime_239Cycles5;
|
||||
ADCChannel_construct(&adc1->channel[1], adc1, &acParameters);
|
||||
|
||||
acParameters.channel = ADC_Channel_2;
|
||||
acParameters.Rank = 2;
|
||||
acParameters.ADC_SampleTime = ADC_SampleTime_239Cycles5;
|
||||
ADCChannel_construct(&adc1->channel[2], adc1, &acParameters);
|
||||
|
||||
acParameters.channel = ADC_Channel_0;
|
||||
acParameters.Rank = 3;
|
||||
acParameters.ADC_SampleTime = ADC_SampleTime_239Cycles5;
|
||||
ADCChannel_construct(&adc1->channel[0], adc1, &acParameters);
|
||||
|
||||
ADC_setDMAStatus(adc1, ENABLE);
|
||||
ADC_setStatus(adc1, ENABLE);
|
||||
ADC_performInternalCalibration(adc1);
|
||||
ADC_SoftwareStartConvCmd(adc1->ADCx, ENABLE);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* RTC */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(RTC_IRQn, 12, 12, ENABLE);
|
||||
RTC_construct(rtc);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* USART1 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(USART1_IRQn, 15, 15, ENABLE);
|
||||
uart1->USART_TypeDef = USART1;
|
||||
Uart_getDefaultParameters(uartLoggerParam);
|
||||
// Adjust to higher baudrate for intensive logging
|
||||
uartLoggerParam->baudrate = UART_LOG_BAUDRATE;
|
||||
// Adjust the TX queue size for intensive logging
|
||||
uartLoggerParam->txQueueSize = UART_LOG_TX_QUEUE;
|
||||
returnValue = Uart_construct(uart1, uartLoggerParam);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* USART3 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Initialize the Terminal UART
|
||||
IRQ_setInterruptProperties(USART3_IRQn, 15, 15, ENABLE);
|
||||
uart3->USART_TypeDef = USART3;
|
||||
Uart_getDefaultParameters(uartTerminalParam);
|
||||
// Adjust to higher baudrate for intensive logging
|
||||
uartTerminalParam->baudrate = UART_TER_BAUDRATE;
|
||||
// Adjust the TX queue size for intensive logging
|
||||
uartTerminalParam->txQueueSize = UART_TER_TX_QUEUE;
|
||||
returnValue = Uart_construct(uart3, uartTerminalParam);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* SPI1 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(SPI1_IRQn, 12, 12, ENABLE);
|
||||
spi1->initialized = false;
|
||||
spi1->SPI_TypeDef = SPI1;
|
||||
MAX5715_getSpiParameters(spiDACParam);
|
||||
GPIO_SetBits(spiDAC->SPI_CE.GPIO_Typedef, spiDAC->SPI_CE.GPIO_InitStruct.GPIO_Pin);
|
||||
SpiDevice_construct(spiDAC, spi1, spiDACParam);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* SPI3 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
IRQ_setInterruptProperties(SPI3_IRQn, 12, 12, ENABLE);
|
||||
spi3->initialized = false;
|
||||
spi3->SPI_TypeDef = SPI3;
|
||||
// Get the SPI parameters from the NHD0420 driver. They are more critical than the parameters from the EEPROM
|
||||
NHD0420_getSpiParameters(spiDisplayParam);
|
||||
// In order to use multiple slaves on this bus (and to increase performance), some parameters are altered
|
||||
// Use full-duples instead of TX only, because the EEPROM is both write- and readable
|
||||
spiDisplayParam->SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||
// Adjust the RX and TX queues for multiple use
|
||||
spiDisplayParam->rxQueueSize = SPI_LCD_EEPROM_RX_QUEUE;
|
||||
spiDisplayParam->txQueueSize = SPI_LCD_EEPROM_TX_QUEUE;
|
||||
///TODO SPI_CE should be initialized individually
|
||||
GPIO_SetBits(spiDisplay->SPI_CE.GPIO_Typedef, spiDisplay->SPI_CE.GPIO_InitStruct.GPIO_Pin);
|
||||
GPIO_SetBits(spiEEPROM->SPI_CE.GPIO_Typedef, spiEEPROM->SPI_CE.GPIO_InitStruct.GPIO_Pin);
|
||||
SpiDevice_construct(spiDisplay, spi3, spiDisplayParam);
|
||||
SpiDevice_construct(spiEEPROM, spi3, spiEEPROMParam);
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* KEYPAD COLUMNS */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Set-up the interrupts for the Keypad columns
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_Line = EXTI_Line4;
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[0].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[0].EXTI_InitStruct);
|
||||
// Enable the interrupts for the Keypad columns
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_Line = EXTI_Line5;
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[1].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[1].EXTI_InitStruct);
|
||||
// Enable the interrupts for the Keypad columns
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_Line = EXTI_Line6;
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[2].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[2].EXTI_InitStruct);
|
||||
// Enable the interrupts for the Keypad columns
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_Line = EXTI_Line7;
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
|
||||
keypad->column[3].EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&keypad->column[3].EXTI_InitStruct);
|
||||
|
||||
IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* GPIOs */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Green LED
|
||||
GPIO_construct(ledGreen, OUTPUT, ledGreen->gpio);
|
||||
// Orange LED
|
||||
GPIO_construct(ledOrange, OUTPUT, ledOrange->gpio);
|
||||
// 6V5 Power Enable
|
||||
GPIO_construct(power6v5Enable, OUTPUT, power6v5Enable->gpio);
|
||||
|
||||
IRQ_setInterruptProperties(EXTI0_IRQn, 12, 0, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI1_IRQn, 12, 0, ENABLE);
|
||||
// InterlockNO
|
||||
EXTI_InitTypeDef intNOEXTI = configureEXTI(EXTI_Line0, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(interlockNO, INPUT, interlockNO->gpio);
|
||||
// InterlockNC
|
||||
EXTI_InitTypeDef intNCEXTI = configureEXTI(EXTI_Line1, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(interlockNC, INPUT, interlockNC->gpio);
|
||||
|
||||
Interlock_construct(interlock, interlockNO, intNOEXTI, interlockNC, intNCEXTI);
|
||||
|
||||
|
||||
// Solenoid
|
||||
GPIO_construct(solenoid, OUTPUT, solenoid->gpio);
|
||||
if (PCBA_getInstance()->pcba == CathodeMCP)
|
||||
{
|
||||
// MCP0Relay
|
||||
GPIO_construct(mcp0Relay, OUTPUT, mcp0Relay->gpio);
|
||||
// MCP1Relay
|
||||
GPIO_construct(mcp1Relay, OUTPUT, mcp1Relay->gpio);
|
||||
// MCP2Relay
|
||||
GPIO_construct(mcp2Relay, OUTPUT, mcp2Relay->gpio);
|
||||
// CAT0Relay
|
||||
GPIO_construct(cat0Relay, OUTPUT, cat0Relay->gpio);
|
||||
// CAT1Relay
|
||||
GPIO_construct(cat1Relay, OUTPUT, cat1Relay->gpio);
|
||||
// CAT2Relay
|
||||
GPIO_construct(cat2Relay, OUTPUT, cat2Relay->gpio);
|
||||
}
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI15_10_IRQn, 12, 12, ENABLE);
|
||||
// Tesla Lock
|
||||
EXTI_InitTypeDef teslaNOEXTI = configureEXTI(EXTI_Line9, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(teslaNO, INPUT, teslaNO->gpio);
|
||||
EXTI_InitTypeDef teslaNCEXTI = configureEXTI(EXTI_Line10, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(teslaNC, INPUT, teslaNC->gpio);
|
||||
|
||||
Interlock_construct(teslalock, teslaNO, teslaNOEXTI, teslaNC, teslaNCEXTI);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus initPlatformDevices (void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* LOGGER */
|
||||
/* --------------------------------------------------------------------*/
|
||||
returnValue = Logger_construct(mainLog, &uart1->device, 1, 512);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* KEYPAD MATRIX */
|
||||
/* --------------------------------------------------------------------*/
|
||||
returnValue = Keypad_construct(keypad, STORM700_NUMBER_OF_ROWS, STORM700_NUMBER_OF_COLUMNS, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* STORM700 Keypad */
|
||||
/* --------------------------------------------------------------------*/
|
||||
returnValue = Storm700_construct(storm700, &keypad->device);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* NewHavenDispplay 04 20 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
returnValue = NHD0420_construct(nhd0420, &spiDisplay->device);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
/* MAX5715 external Quad DAC */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Construct MAX5715
|
||||
returnValue = MAX5715_construct(max5715, &spiDAC->device);
|
||||
// Set external DAC reference to 2V5, always ON
|
||||
MAX5715_writeREF_ON_2V5(max5715);
|
||||
|
||||
if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP))
|
||||
{
|
||||
MAX5715Channel_construct(&max5715->dac[0], max5715, 0);
|
||||
MAX5715Channel_construct(&max5715->dac[1], max5715, 1);
|
||||
MAX5715Channel_construct(&max5715->dac[2], max5715, 2);
|
||||
|
||||
// Set external DAC power mode to NORMAL for channels A, B, C
|
||||
MAX5715_writePOWER_NORMAL(max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
|
||||
// Set external DAC LATCH mode off for channels A, B, C
|
||||
MAX5715_writeCONFIG_LATCH_OFF(max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
|
||||
}
|
||||
else if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
// Construct DAC channel B (channel 1)
|
||||
MAX5715Channel_construct(&max5715->dac[1], max5715, 1);
|
||||
|
||||
// Set external DAC power mode to NORMAL for channels B
|
||||
MAX5715_writePOWER_NORMAL(max5715, MAX5715_SEL_DACB);
|
||||
// Set external DAC LATCH mode off for channels B
|
||||
MAX5715_writeCONFIG_LATCH_OFF(max5715, MAX5715_SEL_DACB);
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
@@ -821,30 +847,3 @@ static EXTI_InitTypeDef configureEXTI (uint32_t line, EXTIMode_TypeDef mode, EXT
|
||||
return EXTI_InitStruct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void EXTI0_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line0);
|
||||
GPIO_setValue(ledGreen, true);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI0 IRQ TRIGGERED");
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line1);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI1 IRQ TRIGGERED");
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
@@ -94,8 +94,14 @@ ErrorStatus RTC_construct(struct Rtc* self)
|
||||
// Reset the counter
|
||||
RTC_SetCounter(0x00);
|
||||
|
||||
Observable_construct(&self->observable);
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
struct Observable* RTC_getObservable(struct Rtc* self)
|
||||
{
|
||||
return &self->observable;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ sysmem.o \
|
||||
startup_stm32f10x_cl.o \
|
||||
\
|
||||
Display.o \
|
||||
Displays.o \
|
||||
FreeRTOSFixes.o \
|
||||
hwValidationMenu.o \
|
||||
repairMenu.o \
|
||||
repairMenus.o \
|
||||
repairProcess.o \
|
||||
\
|
||||
heap_2.o\
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Displays.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file Displays.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef DISPLAYS_H_
|
||||
#define DISPLAYS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Display.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern struct Display* const mainDisplay;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Displays_construct
|
||||
* Constructor for all displays
|
||||
*
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus Displays_construct(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Displays_destruct
|
||||
* Destructor for all displays
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void Displays_destruct(void);
|
||||
#endif /* DISPLAYS_H_ */
|
||||
@@ -0,0 +1,72 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file hsb-mrts.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file hsb-mrts.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef HSB_MRTS_H_
|
||||
#define HSB_MRTS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define HSB_MAINMENU_TASK_PRIORITY (2)
|
||||
#define HSB_MAINMENU_TASK_STACKSIZE (1024)
|
||||
|
||||
#define HSB_MAINDISP_TASK_PRIORITY (2)
|
||||
#define HSB_MAINDISP_TASK_STACKSIZE (512)
|
||||
|
||||
|
||||
// Exports of objects on application level
|
||||
extern struct Display* const mainDisplay;
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* hsb_generateStartScreen
|
||||
* Description of function
|
||||
*
|
||||
* @param Display
|
||||
* @param
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus hsb_generateStartScreen(struct Display* Display);
|
||||
#endif /* HSB_MRTS_H_ */
|
||||
@@ -49,6 +49,14 @@
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MAINMENU,
|
||||
REPAIRMENU
|
||||
} T_MenuState;
|
||||
|
||||
struct RepairMenu
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
@@ -58,6 +66,7 @@ struct RepairMenu
|
||||
SemaphoreHandle_t secondsSyncronisation;
|
||||
bool initialized;
|
||||
struct Display* display;
|
||||
T_MenuState menuState;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file repairMenus.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file repairMenus.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef REPAIRMENUS_H_
|
||||
#define REPAIRMENUS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* repairMenus_construct
|
||||
* Constructor for repair menus
|
||||
*
|
||||
* @return ErrorStatus
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus repairMenus_construct(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* repairMenus_destruct
|
||||
* Destructor for repair menus
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void repairMenus_destruct(void);
|
||||
|
||||
|
||||
#endif /* REPAIRMENUS_H_ */
|
||||
@@ -0,0 +1,113 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Displays.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file Displays.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "Displays.h"
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "nhd0420.h"
|
||||
#include "rtc.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define MAINDISP_MAX_CHAR_CHUNK (10)
|
||||
#define MAINDISP_REFRESH_FEED_MS (1000)
|
||||
#define MAINDISP_REFRESH_PERIOD (5000)
|
||||
|
||||
#define MAINDISP_DEFAULT_BRIGHTNESS (5)
|
||||
#define MAINDISP_DEFAULT_CONTRAST (40)
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct Display _mainDisplay = {.initialized = false};
|
||||
struct Display* const mainDisplay = &_mainDisplay;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus Displays_construct(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_construct(mainDisplay, &nhd0420->displayDevice, HSB_MAINDISP_TASK_PRIORITY, HSB_MAINDISP_TASK_STACKSIZE, MAINDISP_MAX_CHAR_CHUNK, MAINDISP_REFRESH_FEED_MS, MAINDISP_REFRESH_PERIOD);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Observable_addObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_clearScreen(mainDisplay);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_setBrightness(mainDisplay, MAINDISP_DEFAULT_BRIGHTNESS);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_setContrast(mainDisplay, MAINDISP_DEFAULT_CONTRAST);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
extern void Displays_destruct(void)
|
||||
{
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR);
|
||||
Display_destruct(mainDisplay);
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data)
|
||||
{
|
||||
Display_feedRefreshCounter(mainDisplay);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file hsb-mrts.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file hsb-mrts.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "Display.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "PCBA.h"
|
||||
#include "Version.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus hsb_generateStartScreen(struct Display* Display)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Display_write(mainDisplay, pcba->name, strlen(pcba->name), 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
char buffer[20];
|
||||
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major,
|
||||
Version_getInstance()->minor,
|
||||
Version_getInstance()->branch,
|
||||
Version_getInstance()->patch);
|
||||
Display_write(mainDisplay, buffer, strlen(buffer), 3, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -33,9 +33,11 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "Display.h"
|
||||
#include "Displays.h"
|
||||
#include "hsb-mrts.h"
|
||||
#include "hwValidationMenu.h"
|
||||
#include "repairMenu.h"
|
||||
#include "repairMenus.h"
|
||||
#include "repairProcess.h"
|
||||
|
||||
#include "misc.h"
|
||||
@@ -45,9 +47,9 @@
|
||||
#include "KeyboardDevice.h"
|
||||
#include "MAX5715.h"
|
||||
#include "nhd0420.h"
|
||||
#include "storm700.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "Interlock.h"
|
||||
#include "internalADC.h"
|
||||
#include "gpio.h"
|
||||
#include "IODevice.h"
|
||||
@@ -57,7 +59,6 @@
|
||||
#include "uart.h"
|
||||
#include "spi.h"
|
||||
#include "spiDevice.h"
|
||||
#include "Version.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
@@ -91,23 +92,13 @@ static xTaskHandle initTaskHandle;
|
||||
static xTaskHandle ledTaskHandle;
|
||||
static xTaskHandle sysTaskHandle;
|
||||
|
||||
static struct Display _display = {.initialized = false};
|
||||
struct Display* display = &_display;
|
||||
|
||||
static struct NHD0420 nhd0420 = {.initialized = false};
|
||||
static struct MAX5715 max5715 = {.initialized = false};
|
||||
|
||||
static struct RepairMenu _rm = {.initialized = false};
|
||||
static struct HwValidationMenu _hwValidation = {.initialized = false};
|
||||
static struct HwValidationMenuItems hwTestItems;
|
||||
|
||||
struct MAX5715* dac = &max5715;
|
||||
|
||||
struct RepairMenu* rm = &_rm;
|
||||
|
||||
struct HwValidationMenu* hwValidation = &_hwValidation;
|
||||
|
||||
static struct Storm700 _storm700 = {.initialized = false};
|
||||
struct Storm700* storm700 = &_storm700;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
@@ -175,72 +166,35 @@ static ErrorStatus systeminfoCommandHandler(void)
|
||||
OS_logTaskInfo(ledTaskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(sysTaskHandle);
|
||||
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(rm->taskHandle);
|
||||
vTaskDelay(10);
|
||||
OS_logTaskInfo(hwValidation->taskHandle);
|
||||
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
static void initTask(void* parameters)
|
||||
{
|
||||
// Initialize the platform first
|
||||
// All IO is initialized here
|
||||
// Also, all periphery and platform-specifics are initialized here
|
||||
// IRQs are defined here
|
||||
initPlatform();
|
||||
|
||||
// Create a small task that only blinks a LED and flashes the identification letter on the display
|
||||
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 100, &ledTaskArguments, 0, &ledTaskHandle);
|
||||
|
||||
Logger_construct(mainLog, &uart1->device, 1, 512);
|
||||
|
||||
Storm700_construct(storm700, &keypad->device);
|
||||
|
||||
NHD0420_construct(&nhd0420, &spiDisplay->device);
|
||||
|
||||
Display_construct(display, &nhd0420.displayDevice, 2, 256, 10, 1000, 10000);
|
||||
|
||||
Display_clearScreen(display);
|
||||
|
||||
Display_setBrightness(display, 6);
|
||||
|
||||
Display_setContrast(display, 40);
|
||||
|
||||
Display_write(display, pcba->name, strlen(pcba->name), 1, 1);
|
||||
|
||||
char buffer[20];
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major,
|
||||
Version_getInstance()->minor,
|
||||
Version_getInstance()->branch,
|
||||
Version_getInstance()->patch);
|
||||
Display_write(display, buffer, strlen(buffer), 3, 4);
|
||||
|
||||
MAX5715_construct(&max5715, &spiDAC->device);
|
||||
|
||||
MAX5715_writeREF_ON_2V5(&max5715);
|
||||
|
||||
MAX5715_writePOWER_NORMAL(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
|
||||
|
||||
MAX5715_writeCONFIG_LATCH_OFF(&max5715, MAX5715_SEL_DACA | MAX5715_SEL_DACB | MAX5715_SEL_DACC);
|
||||
|
||||
MAX5715Channel_construct(&dac->dac[0], dac, 0);
|
||||
MAX5715Channel_construct(&dac->dac[1], dac, 1);
|
||||
MAX5715Channel_construct(&dac->dac[2], dac, 2);
|
||||
// Construct the displays
|
||||
Displays_construct();
|
||||
|
||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
|
||||
hsb_generateStartScreen(mainDisplay);
|
||||
// Let start screen stay for 5 seconds
|
||||
vTaskDelay(INIT_START_SCREEN_DELAY);
|
||||
|
||||
|
||||
hwTestItems.display = &nhd0420.displayDevice;
|
||||
hwTestItems.display = &nhd0420->displayDevice;
|
||||
hwTestItems.internalADC = adc1;
|
||||
hwTestItems.externalDAC = &max5715;
|
||||
hwTestItems.externalDAC = max5715;
|
||||
hwTestItems.power6v5Enable = power6v5Enable;
|
||||
hwTestItems.interlockNO = interlockNO;
|
||||
hwTestItems.interlockNC = interlockNC;
|
||||
@@ -258,8 +212,14 @@ static void initTask(void* parameters)
|
||||
// EEPROM TO BE DONE
|
||||
// HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 1024);
|
||||
|
||||
Interlock_setEXTI(interlock, ENABLE);
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
Interlock_setEXTI(teslalock, ENABLE);
|
||||
}
|
||||
|
||||
// Construct the repair menu
|
||||
repairMenu_construct(rm, display, 2, 512);
|
||||
repairMenus_construct();
|
||||
|
||||
// Delete this init task
|
||||
vTaskDelete(NULL);
|
||||
@@ -276,10 +236,10 @@ static void ledBlinkTask (void* parameters)
|
||||
while (1)
|
||||
{
|
||||
IODevice_write(&gpio->device, &high, 1);
|
||||
Display_write(display, pcba->name, 1, 1, 20);
|
||||
Display_write(mainDisplay, pcba->name, 1, 1, 20);
|
||||
vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
|
||||
IODevice_write(&gpio->device, &low, 1);
|
||||
Display_write(display, " ", 1, 1, 20);
|
||||
Display_write(mainDisplay, " ", 1, 1, 20);
|
||||
vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "MAX5715.h"
|
||||
|
||||
#include "KeyboardDevice.h"
|
||||
#include "PCBA.h"
|
||||
#include "storm700.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -45,6 +46,11 @@
|
||||
|
||||
|
||||
|
||||
//static const char menuMain[4][20] =
|
||||
// " 1.Tube repair"
|
||||
// " 2.Operator"
|
||||
// " 3.Calibration";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -62,6 +68,9 @@
|
||||
|
||||
static void repairMenu_task(void* parameters);
|
||||
|
||||
static void repairMenu_selectMenu(struct RepairMenu* self, char key);
|
||||
static void repairMenu_printMenu(struct RepairMenu* self);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -90,6 +99,7 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* displa
|
||||
self->runTask = true;
|
||||
self->initialized = true;
|
||||
self->display = display;
|
||||
self->menuState = MAINMENU;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,6 +130,7 @@ void repairMenu_feedSecondsCounter(struct RepairMenu* self)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self)
|
||||
{
|
||||
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
@@ -134,73 +145,66 @@ void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self)
|
||||
}
|
||||
|
||||
|
||||
static struct RepairProcess _rp = {.initialized = false};
|
||||
struct RepairProcess* rp = &_rp;
|
||||
extern struct MAX5715* dac;
|
||||
extern struct Storm700* storm700;
|
||||
static void repairMenu_task(void* parameters)
|
||||
{
|
||||
struct RepairMenu* self = (struct RepairMenu*)parameters;
|
||||
|
||||
Display_clearLine(self->display, 3);
|
||||
|
||||
struct RepairProcessParameters rpParameters;
|
||||
rpParameters.adcRow1 = &adc1->channel[0];
|
||||
rpParameters.adcRow2 = &adc1->channel[1];
|
||||
rpParameters.adcRow3 = &adc1->channel[2];
|
||||
rpParameters.dacRow1 = &dac->dac[0];
|
||||
rpParameters.dacRow2 = &dac->dac[1];
|
||||
rpParameters.dacRow3 = &dac->dac[2];
|
||||
|
||||
// struct RepairPresetParameters presetStage1 = {.voltage = 0xE00, .duration = 300, .softstartDuration = 120};
|
||||
// struct RepairPresetParameters presetStage2 = {.voltage = 0x600, .duration = 120, .softstartDuration = 30};
|
||||
|
||||
struct RepairPresetParameters presetStage1 = {.voltage = 0xE00, .duration = 7200, .softstartDuration = 1800};
|
||||
struct RepairPresetParameters presetStage2 = {.voltage = 0x600, .duration = 1800, .softstartDuration = 900};
|
||||
|
||||
struct RepairPreset repairPreset;
|
||||
repairPreset.numberOfStages = 2;
|
||||
repairPreset.preset[0] = presetStage1;
|
||||
repairPreset.preset[1] = presetStage2;
|
||||
|
||||
rp->repairPreset = &repairPreset;
|
||||
|
||||
repairProcess_construct(rp, &rpParameters, 2, 512);
|
||||
|
||||
|
||||
while(self->runTask)
|
||||
{
|
||||
xSemaphoreTake(self->secondsSyncronisation, portMAX_DELAY);
|
||||
|
||||
uint32_t secondsCounter;
|
||||
repairProcess_getRepairTime(rp, &secondsCounter);
|
||||
int hours = (secondsCounter / (60 * 60));
|
||||
int minutes = (secondsCounter - (hours * 60 * 60)) / 60;
|
||||
int seconds = (secondsCounter - (hours * 60 * 60) - (minutes * 60));
|
||||
char buffer[20];
|
||||
snprintf (buffer, sizeof(buffer) / sizeof(buffer[0]), "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
Display_write(self->display, buffer, strlen(buffer), 2, 7);
|
||||
|
||||
Display_write(self->display, "R1", strlen("R1"), 3, 3);
|
||||
Display_write(self->display, "R2", strlen("R2"), 3, 10);
|
||||
Display_write(self->display, "R3", strlen("R3"), 3, 17);
|
||||
|
||||
uint16_t value;
|
||||
ADCChannel_read(rp->adc[0], &value);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04xV", value);
|
||||
Display_write(self->display, buffer, strlen(buffer), 4, 1);
|
||||
|
||||
ADCChannel_read(rp->adc[1], &value);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04xV", value);
|
||||
Display_write(self->display, buffer, strlen(buffer), 4, 8);
|
||||
|
||||
ADCChannel_read(rp->adc[2], &value);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%04xV", value);
|
||||
Display_write(self->display, buffer, strlen(buffer), 4, 15);
|
||||
|
||||
char key;
|
||||
Keypad_KeyState keyState;
|
||||
|
||||
// Get a new key from keyboard
|
||||
if (KeyboardDevice_read(&storm700->keyboardDevice, &key, &keyState) == SUCCESS)
|
||||
{
|
||||
// New key read
|
||||
if (keyState == RELEASED)
|
||||
{
|
||||
LOGGER_INFO(mainLog, "Key %c is released", key);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_INFO(mainLog, "Key %c is pressed", key);
|
||||
}
|
||||
}
|
||||
vTaskDelay(100);
|
||||
}
|
||||
|
||||
LOGGER_INFO(mainLog, "Deleting RepairMenu task");
|
||||
vTaskDelete(self->taskHandle);
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_selectMenu(struct RepairMenu* self, char key)
|
||||
{
|
||||
switch (self->menuState)
|
||||
{
|
||||
case MAINMENU:
|
||||
{
|
||||
repairMenu_printMenu(self);
|
||||
break;
|
||||
}
|
||||
case REPAIRMENU:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_printMenu(struct RepairMenu* self)
|
||||
{
|
||||
switch (self->menuState)
|
||||
{
|
||||
case MAINMENU:
|
||||
{
|
||||
Display_write(self->display, PCBA_getInstance()->name, strlen(PCBA_getInstance()->name), 1, 1);
|
||||
break;
|
||||
}
|
||||
case REPAIRMENU:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file repairMenus.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file repairMenus.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "repairMenus.h"
|
||||
#include "repairMenu.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "Observable.h"
|
||||
#include "rtc.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct RepairMenu _mainMenu = {.initialized = false};
|
||||
struct RepairMenu* const mainMenu = &_mainMenu;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus repairMenus_mainMenuObserverFromISR(const void* const data);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//TODO REMOVE
|
||||
extern struct Display* display;
|
||||
ErrorStatus repairMenus_construct(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Create first repair menu
|
||||
returnValue = repairMenu_construct(mainMenu, mainDisplay, HSB_MAINMENU_TASK_PRIORITY, HSB_MAINMENU_TASK_STACKSIZE);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Observable_addObserver(RTC_getObservable(rtc), repairMenus_mainMenuObserverFromISR);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void repairMenus_destruct(void)
|
||||
{
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), repairMenus_mainMenuObserverFromISR);
|
||||
repairMenu_destruct(mainMenu);
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus repairMenus_mainMenuObserverFromISR(const void* const data)
|
||||
{
|
||||
repairMenu_feedSecondsCounterFromISR(mainMenu);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -238,14 +238,11 @@ static int SignalProfileGenerator(struct RepairProcess* self)
|
||||
{
|
||||
case PREPARE:
|
||||
{
|
||||
LOGGER_DEBUG(mainLog, "Repair Process: Preparing new stage of repair process");
|
||||
// Prepare a new repair process
|
||||
//Load the timers
|
||||
self->startTime = self->secondsCounter;
|
||||
self->softStartTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].softstartDuration;
|
||||
LOGGER_DEBUG(mainLog, "Softstart timer is %d (%d + %d)", self->softStartTimer, self->secondsCounter, self->repairPreset->preset[self->currentPresetIndex].softstartDuration);
|
||||
self->voltageHoldTimer = self->secondsCounter + self->repairPreset->preset[self->currentPresetIndex].duration;
|
||||
LOGGER_DEBUG(mainLog, "Voltagehold timer is %d (%d + %d)", self->voltageHoldTimer, self->secondsCounter, self->repairPreset->preset[self->currentPresetIndex].duration);
|
||||
|
||||
self->currentState = SOFTSTART;
|
||||
|
||||
@@ -309,12 +306,10 @@ static int SignalProfileGenerator(struct RepairProcess* self)
|
||||
// A next stage is available
|
||||
self->currentPresetIndex++;
|
||||
self->currentState = PREPARE;
|
||||
LOGGER_DEBUG(mainLog, "Another stage is available");
|
||||
}
|
||||
else
|
||||
{
|
||||
self->currentState = FINISHED;
|
||||
LOGGER_DEBUG(mainLog, "last stage reached");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
#include "stm32f10x_it.h"
|
||||
|
||||
#include "stm32f10x_exti.h"
|
||||
@@ -53,12 +54,12 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -231,7 +232,26 @@ void SPI3_IRQHandler (void)
|
||||
}
|
||||
|
||||
|
||||
void EXTI0_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line0);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI0 IRQ TRIGGERED");
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line1);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI1 IRQ TRIGGERED");
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI4_IRQHandler(void)
|
||||
@@ -274,15 +294,47 @@ void EXTI9_5_IRQHandler (void)
|
||||
else if (EXTI_GetITStatus(EXTI_Line9) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line9);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI9 IRQ TRIGGERED");
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
void EXTI15_10_IRQHandler (void)
|
||||
{
|
||||
static signed portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if (EXTI_GetITStatus(EXTI_Line10) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line10);
|
||||
LOGGER_ERROR_ISR(mainLog, "EXTI10 IRQ TRIGGERED");
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line11) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line11);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line12) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line12);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line13) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line13);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line14) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line14);
|
||||
}
|
||||
else if (EXTI_GetITStatus(EXTI_Line15) != RESET)
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line15);
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
|
||||
extern struct Display* display;
|
||||
extern struct RepairProcess* rp;
|
||||
extern struct RepairMenu* rm;
|
||||
|
||||
void RTC_IRQHandler(void)
|
||||
{
|
||||
@@ -294,9 +346,8 @@ void RTC_IRQHandler(void)
|
||||
RTC_ClearITPendingBit(RTC_IT_SEC);
|
||||
|
||||
xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken);
|
||||
Display_feedRefreshCounter(display);
|
||||
repairProcess_feedSecondsCounterFromISR(rp);
|
||||
repairMenu_feedSecondsCounterFromISR(rm);
|
||||
|
||||
Observable_notifyObservers(RTC_getObservable(rtc), NULL);
|
||||
|
||||
|
||||
/* Wait until last write operation on RTC registers has finished */
|
||||
|
||||
Reference in New Issue
Block a user