[Taranis X9E] Top LCD Initialisation. All segments should be ON after
this commit.
This commit is contained in:
@@ -871,6 +871,7 @@ ifeq ($(PCB), TARANIS)
|
||||
CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/uart3_driver.cpp targets/taranis/telemetry_driver.cpp
|
||||
CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp loadboot.cpp debug.cpp
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
EXTRABOARDSRC += targets/taranis/top_lcd_driver.cpp
|
||||
SRC += targets/taranis/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
|
||||
SRC += targets/taranis/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c
|
||||
SRC += targets/taranis/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
|
||||
|
||||
@@ -129,7 +129,6 @@ void perMain()
|
||||
#endif
|
||||
|
||||
#if defined(LUA)
|
||||
|
||||
uint32_t t0 = get_tmr10ms();
|
||||
static uint32_t lastLuaTime = 0;
|
||||
uint16_t interval = (lastLuaTime == 0 ? 0 : (t0 - lastLuaTime));
|
||||
@@ -157,7 +156,8 @@ void perMain()
|
||||
maxLuaDuration = t0;
|
||||
}
|
||||
|
||||
if (!scriptWasRun) {
|
||||
if (!scriptWasRun)
|
||||
{
|
||||
#else
|
||||
lcdRefreshWait(); // WARNING: make sure no code above this line does any change to the LCD display buffer!
|
||||
{
|
||||
@@ -184,5 +184,11 @@ void perMain()
|
||||
}
|
||||
drawStatusLine();
|
||||
}
|
||||
|
||||
lcdRefresh();
|
||||
|
||||
#if defined(REV9E)
|
||||
topLcdRefresh();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -125,6 +125,11 @@ void boardInit()
|
||||
adcInit();
|
||||
delaysInit();
|
||||
lcdInit(); // delaysInit() must be called before
|
||||
|
||||
#if defined(REV9E)
|
||||
topLcdInit();
|
||||
#endif
|
||||
|
||||
audioInit();
|
||||
init2MhzTimer();
|
||||
init5msTimer();
|
||||
|
||||
@@ -314,6 +314,12 @@ int bt_open(void);
|
||||
int bt_write(const void *buffer, int len);
|
||||
int bt_read(void *buffer, int len);
|
||||
|
||||
// Top LCD driver
|
||||
#if defined(REV9E)
|
||||
void topLcdInit(void);
|
||||
void topLcdRefresh(void);
|
||||
#endif
|
||||
|
||||
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
|
||||
|
||||
#if defined(USB_JOYSTICK) && !defined(SIMU)
|
||||
|
||||
@@ -488,4 +488,24 @@
|
||||
#define PIN_HAPTIC GPIO_Pin_12
|
||||
#endif
|
||||
|
||||
// Top LCD on X9E
|
||||
#if defined(REV9E)
|
||||
#define GPIO_VA GPIOG
|
||||
#define PIN_VA_DATA GPIO_Pin_5
|
||||
#define PIN_VA_WR GPIO_Pin_4
|
||||
#define PIN_VA_CS GPIO_Pin_3
|
||||
#define PIN_VA_CS2 GPIO_Pin_15
|
||||
#define PIN_VA_BL GPIO_Pin_2
|
||||
#define RCC_AHB1Periph_VA RCC_AHB1Periph_GPIOG
|
||||
#define CS1_HIGH GPIO_VA->BSRRL = PIN_VA_CS
|
||||
#define CS1_LOW GPIO_VA->BSRRH = PIN_VA_CS
|
||||
#define CS2_HIGH GPIO_VA->BSRRL = PIN_VA_CS2
|
||||
#define CS2_LOW GPIO_VA->BSRRH = PIN_VA_CS2
|
||||
#define WR_HIGH GPIO_VA->BSRRL = PIN_VA_WR
|
||||
#define WR_LOW GPIO_VA->BSRRH = PIN_VA_WR
|
||||
#define DATA_HIGH GPIO_VA->BSRRL = PIN_VA_DATA
|
||||
#define DATA_LOW GPIO_VA->BSRRH = PIN_VA_DATA
|
||||
#define VA_BL_ON GPIO_VA->BSRRL = PIN_VA_BL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,10 +24,6 @@
|
||||
#define WAIT_FOR_DMA_END()
|
||||
#endif
|
||||
|
||||
#if defined(BOOT)
|
||||
extern void hw_delay(uint16_t time);
|
||||
#endif
|
||||
|
||||
bool lcdInitFinished = false;
|
||||
void lcdInitFinish();
|
||||
|
||||
|
||||
Executable
+163
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
uint8_t top_lcd_data[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
void delay1_7us()
|
||||
{
|
||||
delay_01us(17);
|
||||
}
|
||||
|
||||
void ht1621SendCommand(uint8_t chip, unsigned char command)
|
||||
{
|
||||
if (chip)
|
||||
CS2_LOW;
|
||||
else
|
||||
CS1_LOW;
|
||||
|
||||
delay1_7us();
|
||||
WR_LOW; //PRESENT 100 COMMAND CODE
|
||||
delay1_7us();
|
||||
DATA_HIGH;
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
delay1_7us();
|
||||
WR_LOW;
|
||||
delay1_7us();
|
||||
DATA_LOW;
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
delay1_7us();
|
||||
|
||||
WR_LOW;
|
||||
delay1_7us();
|
||||
DATA_LOW;
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
delay1_7us();
|
||||
|
||||
for (int i=0; i<8; i++) {
|
||||
WR_LOW;
|
||||
delay1_7us();
|
||||
if ((command & 0x80) !=0)
|
||||
{
|
||||
DATA_HIGH;
|
||||
delay1_7us();
|
||||
}
|
||||
else
|
||||
{
|
||||
DATA_LOW;
|
||||
delay1_7us();
|
||||
}
|
||||
WR_HIGH;
|
||||
delay1_7us();
|
||||
command = command << 1;
|
||||
}
|
||||
WR_LOW;
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
delay1_7us();
|
||||
|
||||
if (chip)
|
||||
CS2_HIGH;
|
||||
else
|
||||
CS1_HIGH;
|
||||
|
||||
delay1_7us();
|
||||
}
|
||||
|
||||
void ht1621WrData(uint8_t data, uint8_t count)
|
||||
{
|
||||
while (count) {
|
||||
WR_LOW;
|
||||
if (data & 0x80)
|
||||
DATA_HIGH;
|
||||
else
|
||||
DATA_LOW;
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
delay1_7us();
|
||||
data <<= 1;
|
||||
count -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ht1621WrAllData(uint8_t chip, uint8_t *pData)
|
||||
{
|
||||
if (chip)
|
||||
CS2_LOW;
|
||||
else
|
||||
CS1_LOW;
|
||||
delay1_7us();
|
||||
ht1621WrData(0xa0, 3);
|
||||
ht1621WrData(0, 6); // HT1621 6 bit,left 2 bit;
|
||||
for (int i=0; i<16; i++) {
|
||||
ht1621WrData(*pData++, 8);
|
||||
}
|
||||
if (chip)
|
||||
CS2_HIGH;
|
||||
else
|
||||
CS1_HIGH;
|
||||
delay1_7us();
|
||||
}
|
||||
|
||||
void topLcdInit()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_VA, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_VA_DATA | PIN_VA_WR |PIN_VA_BL|PIN_VA_CS|PIN_VA_CS2;
|
||||
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_UP;
|
||||
GPIO_Init(GPIO_VA, &GPIO_InitStructure);
|
||||
|
||||
VA_BL_ON;
|
||||
|
||||
ht1621SendCommand(0, 0x03);
|
||||
ht1621SendCommand(0, 0x01);
|
||||
ht1621SendCommand(0, 0x29);
|
||||
|
||||
ht1621SendCommand(1, 0x03);
|
||||
ht1621SendCommand(1, 0x01);
|
||||
ht1621SendCommand(1, 0x29);
|
||||
}
|
||||
|
||||
void topLcdRefresh()
|
||||
{
|
||||
ht1621WrAllData(0, top_lcd_data);
|
||||
ht1621WrAllData(1, top_lcd_data);
|
||||
}
|
||||
Reference in New Issue
Block a user