Bsongis/gui refactoring for x7 d (#3701)
* [X7D] New board added * Cosmetics
This commit is contained in:
@@ -10,7 +10,12 @@ set(TARGET_DIR 9x)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps)
|
||||
add_definitions(-DPCBSTD -DPCB${PCB} -DCPUM64)
|
||||
set(TARGET_SRC ${TARGET_SRC} board.cpp)
|
||||
set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC})
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
model_inputs_mixes.cpp
|
||||
radio_diagkeys.cpp
|
||||
radio_diaganas.cpp
|
||||
)
|
||||
if(SP22)
|
||||
add_definitions(-DSP22)
|
||||
endif()
|
||||
|
||||
@@ -199,14 +199,16 @@ void processMultiplexAna()
|
||||
#define AIL_STATE() (PINE & (1<<INP_E_AileDR))
|
||||
#endif
|
||||
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
uint8_t result = 0 ;
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
if (enuk < (int)DIM(keys))
|
||||
return keys[enuk].state();
|
||||
uint8_t switchState(uint8_t index)
|
||||
{
|
||||
uint8_t result = 0;
|
||||
|
||||
switch(enuk){
|
||||
switch (index) {
|
||||
case SW_ELE:
|
||||
result = PINE & (1<<INP_E_ElevDR);
|
||||
break;
|
||||
@@ -281,25 +283,25 @@ uint8_t trimDown(uint8_t idx)
|
||||
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t index = KEY_MENU;
|
||||
|
||||
// User buttons ...
|
||||
uint8_t in = ~PINB;
|
||||
for (int i=1; i<7; i++) {
|
||||
keys[enuk].input(in & (1<<i));
|
||||
++enuk;
|
||||
keys[index].input(in & (1<<i));
|
||||
++index;
|
||||
}
|
||||
|
||||
// Trims ...
|
||||
in = ~PIND;
|
||||
for (int i=0; i<8; i++) {
|
||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||
keys[enuk].input(trimHelper(in, i));
|
||||
++enuk;
|
||||
keys[index].input(trimHelper(in, i));
|
||||
++index;
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
keys[enuk].input(ROTENC_DOWN()); // Rotary Enc. Switch
|
||||
keys[index].input(ROTENC_DOWN()); // Rotary Enc. Switch
|
||||
#endif
|
||||
|
||||
#if defined(NAVIGATION_STICKS)
|
||||
|
||||
@@ -138,7 +138,7 @@ bool checkSlaveMode();
|
||||
#define JACK_PPM_OUT() PORTG &= ~(1<<OUT_G_SIM_CTL)
|
||||
#define JACK_PPM_IN() PORTG |= (1<<OUT_G_SIM_CTL)
|
||||
|
||||
// PWM Backlight driver
|
||||
// Backlight driver
|
||||
#define OUT_B_LIGHT 7
|
||||
#if defined(PWM_BACKLIGHT)
|
||||
void backlightEnable();
|
||||
@@ -154,6 +154,13 @@ bool checkSlaveMode();
|
||||
#define backlightDisable() PORTB &= ~(1<<OUT_B_LIGHT)
|
||||
#define isBacklightEnable() (PORTB & (1<<OUT_B_LIGHT))
|
||||
#endif
|
||||
#if defined(VOICE) && !defined(SIMU)
|
||||
#define BACKLIGHT_ENABLE() Voice.Backlight = 1
|
||||
#define BACKLIGHT_DISABLE() Voice.Backlight = 0
|
||||
#else
|
||||
#define BACKLIGHT_ENABLE() backlightEnable()
|
||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||
#endif
|
||||
|
||||
#define OUT_B_PPM 0
|
||||
#define INP_E_PPM_IN 7
|
||||
|
||||
@@ -22,7 +22,7 @@ void lcdSendCtl(uint8_t val)
|
||||
{
|
||||
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
|
||||
#if defined(LCD_MULTIPLEX)
|
||||
DDRA = 0xFF; //Set LCD_DAT pins to output
|
||||
DDRA = 0xFF; // Set LCD_DAT pins to output
|
||||
#endif
|
||||
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_A0);
|
||||
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
|
||||
@@ -31,7 +31,7 @@ void lcdSendCtl(uint8_t val)
|
||||
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
|
||||
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
|
||||
#if defined(LCD_MULTIPLEX)
|
||||
DDRA = 0x00; //Set LCD_DAT pins to input
|
||||
DDRA = 0x00; // Set LCD_DAT pins to input
|
||||
#endif
|
||||
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_CS1);
|
||||
}
|
||||
@@ -85,9 +85,9 @@ const static pm_uchar lcdInitSequence[] PROGMEM =
|
||||
void lcdInit()
|
||||
{
|
||||
LCD_LOCK();
|
||||
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES); //LCD reset
|
||||
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES); // LCD reset
|
||||
_delay_us(2);
|
||||
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); //LCD normal operation
|
||||
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); // LCD normal operation
|
||||
_delay_us(1500);
|
||||
for (uint8_t i=0; i<DIM(lcdInitSequence); i++) {
|
||||
lcdSendCtl(pgm_read_byte(&lcdInitSequence[i])) ;
|
||||
@@ -108,7 +108,6 @@ void lcdSetRefVolt(uint8_t val)
|
||||
LCD_UNLOCK();
|
||||
}
|
||||
|
||||
|
||||
void lcdRefresh()
|
||||
{
|
||||
LCD_LOCK();
|
||||
|
||||
@@ -72,9 +72,9 @@ if(MULTIMODULE)
|
||||
add_definitions(-DMULTIMODULE)
|
||||
set(SRC ${SRC} pulses/multi_arm.cpp telemetry/spektrum.cpp)
|
||||
endif()
|
||||
add_definitions(-DCPUARM)
|
||||
add_definitions(-DCPUARM -DVIRTUAL_INPUTS)
|
||||
add_definitions(-DTELEMETRY_FRSKY -DTELEMETRY_FRSKY_SPORT -DFRSKY_HUB -DGPS -DPXX -DDSM2)
|
||||
add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE)
|
||||
add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE -DGAUGES)
|
||||
include_directories(${COOS_DIR} ${COOS_DIR}/kernel ${COOS_DIR}/portable)
|
||||
foreach(LANGUAGE ${TTS_LANGUAGES})
|
||||
set(SRC ${SRC} translations/tts_${LANGUAGE}.cpp)
|
||||
@@ -104,8 +104,8 @@ set(TARGET_SRC
|
||||
adc_driver.cpp
|
||||
trainer_driver.cpp
|
||||
audio_driver.cpp
|
||||
serial2_driver.cpp
|
||||
telemetry_driver.cpp
|
||||
${SERIAL2_DRIVER}
|
||||
)
|
||||
set(FIRMWARE_SRC
|
||||
${FIRMWARE_SRC}
|
||||
|
||||
@@ -2,8 +2,7 @@ set(LUA "NO" CACHE STRING "Lua scripts (YES/NO/NO_MODEL_SCRIPTS)")
|
||||
set(USB "JOYSTICK" CACHE STRING "USB option (JOYSTICK/MASSSTORAGE/SERIAL)")
|
||||
set(ARCH ARM)
|
||||
set(STM32USB_DIR ${THIRDPARTY_DIR}/STM32_USB-Host-Device_Lib_V2.1.0/Libraries)
|
||||
add_definitions(-DCPUSTM32)
|
||||
add_definitions(-DSBUS -DCROSSFIRE)
|
||||
add_definitions(-DSTM32 -DLUA_INPUTS -DVARIO -DSBUS -DCROSSFIRE)
|
||||
include_directories(${RADIO_SRC_DIRECTORY}/targets/common/arm/stm32)
|
||||
include_directories(${STM32USB_DIR}/STM32_USB_OTG_Driver/inc)
|
||||
include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Core/inc)
|
||||
@@ -20,6 +19,7 @@ set(STM32USB_SRC
|
||||
)
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
../common/arm/stm32/delays.cpp
|
||||
../common/arm/stm32/usb_bsp.c
|
||||
../common/arm/stm32/usbd_desc.c
|
||||
../common/arm/stm32/usbd_usr.cpp
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <OsConfig.h>
|
||||
#include "board.h"
|
||||
#if !defined(PCBX9E)
|
||||
#if defined(STM32F2)
|
||||
#include "dwt.h" // the old ST library that we use does not define DWT register for STM32F2xx
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@ set(STM32LIB_DIR ${THIRDPARTY_DIR}/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries)
|
||||
include_directories(${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/inc)
|
||||
include_directories(${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Include)
|
||||
include_directories(${STM32LIB_DIR}/CMSIS/include)
|
||||
add_definitions(-DSTM32F2)
|
||||
set(STM32LIB_SRC
|
||||
${STM32LIB_SRC}
|
||||
CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
|
||||
// ADC driver
|
||||
#define NUM_POTS 3
|
||||
#define NUM_SLIDERS 0
|
||||
#define NUM_XPOTS 0
|
||||
enum Analogs {
|
||||
STICK1,
|
||||
STICK2,
|
||||
@@ -45,6 +48,75 @@ void adcPrepareBandgap();
|
||||
void getADC();
|
||||
void getADC_bandgap();
|
||||
|
||||
// Keys driver
|
||||
#define NUM_SWITCHES 7
|
||||
enum EnumKeys
|
||||
{
|
||||
KEY_MENU,
|
||||
KEY_ENTER=KEY_MENU,
|
||||
KEY_EXIT,
|
||||
KEY_DOWN,
|
||||
KEY_UP,
|
||||
KEY_RIGHT,
|
||||
KEY_LEFT,
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
TRM_LAST = TRM_RH_UP,
|
||||
|
||||
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
|
||||
BTN_REa,
|
||||
#endif
|
||||
#if ROTARY_ENCODERS > 0
|
||||
BTN_REb,
|
||||
#endif
|
||||
|
||||
NUM_KEYS
|
||||
};
|
||||
|
||||
enum EnumSwitches
|
||||
{
|
||||
SW_ID0,
|
||||
SW_ID1,
|
||||
SW_ID2,
|
||||
SW_THR,
|
||||
SW_RUD,
|
||||
SW_ELE,
|
||||
SW_AIL,
|
||||
SW_GEA,
|
||||
SW_TRN,
|
||||
};
|
||||
#define IS_3POS(sw) ((sw) == 0)
|
||||
#define IS_TOGGLE(sw) ((sw) == SWSRC_TRN)
|
||||
uint8_t keyState(uint8_t index);
|
||||
uint8_t switchState(uint8_t index);
|
||||
|
||||
// LCD driver
|
||||
#define LCD_W 128
|
||||
#define LCD_H 64
|
||||
#define LCD_DEPTH 1
|
||||
void lcdRefresh(void);
|
||||
#define lcdRefreshWait()
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
void lcdSetContrast(void);
|
||||
void lcdInit(void);
|
||||
#define lcdOff()
|
||||
|
||||
#if defined(LCD_KS108)
|
||||
void lcdRefreshSide();
|
||||
#endif
|
||||
|
||||
#if defined(LCD_ST7920)
|
||||
uint8_t lcdRefresh_ST7920(uint8_t full);
|
||||
#endif
|
||||
|
||||
// USART driver (static register dispatcher)
|
||||
#define RXD_DDR1 DDRD
|
||||
#define RXD_DDR_PIN1 DDD2
|
||||
|
||||
@@ -8,5 +8,10 @@ set(TARGET_DIR gruvin9x)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps)
|
||||
add_definitions(-DPCB${PCB} -DCPUM2560 -DROTARY_ENCODERS=2)
|
||||
set(TARGET_SRC ${TARGET_SRC} board.cpp)
|
||||
set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC})
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
model_inputs_mixes.cpp
|
||||
radio_diagkeys.cpp
|
||||
radio_diaganas.cpp
|
||||
)
|
||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/9x/lcd_driver.cpp)
|
||||
|
||||
@@ -168,14 +168,16 @@ uint8_t keyDown()
|
||||
return ((~PINL) & 0x3F) || ROTENC_DOWN();
|
||||
}
|
||||
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
uint8_t result = 0 ;
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
if (enuk < (int)DIM(keys))
|
||||
return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
switch(enuk){
|
||||
uint8_t switchState(uint8_t index)
|
||||
{
|
||||
uint8_t result;
|
||||
|
||||
switch (index) {
|
||||
case SW_ELE:
|
||||
result = PINC & (1<<INP_C_ElevDR);
|
||||
break;
|
||||
@@ -241,7 +243,7 @@ uint8_t trimDown(uint8_t idx)
|
||||
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t index = KEY_MENU;
|
||||
|
||||
// User buttons ...
|
||||
uint8_t tin = ~PINL;
|
||||
@@ -249,16 +251,16 @@ void readKeysAndTrims()
|
||||
in = (tin & 0x0f) << 3;
|
||||
in |= (tin & 0x30) >> 3;
|
||||
for (int i=1; i<7; i++) {
|
||||
keys[enuk].input(in & (1<<i));
|
||||
++enuk;
|
||||
keys[index].input(in & (1<<i));
|
||||
++index;
|
||||
}
|
||||
|
||||
// Trims ...
|
||||
in = ~PINJ;
|
||||
for (int i=0; i<8; i++) {
|
||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i));
|
||||
++enuk;
|
||||
keys[index].input(in & pgm_read_byte(crossTrim+i));
|
||||
++index;
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
|
||||
@@ -87,10 +87,12 @@ void sdPoll10ms();
|
||||
#define speakerOff() TCCR0A &= ~(1 << COM0A0)
|
||||
|
||||
// Backlight driver
|
||||
#define OUT_C_LIGHT 0
|
||||
#define backlightEnable() PORTC |= (1<<OUT_C_LIGHT)
|
||||
#define backlightDisable() PORTC &= ~(1<<OUT_C_LIGHT)
|
||||
#define isBacklightEnable() (PORTC & (1<<OUT_C_LIGHT))
|
||||
#define OUT_C_LIGHT 0
|
||||
#define backlightEnable() PORTC |= (1<<OUT_C_LIGHT)
|
||||
#define backlightDisable() PORTC &= ~(1<<OUT_C_LIGHT)
|
||||
#define isBacklightEnable() (PORTC & (1<<OUT_C_LIGHT))
|
||||
#define BACKLIGHT_ENABLE() backlightEnable()
|
||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||
|
||||
#define INP_E_PPM_IN 7
|
||||
#define INP_E_ROT_ENC_1_B 6
|
||||
|
||||
@@ -9,12 +9,10 @@ set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps)
|
||||
set(LUA_EXPORT lua_export_horus)
|
||||
set(FLAVOUR horus)
|
||||
set(VIRTUAL_INPUTS YES)
|
||||
set(RAMBACKUP YES)
|
||||
option(DISK_CACHE "Enable SD card disk cache" YES)
|
||||
add_definitions(-DPCBHORUS -DCOLORLCD -DSTM32F429_439xx -DSDRAM -DPPM_PIN_UART -DPPM_PIN_TIMER)
|
||||
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
||||
add_definitions(-DLUAINPUTS -DXCURVES -DVARIO)
|
||||
include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
||||
file(GLOB THEMES_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.cpp)
|
||||
file(GLOB LAYOUTS_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.cpp)
|
||||
@@ -27,6 +25,7 @@ set(GUI_SRC
|
||||
radio_hardware.cpp
|
||||
model_inputs.cpp
|
||||
model_mixes.cpp
|
||||
model_curves.cpp
|
||||
view_channels.cpp
|
||||
view_logical_switches.cpp
|
||||
view_about.cpp
|
||||
@@ -40,13 +39,18 @@ set(GUI_SRC
|
||||
${LAYOUTS_SRC}
|
||||
${WIDGETS_SRC}
|
||||
)
|
||||
if(HELI)
|
||||
set(GUI_SRC ${GUI_SRC} model_heli.cpp)
|
||||
endif()
|
||||
if(DISK_CACHE)
|
||||
set(SRC ${SRC} disk_cache.cpp)
|
||||
add_definitions(-DDISK_CACHE)
|
||||
endif()
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
board.cpp
|
||||
led_driver.cpp
|
||||
extmodule_driver.cpp
|
||||
../common/arm/stm32/rtc_driver.cpp
|
||||
)
|
||||
@@ -54,10 +58,8 @@ set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
sdio_sd.c
|
||||
lcd_driver.cpp
|
||||
delays.c
|
||||
pwr_driver.cpp
|
||||
sdram_driver.c
|
||||
led_driver.cpp
|
||||
startup_stm32f40_41xxx.s
|
||||
)
|
||||
set(STM32LIB_SRC
|
||||
@@ -69,6 +71,6 @@ set(STM32LIB_SRC
|
||||
)
|
||||
add_custom_target(datacopy
|
||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DVIRTUALINPUTS -DBACKUP > storage/datacopy.cpp
|
||||
COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DCPUARM -DBACKUP > storage/datacopy.cpp
|
||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||
)
|
||||
|
||||
@@ -172,7 +172,7 @@ void boardInit()
|
||||
|
||||
void boardOff()
|
||||
{
|
||||
BACKLIGHT_OFF();
|
||||
BACKLIGHT_DISABLE();
|
||||
|
||||
while (pwrPressed()) {
|
||||
wdt_reset();
|
||||
|
||||
@@ -77,7 +77,7 @@ extern "C" {
|
||||
extern uint16_t sessionTimer;
|
||||
|
||||
#define SLAVE_MODE() (g_model.trainerMode == TRAINER_MODE_SLAVE)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_GPIO_DETECT, TRAINER_GPIO_PIN_DETECT) == Bit_RESET)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_DETECT_GPIO, TRAINER_DETECT_GPIO_PIN) == Bit_RESET)
|
||||
|
||||
// Board driver
|
||||
void boardInit(void);
|
||||
@@ -118,6 +118,7 @@ uint32_t sdMounted(void);
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#define sdInit()
|
||||
#define sdMount()
|
||||
#define sdDone()
|
||||
#define SD_CARD_PRESENT() true
|
||||
#endif
|
||||
@@ -168,7 +169,82 @@ void init_trainer_capture(void);
|
||||
void stop_trainer_capture(void);
|
||||
|
||||
// Keys driver
|
||||
#define NUM_SWITCHES 8
|
||||
enum EnumKeys
|
||||
{
|
||||
KEY_PGUP,
|
||||
KEY_PGDN,
|
||||
KEY_ENTER,
|
||||
KEY_MODEL,
|
||||
KEY_UP = KEY_MODEL,
|
||||
KEY_EXIT,
|
||||
KEY_DOWN = KEY_EXIT,
|
||||
KEY_TELEM,
|
||||
KEY_RIGHT = KEY_TELEM,
|
||||
KEY_RADIO,
|
||||
KEY_LEFT = KEY_RADIO,
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
TRM_LS_DWN,
|
||||
TRM_LS_UP,
|
||||
TRM_RS_DWN,
|
||||
TRM_RS_UP,
|
||||
TRM_LAST = TRM_RS_UP,
|
||||
|
||||
NUM_KEYS
|
||||
};
|
||||
|
||||
enum EnumSwitches
|
||||
{
|
||||
SW_SA,
|
||||
SW_SB,
|
||||
SW_SC,
|
||||
SW_SD,
|
||||
SW_SE,
|
||||
SW_SF,
|
||||
SW_SG,
|
||||
SW_SH
|
||||
};
|
||||
#define IS_3POS(x) ((x) != SW_SF && (x) != SW_SH)
|
||||
|
||||
enum EnumSwitchesPositions
|
||||
{
|
||||
SW_SA0,
|
||||
SW_SA1,
|
||||
SW_SA2,
|
||||
SW_SB0,
|
||||
SW_SB1,
|
||||
SW_SB2,
|
||||
SW_SC0,
|
||||
SW_SC1,
|
||||
SW_SC2,
|
||||
SW_SD0,
|
||||
SW_SD1,
|
||||
SW_SD2,
|
||||
SW_SE0,
|
||||
SW_SE1,
|
||||
SW_SE2,
|
||||
SW_SF0,
|
||||
SW_SF1,
|
||||
SW_SF2,
|
||||
SW_SG0,
|
||||
SW_SG1,
|
||||
SW_SG2,
|
||||
SW_SH0,
|
||||
SW_SH1,
|
||||
SW_SH2,
|
||||
};
|
||||
void keysInit(void);
|
||||
uint8_t keyState(uint8_t index);
|
||||
uint32_t switchState(uint8_t index);
|
||||
uint32_t readKeys(void);
|
||||
uint32_t readTrims(void);
|
||||
#define TRIMS_PRESSED() (readTrims())
|
||||
@@ -200,15 +276,19 @@ void watchdogInit(unsigned int duration);
|
||||
#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_SFTRSTF))
|
||||
|
||||
// ADC driver
|
||||
#define NUM_POTS 3
|
||||
#define NUM_SLIDERS 4
|
||||
#define NUM_XPOTS 3
|
||||
enum Analogs {
|
||||
STICK1,
|
||||
STICK2,
|
||||
STICK3,
|
||||
STICK4,
|
||||
POT1,
|
||||
POT_FIRST,
|
||||
POT1 = POT_FIRST,
|
||||
POT2,
|
||||
POT3,
|
||||
POT_LAST=POT3,
|
||||
POT_LAST = POT3,
|
||||
SLIDER1,
|
||||
SLIDER2,
|
||||
SLIDER3,
|
||||
@@ -218,6 +298,8 @@ enum Analogs {
|
||||
MOUSE2,
|
||||
NUMBER_ANALOG
|
||||
};
|
||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
||||
#define IS_SLIDER(x) ((x)>=SLIDER1 && (x)<=SLIDER4)
|
||||
extern uint16_t adcValues[NUMBER_ANALOG];
|
||||
void adcInit(void);
|
||||
void adcRead(void);
|
||||
@@ -245,6 +327,9 @@ void ledRed(void);
|
||||
void ledBlue(void);
|
||||
|
||||
// LCD driver
|
||||
#define LCD_W 480
|
||||
#define LCD_H 272
|
||||
#define LCD_DEPTH 16
|
||||
void lcdInit(void);
|
||||
void lcdRefresh(void);
|
||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
||||
@@ -253,12 +338,19 @@ void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y,
|
||||
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
||||
void lcdStoreBackupBuffer(void);
|
||||
int lcdRestoreBackupBuffer(void);
|
||||
void LCD_ControlLight(uint16_t dutyCycle);
|
||||
void lcdSetContrast();
|
||||
#define lcdOff(...)
|
||||
#define lcdSetRefVolt(...)
|
||||
#define lcdRefreshWait(...)
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx) LCD_ControlLight(xx)
|
||||
#define backlightEnable() setBacklight(UNEXPECTED_SHUTDOWN() ? 100 : 100-g_eeGeneral.backlightBright)
|
||||
#define backlightDisable() setBacklight(g_eeGeneral.blOffBright)
|
||||
#if defined(SIMU)
|
||||
#define backlightEnable(...)
|
||||
#else
|
||||
void backlightEnable(uint8_t dutyCycle);
|
||||
#endif
|
||||
#define BACKLIGHT_ENABLE() backlightEnable(UNEXPECTED_SHUTDOWN() ? 100 : 100-g_eeGeneral.backlightBright)
|
||||
#define BACKLIGHT_DISABLE() backlightEnable(UNEXPECTED_SHUTDOWN() ? 100 : g_eeGeneral.blOffBright)
|
||||
#define isBacklightEnable() true
|
||||
|
||||
// USB driver
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <OsConfig.h>
|
||||
#include "board.h"
|
||||
|
||||
#define SYSTEM_TICKS_1US ((CFG_CPU_FREQ + 500000) / 1000000) // number of system ticks in 1us
|
||||
#define SYSTEM_TICKS_01US ((CFG_CPU_FREQ + 5000000) / 10000000) // number of system ticks in 0.1us (rounding needed for sys frequencies that are not multiple of 10MHz)
|
||||
|
||||
void delaysInit(void)
|
||||
{
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
DWT->CYCCNT = 0;
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
}
|
||||
|
||||
void delay_01us(uint16_t nb)
|
||||
{
|
||||
volatile uint32_t dwtStart = DWT->CYCCNT;
|
||||
volatile uint32_t dwtTotal = (SYSTEM_TICKS_01US * nb) - 10;
|
||||
while((DWT->CYCCNT - dwtStart) < dwtTotal);
|
||||
}
|
||||
|
||||
void delay_us(uint16_t nb)
|
||||
{
|
||||
volatile uint32_t dwtStart = DWT->CYCCNT;
|
||||
volatile uint32_t dwtTotal = (SYSTEM_TICKS_1US * nb) - 10;
|
||||
while((DWT->CYCCNT - dwtStart) < dwtTotal);
|
||||
}
|
||||
|
||||
void delay_ms(uint32_t ms)
|
||||
{
|
||||
while(ms--) {
|
||||
delay_us(1000);
|
||||
}
|
||||
}
|
||||
@@ -312,12 +312,12 @@
|
||||
#define TRAINER_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA1)
|
||||
#define TRAINER_RCC_APB1Periph RCC_APB1Periph_TIM3
|
||||
#define TRAINER_GPIO GPIOC
|
||||
#define TRAINER_GPIO_PIN_IN GPIO_Pin_6 // PC.06
|
||||
#define TRAINER_GPIO_PinSource_IN GPIO_PinSource6
|
||||
#define TRAINER_GPIO_PIN_OUT GPIO_Pin_7 // PC.07
|
||||
#define TRAINER_GPIO_PinSource_OUT GPIO_PinSource7
|
||||
#define TRAINER_GPIO_DETECT GPIOB
|
||||
#define TRAINER_GPIO_PIN_DETECT GPIO_Pin_4 // PB.04
|
||||
#define TRAINER_IN_GPIO_PIN GPIO_Pin_6 // PC.06
|
||||
#define TRAINER_IN_GPIO_PinSource GPIO_PinSource6
|
||||
#define TRAINER_OUT_GPIO_PIN GPIO_Pin_7 // PC.07
|
||||
#define TRAINER_OUT_GPIO_PinSource GPIO_PinSource7
|
||||
#define TRAINER_DETECT_GPIO GPIOB
|
||||
#define TRAINER_DETECT_GPIO_PIN GPIO_Pin_4 // PB.04
|
||||
#define TRAINER_TIMER TIM3
|
||||
#define TRAINER_TIMER_IRQn TIM3_IRQn
|
||||
#define TRAINER_TIMER_IRQHandler TIM3_IRQHandler
|
||||
|
||||
@@ -115,10 +115,10 @@ void readKeysAndTrims()
|
||||
{
|
||||
register uint32_t i;
|
||||
|
||||
uint8_t enuk = 0;
|
||||
uint8_t index = 0;
|
||||
uint32_t in = readKeys();
|
||||
for (i = 0; i < TRM_BASE; i++) {
|
||||
keys[enuk++].input(in & (1 << i));
|
||||
keys[index++].input(in & (1 << i));
|
||||
}
|
||||
|
||||
static rotenc_t rePreviousValue;
|
||||
@@ -145,7 +145,7 @@ void readKeysAndTrims()
|
||||
|
||||
in = readTrims();
|
||||
for (i = 1; i < 4096; i <<= 1) {
|
||||
keys[enuk++].input(in & i);
|
||||
keys[index++].input(in & i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,13 +181,16 @@ void readKeysAndTrims()
|
||||
break
|
||||
|
||||
#if !defined(BOOT)
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
uint32_t switchState(uint8_t index)
|
||||
{
|
||||
register uint32_t xxx = 0;
|
||||
|
||||
if (enuk < (int) DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
switch ((uint8_t) enuk) {
|
||||
|
||||
switch (index) {
|
||||
ADD_3POS_CASE(A, 0);
|
||||
ADD_3POS_CASE(B, 1);
|
||||
ADD_3POS_CASE(C, 2);
|
||||
@@ -200,7 +203,7 @@ bool switchState(EnumKeys enuk)
|
||||
break;
|
||||
}
|
||||
|
||||
// TRACE("switch %d => %d", enuk, xxx);
|
||||
// TRACE("switch %d => %d", index, xxx);
|
||||
return xxx;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -318,9 +318,9 @@ void LCD_LayerInit()
|
||||
LTDC_DitherCmd(ENABLE);
|
||||
}
|
||||
|
||||
void LCD_ControlLight(uint16_t dutyCycle)
|
||||
void backlightEnable(uint8_t dutyCycle)
|
||||
{
|
||||
static uint16_t existingDutyCycle;
|
||||
static uint8_t existingDutyCycle;
|
||||
|
||||
if (dutyCycle == existingDutyCycle || dutyCycle < 5) {
|
||||
return;
|
||||
@@ -374,11 +374,12 @@ void LCD_Init(void)
|
||||
|
||||
LCD_Init_LTDC();
|
||||
|
||||
//config backlight
|
||||
// TODO split backlight from LCD
|
||||
// Config backlight
|
||||
LCD_Backlight_Config();
|
||||
|
||||
//Max Value
|
||||
LCD_ControlLight(100);
|
||||
// Max Value
|
||||
backlightEnable(100);
|
||||
}
|
||||
|
||||
BitmapBuffer lcdBuffer1(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)LCD_FIRST_FRAME_BUFFER);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "opentx.h"
|
||||
|
||||
void ledOn()
|
||||
{
|
||||
|
||||
@@ -24,10 +24,10 @@ void trainerSendNextFrame();
|
||||
|
||||
void init_trainer_ppm()
|
||||
{
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_GPIO_PinSource_OUT, TRAINER_GPIO_AF);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_OUT_GPIO_PinSource, TRAINER_GPIO_AF);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_OUT;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_OUT_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
@@ -69,13 +69,13 @@ void init_trainer_capture()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_IN;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_IN_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(TRAINER_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_GPIO_PinSource_IN, TRAINER_GPIO_AF);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_IN_GPIO_PinSource, TRAINER_GPIO_AF);
|
||||
|
||||
TRAINER_TIMER->ARR = 0xFFFF;
|
||||
TRAINER_TIMER->PSC = TRAINER_TIMER_FREQ / 2000000 - 1; // 0.5uS
|
||||
|
||||
@@ -10,7 +10,12 @@ set(TARGET_DIR mega2560)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps)
|
||||
add_definitions(-DPCB${PCB} -DCPUM2560 -DROTARY_ENCODERS=2)
|
||||
set(TARGET_SRC ${TARGET_SRC} board.cpp)
|
||||
set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC})
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
model_inputs_mixes.cpp
|
||||
radio_diagkeys.cpp
|
||||
radio_diaganas.cpp
|
||||
)
|
||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/9x/lcd_driver.cpp)
|
||||
if(PWRMANAGE)
|
||||
add_definitions(-DPWRMANAGE)
|
||||
|
||||
@@ -94,14 +94,16 @@ uint8_t keyDown()
|
||||
return ((~PINL) & 0x3F) || ROTENC_DOWN();
|
||||
}
|
||||
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
uint8_t result = 0 ;
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
if (enuk < (int)DIM(keys))
|
||||
return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
switch(enuk){
|
||||
uint8_t switchState(uint8_t index)
|
||||
{
|
||||
uint8_t result = 0;
|
||||
|
||||
switch (index) {
|
||||
case SW_ELE:
|
||||
result = !(PINL & (1<<INP_L_ElevDR));
|
||||
break;
|
||||
@@ -169,7 +171,7 @@ uint8_t trimDown(uint8_t idx)
|
||||
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t index = KEY_MENU;
|
||||
|
||||
keys[BTN_REa].input(~PINJ & 0x01);
|
||||
keys[BTN_REb].input(~PINJ & 0x02);
|
||||
@@ -180,16 +182,16 @@ void readKeysAndTrims()
|
||||
in |= (tin & 0x30) >> 3;
|
||||
|
||||
for (int i=1; i<7; i++) {
|
||||
keys[enuk].input(in & (1<<i));
|
||||
++enuk;
|
||||
keys[index].input(in & (1<<i));
|
||||
++index;
|
||||
}
|
||||
|
||||
// Trims
|
||||
in = ~PINF;
|
||||
for (int i=0; i<8; i++) {
|
||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i));
|
||||
++enuk;
|
||||
keys[index].input(in & pgm_read_byte(crossTrim+i));
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ void boardInit(void);
|
||||
#define backlightEnable() PORTC |= (1<<OUT_C_LIGHT)
|
||||
#define backlightDisable() PORTC &= ~(1<<OUT_C_LIGHT)
|
||||
#define isBacklightEnable() PORTC & (1<<OUT_C_LIGHT)
|
||||
#define BACKLIGHT_ENABLE() backlightEnable()
|
||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||
|
||||
// SD driver
|
||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||
@@ -143,7 +145,7 @@ void sdPoll10ms(void);
|
||||
#define OUT_C_LCD_A0 5
|
||||
#define OUT_C_LCD_RES 4
|
||||
#define OUT_C_LCD_CS1 3
|
||||
#define OUT_C_LIGHT 2
|
||||
#define OUT_C_LIGHT 2
|
||||
|
||||
// DBLKeys driver
|
||||
#define KEYS_PRESSED() (~PINL)
|
||||
|
||||
@@ -51,10 +51,10 @@ endif()
|
||||
if((NOT WIN32) AND FOX_FOUND)
|
||||
if(SIMU_DISKIO)
|
||||
add_definitions(-DSIMU_DISKIO)
|
||||
set(SIMU_SRC ${SIMU_SRC} ../../thirdparty/FatFs/ff.c ../../thirdparty/FatFs/option/ccsbcs.c)
|
||||
set(SIMU_SRC ${SIMU_SRC} ${FATFS_DIR}/FatFs/ff.c ${FATFS_DIR}/option/ccsbcs.c)
|
||||
endif()
|
||||
|
||||
add_executable(simu WIN32 ${SIMU_SRC} ../../simu.cpp)
|
||||
add_executable(simu WIN32 ${SIMU_SRC} ${RADIO_SRC_DIRECTORY}/simu.cpp)
|
||||
add_dependencies(simu ${FIRMWARE_DEPENDENCIES})
|
||||
target_include_directories(simu PUBLIC ${FOX_INCLUDE_DIR} )
|
||||
target_link_libraries(simu ${FOX_LIBRARY} pthread ${SDL_LIBRARY})
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "opentx.h"
|
||||
#include "simulcd.h"
|
||||
|
||||
int16_t g_anas[NUM_STICKS+NUM_POTS];
|
||||
int16_t g_anas[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
|
||||
|
||||
uint16_t anaIn(uint8_t chan)
|
||||
{
|
||||
@@ -200,7 +200,7 @@ void OpenTxSimulator::sendTelemetry(uint8_t * data, unsigned int len)
|
||||
uint8_t OpenTxSimulator::getSensorInstance(uint16_t id, uint8_t defaultValue)
|
||||
{
|
||||
#if defined(TELEMETRY_FRSKY_SPORT)
|
||||
for (int i = 0; i<MAX_SENSORS; i++) {
|
||||
for (int i = 0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
if (isTelemetryFieldAvailable(i)) {
|
||||
TelemetrySensor * sensor = &g_model.telemetrySensors[i];
|
||||
if (sensor->id == id) {
|
||||
@@ -215,7 +215,7 @@ uint8_t OpenTxSimulator::getSensorInstance(uint16_t id, uint8_t defaultValue)
|
||||
uint16_t OpenTxSimulator::getSensorRatio(uint16_t id)
|
||||
{
|
||||
#if defined(TELEMETRY_FRSKY_SPORT)
|
||||
for (int i = 0; i<MAX_SENSORS; i++) {
|
||||
for (int i = 0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
if (isTelemetryFieldAvailable(i)) {
|
||||
TelemetrySensor * sensor = &g_model.telemetrySensors[i];
|
||||
if (sensor->id == id) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -52,7 +53,7 @@ pthread_t main_thread_pid;
|
||||
uint8_t main_thread_running = 0;
|
||||
char * main_thread_error = NULL;
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
#if defined(STM32)
|
||||
uint32_t Peri1_frequency, Peri2_frequency;
|
||||
GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj;
|
||||
TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10;
|
||||
@@ -120,7 +121,7 @@ uint16_t getTmr2MHz()
|
||||
|
||||
void simuInit()
|
||||
{
|
||||
#if defined(CPUSTM32)
|
||||
#if defined(STM32)
|
||||
RCC->CSR = 0;
|
||||
#endif
|
||||
|
||||
@@ -169,7 +170,8 @@ void simuInit()
|
||||
|
||||
void simuSetKey(uint8_t key, bool state)
|
||||
{
|
||||
// TRACE("simuSetKey(%d, %d)", key, state);
|
||||
// if (state) TRACE("simuSetKey(%d, %d)", key, state);
|
||||
|
||||
switch (key) {
|
||||
#if !defined(PCBHORUS)
|
||||
KEY_CASE(KEY_MENU, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
||||
@@ -230,6 +232,7 @@ void simuSetTrim(uint8_t trim, bool state)
|
||||
void simuSetSwitch(uint8_t swtch, int8_t state)
|
||||
{
|
||||
// TRACE("simuSetSwitch(%d, %d)", swtch, state);
|
||||
|
||||
switch (swtch) {
|
||||
#if defined(PCBFLAMENCO)
|
||||
// SWITCH_3_CASE(0, SWITCHES_GPIO_REG_A_L, SWITCHES_GPIO_REG_A_H, SWITCHES_GPIO_PIN_A_L, SWITCHES_GPIO_PIN_A_H)
|
||||
@@ -243,11 +246,15 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
||||
SWITCH_3_CASE(1, SWITCHES_GPIO_REG_B_L, SWITCHES_GPIO_REG_B_H, SWITCHES_GPIO_PIN_B_L, SWITCHES_GPIO_PIN_B_H)
|
||||
SWITCH_3_CASE(2, SWITCHES_GPIO_REG_C_L, SWITCHES_GPIO_REG_C_H, SWITCHES_GPIO_PIN_C_L, SWITCHES_GPIO_PIN_C_H)
|
||||
SWITCH_3_CASE(3, SWITCHES_GPIO_REG_D_L, SWITCHES_GPIO_REG_D_H, SWITCHES_GPIO_PIN_D_L, SWITCHES_GPIO_PIN_D_H)
|
||||
#if !defined(PCBX7D)
|
||||
SWITCH_3_CASE(4, SWITCHES_GPIO_REG_E_L, SWITCHES_GPIO_REG_E_H, SWITCHES_GPIO_PIN_E_L, SWITCHES_GPIO_PIN_E_H)
|
||||
#endif
|
||||
SWITCH_CASE(5, SWITCHES_GPIO_REG_F, SWITCHES_GPIO_PIN_F)
|
||||
#if !defined(PCBX7D)
|
||||
SWITCH_3_CASE(6, SWITCHES_GPIO_REG_G_L, SWITCHES_GPIO_REG_G_H, SWITCHES_GPIO_PIN_G_L, SWITCHES_GPIO_PIN_G_H)
|
||||
#endif
|
||||
SWITCH_CASE(7, SWITCHES_GPIO_REG_H, SWITCHES_GPIO_PIN_H)
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E)
|
||||
SWITCH_3_CASE(8, SWITCHES_GPIO_REG_I_L, SWITCHES_GPIO_REG_I_H, SWITCHES_GPIO_PIN_I_L, SWITCHES_GPIO_PIN_I_H)
|
||||
SWITCH_3_CASE(9, SWITCHES_GPIO_REG_J_L, SWITCHES_GPIO_REG_J_H, SWITCHES_GPIO_PIN_J_L, SWITCHES_GPIO_PIN_J_H)
|
||||
SWITCH_3_CASE(10, SWITCHES_GPIO_REG_K_L, SWITCHES_GPIO_REG_K_H, SWITCHES_GPIO_PIN_K_L, SWITCHES_GPIO_PIN_K_H)
|
||||
@@ -258,7 +265,7 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
||||
SWITCH_3_CASE(15, SWITCHES_GPIO_REG_P_L, SWITCHES_GPIO_REG_P_H, SWITCHES_GPIO_PIN_P_L, SWITCHES_GPIO_PIN_P_H)
|
||||
SWITCH_3_CASE(16, SWITCHES_GPIO_REG_Q_L, SWITCHES_GPIO_REG_Q_H, SWITCHES_GPIO_PIN_Q_L, SWITCHES_GPIO_PIN_Q_H)
|
||||
SWITCH_3_CASE(17, SWITCHES_GPIO_REG_R_L, SWITCHES_GPIO_REG_R_H, SWITCHES_GPIO_PIN_R_L, SWITCHES_GPIO_PIN_R_H)
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(PCBSKY9X)
|
||||
SWITCH_CASE(0, PIOC->PIO_PDSR, 1<<20)
|
||||
SWITCH_CASE(1, PIOA->PIO_PDSR, 1<<15)
|
||||
@@ -1315,7 +1322,7 @@ uint32_t pwrCheck() { return true; }
|
||||
void pwrOff() { }
|
||||
#endif
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
#if defined(STM32)
|
||||
void pwrInit() { }
|
||||
int usbPlugged() { return false; }
|
||||
void USART_DeInit(USART_TypeDef* ) { }
|
||||
@@ -1376,21 +1383,7 @@ void unlockFlash() { }
|
||||
void lockFlash() { }
|
||||
void writeFlash(uint32_t *address, uint32_t *buffer) { SIMU_SLEEP(100); }
|
||||
uint32_t isBootloaderStart(const void *block) { return 1; }
|
||||
#if defined(PCBX9DP) || defined(PCBX9E)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
{
|
||||
TIM4->CCR4 = (100-level)*color;
|
||||
TIM4->CCR2 = (100-level)*(100-color);
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
{
|
||||
TIM4->CCR4 = 0;
|
||||
TIM4->CCR2 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // #if defined(PCBTARANIS)
|
||||
#endif // defined(PCBTARANIS)
|
||||
|
||||
#if defined(PCBFLAMENCO)
|
||||
void i2cWriteTW8823(unsigned char, unsigned char) { }
|
||||
|
||||
@@ -86,7 +86,7 @@ typedef const uint8_t pm_uint8_t;
|
||||
typedef const int16_t pm_int16_t;
|
||||
typedef const int8_t pm_int8_t;
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
#if defined(STM32)
|
||||
extern GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj;
|
||||
extern TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10;
|
||||
extern USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
|
||||
@@ -349,6 +349,7 @@ extern uint32_t Master_frequency;
|
||||
#define NVIC_EnableIRQ(x)
|
||||
#define NVIC_DisableIRQ(x)
|
||||
#define NVIC_SetPriority(...)
|
||||
#define NVIC_SystemReset() exit(0)
|
||||
#define __disable_irq()
|
||||
#define __enable_irq()
|
||||
#endif
|
||||
@@ -442,7 +443,7 @@ OS_TID CoCreateTask(FUNCPtr task, void *argv, uint32_t parameter, void * stk, ui
|
||||
#define UART3_Stop(...)
|
||||
#define USART_GetITStatus(...) 0
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
#if defined(STM32)
|
||||
inline void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { }
|
||||
#define TIM_DeInit(...)
|
||||
#define TIM_SetCompare2(...)
|
||||
@@ -484,9 +485,7 @@ extern char simuSdDirectory[1024];
|
||||
#define sdPoll10ms()
|
||||
#define sd_card_ready() (true)
|
||||
#if !defined(SIMU_DISKIO)
|
||||
#define sdMounted() (true)
|
||||
#define sdMounted() (true)
|
||||
#endif
|
||||
|
||||
inline void ledOff() { }
|
||||
|
||||
#endif // _SIMPGMSPACE_H_
|
||||
|
||||
@@ -31,6 +31,7 @@ else()
|
||||
set(LINKER_SCRIPT targets/sky9x/sam3s4c_flash.ld)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(MCU cortex-m3)
|
||||
set(SDCARD YES)
|
||||
set(HAPTIC YES)
|
||||
@@ -38,11 +39,26 @@ set(EEPROM EEPROM_RAW)
|
||||
set(GUI_DIR 128x64)
|
||||
set(TARGET_DIR sky9x)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps)
|
||||
|
||||
add_definitions(-DPCBSKY9X -DPPM_PIN_SERIAL)
|
||||
add_definitions(-DAUDIO -DVOICE -DRTCLOCK -DVARIO)
|
||||
add_definitions(-DEEPROM_VARIANT=0)
|
||||
set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC} radio_hardware.cpp view_telemetry.cpp view_text.cpp view_about.cpp)
|
||||
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
model_inputs.cpp
|
||||
model_mixes.cpp
|
||||
model_display.cpp
|
||||
radio_diagkeys.cpp
|
||||
radio_diaganas.cpp
|
||||
radio_hardware.cpp
|
||||
view_telemetry.cpp
|
||||
view_text.cpp
|
||||
view_about.cpp
|
||||
)
|
||||
|
||||
set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} core_cm3.c board_lowlevel.c crt.c vectors_sam3s.c)
|
||||
|
||||
set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp pwr_driver.cpp
|
||||
usb/device/core/USBD_UDP.c usb/device/core/USBDDriver.c
|
||||
usb/device/massstorage/MSDDriver.c usb/device/massstorage/MSDDStateMachine.c usb/device/massstorage/MSDLun.c
|
||||
@@ -51,11 +67,11 @@ set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp pwr_driver.cpp
|
||||
usb/common/core/USBGetDescriptorRequest.c usb/common/core/USBSetAddressRequest.c usb/common/core/USBSetConfigurationRequest.c
|
||||
usb/common/core/USBConfigurationDescriptor.c usb/common/core/USBGenericDescriptor.c MEDSdcard.c
|
||||
)
|
||||
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
board.cpp
|
||||
telemetry_driver.cpp
|
||||
serial2_driver.cpp
|
||||
adc_driver.cpp
|
||||
eeprom_driver.cpp
|
||||
pulses_driver.cpp
|
||||
@@ -66,5 +82,7 @@ set(TARGET_SRC
|
||||
sdcard_driver.cpp
|
||||
massstorage.cpp
|
||||
)
|
||||
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
set(SRC ${SRC} debug.cpp)
|
||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} loadboot.cpp)
|
||||
|
||||
@@ -35,7 +35,54 @@ extern uint16_t ResetReason;
|
||||
void boardInit(void);
|
||||
#define boardOff() pwrOff()
|
||||
|
||||
// Keys
|
||||
// Keys driver
|
||||
#define NUM_SWITCHES 7
|
||||
enum EnumKeys
|
||||
{
|
||||
KEY_MENU,
|
||||
KEY_ENTER=KEY_MENU,
|
||||
KEY_EXIT,
|
||||
KEY_DOWN,
|
||||
KEY_UP,
|
||||
KEY_RIGHT,
|
||||
KEY_LEFT,
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
TRM_LAST = TRM_RH_UP,
|
||||
|
||||
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
|
||||
BTN_REa,
|
||||
#endif
|
||||
#if ROTARY_ENCODERS > 0
|
||||
BTN_REb,
|
||||
#endif
|
||||
|
||||
NUM_KEYS
|
||||
};
|
||||
|
||||
enum EnumSwitches
|
||||
{
|
||||
SW_ID0,
|
||||
SW_ID1,
|
||||
SW_ID2,
|
||||
SW_THR,
|
||||
SW_RUD,
|
||||
SW_ELE,
|
||||
SW_AIL,
|
||||
SW_GEA,
|
||||
SW_TRN,
|
||||
};
|
||||
#define IS_3POS(sw) ((sw) == 0)
|
||||
#define IS_TOGGLE(sw) ((sw) == SWSRC_TRN)
|
||||
|
||||
#if defined(REVA)
|
||||
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_EXIT PIOA->PIO_PDSR
|
||||
@@ -113,6 +160,17 @@ void boardInit(void);
|
||||
#define TRIMS_GPIO_PIN_RHR 0x00000200
|
||||
#endif
|
||||
|
||||
// LCD driver
|
||||
#define LCD_W 128
|
||||
#define LCD_H 64
|
||||
#define LCD_DEPTH 1
|
||||
void lcdInit(void);
|
||||
void lcdRefresh(void);
|
||||
#define lcdRefreshWait()
|
||||
void lcdSetRefVolt(uint8_t val);
|
||||
void lcdSetContrast(void);
|
||||
|
||||
// USB driver
|
||||
void usbMassStorage();
|
||||
|
||||
#define PIN_ENABLE 0x001
|
||||
@@ -170,8 +228,10 @@ void init_trainer_capture();
|
||||
void writeFlash(uint32_t * address, uint32_t * buffer);
|
||||
|
||||
// Keys driver
|
||||
extern uint32_t readKeys();
|
||||
extern uint32_t readTrims();
|
||||
uint8_t keyState(uint8_t index);
|
||||
uint32_t switchState(uint8_t index);
|
||||
uint32_t readKeys(void);
|
||||
uint32_t readTrims(void);
|
||||
#define TRIMS_PRESSED() readTrims()
|
||||
#define KEYS_PRESSED() readKeys()
|
||||
|
||||
@@ -206,7 +266,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// WDT driver
|
||||
#if defined(SIMU)
|
||||
#if defined(WATCHDOG_DISABLED) || defined(SIMU)
|
||||
#define wdt_disable()
|
||||
#define wdt_enable(x)
|
||||
#define wdt_reset()
|
||||
@@ -217,18 +277,23 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Backlight driver
|
||||
#define setBacklight(xx) (PWM->PWM_CH_NUM[0].PWM_CDTYUPD = xx)
|
||||
#define backlightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright)
|
||||
#define backlightDisable() (PWM->PWM_CH_NUM[0].PWM_CDTY = 100)
|
||||
#define isBacklightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100)
|
||||
#define BACKLIGHT_ENABLE() backlightEnable()
|
||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||
|
||||
// ADC driver
|
||||
#define NUM_POTS 3
|
||||
#define NUM_SLIDERS 0
|
||||
#define NUM_XPOTS 0
|
||||
enum Analogs {
|
||||
STICK1,
|
||||
STICK2,
|
||||
STICK3,
|
||||
STICK4,
|
||||
POT1,
|
||||
POT_FIRST,
|
||||
POT1 = POT_FIRST,
|
||||
POT2,
|
||||
POT3,
|
||||
POT_LAST = POT3,
|
||||
@@ -238,6 +303,8 @@ enum Analogs {
|
||||
#endif
|
||||
NUMBER_ANALOG
|
||||
};
|
||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
||||
#define IS_SLIDER(x) false
|
||||
void adcInit();
|
||||
void adcRead(void);
|
||||
uint16_t getAnalogValue(uint8_t index);
|
||||
|
||||
@@ -113,34 +113,34 @@ void readKeysAndTrims()
|
||||
keys[BTN_REa].input(REA_DOWN());
|
||||
#endif
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t index = KEY_MENU;
|
||||
uint8_t in = readKeys();
|
||||
for (i = 1; i < 7; i++) {
|
||||
keys[enuk].input(in & (1 << i));
|
||||
++enuk;
|
||||
keys[index].input(in & (1 << i));
|
||||
++index;
|
||||
}
|
||||
|
||||
in = readTrims();
|
||||
|
||||
for (i = 1; i < 256; i <<= 1) {
|
||||
keys[enuk].input(in & i);
|
||||
++enuk;
|
||||
keys[index].input(in & i);
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
register uint32_t a;
|
||||
register uint32_t c;
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
uint32_t switchState(uint8_t index)
|
||||
{
|
||||
register uint32_t a = PIOA->PIO_PDSR;
|
||||
register uint32_t c = PIOC->PIO_PDSR;
|
||||
|
||||
uint32_t xxx = 0;
|
||||
|
||||
if (enuk < (int) DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
a = PIOA->PIO_PDSR ;
|
||||
c = PIOC->PIO_PDSR ;
|
||||
|
||||
switch ((uint8_t) enuk) {
|
||||
switch (index) {
|
||||
#if defined(REVA)
|
||||
case SW_ELE:
|
||||
xxx = a & 0x00000100; // ELE_DR PA8
|
||||
|
||||
@@ -18,287 +18,287 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
// LCD i/o pins
|
||||
// LCD_RES PC27
|
||||
// LCD_CS1 PC26
|
||||
// LCD_E PC12
|
||||
// LCD_RnW PC13
|
||||
// LCD_A0 PC15
|
||||
// LCD_D0 PC0
|
||||
// LCD_D1 PC7
|
||||
// LCD_D2 PC6
|
||||
// LCD_D3 PC5
|
||||
// LCD_D4 PC4
|
||||
// LCD_D5 PC3
|
||||
// LCD_D6 PC2
|
||||
// LCD_D7 PC1
|
||||
|
||||
#define LCD_DATA 0x000000FFL
|
||||
#if !defined(REVA)
|
||||
#define LCD_A0 0x00000080L
|
||||
#else
|
||||
#define LCD_A0 0x00008000L
|
||||
#endif
|
||||
#define LCD_RnW 0x00002000L
|
||||
#define LCD_E 0x00001000L
|
||||
#define LCD_CS1 0x04000000L
|
||||
#define LCD_RES 0x08000000L
|
||||
|
||||
// Lookup table for prototype board
|
||||
#if defined(REVA)
|
||||
const uint8_t Lcd_lookup[] =
|
||||
{
|
||||
0x00,0x01,0x80,0x81,0x40,0x41,0xC0,0xC1,0x20,0x21,0xA0,0xA1,0x60,0x61,0xE0,0xE1,
|
||||
0x10,0x11,0x90,0x91,0x50,0x51,0xD0,0xD1,0x30,0x31,0xB0,0xB1,0x70,0x71,0xF0,0xF1,
|
||||
0x08,0x09,0x88,0x89,0x48,0x49,0xC8,0xC9,0x28,0x29,0xA8,0xA9,0x68,0x69,0xE8,0xE9,
|
||||
0x18,0x19,0x98,0x99,0x58,0x59,0xD8,0xD9,0x38,0x39,0xB8,0xB9,0x78,0x79,0xF8,0xF9,
|
||||
0x04,0x05,0x84,0x85,0x44,0x45,0xC4,0xC5,0x24,0x25,0xA4,0xA5,0x64,0x65,0xE4,0xE5,
|
||||
0x14,0x15,0x94,0x95,0x54,0x55,0xD4,0xD5,0x34,0x35,0xB4,0xB5,0x74,0x75,0xF4,0xF5,
|
||||
0x0C,0x0D,0x8C,0x8D,0x4C,0x4D,0xCC,0xCD,0x2C,0x2D,0xAC,0xAD,0x6C,0x6D,0xEC,0xED,
|
||||
0x1C,0x1D,0x9C,0x9D,0x5C,0x5D,0xDC,0xDD,0x3C,0x3D,0xBC,0xBD,0x7C,0x7D,0xFC,0xFD,
|
||||
0x02,0x03,0x82,0x83,0x42,0x43,0xC2,0xC3,0x22,0x23,0xA2,0xA3,0x62,0x63,0xE2,0xE3,
|
||||
0x12,0x13,0x92,0x93,0x52,0x53,0xD2,0xD3,0x32,0x33,0xB2,0xB3,0x72,0x73,0xF2,0xF3,
|
||||
0x0A,0x0B,0x8A,0x8B,0x4A,0x4B,0xCA,0xCB,0x2A,0x2B,0xAA,0xAB,0x6A,0x6B,0xEA,0xEB,
|
||||
0x1A,0x1B,0x9A,0x9B,0x5A,0x5B,0xDA,0xDB,0x3A,0x3B,0xBA,0xBB,0x7A,0x7B,0xFA,0xFB,
|
||||
0x06,0x07,0x86,0x87,0x46,0x47,0xC6,0xC7,0x26,0x27,0xA6,0xA7,0x66,0x67,0xE6,0xE7,
|
||||
0x16,0x17,0x96,0x97,0x56,0x57,0xD6,0xD7,0x36,0x37,0xB6,0xB7,0x76,0x77,0xF6,0xF7,
|
||||
0x0E,0x0F,0x8E,0x8F,0x4E,0x4F,0xCE,0xCF,0x2E,0x2F,0xAE,0xAF,0x6E,0x6F,0xEE,0xEF,
|
||||
0x1E,0x1F,0x9E,0x9F,0x5E,0x5F,0xDE,0xDF,0x3E,0x3F,0xBE,0xBF,0x7E,0x7F,0xFE,0xFF
|
||||
};
|
||||
#endif
|
||||
|
||||
void lcdSendCtl(uint8_t val)
|
||||
{
|
||||
register Pio *pioptr;
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr = PIOC;
|
||||
pioptr->PIO_CODR = LCD_CS1; // Select LCD
|
||||
pioptr->PIO_CODR = LCD_A0; // Control
|
||||
pioptr->PIO_CODR = LCD_RnW; // Write
|
||||
pioptr->PIO_ODSR = Lcd_lookup[val];
|
||||
#else
|
||||
pioptr = PIOC;
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_CS1; // Select LCD
|
||||
#endif
|
||||
PIOA->PIO_CODR = LCD_A0;
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_RnW; // Write
|
||||
#endif
|
||||
pioptr->PIO_ODSR = val;
|
||||
#endif
|
||||
|
||||
pioptr->PIO_SODR = LCD_E; // Start E pulse
|
||||
// Need a delay here (250nS)
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 9 ) // Value depends on MCK/2 (used 18MHz)
|
||||
{
|
||||
// Wait
|
||||
}
|
||||
pioptr->PIO_CODR = LCD_E; // End E pulse
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_SODR = LCD_A0; // Data
|
||||
#else
|
||||
PIOA->PIO_SODR = LCD_A0; // Data
|
||||
#endif
|
||||
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcdInit()
|
||||
{
|
||||
register Pio *pioptr;
|
||||
// /home/thus/txt/datasheets/lcd/KS0713.pdf
|
||||
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
|
||||
|
||||
// read the inputs, and lock the LCD lines
|
||||
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
lcdLock = 1;
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr = PIOC;
|
||||
pioptr->PIO_PER = 0x0C00B0FFL; // Enable bits 27,26,15,13,12,7-0
|
||||
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_A0;
|
||||
pioptr->PIO_SODR = LCD_RES | LCD_CS1;
|
||||
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR
|
||||
#else
|
||||
configure_pins( LCD_A0, PIN_ENABLE | PIN_LOW | PIN_OUTPUT | PIN_PORTA | PIN_NO_PULLUP );
|
||||
pioptr = PIOC;
|
||||
#if defined(REVX)
|
||||
pioptr->PIO_PER = PIO_PC27 | PIO_PC12 | 0xFF;
|
||||
pioptr->PIO_CODR = LCD_E;
|
||||
pioptr->PIO_CODR = LCD_RnW | LCD_CS1; // No longer needed, used elsewhere
|
||||
#else
|
||||
pioptr->PIO_PER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF;
|
||||
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_CS1;
|
||||
#endif
|
||||
pioptr->PIO_SODR = LCD_RES;
|
||||
pioptr->PIO_OER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF; // Set bits 27,26,13,12,7-0 output
|
||||
pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR
|
||||
#endif
|
||||
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
pioptr->PIO_CODR = LCD_RES; // Reset LCD
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 500 ) ; // > 10us, Value depends on MCK/2 (used 18MHz)
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
pioptr->PIO_SODR = LCD_RES; // Remove LCD reset
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 27000 ) ; // 1500us, Value depends on MCK/2 (used 18MHz)
|
||||
lcdSendCtl(0xe2); //Initialize the internal functions
|
||||
lcdSendCtl(0xae); //DON = 0: display OFF
|
||||
lcdSendCtl(0xa1); //ADC = 1: reverse direction(SEG132->SEG1)
|
||||
lcdSendCtl(0xA6); //REV = 0: non-reverse display
|
||||
lcdSendCtl(0xA4); //EON = 0: normal display. non-entire
|
||||
lcdSendCtl(0xA2); // Select LCD bias=0
|
||||
lcdSendCtl(0xC0); //SHL = 0: normal direction (COM1->COM64)
|
||||
lcdSendCtl(0x2F); //Control power circuit operation VC=VR=VF=1
|
||||
lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5
|
||||
lcdSendCtl(0x81); //Set reference voltage Mode
|
||||
lcdSendCtl(0x22); // 24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18
|
||||
|
||||
#if defined(REVX)
|
||||
// 200mS delay (only if not wdt reset)
|
||||
if ( ( ( ResetReason & RSTC_SR_RSTTYP ) != (2 << 8) ) && !unexpectedShutdown ) {
|
||||
for (uint32_t j = 0; j < 100; j += 1 ) {
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 ) {
|
||||
// Value depends on MCK/2 (used 18MHz) give 2mS delay
|
||||
wdt_reset(); // Wait
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
lcdSendCtl(0xAF); // DON = 1: display ON
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_ODR = 0x0000003CL; // Set bits 2, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x0000003CL; // Set bits 2, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODSR = 0; // Drive D0 low
|
||||
#else
|
||||
pioptr->PIO_ODR = 0x0000003AL; // Set bits 1, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x0000003AL; // Set bits 1, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODSR = 0; // Drive D0 low
|
||||
#endif
|
||||
|
||||
lcdLock = 0;
|
||||
}
|
||||
|
||||
void lcdSetRefVolt(uint8_t val)
|
||||
{
|
||||
register Pio *pioptr;
|
||||
pioptr = PIOC;
|
||||
|
||||
// read the inputs, and lock the LCD lines
|
||||
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
lcdLock = 1;
|
||||
|
||||
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
|
||||
lcdSendCtl(0x81);
|
||||
if ( val == 0 )
|
||||
{
|
||||
val = 0x22;
|
||||
}
|
||||
lcdSendCtl(val);
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
|
||||
#else
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
|
||||
#endif
|
||||
|
||||
pioptr->PIO_ODSR = 0; // Drive D0 low
|
||||
lcdLock = 0;
|
||||
}
|
||||
|
||||
void lcdRefresh()
|
||||
{
|
||||
register Pio *pioptr;
|
||||
register uint8_t *p = displayBuf;
|
||||
register uint32_t y;
|
||||
register uint32_t x;
|
||||
register uint32_t z;
|
||||
register uint32_t ebit;
|
||||
#if defined(REVA)
|
||||
register uint8_t *lookup;
|
||||
lookup = (uint8_t *) Lcd_lookup;
|
||||
#endif
|
||||
|
||||
ebit = LCD_E;
|
||||
|
||||
#if !defined(REVA)
|
||||
pioptr = PIOA;
|
||||
pioptr->PIO_PER = 0x00000080; // Enable bit 7 (LCD-A0)
|
||||
pioptr->PIO_OER = 0x00000080;// Set bit 7 output
|
||||
#endif
|
||||
|
||||
// read the inputs, and lock the LCD lines
|
||||
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
lcdLock = 1;
|
||||
|
||||
pioptr = PIOC;
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
#else
|
||||
pioptr->PIO_OER = 0x0C0030FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
#endif
|
||||
for (y = 0; y < 8; y++) {
|
||||
lcdSendCtl(g_eeGeneral.optrexDisplay ? 0 : 0x04);
|
||||
lcdSendCtl(0x10); //column addr 0
|
||||
lcdSendCtl(y | 0xB0); //page addr y
|
||||
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_CS1; // Select LCD
|
||||
#endif
|
||||
PIOA->PIO_SODR = LCD_A0; // Data
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_RnW; // Write
|
||||
#endif
|
||||
|
||||
#if defined(REVA)
|
||||
x = lookup[*p];
|
||||
#else
|
||||
x = *p;
|
||||
#endif
|
||||
for (z = 0; z < LCD_W; z += 1) {
|
||||
pioptr->PIO_ODSR = x;
|
||||
pioptr->PIO_SODR = ebit; // Start E pulse
|
||||
// Need a delay here (250nS)
|
||||
p += 1;
|
||||
#if defined(REVA)
|
||||
x = lookup[*p];
|
||||
#else
|
||||
x = *p;
|
||||
#endif
|
||||
// TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
// while ( TC0->TC_CHANNEL[0].TC_CV < 3 ) // Value depends on MCK/2 (used 6MHz)
|
||||
// {
|
||||
// // Wait
|
||||
// }
|
||||
pioptr->PIO_CODR = ebit; // End E pulse
|
||||
}
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
|
||||
#endif
|
||||
}
|
||||
|
||||
pioptr->PIO_ODSR = 0xFF; // Drive lines high
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
|
||||
#else
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
|
||||
#endif
|
||||
|
||||
pioptr->PIO_ODSR = 0xFE; // Drive D0 low
|
||||
lcdLock = 0;
|
||||
}
|
||||
#include "opentx.h"
|
||||
|
||||
// LCD i/o pins
|
||||
// LCD_RES PC27
|
||||
// LCD_CS1 PC26
|
||||
// LCD_E PC12
|
||||
// LCD_RnW PC13
|
||||
// LCD_A0 PC15
|
||||
// LCD_D0 PC0
|
||||
// LCD_D1 PC7
|
||||
// LCD_D2 PC6
|
||||
// LCD_D3 PC5
|
||||
// LCD_D4 PC4
|
||||
// LCD_D5 PC3
|
||||
// LCD_D6 PC2
|
||||
// LCD_D7 PC1
|
||||
|
||||
#define LCD_DATA 0x000000FFL
|
||||
#if !defined(REVA)
|
||||
#define LCD_A0 0x00000080L
|
||||
#else
|
||||
#define LCD_A0 0x00008000L
|
||||
#endif
|
||||
#define LCD_RnW 0x00002000L
|
||||
#define LCD_E 0x00001000L
|
||||
#define LCD_CS1 0x04000000L
|
||||
#define LCD_RES 0x08000000L
|
||||
|
||||
// Lookup table for prototype board
|
||||
#if defined(REVA)
|
||||
const uint8_t Lcd_lookup[] =
|
||||
{
|
||||
0x00,0x01,0x80,0x81,0x40,0x41,0xC0,0xC1,0x20,0x21,0xA0,0xA1,0x60,0x61,0xE0,0xE1,
|
||||
0x10,0x11,0x90,0x91,0x50,0x51,0xD0,0xD1,0x30,0x31,0xB0,0xB1,0x70,0x71,0xF0,0xF1,
|
||||
0x08,0x09,0x88,0x89,0x48,0x49,0xC8,0xC9,0x28,0x29,0xA8,0xA9,0x68,0x69,0xE8,0xE9,
|
||||
0x18,0x19,0x98,0x99,0x58,0x59,0xD8,0xD9,0x38,0x39,0xB8,0xB9,0x78,0x79,0xF8,0xF9,
|
||||
0x04,0x05,0x84,0x85,0x44,0x45,0xC4,0xC5,0x24,0x25,0xA4,0xA5,0x64,0x65,0xE4,0xE5,
|
||||
0x14,0x15,0x94,0x95,0x54,0x55,0xD4,0xD5,0x34,0x35,0xB4,0xB5,0x74,0x75,0xF4,0xF5,
|
||||
0x0C,0x0D,0x8C,0x8D,0x4C,0x4D,0xCC,0xCD,0x2C,0x2D,0xAC,0xAD,0x6C,0x6D,0xEC,0xED,
|
||||
0x1C,0x1D,0x9C,0x9D,0x5C,0x5D,0xDC,0xDD,0x3C,0x3D,0xBC,0xBD,0x7C,0x7D,0xFC,0xFD,
|
||||
0x02,0x03,0x82,0x83,0x42,0x43,0xC2,0xC3,0x22,0x23,0xA2,0xA3,0x62,0x63,0xE2,0xE3,
|
||||
0x12,0x13,0x92,0x93,0x52,0x53,0xD2,0xD3,0x32,0x33,0xB2,0xB3,0x72,0x73,0xF2,0xF3,
|
||||
0x0A,0x0B,0x8A,0x8B,0x4A,0x4B,0xCA,0xCB,0x2A,0x2B,0xAA,0xAB,0x6A,0x6B,0xEA,0xEB,
|
||||
0x1A,0x1B,0x9A,0x9B,0x5A,0x5B,0xDA,0xDB,0x3A,0x3B,0xBA,0xBB,0x7A,0x7B,0xFA,0xFB,
|
||||
0x06,0x07,0x86,0x87,0x46,0x47,0xC6,0xC7,0x26,0x27,0xA6,0xA7,0x66,0x67,0xE6,0xE7,
|
||||
0x16,0x17,0x96,0x97,0x56,0x57,0xD6,0xD7,0x36,0x37,0xB6,0xB7,0x76,0x77,0xF6,0xF7,
|
||||
0x0E,0x0F,0x8E,0x8F,0x4E,0x4F,0xCE,0xCF,0x2E,0x2F,0xAE,0xAF,0x6E,0x6F,0xEE,0xEF,
|
||||
0x1E,0x1F,0x9E,0x9F,0x5E,0x5F,0xDE,0xDF,0x3E,0x3F,0xBE,0xBF,0x7E,0x7F,0xFE,0xFF
|
||||
};
|
||||
#endif
|
||||
|
||||
void lcdSendCtl(uint8_t val)
|
||||
{
|
||||
register Pio *pioptr;
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr = PIOC;
|
||||
pioptr->PIO_CODR = LCD_CS1; // Select LCD
|
||||
pioptr->PIO_CODR = LCD_A0; // Control
|
||||
pioptr->PIO_CODR = LCD_RnW; // Write
|
||||
pioptr->PIO_ODSR = Lcd_lookup[val];
|
||||
#else
|
||||
pioptr = PIOC;
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_CS1; // Select LCD
|
||||
#endif
|
||||
PIOA->PIO_CODR = LCD_A0;
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_RnW; // Write
|
||||
#endif
|
||||
pioptr->PIO_ODSR = val;
|
||||
#endif
|
||||
|
||||
pioptr->PIO_SODR = LCD_E; // Start E pulse
|
||||
// Need a delay here (250nS)
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 9 ) // Value depends on MCK/2 (used 18MHz)
|
||||
{
|
||||
// Wait
|
||||
}
|
||||
pioptr->PIO_CODR = LCD_E; // End E pulse
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_SODR = LCD_A0; // Data
|
||||
#else
|
||||
PIOA->PIO_SODR = LCD_A0; // Data
|
||||
#endif
|
||||
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcdInit()
|
||||
{
|
||||
register Pio *pioptr;
|
||||
// /home/thus/txt/datasheets/lcd/KS0713.pdf
|
||||
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
|
||||
|
||||
// read the inputs, and lock the LCD lines
|
||||
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
lcdLock = 1;
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr = PIOC;
|
||||
pioptr->PIO_PER = 0x0C00B0FFL; // Enable bits 27,26,15,13,12,7-0
|
||||
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_A0;
|
||||
pioptr->PIO_SODR = LCD_RES | LCD_CS1;
|
||||
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR
|
||||
#else
|
||||
configure_pins( LCD_A0, PIN_ENABLE | PIN_LOW | PIN_OUTPUT | PIN_PORTA | PIN_NO_PULLUP );
|
||||
pioptr = PIOC;
|
||||
#if defined(REVX)
|
||||
pioptr->PIO_PER = PIO_PC27 | PIO_PC12 | 0xFF;
|
||||
pioptr->PIO_CODR = LCD_E;
|
||||
pioptr->PIO_CODR = LCD_RnW | LCD_CS1; // No longer needed, used elsewhere
|
||||
#else
|
||||
pioptr->PIO_PER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF;
|
||||
pioptr->PIO_CODR = LCD_E | LCD_RnW | LCD_CS1;
|
||||
#endif
|
||||
pioptr->PIO_SODR = LCD_RES;
|
||||
pioptr->PIO_OER = PIO_PC27 | PIO_PC26 | PIO_PC13 | PIO_PC12 | 0xFF; // Set bits 27,26,13,12,7-0 output
|
||||
pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR
|
||||
#endif
|
||||
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
pioptr->PIO_CODR = LCD_RES; // Reset LCD
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 500 ) ; // > 10us, Value depends on MCK/2 (used 18MHz)
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
pioptr->PIO_SODR = LCD_RES; // Remove LCD reset
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 27000 ) ; // 1500us, Value depends on MCK/2 (used 18MHz)
|
||||
lcdSendCtl(0xe2); //Initialize the internal functions
|
||||
lcdSendCtl(0xae); //DON = 0: display OFF
|
||||
lcdSendCtl(0xa1); //ADC = 1: reverse direction(SEG132->SEG1)
|
||||
lcdSendCtl(0xA6); //REV = 0: non-reverse display
|
||||
lcdSendCtl(0xA4); //EON = 0: normal display. non-entire
|
||||
lcdSendCtl(0xA2); // Select LCD bias=0
|
||||
lcdSendCtl(0xC0); //SHL = 0: normal direction (COM1->COM64)
|
||||
lcdSendCtl(0x2F); //Control power circuit operation VC=VR=VF=1
|
||||
lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5
|
||||
lcdSendCtl(0x81); //Set reference voltage Mode
|
||||
lcdSendCtl(0x22); // 24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18
|
||||
|
||||
#if defined(REVX)
|
||||
// 200mS delay (only if not wdt reset)
|
||||
if ( ( ( ResetReason & RSTC_SR_RSTTYP ) != (2 << 8) ) && !unexpectedShutdown ) {
|
||||
for (uint32_t j = 0; j < 100; j += 1 ) {
|
||||
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 ) {
|
||||
// Value depends on MCK/2 (used 18MHz) give 2mS delay
|
||||
wdt_reset(); // Wait
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
lcdSendCtl(0xAF); // DON = 1: display ON
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_ODR = 0x0000003CL; // Set bits 2, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x0000003CL; // Set bits 2, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODSR = 0; // Drive D0 low
|
||||
#else
|
||||
pioptr->PIO_ODR = 0x0000003AL; // Set bits 1, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x0000003AL; // Set bits 1, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODSR = 0; // Drive D0 low
|
||||
#endif
|
||||
|
||||
lcdLock = 0;
|
||||
}
|
||||
|
||||
void lcdSetRefVolt(uint8_t val)
|
||||
{
|
||||
register Pio *pioptr;
|
||||
pioptr = PIOC;
|
||||
|
||||
// read the inputs, and lock the LCD lines
|
||||
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
lcdLock = 1;
|
||||
|
||||
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
|
||||
lcdSendCtl(0x81);
|
||||
if ( val == 0 )
|
||||
{
|
||||
val = 0x22;
|
||||
}
|
||||
lcdSendCtl(val);
|
||||
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
|
||||
#else
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
|
||||
#endif
|
||||
|
||||
pioptr->PIO_ODSR = 0; // Drive D0 low
|
||||
lcdLock = 0;
|
||||
}
|
||||
|
||||
void lcdRefresh()
|
||||
{
|
||||
register Pio *pioptr;
|
||||
register uint8_t *p = displayBuf;
|
||||
register uint32_t y;
|
||||
register uint32_t x;
|
||||
register uint32_t z;
|
||||
register uint32_t ebit;
|
||||
#if defined(REVA)
|
||||
register uint8_t *lookup;
|
||||
lookup = (uint8_t *) Lcd_lookup;
|
||||
#endif
|
||||
|
||||
ebit = LCD_E;
|
||||
|
||||
#if !defined(REVA)
|
||||
pioptr = PIOA;
|
||||
pioptr->PIO_PER = 0x00000080; // Enable bit 7 (LCD-A0)
|
||||
pioptr->PIO_OER = 0x00000080;// Set bit 7 output
|
||||
#endif
|
||||
|
||||
// read the inputs, and lock the LCD lines
|
||||
lcdInputs = PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
lcdLock = 1;
|
||||
|
||||
pioptr = PIOC;
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_OER = 0x0C00B0FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
#else
|
||||
pioptr->PIO_OER = 0x0C0030FFL; // Set bits 27,26,15,13,12,7-0 output
|
||||
#endif
|
||||
for (y = 0; y < 8; y++) {
|
||||
lcdSendCtl(g_eeGeneral.optrexDisplay ? 0 : 0x04);
|
||||
lcdSendCtl(0x10); //column addr 0
|
||||
lcdSendCtl(y | 0xB0); //page addr y
|
||||
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_CS1; // Select LCD
|
||||
#endif
|
||||
PIOA->PIO_SODR = LCD_A0; // Data
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_CODR = LCD_RnW; // Write
|
||||
#endif
|
||||
|
||||
#if defined(REVA)
|
||||
x = lookup[*p];
|
||||
#else
|
||||
x = *p;
|
||||
#endif
|
||||
for (z = 0; z < LCD_W; z += 1) {
|
||||
pioptr->PIO_ODSR = x;
|
||||
pioptr->PIO_SODR = ebit; // Start E pulse
|
||||
// Need a delay here (250nS)
|
||||
p += 1;
|
||||
#if defined(REVA)
|
||||
x = lookup[*p];
|
||||
#else
|
||||
x = *p;
|
||||
#endif
|
||||
// TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
|
||||
// while ( TC0->TC_CHANNEL[0].TC_CV < 3 ) // Value depends on MCK/2 (used 6MHz)
|
||||
// {
|
||||
// // Wait
|
||||
// }
|
||||
pioptr->PIO_CODR = ebit; // End E pulse
|
||||
}
|
||||
#if !defined(REVX)
|
||||
pioptr->PIO_SODR = LCD_CS1; // Deselect LCD
|
||||
#endif
|
||||
}
|
||||
|
||||
pioptr->PIO_ODSR = 0xFF; // Drive lines high
|
||||
#if defined(REVA)
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
|
||||
#else
|
||||
pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
|
||||
pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
|
||||
#endif
|
||||
|
||||
pioptr->PIO_ODSR = 0xFE; // Drive D0 low
|
||||
lcdLock = 0;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@ if(PCB STREQUAL X9E)
|
||||
bluetooth_driver.cpp
|
||||
startup_stm32f40_41xxx.s
|
||||
)
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
if(STICKS STREQUAL HORUS)
|
||||
add_definitions(-DHORUS_STICKS)
|
||||
endif()
|
||||
set(GUI_DIR 212x64)
|
||||
set(GUI_SRC ${GUI_SRC} bmp.cpp)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps)
|
||||
set(BITMAPS_TARGET taranis_bitmaps)
|
||||
set(LCD_DRIVER lcd_driver_spi.cpp)
|
||||
elseif(PCB STREQUAL X9D+)
|
||||
set(CPU_TYPE STM32F2)
|
||||
@@ -34,41 +35,42 @@ elseif(PCB STREQUAL X9D+)
|
||||
add_definitions(-DEEPROM_VARIANT=0)
|
||||
set(GUI_DIR 212x64)
|
||||
set(GUI_SRC ${GUI_SRC} bmp.cpp)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps)
|
||||
set(BITMAPS_TARGET taranis_bitmaps)
|
||||
set(LCD_DRIVER lcd_driver_spi.cpp)
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
elseif(PCB STREQUAL X9D)
|
||||
set(CPU_TYPE STM32F2)
|
||||
set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld)
|
||||
set(HAPTIC NO)
|
||||
set(LUA_EXPORT lua_export_taranis)
|
||||
set(FLAVOUR x9d)
|
||||
add_definitions(-DPCBX9D)
|
||||
add_definitions(-DEEPROM_VARIANT=0)
|
||||
set(GUI_DIR 212x64)
|
||||
set(GUI_SRC ${GUI_SRC} bmp.cpp)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps)
|
||||
set(BITMAPS_TARGET taranis_bitmaps)
|
||||
set(LCD_DRIVER lcd_driver_aspi.cpp)
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
elseif(PCB STREQUAL X7D)
|
||||
set(CPU_TYPE STM32F2)
|
||||
set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld)
|
||||
set(HAPTIC NO)
|
||||
set(HAPTIC YES)
|
||||
set(LUA_EXPORT lua_export_taranis)
|
||||
set(FLAVOUR x7d)
|
||||
add_definitions(-DPCBX7D)
|
||||
add_definitions(-DEEPROM_VARIANT=0)
|
||||
set(GUI_DIR 128x64)
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps)
|
||||
set(BITMAPS_TARGET 9x_bitmaps)
|
||||
set(LCD_DRIVER lcd_driver_spi.cpp)
|
||||
endif()
|
||||
|
||||
set(HSE_VALUE 12000000)
|
||||
set(SDCARD YES)
|
||||
set(EEPROM EEPROM_RLC)
|
||||
set(VIRTUAL_INPUTS YES)
|
||||
set(TARGET_DIR taranis)
|
||||
|
||||
add_definitions(-DPCBTARANIS -DPPM_PIN_TIMER)
|
||||
add_definitions(-DAUDIO -DVOICE -DRTCLOCK)
|
||||
add_definitions(-DLUAINPUTS -DXCURVES -DVARIO)
|
||||
|
||||
set(GUI_SRC ${GUI_SRC}
|
||||
model_inputs.cpp
|
||||
@@ -84,9 +86,15 @@ set(GUI_SRC ${GUI_SRC}
|
||||
../screenshot.cpp
|
||||
)
|
||||
|
||||
if(PCB STREQUAL X7D)
|
||||
set(LED_DRIVER led_driver.cpp)
|
||||
endif()
|
||||
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
board.cpp
|
||||
${LED_DRIVER}
|
||||
backlight_driver.cpp
|
||||
extmodule_driver.cpp
|
||||
../common/arm/stm32/rtc_driver.cpp
|
||||
)
|
||||
@@ -99,10 +107,8 @@ set(FIRMWARE_SRC
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
${LCD_DRIVER}
|
||||
backlight_driver.cpp
|
||||
delays.c
|
||||
i2c_driver.cpp
|
||||
pwr_driver.c
|
||||
pwr_driver.cpp
|
||||
flash_driver.cpp
|
||||
)
|
||||
|
||||
@@ -118,3 +124,4 @@ if(MIXERS_MONITOR)
|
||||
add_definitions(-DMIXERS_MONITOR)
|
||||
endif()
|
||||
|
||||
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} ${BITMAPS_TARGET})
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,1,-1,-1, -1,-1,-1,1, -1,1,1,1, -1};
|
||||
#elif defined(PCBX9DP)
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,-1, -1,1, 1};
|
||||
#elif defined(PCBX7D)
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1, 1};
|
||||
#elif defined(REV4a)
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,0, -1,1, 1};
|
||||
#else
|
||||
@@ -173,7 +175,7 @@ void adcStop()
|
||||
#if !defined(SIMU)
|
||||
uint16_t getAnalogValue(uint8_t index)
|
||||
{
|
||||
if (IS_POT(index) && !IS_POT_AVAILABLE(index)) {
|
||||
if (IS_POT(index) && !IS_POT_OR_SLIDER_AVAILABLE(index)) {
|
||||
// Use fixed analog value for non-existing and/or non-connected pots.
|
||||
// Non-connected analog inputs will slightly follow the adjacent connected analog inputs,
|
||||
// which produces ghost readings on these inputs.
|
||||
|
||||
@@ -32,27 +32,32 @@ void backlightInit()
|
||||
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);
|
||||
BACKLIGHT_TIMER->ARR = 100 ;
|
||||
BACKLIGHT_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM
|
||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC2E ;
|
||||
BACKLIGHT_TIMER->CCR2 = 0 ;
|
||||
BACKLIGHT_TIMER->CCR1 = 100 ;
|
||||
BACKLIGHT_TIMER->EGR = 0 ;
|
||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
BACKLIGHT_TIMER->ARR = 100;
|
||||
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2; // PWM
|
||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC2E;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
BACKLIGHT_TIMER->CCR1 = 100;
|
||||
BACKLIGHT_TIMER->EGR = 0;
|
||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
||||
}
|
||||
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
void backlightEnable(uint8_t level, uint8_t color)
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR1 = ((100-level)*(20-color))/20;
|
||||
BACKLIGHT_TIMER->CCR2 = ((100-level)*color)/20;
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
void backlightDisable()
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR1 = 0;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
}
|
||||
|
||||
uint8_t isBacklightEnable()
|
||||
{
|
||||
return (BACKLIGHT_TIMER->CCR1 != 0 || BACKLIGHT_TIMER->CCR2 != 0);
|
||||
}
|
||||
#elif defined(PCBX9DP)
|
||||
void backlightInit()
|
||||
{
|
||||
@@ -65,45 +70,99 @@ void backlightInit()
|
||||
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);
|
||||
BACKLIGHT_TIMER->ARR = 100 ;
|
||||
BACKLIGHT_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM
|
||||
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 ; // PWM
|
||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E ;
|
||||
BACKLIGHT_TIMER->CCR2 = 0 ;
|
||||
BACKLIGHT_TIMER->CCR4 = 100 ;
|
||||
BACKLIGHT_TIMER->EGR = 0 ;
|
||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
BACKLIGHT_TIMER->ARR = 100;
|
||||
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2; // PWM
|
||||
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
|
||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
BACKLIGHT_TIMER->CCR4 = 100;
|
||||
BACKLIGHT_TIMER->EGR = 0;
|
||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
||||
}
|
||||
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
void backlightEnable(uint8_t level, uint8_t color)
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR4 = ((100-level)*(20-color))/20;
|
||||
BACKLIGHT_TIMER->CCR2 = ((100-level)*color)/20;
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
void backlightDisable()
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR4 = 0;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
}
|
||||
#else
|
||||
|
||||
uint8_t isBacklightEnable()
|
||||
{
|
||||
return (BACKLIGHT_TIMER->CCR4 != 0 || BACKLIGHT_TIMER->CCR2 != 0);
|
||||
}
|
||||
#elif defined(PCBX7D)
|
||||
void backlightInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1;
|
||||
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
|
||||
BACKLIGHT_TIMER->ARR = 100 ;
|
||||
BACKLIGHT_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = 0x60 ; // PWM
|
||||
BACKLIGHT_TIMER->CCER = 1 ;
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource, BACKLIGHT_GPIO_AF);
|
||||
BACKLIGHT_TIMER->ARR = 100;
|
||||
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2; // PWM
|
||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC2E;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
BACKLIGHT_TIMER->EGR = 0;
|
||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
||||
}
|
||||
|
||||
void backlightEnable(uint8_t level)
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR2 = 100 - level;
|
||||
}
|
||||
|
||||
void backlightDisable()
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
}
|
||||
|
||||
uint8_t isBacklightEnable()
|
||||
{
|
||||
return BACKLIGHT_TIMER->CCR2 != 0;
|
||||
}
|
||||
#else
|
||||
void backlightInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource, BACKLIGHT_GPIO_AF);
|
||||
BACKLIGHT_TIMER->ARR = 100;
|
||||
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
BACKLIGHT_TIMER->CCMR1 = 0x60; // PWM
|
||||
BACKLIGHT_TIMER->CCER = 1;
|
||||
BACKLIGHT_TIMER->CCR1 = 80;
|
||||
BACKLIGHT_TIMER->EGR = 0 ;
|
||||
BACKLIGHT_TIMER->CR1 = 1 ;
|
||||
BACKLIGHT_TIMER->EGR = 0;
|
||||
BACKLIGHT_TIMER->CR1 = 1;
|
||||
}
|
||||
|
||||
void backlightEnable(uint8_t level)
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR1 = 100 - level;
|
||||
}
|
||||
|
||||
void backlightDisable()
|
||||
{
|
||||
BACKLIGHT_TIMER->CCR1 = 0;
|
||||
}
|
||||
|
||||
uint8_t isBacklightEnable()
|
||||
{
|
||||
return BACKLIGHT_TIMER->CCR1 != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -98,7 +98,8 @@ void interrupt5ms()
|
||||
per10ms();
|
||||
}
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E) || defined(PCBX7D)
|
||||
// TODO define ROTARY_ENCODER
|
||||
checkRotaryEncoder();
|
||||
#endif
|
||||
}
|
||||
@@ -137,10 +138,15 @@ void boardInit()
|
||||
pwrInit();
|
||||
#endif
|
||||
|
||||
#if defined(PCBX7D)
|
||||
ledInit();
|
||||
ledGreen();
|
||||
#endif
|
||||
|
||||
keysInit();
|
||||
adcInit();
|
||||
delaysInit();
|
||||
lcdInit(); // delaysInit() must be called before
|
||||
lcdInit(); // delaysInit() must be called before
|
||||
audioInit();
|
||||
init2MhzTimer();
|
||||
init5msTimer();
|
||||
@@ -148,6 +154,8 @@ void boardInit()
|
||||
i2cInit();
|
||||
usbInit();
|
||||
|
||||
modulesInit();
|
||||
|
||||
#if defined(HAPTIC)
|
||||
hapticInit();
|
||||
#endif
|
||||
@@ -179,7 +187,7 @@ void boardInit()
|
||||
}
|
||||
else if (duration >= PWR_PRESS_DURATION_MAX) {
|
||||
drawSleepBitmap();
|
||||
turnBacklightOff();
|
||||
backlightDisable();
|
||||
}
|
||||
else {
|
||||
if (pwr_on != 1) {
|
||||
@@ -209,12 +217,17 @@ void boardInit()
|
||||
|
||||
void boardOff()
|
||||
{
|
||||
BACKLIGHT_OFF();
|
||||
#if defined(PCBX7D)
|
||||
ledOff();
|
||||
#endif
|
||||
|
||||
BACKLIGHT_DISABLE();
|
||||
|
||||
#if defined(PCBX9E)
|
||||
toplcdOff();
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E) || defined(PCBX7D)
|
||||
while (pwrPressed()) {
|
||||
wdt_reset();
|
||||
}
|
||||
@@ -267,7 +280,7 @@ void usbJoystickUpdate(void)
|
||||
USBD_HID_SendReport (&USB_OTG_dev, HID_Buffer, HID_IN_PACKET );
|
||||
}
|
||||
|
||||
#endif //#if defined(USB_JOYSTICK) && defined(PCBTARANIS) && !defined(SIMU)
|
||||
#endif // defined(USB_JOYSTICK) && defined(PCBTARANIS) && !defined(SIMU)
|
||||
|
||||
|
||||
uint8_t currentTrainerMode = 0xff;
|
||||
@@ -289,8 +302,10 @@ void checkTrainerSettings()
|
||||
case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE:
|
||||
stop_sbus_on_heartbeat_capture() ;
|
||||
break;
|
||||
#if defined(SERIAL2)
|
||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||
serial2Stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
currentTrainerMode = requiredTrainerMode;
|
||||
@@ -304,12 +319,14 @@ void checkTrainerSettings()
|
||||
case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE:
|
||||
init_sbus_on_heartbeat_capture() ;
|
||||
break;
|
||||
#if defined(SERIAL2)
|
||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||
if (g_eeGeneral.serial2Mode == UART_MODE_SBUS_TRAINER) {
|
||||
serial2SbusInit();
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
#endif
|
||||
default:
|
||||
// master is default
|
||||
init_trainer_capture();
|
||||
|
||||
@@ -100,7 +100,7 @@ extern uint16_t sessionTimer;
|
||||
#if defined(PCBX9E)
|
||||
#define TRAINER_CONNECTED() (true)
|
||||
#else
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_GPIO_DETECT, TRAINER_GPIO_PIN_DETECT) == Bit_RESET)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_DETECT_GPIO, TRAINER_DETECT_GPIO_PIN) == Bit_RESET)
|
||||
#endif
|
||||
|
||||
// Board driver
|
||||
@@ -158,6 +158,7 @@ uint32_t isFirmwareStart(const void * buffer);
|
||||
uint32_t isBootloaderStart(const void * buffer);
|
||||
|
||||
// Pulses driver
|
||||
void modulesInit(void);
|
||||
#define INTERNAL_MODULE_ON() GPIO_SetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
|
||||
#define INTERNAL_MODULE_OFF() GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
|
||||
#define EXTERNAL_MODULE_ON() GPIO_SetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
|
||||
@@ -187,13 +188,133 @@ void stop_sbus_on_heartbeat_capture(void);
|
||||
int sbusGetByte(uint8_t * byte);
|
||||
|
||||
// Keys driver
|
||||
enum EnumKeys
|
||||
{
|
||||
KEY_MENU,
|
||||
KEY_EXIT,
|
||||
KEY_ENTER,
|
||||
KEY_PAGE,
|
||||
KEY_PLUS,
|
||||
KEY_MINUS,
|
||||
|
||||
TRM_BASE,
|
||||
TRM_LH_DWN = TRM_BASE,
|
||||
TRM_LH_UP,
|
||||
TRM_LV_DWN,
|
||||
TRM_LV_UP,
|
||||
TRM_RV_DWN,
|
||||
TRM_RV_UP,
|
||||
TRM_RH_DWN,
|
||||
TRM_RH_UP,
|
||||
TRM_LAST = TRM_RH_UP,
|
||||
|
||||
NUM_KEYS
|
||||
};
|
||||
|
||||
#if defined(PCBX9E) && !defined(SIMU)
|
||||
#define KEY_UP KEY_MINUS
|
||||
#define KEY_DOWN KEY_PLUS
|
||||
#define KEY_RIGHT KEY_PLUS
|
||||
#define KEY_LEFT KEY_MINUS
|
||||
#else
|
||||
#define KEY_UP KEY_PLUS
|
||||
#define KEY_DOWN KEY_MINUS
|
||||
#define KEY_RIGHT KEY_MINUS
|
||||
#define KEY_LEFT KEY_PLUS
|
||||
#endif
|
||||
|
||||
enum EnumSwitches
|
||||
{
|
||||
SW_SA,
|
||||
SW_SB,
|
||||
SW_SC,
|
||||
SW_SD,
|
||||
SW_SE,
|
||||
SW_SF,
|
||||
SW_SG,
|
||||
SW_SH
|
||||
};
|
||||
#define IS_3POS(x) ((x) != SW_SF && (x) != SW_SH)
|
||||
|
||||
enum EnumSwitchesPositions
|
||||
{
|
||||
SW_SA0,
|
||||
SW_SA1,
|
||||
SW_SA2,
|
||||
SW_SB0,
|
||||
SW_SB1,
|
||||
SW_SB2,
|
||||
SW_SC0,
|
||||
SW_SC1,
|
||||
SW_SC2,
|
||||
SW_SD0,
|
||||
SW_SD1,
|
||||
SW_SD2,
|
||||
#if !defined(PCBX7D)
|
||||
SW_SE0,
|
||||
SW_SE1,
|
||||
SW_SE2,
|
||||
#endif
|
||||
SW_SF0,
|
||||
SW_SF1,
|
||||
SW_SF2,
|
||||
#if !defined(PCBX7D)
|
||||
SW_SG0,
|
||||
SW_SG1,
|
||||
SW_SG2,
|
||||
#endif
|
||||
SW_SH0,
|
||||
SW_SH1,
|
||||
SW_SH2,
|
||||
#if defined(PCBX9E)
|
||||
SW_SI0,
|
||||
SW_SI1,
|
||||
SW_SI2,
|
||||
SW_SJ0,
|
||||
SW_SJ1,
|
||||
SW_SJ2,
|
||||
SW_SK0,
|
||||
SW_SK1,
|
||||
SW_SK2,
|
||||
SW_SL0,
|
||||
SW_SL1,
|
||||
SW_SL2,
|
||||
SW_SM0,
|
||||
SW_SM1,
|
||||
SW_SM2,
|
||||
SW_SN0,
|
||||
SW_SN1,
|
||||
SW_SN2,
|
||||
SW_SO0,
|
||||
SW_SO1,
|
||||
SW_SO2,
|
||||
SW_SP0,
|
||||
SW_SP1,
|
||||
SW_SP2,
|
||||
SW_SQ0,
|
||||
SW_SQ1,
|
||||
SW_SQ2,
|
||||
SW_SR0,
|
||||
SW_SR1,
|
||||
SW_SR2,
|
||||
#endif
|
||||
};
|
||||
#if defined(PCBX7D)
|
||||
#define NUM_SWITCHES 6
|
||||
#elif defined(PCBX9E)
|
||||
#define NUM_SWITCHES 18 // yes, it's a lot!
|
||||
#else
|
||||
#define NUM_SWITCHES 8
|
||||
#endif
|
||||
void keysInit(void);
|
||||
uint8_t keyState(uint8_t index);
|
||||
uint32_t switchState(uint8_t index);
|
||||
uint32_t readKeys(void);
|
||||
uint32_t readTrims(void);
|
||||
#define TRIMS_PRESSED() (readTrims())
|
||||
#define KEYS_PRESSED() (readKeys())
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E) || defined(PCBX7D)
|
||||
// Rotary Encoder driver
|
||||
extern int32_t rotencValue;
|
||||
void rotencInit(void);
|
||||
@@ -222,24 +343,37 @@ enum Analogs {
|
||||
STICK2,
|
||||
STICK3,
|
||||
STICK4,
|
||||
POT1,
|
||||
POT_FIRST,
|
||||
POT1 = POT_FIRST,
|
||||
POT2,
|
||||
#if defined(PCBX7D)
|
||||
POT_LAST = POT2,
|
||||
#elif defined(PCBX9E)
|
||||
POT3,
|
||||
#if defined(PCBX9E)
|
||||
POT4,
|
||||
POT_LAST = POT4,
|
||||
#else
|
||||
POT_LAST = POT3,
|
||||
#endif
|
||||
POT4,
|
||||
POT_LAST = POT4,
|
||||
SLIDER1,
|
||||
SLIDER2,
|
||||
#if defined(PCBX9E)
|
||||
SLIDER3,
|
||||
SLIDER4,
|
||||
#endif
|
||||
SLIDER3,
|
||||
SLIDER4,
|
||||
#else
|
||||
POT3,
|
||||
POT_LAST = POT3,
|
||||
SLIDER1,
|
||||
SLIDER2,
|
||||
#endif
|
||||
TX_VOLTAGE,
|
||||
NUMBER_ANALOG
|
||||
};
|
||||
#define NUM_POTS (POT_LAST-POT_FIRST+1)
|
||||
#define NUM_SLIDERS (TX_VOLTAGE-POT_FIRST-NUM_POTS)
|
||||
#define NUM_XPOTS NUM_POTS
|
||||
#if defined(PCBX9D)
|
||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT2) // POT3 is only defined in software
|
||||
#else
|
||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
||||
#endif
|
||||
#define IS_SLIDER(x) ((x)>POT_LAST && (x)<TX_VOLTAGE)
|
||||
void adcInit(void);
|
||||
void adcRead(void);
|
||||
extern uint16_t adcValues[NUMBER_ANALOG];
|
||||
@@ -257,29 +391,26 @@ void pwrInit(void);
|
||||
uint32_t pwrCheck(void);
|
||||
void pwrOn(void);
|
||||
void pwrOff(void);
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PWR_PRESS_BUTTON)
|
||||
uint32_t pwrPressed(void);
|
||||
uint32_t pwrPressedDuration(void);
|
||||
#define pwroffPressed() pwrPressed()
|
||||
#else
|
||||
uint32_t pwroffPressed(void);
|
||||
#endif
|
||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||
|
||||
// Backlight driver
|
||||
void backlightInit(void);
|
||||
void backlightDisable(void);
|
||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||
uint8_t isBacklightEnable(void);
|
||||
#if defined(PCBX9E) || defined(PCBX9DP)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color);
|
||||
void turnBacklightOff(void);
|
||||
#define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor)
|
||||
#define backlightEnable() turnBacklightOn(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||
#define backlightDisable() turnBacklightOff()
|
||||
#define isBacklightEnable() ((BACKLIGHT_TIMER->CCR4 != 0) || (BACKLIGHT_TIMER->CCR2 != 0))
|
||||
void backlightEnable(uint8_t level, uint8_t color);
|
||||
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||
#else
|
||||
#define setBacklight(xx) BACKLIGHT_TIMER->CCR1 = 100-xx
|
||||
#define backlightEnable() BACKLIGHT_TIMER->CCR1 = 100-g_eeGeneral.backlightBright
|
||||
#define backlightDisable() BACKLIGHT_TIMER->CCR1 = 0
|
||||
#define isBacklightEnable() (BACKLIGHT_TIMER->CCR1 != 0)
|
||||
void backlightEnable(uint8_t level);
|
||||
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright)
|
||||
#endif
|
||||
|
||||
// USB driver
|
||||
@@ -334,12 +465,15 @@ void hapticOff(void);
|
||||
|
||||
// Second serial port driver
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
#if !defined(PCBX7D)
|
||||
#define SERIAL2
|
||||
extern uint8_t serial2Mode;
|
||||
void serial2Init(unsigned int mode, unsigned int protocol);
|
||||
void serial2Putc(char c);
|
||||
#define serial2TelemetryInit(protocol) serial2Init(UART_MODE_TELEMETRY, protocol)
|
||||
void serial2SbusInit(void);
|
||||
void serial2Stop(void);
|
||||
#endif
|
||||
|
||||
// BT driver
|
||||
#define BLUETOOTH_DEFAULT_BAUDRATE 115200
|
||||
@@ -351,11 +485,41 @@ void bluetoothWriteString(const char * str);
|
||||
int bluetoothRead(void * buffer, int len);
|
||||
void bluetoothWakeup(void);
|
||||
|
||||
// LED driver
|
||||
void ledInit(void);
|
||||
void ledOff(void);
|
||||
void ledRed(void);
|
||||
void ledGreen(void);
|
||||
void ledBlue(void);
|
||||
|
||||
// LCD driver
|
||||
#if defined(PCBX7D)
|
||||
#define LCD_W 128
|
||||
#define LCD_H 64
|
||||
#define LCD_DEPTH 1
|
||||
#else
|
||||
#define LCD_W 212
|
||||
#define LCD_H 64
|
||||
#define LCD_DEPTH 4
|
||||
#endif
|
||||
void lcdInit(void);
|
||||
void lcdInitFinish(void);
|
||||
void lcdOff(void);
|
||||
|
||||
// TODO lcdRefreshWait() stub in simpgmspace and remove LCD_DUAL_BUFFER
|
||||
#if (defined(PCBX9E) || defined(PCBX9DP) || defined(PCBX7D)) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU)
|
||||
void lcdRefreshWait();
|
||||
#else
|
||||
#define lcdRefreshWait()
|
||||
#endif
|
||||
#if defined(PCBX9D) || defined(SIMU) || !defined(__cplusplus)
|
||||
void lcdRefresh(void);
|
||||
#else
|
||||
void lcdRefresh(bool wait=true); // TODO uint8_t wait to simplify this
|
||||
#endif
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
void lcdSetContrast(void);
|
||||
|
||||
// Top LCD driver
|
||||
#if defined(PCBX9E)
|
||||
void toplcdInit(void);
|
||||
|
||||
@@ -28,8 +28,8 @@ endif()
|
||||
|
||||
set(BOOTLOADER_SRC
|
||||
${BOOTLOADER_SRC}
|
||||
../../../gui/212x64/lcd.cpp
|
||||
../../../gui/212x64/fonts.cpp
|
||||
../../../gui/${GUI_DIR}/lcd.cpp
|
||||
../../../gui/${GUI_DIR}/fonts.cpp
|
||||
../../../keys.cpp
|
||||
../../../strhelpers.cpp
|
||||
../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_core.c
|
||||
@@ -52,11 +52,11 @@ set(BOOTLOADER_SRC
|
||||
../diskio.cpp
|
||||
../../common/arm/stm32/usbd_usr.cpp
|
||||
../../common/arm/stm32/usbd_storage_msd.cpp
|
||||
../delays.c
|
||||
../../common/arm/stm32/delays.cpp
|
||||
../../common/arm/stm32/usbd_desc.c
|
||||
../../common/arm/stm32/usb_bsp.c
|
||||
../../common/arm/stm32/usb_driver.c
|
||||
../pwr_driver.c
|
||||
../pwr_driver.cpp
|
||||
init.c
|
||||
boot.cpp
|
||||
)
|
||||
@@ -67,7 +67,7 @@ add_definitions(-DBOOT -DUSB_MASS_STORAGE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC_DIRECTORY}/targets/taranis/stm32_ramboot.ld -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections")
|
||||
|
||||
add_executable(bootloader ${BOOTLOADER_SRC})
|
||||
add_dependencies(bootloader taranis_fonts firmware_translations)
|
||||
add_dependencies(bootloader ${BITMAPS_TARGET} firmware_translations)
|
||||
|
||||
add_custom_command(
|
||||
TARGET bootloader POST_BUILD
|
||||
|
||||
@@ -1,60 +1,29 @@
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2014 by Michael Blandford. All rights reserved.
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************
|
||||
* Other Authors:
|
||||
* - Andre Bernet
|
||||
* - Bertrand Songis
|
||||
* - Bryan J. Rentoul (Gruvin)
|
||||
* - Cameron Weeks
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini
|
||||
* - Thomas Husterer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../../gui/212x64/lcd.h"
|
||||
#include "board.h"
|
||||
#include "lcd.h"
|
||||
#include "storage/eeprom_rlc.h"
|
||||
#include "pwr.h"
|
||||
#include "keys.h"
|
||||
@@ -164,12 +133,12 @@ void interrupt10ms(void)
|
||||
{
|
||||
Tenms |= 1; // 10 mS has passed
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t index = KEY_MENU;
|
||||
uint8_t in = readKeys();
|
||||
for (uint8_t i = 1; i != uint8_t(1 << TRM_BASE); i <<= 1) {
|
||||
uint8_t value = (in & i);
|
||||
keys[enuk].input(value);
|
||||
++enuk;
|
||||
keys[index].input(value);
|
||||
++index;
|
||||
}
|
||||
|
||||
#if defined(PCBX9E)
|
||||
@@ -399,7 +368,7 @@ int main()
|
||||
#endif
|
||||
|
||||
pwrInit();
|
||||
delaysInit(); //needed for lcdInit()
|
||||
delaysInit(); // needed for lcdInit()
|
||||
lcdInit();
|
||||
backlightInit();
|
||||
|
||||
@@ -672,7 +641,7 @@ int main()
|
||||
}
|
||||
|
||||
if (state != ST_FLASHING && state != ST_USB) {
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E) || defined(PCBX7D)
|
||||
if (pwrPressed()) {
|
||||
#else
|
||||
if (pwrCheck() == e_power_off) {
|
||||
|
||||
+134
-38
@@ -22,21 +22,28 @@
|
||||
#define _HAL_H_
|
||||
|
||||
// Keys
|
||||
#define KEYS_GPIO_REG_MENU GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
|
||||
#define KEYS_GPIO_REG_EXIT GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02
|
||||
#define KEYS_GPIO_REG_PAGE GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03
|
||||
#if defined(PCBX7D)
|
||||
#define KEYS_GPIO_REG_PAGE GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_PAGE GPIO_Pin_2 // PD.02
|
||||
#define KEYS_GPIO_REG_MENU GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
|
||||
#define KEYS_GPIO_REG_EXIT GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_EXIT GPIO_Pin_3 // PD.03
|
||||
#else
|
||||
#define KEYS_GPIO_REG_MENU GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
|
||||
#define KEYS_GPIO_REG_EXIT GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02
|
||||
#define KEYS_GPIO_REG_PAGE GPIOD->IDR
|
||||
#define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#if defined(SIMU)
|
||||
#define KEYS_GPIO_REG_PLUS GPIOE->IDR
|
||||
#define KEYS_GPIO_PIN_PLUS GPIO_Pin_5 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#define KEYS_GPIO_REG_MINUS GPIOE->IDR
|
||||
#define KEYS_GPIO_PIN_MINUS GPIO_Pin_6 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#endif
|
||||
#define KEYS_GPIO_REG_ENTER GPIOF->IDR
|
||||
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_0 // PF.00
|
||||
#elif defined(PCBX7D)
|
||||
#define KEYS_GPIO_REG_ENTER GPIOE->IDR
|
||||
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_10 // PE.10
|
||||
#else
|
||||
#define KEYS_GPIO_REG_PLUS GPIOE->IDR
|
||||
#define KEYS_GPIO_PIN_PLUS GPIO_Pin_10 // PE.10
|
||||
@@ -47,9 +54,23 @@
|
||||
#endif
|
||||
|
||||
// Rotary Encoder
|
||||
#define ENC_GPIO GPIOD
|
||||
#define ENC_GPIO_PIN_A GPIO_Pin_12 // PD.12
|
||||
#define ENC_GPIO_PIN_B GPIO_Pin_13 // PD.13
|
||||
#if defined(PCBX9E)
|
||||
#define ENC_GPIO GPIOD
|
||||
#define ENC_GPIO_PIN_A GPIO_Pin_12 // PD.12
|
||||
#define ENC_GPIO_PIN_B GPIO_Pin_13 // PD.13
|
||||
#elif defined(PCBX7D)
|
||||
#define ENC_GPIO GPIOE
|
||||
#define ENC_GPIO_PIN_A GPIO_Pin_9 // PE.09
|
||||
#define ENC_GPIO_PIN_B GPIO_Pin_11 // PE.11
|
||||
#endif
|
||||
|
||||
// This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#if defined(SIMU) && (defined(PCBX9E) || defined(PCBX7D))
|
||||
#define KEYS_GPIO_REG_PLUS ENC_GPIO->IDR
|
||||
#define KEYS_GPIO_PIN_PLUS ENC_GPIO_PIN_A
|
||||
#define KEYS_GPIO_REG_MINUS ENC_GPIO->IDR
|
||||
#define KEYS_GPIO_PIN_MINUS ENC_GPIO_PIN_B
|
||||
#endif
|
||||
|
||||
// Trims
|
||||
#if defined(PCBX9E)
|
||||
@@ -94,6 +115,11 @@
|
||||
#define SWITCHES_GPIO_PIN_A_H GPIO_Pin_10 // PD.10
|
||||
#define SWITCHES_GPIO_REG_A_L GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_A_L GPIO_Pin_14 // PD.14
|
||||
#elif defined(PCBX7D)
|
||||
#define SWITCHES_GPIO_REG_A_H GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_A_H GPIO_Pin_11 // PD.11
|
||||
#define SWITCHES_GPIO_REG_A_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_A_L GPIO_Pin_0 // PE.00
|
||||
#else
|
||||
#define SWITCHES_GPIO_REG_A_H GPIOB->IDR
|
||||
#define SWITCHES_GPIO_PIN_A_H GPIO_Pin_5 // PB.05
|
||||
@@ -118,6 +144,11 @@
|
||||
#define SWITCHES_GPIO_PIN_C_H GPIO_Pin_13 // PF.13
|
||||
#define SWITCHES_GPIO_REG_C_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_C_L GPIO_Pin_14 // PF.14
|
||||
#elif defined(PCBX7D)
|
||||
#define SWITCHES_GPIO_REG_C_H GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_C_H GPIO_Pin_14 // PD.14
|
||||
#define SWITCHES_GPIO_REG_C_L GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_C_L GPIO_Pin_15 // PD.15
|
||||
#else
|
||||
#define SWITCHES_GPIO_REG_C_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_C_H GPIO_Pin_15 // PE.15
|
||||
@@ -130,7 +161,7 @@
|
||||
#define SWITCHES_GPIO_PIN_D_H GPIO_Pin_1 // PE.01
|
||||
#define SWITCHES_GPIO_REG_D_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_D_L GPIO_Pin_2 // PE.02
|
||||
#elif defined(PCBX9DP)
|
||||
#elif defined(PCBX9DP) || defined(PCBX7D)
|
||||
#define SWITCHES_GPIO_REG_D_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_D_H GPIO_Pin_7 // PE.07
|
||||
#define SWITCHES_GPIO_REG_D_L GPIOE->IDR
|
||||
@@ -147,7 +178,7 @@
|
||||
#define SWITCHES_GPIO_PIN_E_H GPIO_Pin_7 // PE.07
|
||||
#define SWITCHES_GPIO_REG_E_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_E_L GPIO_Pin_13 // PE.13
|
||||
#else
|
||||
#elif !defined(PCBX7D)
|
||||
#define SWITCHES_GPIO_REG_E_H GPIOB->IDR
|
||||
#define SWITCHES_GPIO_PIN_E_H GPIO_Pin_3 // PB.03
|
||||
#define SWITCHES_GPIO_REG_E_L GPIOB->IDR
|
||||
@@ -167,7 +198,7 @@
|
||||
#define SWITCHES_GPIO_PIN_G_H GPIO_Pin_3 // PF.03
|
||||
#define SWITCHES_GPIO_REG_G_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_G_L GPIO_Pin_4 // PF.04
|
||||
#else
|
||||
#elif !defined(PCBX7D)
|
||||
#define SWITCHES_GPIO_REG_G_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_G_H GPIO_Pin_9 // PE.09
|
||||
#define SWITCHES_GPIO_REG_G_L GPIOE->IDR
|
||||
@@ -177,9 +208,11 @@
|
||||
#if defined(PCBX9E)
|
||||
#define SWITCHES_GPIO_REG_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_1 // PF.01
|
||||
#elif defined(PCBX9DP)
|
||||
#define SWITCHES_GPIO_REG_H GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_14 // PD.14
|
||||
#elif defined(PCBX7D)
|
||||
#define SWITCHES_GPIO_REG_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_15 // PE.15
|
||||
// #define SWITCHES_GPIO_REG_H_L GPIOA->IDR
|
||||
// #define SWITCHES_GPIO_PIN_H_L GPIO_Pin_5 // PA.05
|
||||
#else
|
||||
#define SWITCHES_GPIO_REG_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_13 // PE.13
|
||||
@@ -244,6 +277,11 @@
|
||||
#define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR)
|
||||
#define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_H)
|
||||
#define KEYS_GPIOE_PINS (KEYS_GPIO_PIN_PLUS | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_MINUS | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L)
|
||||
#elif defined(PCBX7D)
|
||||
#define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
|
||||
#define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR)
|
||||
#define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_C_L | SWITCHES_GPIO_PIN_C_H)
|
||||
#define KEYS_GPIOE_PINS (ENC_GPIO_PIN_A | ENC_GPIO_PIN_B | KEYS_GPIO_PIN_ENTER | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_H)
|
||||
#else
|
||||
#define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
|
||||
#define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_C_L)
|
||||
@@ -316,6 +354,19 @@
|
||||
#define ADC_CHANNEL_SLIDER1 ADC_Channel_14
|
||||
#define ADC_CHANNEL_SLIDER2 ADC_Channel_15
|
||||
#define ADC_CHANNEL_BATT ADC_Channel_10
|
||||
#elif defined(PCBX7D)
|
||||
#define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
|
||||
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
||||
#define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
|
||||
#define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT1)
|
||||
#define ADC_GPIOB_PINS ADC_GPIO_PIN_POT2
|
||||
#define ADC_GPIOC_PINS ADC_GPIO_PIN_BATT
|
||||
#define ADC_CHANNEL_POT1 ADC_Channel_6
|
||||
#define ADC_CHANNEL_POT2 ADC_Channel_8
|
||||
#define ADC_CHANNEL_POT3 ADC_Channel_9
|
||||
#define ADC_CHANNEL_SLIDER1 ADC_Channel_14
|
||||
#define ADC_CHANNEL_SLIDER2 ADC_Channel_15
|
||||
#define ADC_CHANNEL_BATT ADC_Channel_10
|
||||
#else
|
||||
#define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
|
||||
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
||||
@@ -333,16 +384,27 @@
|
||||
#define ADC_CHANNEL_BATT ADC_Channel_10
|
||||
#endif
|
||||
|
||||
// Power_OFF Delay and LED
|
||||
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
|
||||
// PWR and LED driver
|
||||
#define PWR_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
|
||||
#if defined(PCBX9E) || defined(PCBX7D)
|
||||
#define PWR_PRESS_BUTTON
|
||||
#endif
|
||||
#define PWR_GPIO GPIOD
|
||||
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_1 // PD.01
|
||||
#define PWR_ON_GPIO_PIN GPIO_Pin_0 // PD.00
|
||||
#if defined(PCBX7D)
|
||||
#define LED_GREEN_GPIO GPIOC
|
||||
#define LED_GREEN_GPIO_PIN GPIO_Pin_4 // PC.04
|
||||
#define LED_RED_GPIO GPIOC
|
||||
#define LED_RED_GPIO_PIN GPIO_Pin_5 // PC.05
|
||||
#define LED_BLUE_GPIO GPIOB
|
||||
#define LED_BLUE_GPIO_PIN GPIO_Pin_1 // PB.01
|
||||
#endif
|
||||
|
||||
// Internal Module
|
||||
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
|
||||
#define INTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1
|
||||
#if defined(PCBX9E) || defined(PCBX9DP)
|
||||
#if defined(PCBX9E) || defined(PCBX9DP) || defined(PCBX7D)
|
||||
#define INTMODULE_PWR_GPIO GPIOC
|
||||
#define INTMODULE_PWR_GPIO_PIN GPIO_Pin_6 // PC.06
|
||||
#else
|
||||
@@ -386,12 +448,12 @@
|
||||
#define TRAINER_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC)
|
||||
#define TRAINER_RCC_APB1Periph RCC_APB1Periph_TIM3
|
||||
#define TRAINER_GPIO GPIOC
|
||||
#define TRAINER_GPIO_PIN_IN GPIO_Pin_8 // PC.08
|
||||
#define TRAINER_GPIO_PinSource_IN GPIO_PinSource8
|
||||
#define TRAINER_GPIO_PIN_OUT GPIO_Pin_9 // PC.09
|
||||
#define TRAINER_GPIO_PinSource_OUT GPIO_PinSource9
|
||||
#define TRAINER_GPIO_DETECT GPIOA
|
||||
#define TRAINER_GPIO_PIN_DETECT GPIO_Pin_8 // PA.08
|
||||
#define TRAINER_IN_GPIO_PIN GPIO_Pin_8 // PC.08
|
||||
#define TRAINER_IN_GPIO_PinSource GPIO_PinSource8
|
||||
#define TRAINER_OUT_GPIO_PIN GPIO_Pin_9 // PC.09
|
||||
#define TRAINER_OUT_GPIO_PinSource GPIO_PinSource9
|
||||
#define TRAINER_DETECT_GPIO GPIOA
|
||||
#define TRAINER_DETECT_GPIO_PIN GPIO_Pin_8 // PA.08
|
||||
#define TRAINER_TIMER TIM3
|
||||
#define TRAINER_TIMER_IRQn TIM3_IRQn
|
||||
#define TRAINER_GPIO_AF GPIO_AF_TIM3
|
||||
@@ -406,6 +468,10 @@
|
||||
#define TRAINER_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
||||
|
||||
// Serial Port
|
||||
#if defined(PCBX7D)
|
||||
#define SERIAL_RCC_AHB1Periph 0
|
||||
#define SERIAL_RCC_APB1Periph 0
|
||||
#else
|
||||
#define SERIAL_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
||||
#define SERIAL_RCC_APB1Periph RCC_APB1Periph_USART3
|
||||
#define SERIAL_GPIO GPIOB
|
||||
@@ -419,6 +485,7 @@
|
||||
#define SERIAL_USART_IRQn USART3_IRQn
|
||||
#define SERIAL_DMA_Stream_RX DMA1_Stream1
|
||||
#define SERIAL_DMA_Channel_RX DMA_Channel_4
|
||||
#endif
|
||||
|
||||
// Telemetry
|
||||
#define TELEMETRY_RCC_AHB1Periph (RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
|
||||
@@ -469,6 +536,7 @@
|
||||
#define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOE
|
||||
#define BACKLIGHT_RCC_APB1Periph 0
|
||||
#define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM9
|
||||
#define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||
#define BACKLIGHT_TIMER TIM9
|
||||
#define BACKLIGHT_GPIO GPIOE
|
||||
#define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_6 // PE.06
|
||||
@@ -481,6 +549,7 @@
|
||||
#define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
|
||||
#define BACKLIGHT_RCC_APB1Periph RCC_APB1Periph_TIM4
|
||||
#define BACKLIGHT_RCC_APB2Periph 0
|
||||
#define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
||||
#define BACKLIGHT_TIMER TIM4
|
||||
#define BACKLIGHT_GPIO GPIOD
|
||||
#define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_15 // PD.15
|
||||
@@ -489,18 +558,29 @@
|
||||
#define BACKLIGHT_GPIO_PinSource_2 GPIO_PinSource13
|
||||
#define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM4
|
||||
#define BACKLIGHT_GPIO_AF_2 GPIO_AF_TIM4
|
||||
#elif defined(PCBX7D)
|
||||
#define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
|
||||
#define BACKLIGHT_RCC_APB1Periph RCC_APB1Periph_TIM4
|
||||
#define BACKLIGHT_RCC_APB2Periph 0
|
||||
#define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
||||
#define BACKLIGHT_TIMER TIM4
|
||||
#define BACKLIGHT_GPIO GPIOD
|
||||
#define BACKLIGHT_GPIO_PIN GPIO_Pin_13 // PD.13
|
||||
#define BACKLIGHT_GPIO_PinSource GPIO_PinSource13
|
||||
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM4
|
||||
#else
|
||||
#define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||
#define BACKLIGHT_RCC_APB1Periph 0
|
||||
#define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM10
|
||||
#define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||
#define BACKLIGHT_TIMER TIM10
|
||||
#define BACKLIGHT_GPIO GPIOB
|
||||
#define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_8 // PB.08
|
||||
#define BACKLIGHT_GPIO_PinSource_1 GPIO_PinSource8
|
||||
#define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM10
|
||||
#define BACKLIGHT_GPIO_PIN GPIO_Pin_8 // PB.08
|
||||
#define BACKLIGHT_GPIO_PinSource GPIO_PinSource8
|
||||
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM10
|
||||
#endif
|
||||
|
||||
// LCD
|
||||
// LCD driver
|
||||
#if defined(PCBX9E)
|
||||
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
|
||||
#define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3
|
||||
@@ -522,7 +602,7 @@
|
||||
#define LCD_DMA_FLAG_INT DMA_HIFCR_CTCIF7
|
||||
#define LCD_SPI SPI3
|
||||
#define LCD_GPIO_AF GPIO_AF_SPI3
|
||||
#elif defined(PCBX9DP)
|
||||
#elif defined(PCBX9DP) || defined(PCBX7D)
|
||||
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
|
||||
#define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3
|
||||
#define LCD_SPI_GPIO GPIOC
|
||||
@@ -617,12 +697,12 @@
|
||||
#define AUDIO_DMA DMA1
|
||||
|
||||
// Haptic
|
||||
#if defined(PCBX9E) || defined(PCBX9DP)
|
||||
#if defined(PCBX9E) || defined(PCBX9DP) || defined(PCBX7D)
|
||||
#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||
#define HAPTIC_RCC_APB2Periph RCC_APB2Periph_TIM10
|
||||
#define HAPTIC_GPIO_PinSource GPIO_PinSource8
|
||||
#define HAPTIC_GPIO GPIOB
|
||||
#define HAPTIC_GPIO_PIN GPIO_Pin_8
|
||||
#define HAPTIC_GPIO_PIN GPIO_Pin_8 // PB.08
|
||||
#define HAPTIC_GPIO_AF GPIO_AF_TIM10
|
||||
#define HAPTIC_TIMER TIM10
|
||||
#else
|
||||
@@ -643,7 +723,7 @@
|
||||
#define TOPLCD_GPIO_PIN_BL GPIO_Pin_2
|
||||
#endif
|
||||
|
||||
// Bluetooth on X9E
|
||||
// Bluetooth
|
||||
#if defined(PCBX9E)
|
||||
#define BT_USART USART6
|
||||
#define BT_GPIO_AF GPIO_AF_USART6
|
||||
@@ -660,6 +740,22 @@
|
||||
#define BT_GPIO_PIN_BCTS GPIO_Pin_6 // PG.06
|
||||
#define BT_GPIO_PinSource_TX GPIO_PinSource14
|
||||
#define BT_GPIO_PinSource_RX GPIO_PinSource9
|
||||
#elif defined(PCBX7D)
|
||||
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_DMA1)
|
||||
#define BT_RCC_APB1Periph RCC_APB1Periph_USART3
|
||||
#define BT_GPIO_EN GPIOE
|
||||
#define BT_GPIO_PIN_EN GPIO_Pin_12 // PE.12
|
||||
#define BT_GPIO GPIOB
|
||||
#define BT_GPIO_PIN_TX GPIO_Pin_10 // PB.10
|
||||
#define BT_GPIO_PIN_RX GPIO_Pin_11 // PB.11
|
||||
#define BT_GPIO_PinSource_TX GPIO_PinSource10
|
||||
#define BT_GPIO_PinSource_RX GPIO_PinSource11
|
||||
#define BT_GPIO_AF GPIO_AF_USART3
|
||||
#define BT_USART USART3
|
||||
#define BT_USART_IRQHandler USART3_IRQHandler
|
||||
#define BT_USART_IRQn USART3_IRQn
|
||||
#define BT_DMA_Stream_RX DMA1_Stream1
|
||||
#define BT_DMA_Channel_RX DMA_Channel_4
|
||||
#endif
|
||||
|
||||
// 5ms Interrupt
|
||||
|
||||
@@ -33,14 +33,14 @@ uint32_t readKeys()
|
||||
if (~KEYS_GPIO_REG_EXIT & KEYS_GPIO_PIN_EXIT)
|
||||
result |= 1 << KEY_EXIT;
|
||||
|
||||
#if !defined(PCBX9E) || defined(SIMU)
|
||||
#if (!defined(PCBX9E) && !defined(PCBX7D)) || defined(SIMU)
|
||||
if (~KEYS_GPIO_REG_PLUS & KEYS_GPIO_PIN_PLUS)
|
||||
result |= 1 << KEY_PLUS;
|
||||
if (~KEYS_GPIO_REG_MINUS & KEYS_GPIO_PIN_MINUS)
|
||||
result |= 1 << KEY_MINUS;
|
||||
#endif
|
||||
|
||||
// TRACE("readKeys(): result=0x%02x", result);
|
||||
// if (result != 0) TRACE("readKeys(): result=0x%02x", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -81,42 +81,43 @@ uint8_t keyDown()
|
||||
return readKeys();
|
||||
}
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PCBX9E) || defined(PCBX7D)
|
||||
uint32_t Rotary_position;
|
||||
rotenc_t rotencValue;
|
||||
void checkRotaryEncoder()
|
||||
{
|
||||
register uint32_t dummy ;
|
||||
register uint32_t dummy = ENC_GPIO->IDR; // Read Rotary encoder
|
||||
|
||||
dummy = ENC_GPIO->IDR; // Read Rotary encoder
|
||||
dummy >>= 12; // quick & dirty!
|
||||
dummy &= 0x03;
|
||||
if ( dummy != ( Rotary_position & 0x03 ) )
|
||||
{
|
||||
if ( ( Rotary_position & 0x01 ) ^ ( ( dummy & 0x02) >> 1 ) )
|
||||
{
|
||||
--rotencValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
++rotencValue;
|
||||
}
|
||||
Rotary_position &= ~0x03 ;
|
||||
Rotary_position |= dummy ;
|
||||
}
|
||||
// TODO quick & dirty!
|
||||
#if defined(PCBX9E)
|
||||
dummy >>= 12;
|
||||
dummy &= 0x03;
|
||||
#else
|
||||
dummy = ((dummy >> 11) & 0x01) + ((dummy >> 8) & 0x02);
|
||||
#endif
|
||||
if (dummy != (Rotary_position & 0x03)) {
|
||||
if ((Rotary_position & 0x01) ^ ((dummy & 0x02) >> 1)) {
|
||||
--rotencValue;
|
||||
}
|
||||
else {
|
||||
++rotencValue;
|
||||
}
|
||||
Rotary_position &= ~0x03 ;
|
||||
Rotary_position |= dummy ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* TODO common to ARM */
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = 0;
|
||||
uint8_t index = 0;
|
||||
uint32_t in = readKeys();
|
||||
for (uint8_t i = 1; i != uint8_t(1 << TRM_BASE); i <<= 1) {
|
||||
keys[enuk++].input(in & i);
|
||||
keys[index++].input(in & i);
|
||||
}
|
||||
|
||||
#if defined(PCBX9E) && !defined(SIMU)
|
||||
#if (defined(PCBX9E) || defined(PCBX7D)) && !defined(SIMU)
|
||||
#define X9E_RE_TIMEOUT 5
|
||||
static rotenc_t rePreviousValue;
|
||||
rotenc_t reNewValue = (rotencValue / 2);
|
||||
@@ -148,12 +149,11 @@ void readKeysAndTrims()
|
||||
putEvent(EVT_KEY_BREAK(lastkey));
|
||||
lastkey = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
in = readTrims();
|
||||
for (uint8_t i = 1; i != uint8_t(1 << 8); i <<= 1) {
|
||||
keys[enuk++].input(in & i);
|
||||
keys[index++].input(in & i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ void readKeysAndTrims()
|
||||
#define ADD_3POS_CASE(x, i) \
|
||||
case SW_S ## x ## 0: \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
if (IS_3POS(i)) { \
|
||||
if (IS_CONFIG_3POS(i)) { \
|
||||
xxx = xxx && (~SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break; \
|
||||
@@ -195,28 +195,36 @@ void readKeysAndTrims()
|
||||
break; \
|
||||
case SW_S ## x ## 2: \
|
||||
xxx = (~SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
if (IS_3POS(i)) { \
|
||||
if (IS_CONFIG_3POS(i)) { \
|
||||
xxx = xxx && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT)
|
||||
bool switchState(EnumKeys enuk)
|
||||
uint8_t keyState(uint8_t index)
|
||||
{
|
||||
return keys[index].state();
|
||||
}
|
||||
|
||||
uint32_t switchState(uint8_t index)
|
||||
{
|
||||
register uint32_t xxx = 0;
|
||||
|
||||
if (enuk < (int) DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
switch ((uint8_t) enuk) {
|
||||
|
||||
switch (index) {
|
||||
ADD_3POS_CASE(A, 0);
|
||||
ADD_3POS_CASE(B, 1);
|
||||
ADD_3POS_CASE(C, 2);
|
||||
ADD_3POS_CASE(D, 3);
|
||||
#if defined(PCBX7D)
|
||||
ADD_2POS_CASE(F);
|
||||
ADD_2POS_CASE(H);
|
||||
#else
|
||||
ADD_3POS_CASE(E, 4);
|
||||
ADD_2POS_CASE(F);
|
||||
ADD_3POS_CASE(G, 6);
|
||||
ADD_2POS_CASE(H);
|
||||
#endif
|
||||
#if defined(PCBX9E)
|
||||
ADD_3POS_CASE(I, 8);
|
||||
ADD_3POS_CASE(J, 9);
|
||||
@@ -234,7 +242,7 @@ bool switchState(EnumKeys enuk)
|
||||
break;
|
||||
}
|
||||
|
||||
// TRACE("switch %d => %d", enuk, xxx);
|
||||
// TRACE("switch %d => %d", index, xxx);
|
||||
return xxx;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#define CONTRAST_OFS 160
|
||||
#define CONTRAST_OFS 160
|
||||
#define RESET_WAIT_DELAY_MS 300 // Wait time after LCD reset before first command
|
||||
#define WAIT_FOR_DMA_END() { while(lcd_busy) {}; }
|
||||
#define WAIT_FOR_DMA_END() do { } while (lcd_busy)
|
||||
|
||||
#define LCD_NCS_HIGH() LCD_NCS_GPIO->BSRRL = LCD_NCS_GPIO_PIN
|
||||
#define LCD_NCS_LOW() LCD_NCS_GPIO->BSRRH = LCD_NCS_GPIO_PIN
|
||||
@@ -36,16 +36,16 @@
|
||||
bool lcdInitFinished = false;
|
||||
void lcdInitFinish();
|
||||
|
||||
void lcdWriteCommand(uint8_t Command_Byte)
|
||||
void lcdWriteCommand(uint8_t byte)
|
||||
{
|
||||
LCD_A0_LOW();
|
||||
LCD_NCS_LOW();
|
||||
while ( ( SPI3->SR & SPI_SR_TXE ) == 0 ) {
|
||||
while ((SPI3->SR & SPI_SR_TXE) == 0) {
|
||||
// Wait
|
||||
}
|
||||
(void)SPI3->DR; // Clear receive
|
||||
SPI3->DR = Command_Byte;
|
||||
while ( ( SPI3->SR & SPI_SR_RXNE ) == 0 ) {
|
||||
(void)SPI3->DR; // Clear receive
|
||||
LCD_SPI->DR = byte;
|
||||
while ((SPI3->SR & SPI_SR_RXNE) == 0) {
|
||||
// Wait
|
||||
}
|
||||
LCD_NCS_HIGH();
|
||||
@@ -89,13 +89,33 @@ void lcdHardwareInit()
|
||||
LCD_DMA->HIFCR = LCD_DMA_FLAGS; // Write ones to clear bits
|
||||
LDC_DMA_Stream->CR = DMA_SxCR_PL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0;
|
||||
LDC_DMA_Stream->PAR = (uint32_t)&LCD_SPI->DR;
|
||||
#if defined(PCBX7D)
|
||||
LDC_DMA_Stream->NDTR = LCD_W;
|
||||
#else
|
||||
LDC_DMA_Stream->M0AR = (uint32_t)displayBuf;
|
||||
LDC_DMA_Stream->FCR = 0x05; // DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||
LDC_DMA_Stream->NDTR = LCD_W*LCD_H/8*4;
|
||||
#endif
|
||||
LDC_DMA_Stream->FCR = 0x05; // DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||
|
||||
NVIC_EnableIRQ(LCD_DMA_Stream_IRQn);
|
||||
}
|
||||
|
||||
#if defined(PCBX7D)
|
||||
void lcdStart()
|
||||
{
|
||||
lcdWriteCommand(0xe2); // (14) Soft reset
|
||||
lcdWriteCommand(0xa0); // Set seg direct
|
||||
lcdWriteCommand(0xc8); // Set com direct
|
||||
lcdWriteCommand(0xf8); // Set booster
|
||||
lcdWriteCommand(0x00); // 5x
|
||||
lcdWriteCommand(0xa3); // Set bias=1/6
|
||||
lcdWriteCommand(0x22); // Set internal rb/ra=5.0
|
||||
lcdWriteCommand(0x2f); // All built-in power circuits on
|
||||
lcdWriteCommand(0x81); // Set contrast
|
||||
lcdWriteCommand(0x36); // Set Vop
|
||||
lcdWriteCommand(0xa6); // Set display mode
|
||||
}
|
||||
#else
|
||||
void lcdStart()
|
||||
{
|
||||
lcdWriteCommand(0x2F); // Internal pump control
|
||||
@@ -139,11 +159,12 @@ void lcdWriteAddress(uint8_t x, uint8_t y)
|
||||
lcdWriteCommand((y&0x0F) | 0x60); // Set Row Address LSB RA [3:0]
|
||||
lcdWriteCommand(((y>>4) & 0x0F) | 0x70); // Set Row Address MSB RA [7:4]
|
||||
}
|
||||
#endif
|
||||
|
||||
volatile bool lcd_busy;
|
||||
|
||||
#if !defined(LCD_DUAL_BUFFER)
|
||||
void lcdRefreshWait()
|
||||
void lcdRefreshWait()
|
||||
{
|
||||
WAIT_FOR_DMA_END();
|
||||
}
|
||||
@@ -155,6 +176,29 @@ void lcdRefresh(bool wait)
|
||||
lcdInitFinish();
|
||||
}
|
||||
|
||||
#if defined(PCBX7D)
|
||||
uint8_t * p = displayBuf;
|
||||
for (uint8_t y=0; y < 8; y++, p+=LCD_W) {
|
||||
lcdWriteCommand(0x10); // Column addr 0
|
||||
lcdWriteCommand(0xB0 | y); // Page addr y
|
||||
lcdWriteCommand(0x00);
|
||||
|
||||
LCD_NCS_LOW();
|
||||
LCD_A0_HIGH();
|
||||
|
||||
lcd_busy = true;
|
||||
LDC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
LCD_DMA->HIFCR = LCD_DMA_FLAGS; // Write ones to clear bits
|
||||
LDC_DMA_Stream->M0AR = (uint32_t)p;
|
||||
LDC_DMA_Stream->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA & TC interrupts
|
||||
LCD_SPI->CR2 |= SPI_CR2_TXDMAEN;
|
||||
|
||||
WAIT_FOR_DMA_END();
|
||||
|
||||
LCD_NCS_HIGH();
|
||||
LCD_A0_HIGH();
|
||||
}
|
||||
#else
|
||||
// Wait if previous DMA transfer still active
|
||||
WAIT_FOR_DMA_END();
|
||||
lcd_busy = true;
|
||||
@@ -175,6 +219,7 @@ void lcdRefresh(bool wait)
|
||||
|
||||
LDC_DMA_Stream->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA & TC interrupts
|
||||
LCD_SPI->CR2 |= SPI_CR2_TXDMAEN;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void LCD_DMA_Stream_IRQHandler()
|
||||
@@ -186,8 +231,8 @@ extern "C" void LCD_DMA_Stream_IRQHandler()
|
||||
LCD_SPI->CR2 &= ~SPI_CR2_TXDMAEN;
|
||||
LDC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
|
||||
while ( LCD_SPI->SR & SPI_SR_BSY ) {
|
||||
/* Wait for SPI to finish sending data
|
||||
while (LCD_SPI->SR & SPI_SR_BSY) {
|
||||
/* Wait for SPI to finish sending data
|
||||
The DMA TX End interrupt comes two bytes before the end of SPI transmission,
|
||||
therefore we have to wait here.
|
||||
*/
|
||||
@@ -204,18 +249,22 @@ void lcdOff()
|
||||
{
|
||||
WAIT_FOR_DMA_END();
|
||||
|
||||
/*
|
||||
/*
|
||||
LCD Sleep mode is also good for draining capacitors and enables us
|
||||
to re-init LCD without any delay
|
||||
*/
|
||||
lcdWriteCommand(0xAE); //LCD sleep
|
||||
delay_ms(3); //wait for caps to drain
|
||||
lcdWriteCommand(0xAE); // LCD sleep
|
||||
delay_ms(3); // Wait for caps to drain
|
||||
}
|
||||
|
||||
void lcdReset()
|
||||
{
|
||||
LCD_RST_LOW();
|
||||
delay_ms(1); // only 3 us needed according to data-sheet, we use 1 ms
|
||||
#if defined(PCBX7D)
|
||||
delay_ms(150);
|
||||
#else
|
||||
delay_ms(1); // Only 3 us needed according to data-sheet, we use 1 ms
|
||||
#endif
|
||||
LCD_RST_HIGH();
|
||||
}
|
||||
|
||||
@@ -236,7 +285,7 @@ void lcdInit()
|
||||
}
|
||||
|
||||
/*
|
||||
Finishes LCD initialization. It is called auto-magically when first LCD command is
|
||||
Finishes LCD initialization. It is called auto-magically when first LCD command is
|
||||
issued by the other parts of the code.
|
||||
*/
|
||||
void lcdInitFinish()
|
||||
@@ -244,19 +293,19 @@ void lcdInitFinish()
|
||||
lcdInitFinished = true;
|
||||
|
||||
/*
|
||||
LCD needs longer time to initialize in low temperatures. The data-sheet
|
||||
mentions a time of at least 150 ms. The delay of 1300 ms was obtained
|
||||
LCD needs longer time to initialize in low temperatures. The data-sheet
|
||||
mentions a time of at least 150 ms. The delay of 1300 ms was obtained
|
||||
experimentally. It was tested down to -10 deg Celsius.
|
||||
|
||||
The longer initialization time seems to only be needed for regular Taranis,
|
||||
The longer initialization time seems to only be needed for regular Taranis,
|
||||
the Taranis Plus (9XE) has been tested to work without any problems at -18 deg Celsius.
|
||||
Therefore the delay for T+ is lower.
|
||||
|
||||
If radio is reset by watchdog or boot-loader the wait is skipped, but the LCD
|
||||
is initialized in any case.
|
||||
is initialized in any case.
|
||||
|
||||
This initialization is needed in case the user moved power switch to OFF and
|
||||
then immediately to ON position, because lcdOff() was called. In any case the LCD
|
||||
This initialization is needed in case the user moved power switch to OFF and
|
||||
then immediately to ON position, because lcdOff() was called. In any case the LCD
|
||||
initialization (without reset) is also recommended by the data sheet.
|
||||
*/
|
||||
|
||||
@@ -279,8 +328,10 @@ void lcdSetRefVolt(uint8_t val)
|
||||
lcdInitFinish();
|
||||
}
|
||||
|
||||
#if !defined(PCBX7D)
|
||||
WAIT_FOR_DMA_END();
|
||||
|
||||
lcdWriteCommand(0x81); // Set Vop
|
||||
lcdWriteCommand(val+CONTRAST_OFS); // 0-255
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void ledInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = LED_GREEN_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(LED_GREEN_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = LED_RED_GPIO_PIN;
|
||||
GPIO_Init(LED_RED_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = LED_BLUE_GPIO_PIN;
|
||||
GPIO_Init(LED_BLUE_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void ledOff()
|
||||
{
|
||||
GPIO_ResetBits(LED_RED_GPIO, LED_RED_GPIO_PIN);
|
||||
GPIO_ResetBits(LED_BLUE_GPIO, LED_BLUE_GPIO_PIN);
|
||||
GPIO_ResetBits(LED_GREEN_GPIO, LED_GREEN_GPIO_PIN);
|
||||
}
|
||||
|
||||
void ledRed()
|
||||
{
|
||||
ledOff();
|
||||
GPIO_SetBits(LED_RED_GPIO, LED_RED_GPIO_PIN);
|
||||
}
|
||||
|
||||
void ledGreen()
|
||||
{
|
||||
ledOff();
|
||||
GPIO_SetBits(LED_GREEN_GPIO, LED_GREEN_GPIO_PIN);
|
||||
}
|
||||
|
||||
void ledBlue()
|
||||
{
|
||||
ledOff();
|
||||
GPIO_SetBits(LED_BLUE_GPIO, LED_BLUE_GPIO_PIN);
|
||||
}
|
||||
@@ -39,6 +39,25 @@ void extmoduleCrossfireStart(void);
|
||||
|
||||
void intmoduleSendNextFrame();
|
||||
|
||||
void modulesInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(INTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(EXTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_DETECT_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(TRAINER_DETECT_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void init_pxx(uint32_t port)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
|
||||
@@ -38,21 +38,6 @@ void pwrInit()
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
// TODO not here
|
||||
GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(INTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(EXTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_DETECT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(TRAINER_GPIO_DETECT, &GPIO_InitStructure);
|
||||
|
||||
pwrOn();
|
||||
}
|
||||
|
||||
@@ -66,12 +51,12 @@ void pwrOff()
|
||||
GPIO_ResetBits(PWR_GPIO, PWR_ON_GPIO_PIN);
|
||||
|
||||
// disable interrupts
|
||||
__disable_irq();
|
||||
__disable_irq();
|
||||
|
||||
while(1) {
|
||||
while (1) {
|
||||
wdt_reset();
|
||||
#if defined(PCBX9E)
|
||||
// 9E needs watchdog reset because CPU is still running while
|
||||
#if defined(PWR_PRESS_BUTTON)
|
||||
// X9E/X7D needs watchdog reset because CPU is still running while
|
||||
// the power key is held pressed by the user.
|
||||
// The power key should be released by now, but we must make sure
|
||||
if (!pwrPressed()) {
|
||||
@@ -90,7 +75,7 @@ void pwrOff()
|
||||
// this function must not return!
|
||||
}
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#if defined(PWR_PRESS_BUTTON)
|
||||
uint32_t pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
@@ -100,9 +85,6 @@ uint32_t pwroffPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) != Bit_RESET;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBX9E)
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
if (!pwroffPressed())
|
||||
@@ -171,6 +171,7 @@ extern "C" void TELEMETRY_USART_IRQHandler(void)
|
||||
// TODO we should have telemetry in an higher layer, functions above should move to a sport_driver.cpp
|
||||
int telemetryGetByte(uint8_t * byte)
|
||||
{
|
||||
#if defined(SERIAL2)
|
||||
if (telemetryProtocol == PROTOCOL_FRSKY_D_SECONDARY) {
|
||||
if (serial2Mode == UART_MODE_TELEMETRY)
|
||||
return serial2RxFifo.pop(*byte);
|
||||
@@ -180,4 +181,7 @@ int telemetryGetByte(uint8_t * byte)
|
||||
else {
|
||||
return telemetryFifo.pop(*byte);
|
||||
}
|
||||
#else
|
||||
return telemetryFifo.pop(*byte);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ void trainerSendNextFrame();
|
||||
|
||||
void init_trainer_ppm()
|
||||
{
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_GPIO_PinSource_OUT, TRAINER_GPIO_AF);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_OUT_GPIO_PinSource, TRAINER_GPIO_AF);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_OUT;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_OUT_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
@@ -66,10 +66,10 @@ void stop_trainer_ppm()
|
||||
|
||||
void init_trainer_capture()
|
||||
{
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_GPIO_PinSource_IN, TRAINER_GPIO_AF);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, TRAINER_IN_GPIO_PinSource, TRAINER_GPIO_AF);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_IN;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_IN_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
@@ -261,8 +261,10 @@ int sbusGetByte(uint8_t * byte)
|
||||
switch (currentTrainerMode) {
|
||||
case TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE:
|
||||
return heartbeatFifo.pop(*byte);
|
||||
#if defined(SERIAL2)
|
||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||
return serial2RxFifo.pop(*byte);
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user