diff --git a/radio/src/io/frsky_sport.cpp b/radio/src/io/frsky_sport.cpp index 6f8f7aaa6..8fa5cbe18 100644 --- a/radio/src/io/frsky_sport.cpp +++ b/radio/src/io/frsky_sport.cpp @@ -182,7 +182,7 @@ const char * sportUpdatePowerOn(ModuleIndex module) if (module == INTERNAL_MODULE) INTERNAL_MODULE_ON(); else - EXTERNAL_MODULE_ON(); + SPORT_UPDATE_POWER_ON(); #endif sportWaitState(SPORT_IDLE, 50); // Clear the fifo @@ -196,7 +196,8 @@ const char * sportUpdatePowerOn(ModuleIndex module) if (sportWaitState(SPORT_POWERUP_ACK, 100)) return NULL; } - return "Module not responding"; + + return TR("Not responding", "Module not responding"); } const char * sportUpdateReqVersion() @@ -305,7 +306,7 @@ void sportFlashDevice(ModuleIndex module, const char * filename) #if defined(PCBTARANIS) || defined(PCBHORUS) INTERNAL_MODULE_OFF(); - EXTERNAL_MODULE_OFF(); + SPORT_UPDATE_POWER_OFF(); #endif sportWaitState(SPORT_IDLE, 500); // Clear the fifo diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index f67807e92..f75d93f29 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -490,6 +490,10 @@ void telemetryPortSetDirectionOutput(void); void sportSendBuffer(uint8_t * buffer, uint32_t count); uint8_t telemetryGetByte(uint8_t * byte); +// Sport update driver +#define SPORT_UPDATE_POWER_ON() EXTERNAL_MODULE_ON() +#define SPORT_UPDATE_POWER_OFF() EXTERNAL_MODULE_OFF() + // Haptic driver void hapticInit(void); void hapticDone(void); diff --git a/radio/src/targets/taranis/board.cpp b/radio/src/targets/taranis/board.cpp index d9a5c7c46..a76073e2e 100644 --- a/radio/src/targets/taranis/board.cpp +++ b/radio/src/targets/taranis/board.cpp @@ -111,10 +111,39 @@ const pm_uchar bmp_lock[] PROGMEM = { }; #endif // defined(PCBX9E) && !defined(SIMU) +#if defined(PCBX7) +void sportUpdateInit() +{ + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_InitStructure.GPIO_Pin = SPORT_UPDATE_PWR_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(SPORT_UPDATE_PWR_GPIO, &GPIO_InitStructure); +} + +void sportUpdatePowerOn() +{ + if (IS_PCBREV_40()) + GPIO_SetBits(SPORT_UPDATE_PWR_GPIO, SPORT_UPDATE_PWR_GPIO_PIN); + else + EXTERNAL_MODULE_ON(); +} + +void sportUpdatePowerOff() +{ + if (IS_PCBREV_40()) + GPIO_ResetBits(SPORT_UPDATE_PWR_GPIO, SPORT_UPDATE_PWR_GPIO_PIN); + else + EXTERNAL_MODULE_OFF(); +} +#endif + void boardInit() { #if !defined(SIMU) - RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | KEYS_RCC_AHB1Periph | LCD_RCC_AHB1Periph | AUDIO_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph | ADC_RCC_AHB1Periph | I2C_RCC_AHB1Periph | SD_RCC_AHB1Periph | HAPTIC_RCC_AHB1Periph | INTMODULE_RCC_AHB1Periph | EXTMODULE_RCC_AHB1Periph | TELEMETRY_RCC_AHB1Periph | SERIAL_RCC_AHB1Periph | TRAINER_RCC_AHB1Periph | HEARTBEAT_RCC_AHB1Periph, ENABLE); + RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | PCBREV_RCC_AHB1Periph | KEYS_RCC_AHB1Periph | LCD_RCC_AHB1Periph | AUDIO_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph | ADC_RCC_AHB1Periph | I2C_RCC_AHB1Periph | SD_RCC_AHB1Periph | HAPTIC_RCC_AHB1Periph | INTMODULE_RCC_AHB1Periph | EXTMODULE_RCC_AHB1Periph | TELEMETRY_RCC_AHB1Periph | SPORT_UPDATE_RCC_AHB1Periph | SERIAL_RCC_AHB1Periph | TRAINER_RCC_AHB1Periph | HEARTBEAT_RCC_AHB1Periph, ENABLE); RCC_APB1PeriphClockCmd(LCD_RCC_APB1Periph | AUDIO_RCC_APB1Periph | BACKLIGHT_RCC_APB1Periph | INTERRUPT_5MS_APB1Periph | TIMER_2MHz_APB1Periph | I2C_RCC_APB1Periph | SD_RCC_APB1Periph | TRAINER_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph | SERIAL_RCC_APB1Periph, ENABLE); RCC_APB2PeriphClockCmd(BACKLIGHT_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph | EXTMODULE_RCC_APB2Periph | HEARTBEAT_RCC_APB2Periph, ENABLE); @@ -200,6 +229,13 @@ void boardInit() #else backlightInit(); #endif + +#if defined(PCBX7) + if (IS_PCBREV_40()) { + sportUpdateInit(); + } +#endif + #endif // !defined(SIMU) } diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index 4e40d8e1c..ff6cf2ebb 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -487,6 +487,22 @@ void sportSendBuffer(uint8_t * buffer, uint32_t count); uint8_t telemetryGetByte(uint8_t * byte); extern uint32_t telemetryErrors; +// PCBREV driver +#if defined(PCBX7) +#define IS_PCBREV_40() (GPIO_ReadInputDataBit(PCBREV_GPIO, PCBREV_GPIO_PIN) == Bit_SET) +#endif + +// Sport update driver +#if defined(PCBX7) +void sportUpdatePowerOn(void); +void sportUpdatePowerOff(void); +#define SPORT_UPDATE_POWER_ON() sportUpdatePowerOn() +#define SPORT_UPDATE_POWER_OFF() sportUpdatePowerOff() +#else +#define SPORT_UPDATE_POWER_ON() EXTERNAL_MODULE_ON() +#define SPORT_UPDATE_POWER_OFF() EXTERNAL_MODULE_OFF() +#endif + // Audio driver void audioInit(void) ; void audioEnd(void) ; diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 384453051..65cf327b3 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -551,6 +551,24 @@ #define TELEMETRY_USART_IRQHandler USART2_IRQHandler #define TELEMETRY_USART_IRQn USART2_IRQn +// PCBREV +#if defined(PCBX7) +#define PCBREV_RCC_AHB1Periph RCC_AHB1Periph_GPIOA +#define PCBREV_GPIO GPIOA +#define PCBREV_GPIO_PIN GPIO_Pin_14 // PA.14 +#else +#define PCBREV_RCC_AHB1Periph 0 +#endif + +// SPORT update connector +#if defined(PCBX7) +#define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOB +#define SPORT_UPDATE_PWR_GPIO GPIOB +#define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_2 // PB.02 +#else +#define SPORT_UPDATE_RCC_AHB1Periph 0 +#endif + // Heartbeat #define HEARTBEAT_RCC_AHB1Periph RCC_AHB1Periph_GPIOC #define HEARTBEAT_RCC_APB2Periph RCC_APB2Periph_USART6 diff --git a/radio/src/targets/taranis/pwr_driver.cpp b/radio/src/targets/taranis/pwr_driver.cpp index a53519238..10ad32558 100644 --- a/radio/src/targets/taranis/pwr_driver.cpp +++ b/radio/src/targets/taranis/pwr_driver.cpp @@ -47,7 +47,15 @@ void pwrInit() GPIO_InitStructure.GPIO_Pin = TRAINER_DETECT_GPIO_PIN; GPIO_Init(TRAINER_DETECT_GPIO, &GPIO_InitStructure); - + +#if defined(PCBX7) + // Init PCBREV PIN + GPIO_ResetBits(PCBREV_GPIO, PCBREV_GPIO_PIN); + GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; + GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure); +#endif + pwrOn(); }