Started working on next milestone

- Removed the 6V5 power enable 
- Tweaked the cursor position for preset configuration
- Updated the MenuText header file for translation at Photonis

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@320 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-11-30 13:35:51 +00:00
parent afe3113a97
commit 1415b5c6f2
15 changed files with 177 additions and 498 deletions

View File

@@ -31,8 +31,10 @@
#include "stm32f10x_adc.h"
#include "stm32f10x_bkp.h"
#include "stm32f10x_dma.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_it.h"
#include "Logger.h"
@@ -48,7 +50,6 @@
#include "MAX5715.h"
#include "nhd0420.h"
#include "PCBA.h"
#include "Power6V5Supply.h"
#include "rtc.h"
#include "spi.h"
#include "spiDevice.h"
@@ -78,9 +79,9 @@
// SPI1 settings
// SPI3 settings (LCD / EEPROM)
#define SPI_LCD_EEPROM_Direction (SPI_Direction_2Lines_FullDuplex)
#define SPI_LCD_EEPROM_RX_QUEUE (32)
#define SPI_LCD_EEPROM_TX_QUEUE (32)
#define SPI_LCD_Direction (SPI_Direction_2Lines_FullDuplex)
#define SPI_LCD_RX_QUEUE (32)
#define SPI_LCD_TX_QUEUE (32)
// Keypad Settings
#define KEYPAD_DEBOUNCE_TIME_MS (20)
@@ -124,9 +125,7 @@ static struct SpiDevice _spiDAC = {.initialized = false};
static struct SpiParameters _spi1DACParameters;
static struct Spi _spi3 = {.initialized = false};
static struct SpiParameters _spi3DisplayParameters;
static struct SpiParameters _spi3EEPROMParameters;
static struct SpiDevice _spiDisplay = {.initialized = false};
static struct SpiDevice _spiEEPROM = {.initialized = false};
// Keypad
static struct Keypad _keypad = {.initialized = false};
@@ -138,7 +137,6 @@ static struct InternalFlash _iFlash = {.initialized = false};
// GPIOs
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};
@@ -180,8 +178,6 @@ struct SpiDevice* const spiDAC = &_spiDAC;
struct SpiParameters* const spiDACParam = &_spi1DACParameters;
struct SpiDevice* const spiDisplay = &_spiDisplay;
struct SpiParameters* const spiDisplayParam = &_spi3DisplayParameters;
struct SpiDevice* const spiEEPROM = &_spiEEPROM;
struct SpiParameters* const spiEEPROMParam = &_spi3EEPROMParameters;
struct Keypad* const keypad = &_keypad;
struct Storm700* const storm700 = &_storm700;
@@ -369,164 +365,83 @@ static ErrorStatus initIO (void)
/* SPI initialisation ----------------------------------------------------*/
// SPI1 CLK
_spi1.SPI_CLK.GPIO_Typedef = GPIOA;
_spi1.SPI_CLK.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
_spi1.SPI_CLK.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
_spi1.SPI_CLK.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spi1.SPI_CLK.GPIO_Typedef, &_spi1.SPI_CLK.GPIO_InitStruct);
spi1->SPI_CLK = configureGPIO(GPIOA, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_5);
// SPI1 MISO
_spi1.SPI_MISO.GPIO_Typedef = GPIOA;
_spi1.SPI_MISO.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
_spi1.SPI_MISO.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(_spi1.SPI_MISO.GPIO_Typedef, &_spi1.SPI_MISO.GPIO_InitStruct);
spi1->SPI_MISO = configureGPIO(GPIOA, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_6);
// SPI1 MOSI
_spi1.SPI_MOSI.GPIO_Typedef = GPIOA;
_spi1.SPI_MOSI.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
_spi1.SPI_MOSI.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
_spi1.SPI_MOSI.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spi1.SPI_MOSI.GPIO_Typedef, &_spi1.SPI_MOSI.GPIO_InitStruct);
// SPI1 CE
_spiDAC.SPI_CE.GPIO_Typedef = GPIOA;
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spiDAC.SPI_CE.GPIO_Typedef, &_spiDAC.SPI_CE.GPIO_InitStruct);
spi1->SPI_MOSI = configureGPIO(GPIOA, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_7);
spiDAC->spi = &_spi1;
// Assign spi1 to purpose
spiDAC->spi = spi1;
// SPIDAC specific CE
spiDAC->SPI_CE = configureGPIO(GPIOA, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_4);
// SPI3 CLK
_spi3.SPI_CLK.GPIO_Typedef = GPIOC;
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10;
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spi3.SPI_CLK.GPIO_Typedef, &_spi3.SPI_CLK.GPIO_InitStruct);
spi3->SPI_CLK = configureGPIO(GPIOC, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_10);
// SPI3 MISO
_spi3.SPI_MISO.GPIO_Typedef = GPIOC;
_spi3.SPI_MISO.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
_spi3.SPI_MISO.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
_spi3.SPI_MISO.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spi3.SPI_MISO.GPIO_Typedef, &_spi3.SPI_MISO.GPIO_InitStruct);
spi3->SPI_MISO = configureGPIO(GPIOC, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_Pin_11);
// SPI3 MOSI
_spi3.SPI_MOSI.GPIO_Typedef = GPIOC;
_spi3.SPI_MOSI.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
_spi3.SPI_MOSI.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
_spi3.SPI_MOSI.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spi3.SPI_MOSI.GPIO_Typedef, &_spi3.SPI_MOSI.GPIO_InitStruct);
spi3->SPI_MOSI = configureGPIO(GPIOC, GPIO_Mode_AF_PP, GPIO_Speed_50MHz, GPIO_Pin_12);
// Apply pin-remapping for SPI3 I/Os (alternative I/Os usage)
GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
// SPI3 Display shares all parameters with SPI3 but the ChipEnable, which is different
_spiDisplay.spi = &_spi3;
// SPI3 CE EEPROM
_spiDisplay.SPI_CE.GPIO_Typedef = GPIOE;
_spiDisplay.SPI_CE.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
_spiDisplay.SPI_CE.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
_spiDisplay.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spiDisplay.SPI_CE.GPIO_Typedef, &_spiDisplay.SPI_CE.GPIO_InitStruct);
// SPI3 EEPROM shares all parameters with SPI3 but the ChipEnable, which is different
_spiEEPROM.spi = &_spi3;
// SPI3 CE EEPROM
_spiEEPROM.SPI_CE.GPIO_Typedef = GPIOE;
_spiEEPROM.SPI_CE.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
_spiEEPROM.SPI_CE.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
_spiEEPROM.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(_spiEEPROM.SPI_CE.GPIO_Typedef, &_spiEEPROM.SPI_CE.GPIO_InitStruct);
spiDisplay->spi = spi3;
// SPI Display specific CE
spiDisplay->SPI_CE = configureGPIO(GPIOE, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_0);
/* KEYPAD initialisation -------------------------------------------------*/
// Row1
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_Pin = GPIO_Pin_0;
keypad->row[0].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->row[0].gpio.GPIO_Typedef, &keypad->row[0].gpio.GPIO_InitStruct);
keypad->row[0].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_0);
// Row2
keypad->row[1].gpio.GPIO_Typedef = GPIOD;
keypad->row[1].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
keypad->row[1].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
keypad->row[1].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->row[1].gpio.GPIO_Typedef, &keypad->row[1].gpio.GPIO_InitStruct);
keypad->row[1].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_1);
// Row3
keypad->row[2].gpio.GPIO_Typedef = GPIOD;
keypad->row[2].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
keypad->row[2].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
keypad->row[2].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->row[2].gpio.GPIO_Typedef, &keypad->row[2].gpio.GPIO_InitStruct);
keypad->row[2].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_2);
// Row4
keypad->row[3].gpio.GPIO_Typedef = GPIOD;
keypad->row[3].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
keypad->row[3].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
keypad->row[3].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->row[3].gpio.GPIO_Typedef, &keypad->row[3].gpio.GPIO_InitStruct);
keypad->row[3].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_3);
// Column1
keypad->column[0].gpio.GPIO_Typedef = GPIOD;
keypad->column[0].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
keypad->column[0].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
keypad->column[0].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->column[0].gpio.GPIO_Typedef, &keypad->column[0].gpio.GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);
keypad->column[0].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_4);
// Column2
keypad->column[1].gpio.GPIO_Typedef = GPIOD;
keypad->column[1].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
keypad->column[1].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
keypad->column[1].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->column[1].gpio.GPIO_Typedef, &keypad->column[1].gpio.GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource5);
keypad->column[1].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_5);
// Column3
keypad->column[2].gpio.GPIO_Typedef = GPIOD;
keypad->column[2].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
keypad->column[2].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
keypad->column[2].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->column[2].gpio.GPIO_Typedef, &keypad->column[2].gpio.GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource6);
keypad->column[2].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_6);
// Column4
keypad->column[3].gpio.GPIO_Typedef = GPIOD;
keypad->column[3].gpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
keypad->column[3].gpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
keypad->column[3].gpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(keypad->column[3].gpio.GPIO_Typedef, &keypad->column[3].gpio.GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource7);
keypad->column[3].gpio = configureGPIO(GPIOD, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_7);
/* GPIO initialisation ---------------------------------------------------*/
// 6V5 enable -> PE12 output
_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);
}
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
// Tesla Gun relay PB9 (or 10???)
_teslaRelay.gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_9);
// Tesla Gun relay PB9
_teslaRelay.gpio = configureGPIO(GPIOB, GPIO_Mode_Out_PP, GPIO_Speed_50MHz, GPIO_Pin_9);
}
return returnValue;
}
@@ -657,13 +572,12 @@ static ErrorStatus initPeriphery(void)
// 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;
spiDisplayParam->rxQueueSize = SPI_LCD_RX_QUEUE;
spiDisplayParam->txQueueSize = SPI_LCD_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 */
@@ -703,7 +617,6 @@ static ErrorStatus initPeriphery(void)
InternalFlash_construct(iFlash);
/* --------------------------------------------------------------------*/
/* GPIOs */
/* --------------------------------------------------------------------*/
@@ -711,8 +624,6 @@ static ErrorStatus initPeriphery(void)
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);
@@ -765,11 +676,6 @@ static ErrorStatus initPlatformDevices (void)
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);