Added some IO modules (teslaGun, solenoid, powerEnable) as dedicated modules instead of general IO
Fixed code behind them git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@266 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -82,21 +82,8 @@ extern struct Storm700* const storm700;
|
||||
// Export of GPIOs
|
||||
extern struct Gpio* const ledGreen;
|
||||
extern struct Gpio* const ledOrange;
|
||||
extern struct Gpio* const power6v5Enable;
|
||||
extern struct Gpio* const interlockNO;
|
||||
extern struct Gpio* const interlockNC;
|
||||
extern struct Gpio* const teslaNO;
|
||||
extern struct Gpio* const teslaNC;
|
||||
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 Interlock* const interlock;
|
||||
extern struct Interlock* const teslalock;
|
||||
|
||||
extern struct NHD0420* const nhd0420;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "stm32f10x_adc.h"
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
#include "platform.h"
|
||||
#include "CathodeMCP.h"
|
||||
#include "CoverSolenoid.h"
|
||||
#include "gpio.h"
|
||||
#include "Interlock.h"
|
||||
#include "internalADC.h"
|
||||
@@ -45,10 +47,12 @@
|
||||
#include "MAX5715.h"
|
||||
#include "nhd0420.h"
|
||||
#include "PCBA.h"
|
||||
#include "Power6V5Supply.h"
|
||||
#include "rtc.h"
|
||||
#include "spi.h"
|
||||
#include "spiDevice.h"
|
||||
#include "storm700.h"
|
||||
#include "TeslaGunSafety.h"
|
||||
#include "uart.h"
|
||||
#include "Version.h"
|
||||
|
||||
@@ -132,9 +136,9 @@ static struct Gpio _ledGreen = {.initialized = false};
|
||||
static struct Gpio _ledOrange = {.initialized = false};
|
||||
static struct Gpio _power6v5Enable = {.initialized = false};
|
||||
static struct Gpio _interlockNO = {.initialized = false};
|
||||
static EXTI_InitTypeDef _interlockNOEXTI;
|
||||
static struct Gpio _interlockNC = {.initialized = false};
|
||||
static struct Gpio _teslaNO = {.initialized = false};
|
||||
static struct Gpio _teslaNC = {.initialized = false};
|
||||
static EXTI_InitTypeDef _interlockNCEXTI;
|
||||
static struct Gpio _solenoid = {.initialized = false};
|
||||
static struct Gpio _mcp0Relay = {.initialized = false};
|
||||
static struct Gpio _mcp1Relay = {.initialized = false};
|
||||
@@ -142,9 +146,9 @@ 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 _teslaRelay = {.initialized = false};
|
||||
|
||||
static struct Interlock _interlock = {.initialized = false};
|
||||
static struct Interlock _teslalock = {.initialized = false};
|
||||
|
||||
static struct NHD0420 _nhd0420 = {.initialized = false};
|
||||
|
||||
@@ -180,21 +184,10 @@ struct Storm700* const storm700 = &_storm700;
|
||||
|
||||
struct Gpio* const ledGreen = &_ledGreen;
|
||||
struct Gpio* const ledOrange = &_ledOrange;
|
||||
struct Gpio* const power6v5Enable = & _power6v5Enable;
|
||||
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 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 Interlock* const interlock = &_interlock;
|
||||
struct Interlock* const teslalock = &_teslalock;
|
||||
|
||||
|
||||
struct NHD0420* const nhd0420 = &_nhd0420;
|
||||
|
||||
@@ -497,41 +490,37 @@ static ErrorStatus initIO (void)
|
||||
|
||||
/* GPIO initialisation ---------------------------------------------------*/
|
||||
// 6V5 enable -> PE12 output
|
||||
power6v5Enable->gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_12);
|
||||
_power6v5Enable.gpio = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_12);
|
||||
// Interlock1 - PB0 input
|
||||
interlockNO->gpio = configureGPIO(GPIOB, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_0);
|
||||
_interlockNO.gpio = configureGPIO(GPIOB, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_0);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource0);
|
||||
// Interlock2 - PB1 input
|
||||
interlockNC->gpio = configureGPIO(GPIOB, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_1);
|
||||
_interlockNC.gpio = configureGPIO(GPIOB, GPIO_Mode_IPU, GPIO_Speed_50MHz, GPIO_Pin_1);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource1);
|
||||
// Solenoid - PB5 output
|
||||
solenoid->gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_5);
|
||||
_solenoid.gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_5);
|
||||
|
||||
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||
{
|
||||
// MCP0Relay - PD8 output
|
||||
mcp0Relay->gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_8);
|
||||
_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);
|
||||
_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);
|
||||
_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);
|
||||
_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);
|
||||
_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);
|
||||
_cat2Relay.gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_13);
|
||||
|
||||
CathodeMCP_setIO(mcp0Relay, mcp1Relay, mcp2Relay, cat0Relay, cat1Relay, cat2Relay);
|
||||
}
|
||||
|
||||
if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
// Tesla lock PB10 output
|
||||
teslaNO->gpio = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_9);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
|
||||
teslaNC->gpio = configureGPIO(GPIOB, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_10);
|
||||
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource10);
|
||||
// Tesla Gun relay PB9 (or 10???)
|
||||
_teslaRelay.gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_9);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -709,50 +698,39 @@ static ErrorStatus initPeriphery(void)
|
||||
// Orange LED
|
||||
GPIO_construct(ledOrange, OUTPUT, ledOrange->gpio);
|
||||
// 6V5 Power Enable
|
||||
GPIO_construct(power6v5Enable, OUTPUT, power6v5Enable->gpio);
|
||||
// powerEnable is inverted. Set to HIGH/TRUE to switch OFF
|
||||
GPIO_setValue(power6v5Enable, true);
|
||||
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);
|
||||
_interlockNOEXTI = 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, COMMON_INTERLOCK, interlockNO, intNOEXTI, interlockNC, intNCEXTI, INTERLOCK_DEBOUNCE_TIME_MS);
|
||||
_interlockNCEXTI = configureEXTI(EXTI_Line1, EXTI_Mode_Interrupt, EXTI_Trigger_Rising_Falling, DISABLE);
|
||||
GPIO_construct(&_interlockNC, INPUT, _interlockNC.gpio);
|
||||
|
||||
// Solenoid
|
||||
GPIO_construct(solenoid, OUTPUT, solenoid->gpio);
|
||||
GPIO_construct(&_solenoid, OUTPUT, _solenoid.gpio);
|
||||
|
||||
|
||||
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||
{
|
||||
// MCP0Relay
|
||||
GPIO_construct(mcp0Relay, OUTPUT, mcp0Relay->gpio);
|
||||
GPIO_construct(&_mcp0Relay, OUTPUT, _mcp0Relay.gpio);
|
||||
// MCP1Relay
|
||||
GPIO_construct(mcp1Relay, OUTPUT, mcp1Relay->gpio);
|
||||
GPIO_construct(&_mcp1Relay, OUTPUT, _mcp1Relay.gpio);
|
||||
// MCP2Relay
|
||||
GPIO_construct(mcp2Relay, OUTPUT, mcp2Relay->gpio);
|
||||
GPIO_construct(&_mcp2Relay, OUTPUT, _mcp2Relay.gpio);
|
||||
// CAT0Relay
|
||||
GPIO_construct(cat0Relay, OUTPUT, cat0Relay->gpio);
|
||||
GPIO_construct(&_cat0Relay, OUTPUT, _cat0Relay.gpio);
|
||||
// CAT1Relay
|
||||
GPIO_construct(cat1Relay, OUTPUT, cat1Relay->gpio);
|
||||
GPIO_construct(&_cat1Relay, OUTPUT, _cat1Relay.gpio);
|
||||
// CAT2Relay
|
||||
GPIO_construct(cat2Relay, OUTPUT, cat2Relay->gpio);
|
||||
GPIO_construct(&_cat2Relay, OUTPUT, _cat2Relay.gpio);
|
||||
}
|
||||
if (PCBA_getInstance()->pcba == 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, TESLA_INTERLOCK, teslaNO, teslaNOEXTI, teslaNC, teslaNCEXTI, INTERLOCK_DEBOUNCE_TIME_MS);
|
||||
GPIO_construct(&_teslaRelay, OUTPUT, _teslaRelay.gpio);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
@@ -763,6 +741,31 @@ static ErrorStatus initPlatformDevices (void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
CathodeMCP_setIO(&_mcp0Relay, &_mcp1Relay, &_mcp2Relay, &_cat0Relay, &_cat1Relay, &_cat2Relay);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
Interlock_construct(interlock, COMMON_INTERLOCK, &_interlockNO, _interlockNOEXTI, &_interlockNC, _interlockNCEXTI, INTERLOCK_DEBOUNCE_TIME_MS);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
Power6V5Supply_construct(&_power6v5Enable);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
CoverSolenoid_construct(&_solenoid);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
TeslaGunSafety_construct(&_teslaRelay);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
/* --------------------------------------------------------------------*/
|
||||
@@ -793,7 +796,6 @@ static ErrorStatus initPlatformDevices (void)
|
||||
/* NewHavenDispplay 04 20 */
|
||||
/* --------------------------------------------------------------------*/
|
||||
returnValue = NHD0420_construct(nhd0420, &spiDisplay->device);
|
||||
// returnValue = NHD0420_construct(nhd0420, &uart1->device);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
|
||||
Reference in New Issue
Block a user