Constants renamed (so that Taranis hal is now nice)

This commit is contained in:
bsongis
2015-06-09 21:15:10 +02:00
parent bab4168ac4
commit 8365a8dbaf
39 changed files with 998 additions and 1005 deletions
+34 -34
View File
@@ -42,9 +42,9 @@ static void Delay(uint32_t ms)
// New hardware SPI driver for LCD
void initLcdSpi()
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD_RST, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD_NCS, ENABLE);
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph, ENABLE);
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph_RST, ENABLE);
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph_NCS, ENABLE);
RCC->APB1ENR |= RCC_APB1ENR_SPI3EN ; // Enable clock
// APB1 clock / 2 = 133nS per clock
@@ -54,10 +54,10 @@ void initLcdSpi()
SPI3->CR1 |= SPI_CR1_MSTR ; // Make sure in case SSM/SSI needed to be set first
SPI3->CR1 |= SPI_CR1_SPE ;
configure_pins( PIN_LCD_NCS, PIN_OUTPUT | PIN_PORTA | PIN_OS25) ;
configure_pins( PIN_LCD_RST, PIN_OUTPUT | PIN_PORTD | PIN_OS25) ;
configure_pins( PIN_LCD_A0, PIN_OUTPUT | PIN_PORTC | PIN_OS50) ;
configure_pins( PIN_LCD_MOSI|PIN_LCD_CLK, PIN_PORTC | PIN_OS50 | PIN_PER_6 | PIN_PERIPHERAL ) ;
configure_pins( LCD_GPIO_PIN_NCS, PIN_OUTPUT | PIN_PORTA | PIN_OS25) ;
configure_pins( LCD_GPIO_PIN_RST, PIN_OUTPUT | PIN_PORTD | PIN_OS25) ;
configure_pins( LCD_GPIO_PIN_A0, PIN_OUTPUT | PIN_PORTC | PIN_OS50) ;
configure_pins( LCD_GPIO_PIN_MOSI|LCD_GPIO_PIN_CLK, PIN_PORTC | PIN_OS50 | PIN_PER_6 | PIN_PERIPHERAL ) ;
// NVIC_SetPriority( DMA1_Stream7_IRQn, 8 ) ;
@@ -263,18 +263,18 @@ void lcdRefresh()
/**Init the Backlight GPIO */
static void LCD_BL_Config()
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
RCC_AHB1PeriphClockCmd(BACKLIGHT_RCC_AHB1Periph_GPIO, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
#if defined(REV9E)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL|GPIO_Pin_BLW;
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1|BACKLIGHT_GPIO_PIN_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOBL, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BL_AF);
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_2, BACKLIGHT_GPIO_AF_1);
RCC->APB2ENR |= RCC_APB2ENR_TIM9EN ; // Enable clock
TIM9->ARR = 100 ;
TIM9->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 50000 - 1; // 20us * 100 = 2ms => 500Hz
@@ -285,14 +285,14 @@ static void LCD_BL_Config()
TIM9->EGR = 0 ;
TIM9->CR1 = TIM_CR1_CEN ; // Counter enable
#elif defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL|GPIO_Pin_BLW;
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1|BACKLIGHT_GPIO_PIN_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOBL, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BL_AF);
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_2, BACKLIGHT_GPIO_AF_1);
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock
TIM4->ARR = 100 ;
@@ -305,13 +305,13 @@ static void LCD_BL_Config()
TIM4->EGR = 0 ;
TIM4->CR1 = TIM_CR1_CEN ; // Counter enable
#else
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOBL, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
TIM10->ARR = 100 ;
@@ -328,31 +328,31 @@ static void LCD_BL_Config()
*/
static void LCD_Hardware_Init()
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE);
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
/*!< Configure lcd CLK\ MOSI\ A0pin in output push-pull mode *************/
GPIO_InitStructure.GPIO_Pin = PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0;
GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_MOSI | LCD_GPIO_PIN_CLK | LCD_GPIO_PIN_A0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_LCD_SPI, &GPIO_InitStructure);
GPIO_Init(LCD_GPIO_SPI, &GPIO_InitStructure);
LCD_NCS_HIGH();
/*!< Configure lcd NCS pin in output push-pull mode ,PULLUP *************/
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS;
GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_NCS;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIO_LCD_NCS, &GPIO_InitStructure);
GPIO_Init(LCD_GPIO_NCS, &GPIO_InitStructure);
/*!< Configure lcd RST pin in output pushpull mode ,PULLUP *************/
GPIO_InitStructure.GPIO_Pin = PIN_LCD_RST;
GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_RST;
GPIO_Init(LCD_GPIO_RST, &GPIO_InitStructure);
}
/*
@@ -445,25 +445,25 @@ void lcdSetRefVolt(uint8_t val)
#if defined(REV9E)
void turnBacklightOn(uint8_t level, uint8_t color)
{
TIM_BL->CCR1 = ((100-level)*(20-color))/20;
TIM_BL->CCR2 = ((100-level)*color)/20;
BACKLIGHT_TIMER->CCR1 = ((100-level)*(20-color))/20;
BACKLIGHT_TIMER->CCR2 = ((100-level)*color)/20;
}
void turnBacklightOff(void)
{
TIM_BL->CCR1 = 0;
TIM_BL->CCR2 = 0;
BACKLIGHT_TIMER->CCR1 = 0;
BACKLIGHT_TIMER->CCR2 = 0;
}
#elif defined(REVPLUS)
void turnBacklightOn(uint8_t level, uint8_t color)
{
TIM_BL->CCR4 = ((100-level)*(20-color))/20;
TIM_BL->CCR2 = ((100-level)*color)/20;
BACKLIGHT_TIMER->CCR4 = ((100-level)*(20-color))/20;
BACKLIGHT_TIMER->CCR2 = ((100-level)*color)/20;
}
void turnBacklightOff(void)
{
TIM_BL->CCR4 = 0;
TIM_BL->CCR2 = 0;
BACKLIGHT_TIMER->CCR4 = 0;
BACKLIGHT_TIMER->CCR2 = 0;
}
#endif