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:
@@ -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);
|
||||
}
|
||||
|
||||
// Interlock_setEXTI(interlock, ENABLE);
|
||||
returnValue = initPeriphery();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user