Bsongis/gui refactoring for x7 d (#3701)
* [X7D] New board added * Cosmetics
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -1,56 +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"
|
||||
#if !defined(PCBX9E)
|
||||
#include "dwt.h" // the old ST library that we use does not define DWT register for STM32F2xx
|
||||
#endif
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
+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