From 445899b58bd7225a10f191081a82266824d3ecca Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 31 Dec 2013 11:05:55 +0100 Subject: [PATCH] [9XR-PRO] USB Bootloader fix --- radio/src/opentx.cpp | 24 +++++++++++++-------- radio/src/targets/sky9x/board_sky9x.cpp | 28 ++++++++++++++----------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 48843f784..44212e1f6 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -289,10 +289,24 @@ volatile tmr10ms_t g_tmr10ms; #if defined(CPUARM) volatile uint8_t rtc_count = 0; uint32_t watchdogTimeout = 0; + void watchdogSetTimeout(uint32_t timeout) { watchdogTimeout = timeout; } + +void opentxBootloader() +{ + BACKLIGHT_ON(); + + lcd_clear(); + lcd_putcAtt( 48, 24, 'U', DBLSIZE ) ; + lcd_putcAtt( 60, 24, 'S', DBLSIZE ) ; + lcd_putcAtt( 72, 24, 'B', DBLSIZE ) ; + lcdRefresh() ; + + usbBootloader(); +} #endif void per10ms() @@ -5066,15 +5080,7 @@ int main(void) g_eeGeneral.backlightBright = 0; g_eeGeneral.contrast = 25; - BACKLIGHT_ON(); - - lcd_clear(); - lcd_putcAtt( 48, 24, 'U', DBLSIZE ) ; - lcd_putcAtt( 60, 24, 'S', DBLSIZE ) ; - lcd_putcAtt( 72, 24, 'B', DBLSIZE ) ; - lcdRefresh() ; - - usbBootloader(); + opentxBootloader(); } CoInitOS(); diff --git a/radio/src/targets/sky9x/board_sky9x.cpp b/radio/src/targets/sky9x/board_sky9x.cpp index 5a50c20df..a873bb40b 100644 --- a/radio/src/targets/sky9x/board_sky9x.cpp +++ b/radio/src/targets/sky9x/board_sky9x.cpp @@ -529,6 +529,8 @@ void configure_pins( uint32_t pins, uint16_t config ) } } +void opentxBootloader(); + void boardInit() { register Pio *pioptr ; @@ -539,33 +541,35 @@ void boardInit() PMC->PMC_PCER0 = (1<PIO_PER = PIO_PC25 ; // Enable bit C25 (USB-detect) + +#if defined(REVX) + if (usbPlugged()) { + lcdInit() ; + opentxBootloader(); + } +#endif + #if defined(REVA) // On REVB, PA21 is used as AD8, and measures current consumption. pioptr = PIOA ; pioptr->PIO_PER = PIO_PA21 ; // Enable bit A21 (EXT3) pioptr->PIO_OER = PIO_PA21 ; // Set bit A21 as output pioptr->PIO_SODR = PIO_PA21 ; // Set bit A21 ON -#else - pwrInit() ; -#endif - // pioptr->PIO_PUER = 0x80000000 ; // Enable pullup on bit A31 (EXIT) - // pioptr->PIO_PER = 0x80000000 ; // Enable bit A31 - - pioptr = PIOC ; - pioptr->PIO_PER = PIO_PC25 ; // Enable bit C25 (USB-detect) - // pioptr->PIO_OER = 0x80000000L ; // Set bit C31 as output - // pioptr->PIO_SODR = 0x80000000L ; // Set bit C31 - -#if defined(REVA) // Configure RF_power (PC17) and PPM-jack-in (PC19), neither need pullups pioptr->PIO_PER = 0x000A0000L ; // Enable bit C19, C17 pioptr->PIO_ODR = 0x000A0000L ; // Set bits C19 and C17 as input #endif +#if !defined(REVA) + pwrInit() ; +#endif + config_free_pins() ; // Next section configures the key inputs on the LCD data + pioptr = PIOC; #if defined(REVA) pioptr->PIO_PER = 0x0000003DL ; // Enable bits 2,3,4,5, 0 pioptr->PIO_OER = PIO_PC0 ; // Set bit 0 output