Added all required GPIOs
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@242 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -56,6 +56,7 @@ struct Gpio
|
|||||||
T_PL_GPIO gpio;
|
T_PL_GPIO gpio;
|
||||||
GpioDirection direction;
|
GpioDirection direction;
|
||||||
bool status;
|
bool status;
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -64,10 +64,6 @@ extern struct Logger* mainLog;
|
|||||||
|
|
||||||
// Export of PCBA information
|
// Export of PCBA information
|
||||||
extern struct Pcba* pcba;
|
extern struct Pcba* pcba;
|
||||||
|
|
||||||
// Export of LEDs
|
|
||||||
extern struct Gpio* const ledGreen;
|
|
||||||
extern struct Gpio* const ledOrange;
|
|
||||||
// Export of ADCs
|
// Export of ADCs
|
||||||
extern struct Adc* const adc1;
|
extern struct Adc* const adc1;
|
||||||
// Export of the rtc
|
// Export of the rtc
|
||||||
@@ -81,9 +77,22 @@ extern struct Spi* const spi3;
|
|||||||
extern struct SpiDevice* const spiDAC;
|
extern struct SpiDevice* const spiDAC;
|
||||||
extern struct SpiDevice* const spiDisplay;
|
extern struct SpiDevice* const spiDisplay;
|
||||||
extern struct SpiDevice* const spiEEPROM;
|
extern struct SpiDevice* const spiEEPROM;
|
||||||
|
// Export of Keypad
|
||||||
extern struct Keypad* const keypad;
|
extern struct Keypad* const keypad;
|
||||||
|
// Export of GPIOs
|
||||||
|
extern struct Gpio* const ledGreen;
|
||||||
|
extern struct Gpio* const ledOrange;
|
||||||
|
extern struct Gpio* const power6v5Enable;
|
||||||
|
extern struct Gpio* const interlock1;
|
||||||
|
extern struct Gpio* const interlock2;
|
||||||
|
extern struct Gpio* const solenoid;
|
||||||
|
extern struct Gpio* const mcp0Relay;
|
||||||
|
extern struct Gpio* const mcp1Relay;
|
||||||
|
extern struct Gpio* const mcp2Relay;
|
||||||
|
extern struct Gpio* const cat0Relay;
|
||||||
|
extern struct Gpio* const cat1Relay;
|
||||||
|
extern struct Gpio* const cat2Relay;
|
||||||
|
extern struct Gpio* const teslaLock;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "IODevice.h"
|
#include "IODevice.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ struct SpiDevice
|
|||||||
struct Spi* spi;
|
struct Spi* spi;
|
||||||
struct SpiParameters parameters;
|
struct SpiParameters parameters;
|
||||||
T_PL_GPIO SPI_CE;
|
T_PL_GPIO SPI_CE;
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
// Include files
|
// Include files
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
|
|
||||||
@@ -85,6 +87,7 @@ struct Uart
|
|||||||
SemaphoreHandle_t txSemaphore; //! Semaphore for transmit handler
|
SemaphoreHandle_t txSemaphore; //! Semaphore for transmit handler
|
||||||
xQueueHandle txQueue; //! USART Transfer queue identifier
|
xQueueHandle txQueue; //! USART Transfer queue identifier
|
||||||
xQueueHandle rxQueue; //! USART Receive queue identifier
|
xQueueHandle rxQueue; //! USART Receive queue identifier
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -62,11 +62,20 @@ static ErrorStatus read(const struct IODevice* self, char* buffer, size_t length
|
|||||||
ErrorStatus GPIO_construct(struct Gpio* self, GpioDirection direction, T_PL_GPIO io)
|
ErrorStatus GPIO_construct(struct Gpio* self, GpioDirection direction, T_PL_GPIO io)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
if (!self->initialized)
|
||||||
|
{
|
||||||
returnValue = IODevice_construct(&self->device, read, write);
|
returnValue = IODevice_construct(&self->device, read, write);
|
||||||
|
if (returnValue == SUCCESS)
|
||||||
|
{
|
||||||
self->direction = direction;
|
self->direction = direction;
|
||||||
self->gpio = io;
|
self->gpio = io;
|
||||||
|
self->initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -76,7 +85,8 @@ ErrorStatus GPIO_construct(struct Gpio* self, GpioDirection direction, T_PL_GPIO
|
|||||||
ErrorStatus GPIO_setValue(struct Gpio* self, bool value)
|
ErrorStatus GPIO_setValue(struct Gpio* self, bool value)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
if (self->direction == OUTPUT)
|
if (self->direction == OUTPUT)
|
||||||
{
|
{
|
||||||
// Writing to output is valid
|
// Writing to output is valid
|
||||||
@@ -98,7 +108,11 @@ ErrorStatus GPIO_setValue(struct Gpio* self, bool value)
|
|||||||
// Writing to input is invalid
|
// Writing to input is invalid
|
||||||
returnValue = ERROR;
|
returnValue = ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +120,8 @@ ErrorStatus GPIO_setValue(struct Gpio* self, bool value)
|
|||||||
ErrorStatus GPIO_getValue(struct Gpio* self, bool* value)
|
ErrorStatus GPIO_getValue(struct Gpio* self, bool* value)
|
||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
if (self->direction == OUTPUT)
|
if (self->direction == OUTPUT)
|
||||||
{
|
{
|
||||||
// Reading an output is impossible - but returning its current status is valid
|
// Reading an output is impossible - but returning its current status is valid
|
||||||
@@ -136,6 +151,11 @@ ErrorStatus GPIO_getValue(struct Gpio* self, bool* value)
|
|||||||
self->status = false;
|
self->status = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,37 +92,46 @@
|
|||||||
// Logger
|
// Logger
|
||||||
static struct Logger _mainLog = {.initialized = false};
|
static struct Logger _mainLog = {.initialized = false};
|
||||||
|
|
||||||
// PCBA information
|
|
||||||
|
|
||||||
// LEDs
|
|
||||||
static struct Gpio _ledGreen;
|
|
||||||
static struct Gpio _ledOrange;
|
|
||||||
|
|
||||||
// ADC
|
// ADC
|
||||||
static struct Adc _adc1;
|
static struct Adc _adc1 = {.initialized = false};
|
||||||
static struct AdcParameters _adc1Parameters;
|
static struct AdcParameters _adc1Parameters;
|
||||||
|
|
||||||
// RTC
|
// RTC
|
||||||
static struct Rtc _rtc;
|
static struct Rtc _rtc;
|
||||||
|
|
||||||
// USART
|
// USART
|
||||||
static struct Uart _uart1;
|
static struct Uart _uart1 = {.initialized = false};
|
||||||
static struct UartParameters _uart1Parameters;
|
static struct UartParameters _uart1Parameters;
|
||||||
static struct Uart _uart3;
|
static struct Uart _uart3 = {.initialized = false};
|
||||||
static struct UartParameters _uart3Parameters;
|
static struct UartParameters _uart3Parameters;
|
||||||
|
|
||||||
// SPI
|
// SPI
|
||||||
static struct Spi _spi1;
|
static struct Spi _spi1 = {.initialized = false};
|
||||||
static struct SpiDevice _spiDAC;
|
static struct SpiDevice _spiDAC = {.initialized = false};
|
||||||
static struct SpiParameters _spi1DACParameters;
|
static struct SpiParameters _spi1DACParameters;
|
||||||
static struct Spi _spi3;
|
static struct Spi _spi3 = {.initialized = false};
|
||||||
static struct SpiParameters _spi3DisplayParameters;
|
static struct SpiParameters _spi3DisplayParameters;
|
||||||
static struct SpiParameters _spi3EEPROMParameters;
|
static struct SpiParameters _spi3EEPROMParameters;
|
||||||
static struct SpiDevice _spiDisplay;
|
static struct SpiDevice _spiDisplay = {.initialized = false};
|
||||||
static struct SpiDevice _spiEEPROM;
|
static struct SpiDevice _spiEEPROM = {.initialized = false};
|
||||||
|
|
||||||
// Keypad
|
// Keypad
|
||||||
static struct Keypad _keypad;
|
static struct Keypad _keypad = {.initialized = false};
|
||||||
|
|
||||||
|
// GPIOs
|
||||||
|
static struct Gpio _ledGreen = {.initialized = false};
|
||||||
|
static struct Gpio _ledOrange = {.initialized = false};
|
||||||
|
static struct Gpio _power6v5Enable = {.initialized = false};
|
||||||
|
static struct Gpio _interlock1 = {.initialized = false};
|
||||||
|
static struct Gpio _interlock2 = {.initialized = false};
|
||||||
|
static struct Gpio _solenoid = {.initialized = false};
|
||||||
|
static struct Gpio _mcp0Relay = {.initialized = false};
|
||||||
|
static struct Gpio _mcp1Relay = {.initialized = false};
|
||||||
|
static struct Gpio _mcp2Relay = {.initialized = false};
|
||||||
|
static struct Gpio _cat0Relay = {.initialized = false};
|
||||||
|
static struct Gpio _cat1Relay = {.initialized = false};
|
||||||
|
static struct Gpio _cat2Relay = {.initialized = false};
|
||||||
|
static struct Gpio _teslaLock = {.initialized = false};
|
||||||
|
|
||||||
|
|
||||||
// The following pointers are for export (see platform.h) and external use.
|
// The following pointers are for export (see platform.h) and external use.
|
||||||
@@ -130,10 +139,7 @@ static struct Keypad _keypad;
|
|||||||
|
|
||||||
struct Logger* mainLog = &_mainLog;
|
struct Logger* mainLog = &_mainLog;
|
||||||
|
|
||||||
struct Pcba* pcba;
|
struct Pcba* pcba; // Singleton
|
||||||
|
|
||||||
struct Gpio* const ledGreen = &_ledGreen;
|
|
||||||
struct Gpio* const ledOrange = &_ledOrange;
|
|
||||||
|
|
||||||
struct Adc* const adc1 = &_adc1;
|
struct Adc* const adc1 = &_adc1;
|
||||||
struct AdcParameters* adc1Parameters = &_adc1Parameters;
|
struct AdcParameters* adc1Parameters = &_adc1Parameters;
|
||||||
@@ -156,12 +162,27 @@ struct SpiParameters* const spiEEPROMParam = &_spi3EEPROMParameters;
|
|||||||
|
|
||||||
struct Keypad* const keypad = &_keypad;
|
struct Keypad* const keypad = &_keypad;
|
||||||
|
|
||||||
|
struct Gpio* const ledGreen = &_ledGreen;
|
||||||
|
struct Gpio* const ledOrange = &_ledOrange;
|
||||||
|
struct Gpio* const power6v5Enable = & _power6v5Enable;
|
||||||
|
struct Gpio* const interlock1 = &_interlock1;
|
||||||
|
struct Gpio* const interlock2 = &_interlock2;
|
||||||
|
struct Gpio* const solenoid = & _solenoid;
|
||||||
|
struct Gpio* const mcp0Relay = &_mcp0Relay;
|
||||||
|
struct Gpio* const mcp1Relay = &_mcp1Relay;
|
||||||
|
struct Gpio* const mcp2Relay = &_mcp2Relay;
|
||||||
|
struct Gpio* const cat0Relay = & _cat0Relay;
|
||||||
|
struct Gpio* const cat1Relay = &_cat1Relay;
|
||||||
|
struct Gpio* const cat2Relay = &_cat2Relay;
|
||||||
|
struct Gpio* const teslaLock = &_teslaLock;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static ErrorStatus initClocks(void);
|
static ErrorStatus initClocks(void);
|
||||||
static ErrorStatus initIO (void);
|
static ErrorStatus initIO (void);
|
||||||
|
static T_PL_GPIO configureGPIO (GPIO_TypeDef* gpioTypeDef, GPIOMode_TypeDef gpioMode, GPIOSpeed_TypeDef gpioSpeed, uint16_t gpioPin);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function definitions
|
// Function definitions
|
||||||
@@ -194,12 +215,6 @@ ErrorStatus initPlatform(void)
|
|||||||
/* --------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------*/
|
||||||
pcba = PCBA_getInstance();
|
pcba = PCBA_getInstance();
|
||||||
|
|
||||||
/* --------------------------------------------------------------------*/
|
|
||||||
/* LEDs */
|
|
||||||
/* --------------------------------------------------------------------*/
|
|
||||||
GPIO_construct(ledGreen, OUTPUT, ledGreen->gpio);
|
|
||||||
GPIO_construct(ledOrange, OUTPUT, ledOrange->gpio);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------*/
|
||||||
/* DMA1 - Channel 1 - For use with ADC1 */
|
/* DMA1 - Channel 1 - For use with ADC1 */
|
||||||
/* --------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------*/
|
||||||
@@ -352,6 +367,43 @@ ErrorStatus initPlatform(void)
|
|||||||
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
|
IRQ_setInterruptProperties(EXTI9_5_IRQn, 12, 12, ENABLE);
|
||||||
|
|
||||||
Keypad_construct(keypad, KEYPAD_DEBOUNCE_TIME_MS, KEYPAD_TASK_PRIORITY, KEYPAD_STACK_SIZE, KEYPAD_DEF_QUEUESIZE);
|
Keypad_construct(keypad, 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);
|
||||||
|
// Interlock1
|
||||||
|
GPIO_construct(interlock1, INPUT, interlock1->gpio);
|
||||||
|
// Interlock2
|
||||||
|
GPIO_construct(interlock2, INPUT, interlock2->gpio);
|
||||||
|
// 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
|
||||||
|
GPIO_construct(teslaLock, INPUT, teslaLock->gpio);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -571,10 +623,8 @@ static ErrorStatus initIO (void)
|
|||||||
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_Init(_spiDAC.SPI_CE.GPIO_Typedef, &_spiDAC.SPI_CE.GPIO_InitStruct);
|
GPIO_Init(_spiDAC.SPI_CE.GPIO_Typedef, &_spiDAC.SPI_CE.GPIO_InitStruct);
|
||||||
|
|
||||||
|
|
||||||
spiDAC->spi = &_spi1;
|
spiDAC->spi = &_spi1;
|
||||||
|
|
||||||
|
|
||||||
// SPI3 CLK
|
// SPI3 CLK
|
||||||
_spi3.SPI_CLK.GPIO_Typedef = GPIOC;
|
_spi3.SPI_CLK.GPIO_Typedef = GPIOC;
|
||||||
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
@@ -616,7 +666,7 @@ static ErrorStatus initIO (void)
|
|||||||
GPIO_Init(_spiEEPROM.SPI_CE.GPIO_Typedef, &_spiEEPROM.SPI_CE.GPIO_InitStruct);
|
GPIO_Init(_spiEEPROM.SPI_CE.GPIO_Typedef, &_spiEEPROM.SPI_CE.GPIO_InitStruct);
|
||||||
|
|
||||||
|
|
||||||
// Keypad I/O
|
/* KEYPAD initialisation -------------------------------------------------*/
|
||||||
// Row1
|
// Row1
|
||||||
keypad->row[0].gpio.GPIO_Typedef = GPIOD;
|
keypad->row[0].gpio.GPIO_Typedef = GPIOD;
|
||||||
keypad->row[0].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
keypad->row[0].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
@@ -675,6 +725,55 @@ static ErrorStatus initIO (void)
|
|||||||
GPIO_Init(keypad->column[3].gpio.GPIO_Typedef, &keypad->column[3].gpio.GPIO_InitStruct);
|
GPIO_Init(keypad->column[3].gpio.GPIO_Typedef, &keypad->column[3].gpio.GPIO_InitStruct);
|
||||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource7);
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource7);
|
||||||
|
|
||||||
|
/* GPIO initialisation ---------------------------------------------------*/
|
||||||
|
// 6V5 enable -> PE12 output
|
||||||
|
power6v5Enable->gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_12);
|
||||||
|
// Interlock1 - PB0 input
|
||||||
|
interlock1->gpio = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_0);
|
||||||
|
// Interlock2 - PB1 input
|
||||||
|
interlock2->gpio = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_1);
|
||||||
|
// Solenoid - PB5 output
|
||||||
|
solenoid->gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_5);
|
||||||
|
if (PCBA_getInstance()->pcba == CathodeMCP)
|
||||||
|
{
|
||||||
|
// MCP0Relay - PD8 output
|
||||||
|
mcp0Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_8);
|
||||||
|
// MCP1Relay - PD9 output
|
||||||
|
mcp1Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_9);
|
||||||
|
// MCP2Relay - PD10 output
|
||||||
|
mcp2Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_10);
|
||||||
|
// CAT0Relay - PD11 output
|
||||||
|
cat0Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_11);
|
||||||
|
// CAT1Relay - PD12 output
|
||||||
|
cat1Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_12);
|
||||||
|
// CAT2Relay - PD13 output
|
||||||
|
cat2Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_13);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
if (PCBA_getInstance()->pcba == Tesla)
|
||||||
|
{
|
||||||
|
// Tesla lock PB10 output
|
||||||
|
teslaLock->gpio = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static T_PL_GPIO configureGPIO (GPIO_TypeDef* gpioTypeDef, GPIOMode_TypeDef gpioMode, GPIOSpeed_TypeDef gpioSpeed, uint16_t gpioPin)
|
||||||
|
{
|
||||||
|
T_PL_GPIO gpio;
|
||||||
|
gpio.GPIO_Typedef = gpioTypeDef;
|
||||||
|
gpio.GPIO_InitStruct.GPIO_Mode = gpioMode;
|
||||||
|
gpio.GPIO_InitStruct.GPIO_Pin = gpioPin;
|
||||||
|
gpio.GPIO_InitStruct.GPIO_Speed = gpioSpeed;
|
||||||
|
GPIO_Init(gpio.GPIO_Typedef, &gpio.GPIO_InitStruct);
|
||||||
|
|
||||||
|
return gpio;
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,9 +63,16 @@ ErrorStatus SpiDevice_construct(struct SpiDevice* self, struct Spi* spi, const s
|
|||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
if (!self->initialized)
|
||||||
|
{
|
||||||
IODevice_construct(&self->device, NULL, write);
|
IODevice_construct(&self->device, NULL, write);
|
||||||
|
|
||||||
SPI_construct(self->spi, parameters);
|
SPI_construct(self->spi, parameters);
|
||||||
|
self->initialized = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
@@ -82,6 +89,8 @@ ErrorStatus SpiDevice_write (const struct SpiDevice* self, const char* buffer, i
|
|||||||
ErrorStatus returnValue = SUCCESS; //! Define return variable
|
ErrorStatus returnValue = SUCCESS; //! Define return variable
|
||||||
int txCounter; //! Define a loop counter var
|
int txCounter; //! Define a loop counter var
|
||||||
|
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
|
|
||||||
xSemaphoreTake(self->spi->spiClaimed, portMAX_DELAY);
|
xSemaphoreTake(self->spi->spiClaimed, portMAX_DELAY);
|
||||||
if (self->spi->SPI_InitStruct.SPI_NSS == SPI_NSS_Soft)
|
if (self->spi->SPI_InitStruct.SPI_NSS == SPI_NSS_Soft)
|
||||||
@@ -149,6 +158,11 @@ ErrorStatus SpiDevice_write (const struct SpiDevice* self, const char* buffer, i
|
|||||||
{
|
{
|
||||||
//! Do nothing
|
//! Do nothing
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return returnValue; //! Return result to caller
|
return returnValue; //! Return result to caller
|
||||||
@@ -159,5 +173,13 @@ ErrorStatus SpiDevice_read(const struct SpiDevice* self, char* buffer, size_t le
|
|||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ ErrorStatus Uart_construct(struct Uart* self, struct UartParameters* parameters)
|
|||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
if(!self->initialized)
|
||||||
|
{
|
||||||
IODevice_construct(&self->device, read, write);
|
IODevice_construct(&self->device, read, write);
|
||||||
|
|
||||||
//! Create semaphore to synchronize with USART interrupt handler
|
//! Create semaphore to synchronize with USART interrupt handler
|
||||||
@@ -72,14 +74,6 @@ ErrorStatus Uart_construct(struct Uart* self, struct UartParameters* parameters)
|
|||||||
|
|
||||||
USART_DeInit(self->USART_TypeDef);
|
USART_DeInit(self->USART_TypeDef);
|
||||||
|
|
||||||
// self->USART_ClockInitStruct->USART_Clock = USART_Clock_Enable;
|
|
||||||
// self->USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge;
|
|
||||||
// self->USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low;
|
|
||||||
// self->USART_ClockInitStruct->USART_LastBit = USART_LastBit_Enable;
|
|
||||||
//
|
|
||||||
// //! Enable USART clock
|
|
||||||
// USART_ClockInit(self->USART_TypeDef, self->USART_ClockInitStruct);
|
|
||||||
|
|
||||||
// Initialise the UART
|
// Initialise the UART
|
||||||
self->USART_InitStruct.USART_BaudRate = parameters->baudrate;
|
self->USART_InitStruct.USART_BaudRate = parameters->baudrate;
|
||||||
self->USART_InitStruct.USART_WordLength = parameters->wordlength;
|
self->USART_InitStruct.USART_WordLength = parameters->wordlength;
|
||||||
@@ -117,18 +111,16 @@ ErrorStatus Uart_construct(struct Uart* self, struct UartParameters* parameters)
|
|||||||
returnValue = ERROR;
|
returnValue = ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usartQueueItem tmp;
|
|
||||||
tmp.byte = 0x01;
|
|
||||||
xQueueSend(self->rxQueue, &tmp, 0);
|
|
||||||
tmp.byte++;
|
|
||||||
xQueueSend(self->rxQueue, &tmp, 0);
|
|
||||||
tmp.byte++;
|
|
||||||
xQueueSend(self->rxQueue, &tmp, 0);
|
|
||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
//! Enable the UART RX not empty interrupt
|
//! Enable the UART RX not empty interrupt
|
||||||
USART_ITConfig(self->USART_TypeDef, USART_IT_RXNE, ENABLE);
|
USART_ITConfig(self->USART_TypeDef, USART_IT_RXNE, ENABLE);
|
||||||
|
self->initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -169,6 +161,9 @@ ErrorStatus Uart_write(struct Uart* self, const char* buffer, int length)
|
|||||||
ErrorStatus returnValue = SUCCESS; //! Define return variable
|
ErrorStatus returnValue = SUCCESS; //! Define return variable
|
||||||
int txCounter; //! Define a loop counter var
|
int txCounter; //! Define a loop counter var
|
||||||
|
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
|
|
||||||
//! Copy the incoming data into UART data structure
|
//! Copy the incoming data into UART data structure
|
||||||
for (txCounter = 0; txCounter < length; txCounter++)
|
for (txCounter = 0; txCounter < length; txCounter++)
|
||||||
{
|
{
|
||||||
@@ -215,6 +210,11 @@ ErrorStatus Uart_write(struct Uart* self, const char* buffer, int length)
|
|||||||
{
|
{
|
||||||
//! Do nothing
|
//! Do nothing
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
return (returnValue); //! Return result to caller
|
return (returnValue); //! Return result to caller
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +227,8 @@ ErrorStatus Uart_read (struct Uart* self, char* buffer, size_t length, size_t* a
|
|||||||
*actualLength = 0;
|
*actualLength = 0;
|
||||||
struct usartQueueItem usartRxItem;
|
struct usartQueueItem usartRxItem;
|
||||||
|
|
||||||
|
if (self->initialized)
|
||||||
|
{
|
||||||
|
|
||||||
for (loopCounter = 0; loopCounter < length; loopCounter++)
|
for (loopCounter = 0; loopCounter < length; loopCounter++)
|
||||||
{
|
{
|
||||||
@@ -241,6 +243,11 @@ ErrorStatus Uart_read (struct Uart* self, char* buffer, size_t length, size_t* a
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ struct HwValidationMenuItems
|
|||||||
struct Gpio* cat0Relay;
|
struct Gpio* cat0Relay;
|
||||||
struct Gpio* cat1Relay;
|
struct Gpio* cat1Relay;
|
||||||
struct Gpio* cat2Relay;
|
struct Gpio* cat2Relay;
|
||||||
|
struct Gpio* teslaLock;
|
||||||
struct Pcba* pcba;
|
struct Pcba* pcba;
|
||||||
// struct Eeprom* eeprom; // Not implemented yet
|
// struct Eeprom* eeprom; // Not implemented yet
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
tick hook. */
|
tick hook. */
|
||||||
#define mainCHECK_DELAY ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
|
#define mainCHECK_DELAY ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
|
||||||
|
|
||||||
|
#define INIT_START_SCREEN_DELAY (5000)
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Type definitions
|
// Type definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -209,19 +210,20 @@ static void initTask(void* parameters)
|
|||||||
hwTestItems.display = &nhd0420.displayDevice;
|
hwTestItems.display = &nhd0420.displayDevice;
|
||||||
hwTestItems.internalADC = adc1;
|
hwTestItems.internalADC = adc1;
|
||||||
hwTestItems.externalDAC = &max5715;
|
hwTestItems.externalDAC = &max5715;
|
||||||
hwTestItems.power6v5Enable = NULL;
|
hwTestItems.power6v5Enable = power6v5Enable;
|
||||||
hwTestItems.interlock1 = NULL;
|
hwTestItems.interlock1 = interlock1;
|
||||||
hwTestItems.interlock2 = NULL;
|
hwTestItems.interlock2 = interlock2;
|
||||||
hwTestItems.solenoid = NULL;
|
hwTestItems.solenoid = solenoid;
|
||||||
hwTestItems.mcp0Relay = NULL;
|
hwTestItems.mcp0Relay = mcp0Relay;
|
||||||
hwTestItems.mcp1Relay = NULL;
|
hwTestItems.mcp1Relay = mcp1Relay;
|
||||||
hwTestItems.mcp2Relay = NULL;
|
hwTestItems.mcp2Relay = mcp2Relay;
|
||||||
hwTestItems.cat0Relay = NULL;
|
hwTestItems.cat0Relay = cat0Relay;
|
||||||
hwTestItems.cat1Relay = NULL;
|
hwTestItems.cat1Relay = cat1Relay;
|
||||||
hwTestItems.cat2Relay = NULL;
|
hwTestItems.cat2Relay = cat2Relay;
|
||||||
|
hwTestItems.teslaLock = teslaLock;
|
||||||
hwTestItems.pcba = pcba;
|
hwTestItems.pcba = pcba;
|
||||||
// EEPROM TO BE DONE
|
// EEPROM TO BE DONE
|
||||||
// HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 2, 1024);
|
// HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 1024);
|
||||||
|
|
||||||
|
|
||||||
MAX5715_construct(&max5715, &spiDAC->device);
|
MAX5715_construct(&max5715, &spiDAC->device);
|
||||||
@@ -244,6 +246,9 @@ static void initTask(void* parameters)
|
|||||||
repairProcess_construct(rp, 3, 1024);
|
repairProcess_construct(rp, 3, 1024);
|
||||||
|
|
||||||
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 1, &sysTaskHandle);
|
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 1, &sysTaskHandle);
|
||||||
|
|
||||||
|
// Let start screen stay for 5 seconds
|
||||||
|
vTaskDelay(INIT_START_SCREEN_DELAY);
|
||||||
// Delete this init task
|
// Delete this init task
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user