Updated all GPIO to PCBA updated version
Added LED module git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@321 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -33,6 +33,7 @@ hsb-mrts.o \
|
||||
Interlock.o \
|
||||
IODevice.o \
|
||||
KeyboardDevice.o \
|
||||
Leds.o \
|
||||
Logger.o \
|
||||
MAX5715.o \
|
||||
MemoryDevice.o \
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Leds.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 Leds.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef INC_LEDS_H_
|
||||
#define INC_LEDS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LED_ONBOARD_GREEN = 0,
|
||||
LED_ONBOARD_ORANGE,
|
||||
LED_BICOLOR_GREEN,
|
||||
LED_BICOLOR_RED,
|
||||
LED_BICOLOR_ORANGE,
|
||||
LED_NUMBER_OF_LEDS
|
||||
} Led;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Led_construct
|
||||
* Constructor for LEDs
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void Led_construct(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Led_on
|
||||
* Turns on the LED given in argument led
|
||||
*
|
||||
* @param led The LED to set
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void Led_on(Led led);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Led_off
|
||||
* Turns off the LED given in argument led
|
||||
*
|
||||
* @param led The LED to set
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void Led_off(Led led);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* Led_getStatus
|
||||
* Returns the status of the led in arugment led
|
||||
*
|
||||
* @param led The led to request the status of
|
||||
* @param
|
||||
* @return bool TRUE if led is ON
|
||||
* FALSE if led is OFF
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern bool Led_getStatus(Led led);
|
||||
|
||||
#endif /* INC_LEDS_H_ */
|
||||
@@ -0,0 +1,158 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file Leds.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 Leds.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "gpio.h"
|
||||
#include "platform.h"
|
||||
|
||||
#include "IODevice.h"
|
||||
#include "Leds.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct Led
|
||||
{
|
||||
bool initialized;
|
||||
struct IODevice* ioDevice;
|
||||
};
|
||||
|
||||
|
||||
struct Leds
|
||||
{
|
||||
bool initialized;
|
||||
struct Led leds[LED_NUMBER_OF_LEDS];
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct Leds self = { .initialized = false };
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Led_construct(void)
|
||||
{
|
||||
if (!self.initialized)
|
||||
{
|
||||
self.initialized = true;
|
||||
|
||||
self.leds[LED_ONBOARD_GREEN].ioDevice = &ledInternGreen->device;
|
||||
self.leds[LED_ONBOARD_GREEN].initialized = true;
|
||||
|
||||
self.leds[LED_ONBOARD_ORANGE].ioDevice = &ledInternOrange->device;
|
||||
self.leds[LED_ONBOARD_ORANGE].initialized = true;
|
||||
|
||||
self.leds[LED_BICOLOR_GREEN].ioDevice = &ledBicolourGreen->device;
|
||||
self.leds[LED_BICOLOR_GREEN].initialized = true;
|
||||
|
||||
self.leds[LED_BICOLOR_RED].ioDevice = &ledBicolourRed->device;
|
||||
self.leds[LED_BICOLOR_RED].initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern void Led_on(Led led)
|
||||
{
|
||||
char bufferTrue = (char)true;
|
||||
if (self.initialized)
|
||||
{
|
||||
if (self.leds[led].initialized)
|
||||
{
|
||||
// IN case of the BICOLOUR ORANGE LED, actually the GREEN and RED LEDs must be switched
|
||||
if (led == LED_BICOLOR_ORANGE)
|
||||
{
|
||||
IODevice_write(self.leds[LED_BICOLOR_GREEN].ioDevice, &bufferTrue, 1);
|
||||
IODevice_write(self.leds[LED_BICOLOR_RED].ioDevice, &bufferTrue, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IODevice_write(self.leds[led].ioDevice, &bufferTrue, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern void Led_off(Led led)
|
||||
{
|
||||
char bufferFalse = (char)false;
|
||||
if (self.initialized)
|
||||
{
|
||||
if (self.leds[led].initialized)
|
||||
{
|
||||
// IN case of the BICOLOUR ORANGE LED, actually the GREEN and RED LEDs must be switched
|
||||
if (led == LED_BICOLOR_ORANGE)
|
||||
{
|
||||
IODevice_write(self.leds[LED_BICOLOR_GREEN].ioDevice, &bufferFalse, 1);
|
||||
IODevice_write(self.leds[LED_BICOLOR_RED].ioDevice, &bufferFalse, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IODevice_write(self.leds[led].ioDevice, &bufferFalse, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern bool Led_getStatus(Led led)
|
||||
{
|
||||
bool returnValue = false;
|
||||
if (self.initialized)
|
||||
{
|
||||
if (self.leds[led].initialized)
|
||||
{
|
||||
char value;
|
||||
IODevice_read(self.leds[led].ioDevice, &value, 1, NULL);
|
||||
if (value != (char)false)
|
||||
{
|
||||
returnValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ RELEASE_PRODUCT = \""S0\""
|
||||
RELEASE_MAJOR = 0
|
||||
RELEASE_MINOR = 9
|
||||
RELEASE_BRANCH = 0
|
||||
RELEASE_PATCH = 4
|
||||
RELEASE_PATCH = 5
|
||||
|
||||
# Define the platform to use
|
||||
PLATFORM_OLIMEX_STM32_H107 = OLI_STM32_H107
|
||||
|
||||
@@ -82,8 +82,10 @@ extern struct Storm700* const storm700;
|
||||
// internal FLASH
|
||||
extern struct InternalFlash* const iFlash;
|
||||
// Export of GPIOs
|
||||
extern struct Gpio* const ledGreen;
|
||||
extern struct Gpio* const ledOrange;
|
||||
extern struct Gpio* const ledInternGreen;
|
||||
extern struct Gpio* const ledInternOrange;
|
||||
extern struct Gpio* const ledBicolourGreen;
|
||||
extern struct Gpio* const ledBicolourRed;
|
||||
|
||||
extern struct Interlock* const interlock;
|
||||
|
||||
|
||||
@@ -135,8 +135,11 @@ static struct Storm700 _storm700 = {.initialized = false};
|
||||
static struct InternalFlash _iFlash = {.initialized = false};
|
||||
|
||||
// GPIOs
|
||||
static struct Gpio _ledGreen = {.initialized = false};
|
||||
static struct Gpio _ledOrange = {.initialized = false};
|
||||
static struct Gpio _ledInternGreen = {.initialized = false};
|
||||
static struct Gpio _ledInternOrange = {.initialized = false};
|
||||
static struct Gpio _ledBicolourGreen = {.initialized = false};
|
||||
static struct Gpio _ledBicolourRed = {.initialized = false};
|
||||
static struct Gpio _buzzer = {.initialized = false};
|
||||
static struct Gpio _interlockNO = {.initialized = false};
|
||||
static EXTI_InitTypeDef _interlockNOEXTI;
|
||||
static struct Gpio _interlockNC = {.initialized = false};
|
||||
@@ -149,6 +152,9 @@ static struct Gpio _cat0Relay = {.initialized = false};
|
||||
static struct Gpio _cat1Relay = {.initialized = false};
|
||||
static struct Gpio _cat2Relay = {.initialized = false};
|
||||
static struct Gpio _teslaRelay = {.initialized = false};
|
||||
static struct Gpio _hv0Present = {.initialized = false};
|
||||
static struct Gpio _hv1Present = {.initialized = false};
|
||||
static struct Gpio _hv2Present = {.initialized = false};
|
||||
|
||||
static struct Interlock _interlock = {.initialized = false};
|
||||
|
||||
@@ -184,9 +190,14 @@ struct Storm700* const storm700 = &_storm700;
|
||||
|
||||
struct InternalFlash* const iFlash = &_iFlash;
|
||||
|
||||
struct Gpio* const ledGreen = &_ledGreen;
|
||||
struct Gpio* const ledOrange = &_ledOrange;
|
||||
|
||||
struct Gpio* const ledInternGreen = &_ledInternGreen;
|
||||
struct Gpio* const ledInternOrange = &_ledInternOrange;
|
||||
struct Gpio* const ledBicolourGreen = &_ledBicolourGreen;
|
||||
struct Gpio* const ledBicolourRed = &_ledBicolourRed;
|
||||
struct Gpio* const buzzer = &_buzzer;
|
||||
struct Gpio* const hv0Present = &_hv0Present;
|
||||
struct Gpio* const hv1Present = &_hv1Present;
|
||||
struct Gpio* const hv2Present = &_hv2Present;
|
||||
|
||||
struct Interlock* const interlock = &_interlock;
|
||||
|
||||
@@ -322,11 +333,25 @@ static ErrorStatus initIO (void)
|
||||
|
||||
|
||||
/*LED IO initialisation --------------------------------------------------*/
|
||||
// Init LED Green
|
||||
ledGreen->gpio = configureGPIO(GPIOC, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_6);
|
||||
// Init LED Green on DevKit
|
||||
ledInternGreen->gpio = configureGPIO(GPIOC, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_6);
|
||||
// Init LED Orange on DevKit
|
||||
ledInternOrange->gpio = configureGPIO(GPIOC, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_7);
|
||||
// Init LED Green of BiColour led
|
||||
ledBicolourGreen->gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_PinSource11);
|
||||
// Init LED Red of BiColour led
|
||||
ledBicolourRed->gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_PinSource13);
|
||||
|
||||
// Init LED Orange
|
||||
ledOrange->gpio = configureGPIO(GPIOC, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_7);
|
||||
/* BUZZER initialisation -------------------------------------------------*/
|
||||
buzzer->gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_PinSource12);
|
||||
|
||||
/* HIGH VOLTAGE PRESENT initialisation -----------------------------------*/
|
||||
// HV0 Present
|
||||
hv0Present->gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_PinSource12);
|
||||
// HV1 Present
|
||||
hv1Present->gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_PinSource13);
|
||||
// HV2 Present
|
||||
hv2Present->gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_PinSource14);
|
||||
|
||||
/* ADC1 initialisation ---------------------------------------------------*/
|
||||
// Channel 0 - PA0
|
||||
@@ -346,22 +371,11 @@ static ErrorStatus initIO (void)
|
||||
GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE);
|
||||
|
||||
/* USART3 initialisation -------------------------------------------------*/
|
||||
// For PCBA 0 (Cathode/MCP) and 2 (Anode), use the common USART3 IO
|
||||
if ((PCBA_getInstance()->pcba == PCBA_Anode) || (PCBA_getInstance()->pcba == PCBA_CathodeMCP))
|
||||
{
|
||||
// Init TX line
|
||||
uart3->USART_TX = configureGPIO(GPIOB, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_10);
|
||||
// Init RX line
|
||||
uart1->USART_RX = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_11);
|
||||
}
|
||||
else if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
// Init TX line
|
||||
uart3->USART_TX = configureGPIO(GPIOD, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_8);
|
||||
// Init RX line
|
||||
uart1->USART_RX = configureGPIO(GPIOD, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_9);
|
||||
GPIO_PinRemapConfig(GPIO_FullRemap_USART3, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
/* SPI initialisation ----------------------------------------------------*/
|
||||
// SPI1 CLK
|
||||
@@ -403,13 +417,13 @@ static ErrorStatus initIO (void)
|
||||
keypad->row[3].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_3);
|
||||
|
||||
// Column1
|
||||
keypad->column[0].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_4);
|
||||
keypad->column[0].gpio = configureGPIO(GPIOD, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_4);
|
||||
// Column2
|
||||
keypad->column[1].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_5);
|
||||
keypad->column[1].gpio = configureGPIO(GPIOD, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_5);
|
||||
// Column3
|
||||
keypad->column[2].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_6);
|
||||
keypad->column[2].gpio = configureGPIO(GPIOD, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_6);
|
||||
// Column4
|
||||
keypad->column[3].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_7);
|
||||
keypad->column[3].gpio = configureGPIO(GPIOD, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_7);
|
||||
|
||||
/* GPIO initialisation ---------------------------------------------------*/
|
||||
// Interlock1 - PB0 input
|
||||
@@ -441,7 +455,7 @@ static ErrorStatus initIO (void)
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
// Tesla Gun relay PB9
|
||||
_teslaRelay.gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_9);
|
||||
_teslaRelay.gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_3);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -583,29 +597,17 @@ static ErrorStatus initPeriphery(void)
|
||||
/* 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);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);
|
||||
keypad->column[0].EXTI_InitStruct = configureEXTI(EXTI_Line4, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, ENABLE);
|
||||
// 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);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource5);
|
||||
keypad->column[1].EXTI_InitStruct = configureEXTI(EXTI_Line5, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, ENABLE);
|
||||
// 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);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource6);
|
||||
keypad->column[2].EXTI_InitStruct = configureEXTI(EXTI_Line6, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, ENABLE);
|
||||
// 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);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource7);
|
||||
keypad->column[3].EXTI_InitStruct = configureEXTI(EXTI_Line7, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, ENABLE);
|
||||
|
||||
IRQ_setInterruptProperties(EXTI4_IRQn, 12, 12, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
|
||||
@@ -621,9 +623,9 @@ static ErrorStatus initPeriphery(void)
|
||||
/* GPIOs */
|
||||
/* --------------------------------------------------------------------*/
|
||||
// Green LED
|
||||
GPIO_construct(ledGreen, OUTPUT, ledGreen->gpio);
|
||||
GPIO_construct(ledInternGreen, OUTPUT, ledInternGreen->gpio);
|
||||
// Orange LED
|
||||
GPIO_construct(ledOrange, OUTPUT, ledOrange->gpio);
|
||||
GPIO_construct(ledInternOrange, OUTPUT, ledInternOrange->gpio);
|
||||
|
||||
IRQ_setInterruptProperties(EXTI0_IRQn, 12, 0, ENABLE);
|
||||
IRQ_setInterruptProperties(EXTI1_IRQn, 12, 0, ENABLE);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#define MAINDISP_REFRESH_FEED_MS (1000)
|
||||
#define MAINDISP_REFRESH_PERIOD (5000)
|
||||
|
||||
#define MAINDISP_DEFAULT_BRIGHTNESS (5)
|
||||
#define MAINDISP_DEFAULT_BRIGHTNESS (8) // Set to MAX to avoid background light issue
|
||||
#define MAINDISP_DEFAULT_CONTRAST (40)
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
@@ -61,6 +61,7 @@ struct Display* const mainDisplay = &_mainDisplay;
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus Displays_initMainDisplay(void);
|
||||
static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -71,6 +72,26 @@ ErrorStatus Displays_construct(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = Displays_initMainDisplay();
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
extern void Displays_destruct(void)
|
||||
{
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR);
|
||||
Display_destruct(mainDisplay);
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus Displays_initMainDisplay(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);
|
||||
@@ -105,13 +126,6 @@ ErrorStatus Displays_construct(void)
|
||||
}
|
||||
|
||||
|
||||
extern void Displays_destruct(void)
|
||||
{
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR);
|
||||
Display_destruct(mainDisplay);
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus Displays_mainDisplayObserverFromISR(const void* const data)
|
||||
{
|
||||
Display_feedRefreshCounterFromISR(mainDisplay);
|
||||
|
||||
@@ -173,7 +173,7 @@ static void MenuCore_task(void* parameters)
|
||||
MenuCore_printCursor(self);
|
||||
}
|
||||
}
|
||||
vTaskDelay(100);
|
||||
vTaskDelay(50);
|
||||
}
|
||||
|
||||
LOGGER_INFO(mainLog, "Deleting MenuCore task");
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "CathodeMCP.h"
|
||||
#include "CoverSolenoid.h"
|
||||
#include "Interlock.h"
|
||||
#include "Leds.h"
|
||||
#include "Logger.h"
|
||||
#include "nhd0420.h"
|
||||
#include "TeslaGunSafety.h"
|
||||
@@ -73,7 +74,7 @@ tick hook. */
|
||||
|
||||
struct LedTaskArguments
|
||||
{
|
||||
struct Gpio* led;
|
||||
Led led;
|
||||
int frequency;
|
||||
};
|
||||
|
||||
@@ -119,7 +120,7 @@ int main (void)
|
||||
|
||||
// Create TaskHandles
|
||||
|
||||
ledTaskArguments.led = ledOrange;
|
||||
ledTaskArguments.led = LED_ONBOARD_ORANGE;
|
||||
ledTaskArguments.frequency = 1;
|
||||
|
||||
xTaskCreate(initTask, (const char* const)"initTask", 1024, NULL, 5, &initTaskHandle);
|
||||
@@ -192,6 +193,12 @@ static void initTask(void* parameters)
|
||||
initPlatform();
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Construct the LEDs
|
||||
Led_construct();
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Construct the displays
|
||||
@@ -235,7 +242,7 @@ static void initTask(void* parameters)
|
||||
hwTestItems.display = &nhd0420->displayDevice;
|
||||
hwTestItems.internalADC = adc1;
|
||||
hwTestItems.externalDAC = max5715;
|
||||
hwTestItems.power6v5Enable = Power6V5Supply_getGPIO();
|
||||
// hwTestItems.power6v5Enable = Power6V5Supply_getGPIO();
|
||||
hwTestItems.interlockNO = interlock->NO.io;
|
||||
hwTestItems.interlockNC = interlock->NC.io;
|
||||
hwTestItems.TeslaSecurity = TeslaGunSafety_getGpio();
|
||||
@@ -249,7 +256,7 @@ static void initTask(void* parameters)
|
||||
hwTestItems.pcba = PCBA_getInstance();
|
||||
hwTestItems.keypad = keypad;
|
||||
// EEPROM TO BE DONE
|
||||
HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 1024);
|
||||
HwValidationMenu_construct(hwValidation, &uart3->device, &hwTestItems, 1, 1024);
|
||||
}
|
||||
#endif
|
||||
if (returnValue == SUCCESS)
|
||||
@@ -273,17 +280,15 @@ static void initTask(void* parameters)
|
||||
|
||||
static void ledBlinkTask (void* parameters)
|
||||
{
|
||||
char high = 1;
|
||||
char low = 0;
|
||||
char indicator[2];
|
||||
indicator[0] = ' ';
|
||||
indicator[1] = '\0';
|
||||
struct LedTaskArguments* arguments = (struct LedTaskArguments*) parameters;
|
||||
struct Gpio* gpio = arguments->led;
|
||||
int frequency = arguments->frequency;
|
||||
while (1)
|
||||
{
|
||||
IODevice_write(&gpio->device, &high, 1);
|
||||
Led_on(arguments->led);
|
||||
|
||||
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||
{
|
||||
indicator[0] = CathodeMCP_getInstance()->name[0];
|
||||
@@ -296,7 +301,7 @@ static void ledBlinkTask (void* parameters)
|
||||
}
|
||||
|
||||
vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
|
||||
IODevice_write(&gpio->device, &low, 1);
|
||||
Led_off(arguments->led);
|
||||
indicator[0] = ' ';
|
||||
// Display_write(mainDisplay, indicator, 1, 20);
|
||||
vTaskDelay(configTICK_RATE_HZ / (frequency * 2));
|
||||
|
||||
Reference in New Issue
Block a user