1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-20 14:55:09 +03:00

Now bootloader OK on Taranis

This commit is contained in:
bsongis 2014-03-12 16:06:13 +01:00
parent 4e6def3ba3
commit 68c270760c
9 changed files with 123 additions and 151 deletions

View file

@ -1097,14 +1097,16 @@ all: begin gccversion sizebefore build sizeafter end
# Change the build target to build a HEX file or a library. # Change the build target to build a HEX file or a library.
ifeq ($(ARCH), AVR) ifeq ($(ARCH), AVR)
build: stamp_header tra lbm allsrc.cpp elf remallsrc hex build: stamp_header tra lbm allsrc.cpp elf remallsrc hex
else else ifeq ($(PCB), TARANIS)
build: stamp_header tra lbm bootloader.lbm allsrc.cpp elf remallsrc bin build: stamp_header tra lbm bootloader.lbm allsrc.cpp elf remallsrc bin
else
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
endif endif
# build bootloader # build bootloader
.PHONY bootloader.lbm: .PHONY bootloader.lbm:
@echo "Building bootloader..." @echo "Building bootloader..."
$(MAKE) -C bootloader PCB=TARANIS $(MAKE) -C bootloader PCB=$(PCB) PCBREV=$(PCBREV)
$(BIN2LBM) bootloader.lbm bootloader/bootloader_ramBoot.bin $(BIN2LBM) bootloader.lbm bootloader/bootloader_ramBoot.bin
tra: translations/en.h translations/cz.h translations/de.h translations/es.h translations/fi.h translations/fr.h translations/it.h translations/pl.h translations/pt.h translations/se.h tra: translations/en.h translations/cz.h translations/de.h translations/es.h translations/fi.h translations/fr.h translations/it.h translations/pl.h translations/pt.h translations/se.h

View file

@ -70,6 +70,9 @@ RUN_FROM_FLASH = 0
endif endif
endif endif
# PCB revision
PCBREV =
EXTRAINCDIRS = EXTRAINCDIRS =
# #
@ -90,6 +93,14 @@ ifeq ($(RUN_FROM_FLASH), 1)
TRGT = arm-none-eabi- TRGT = arm-none-eabi-
CPPDEFS += -DPCBSKY CPPDEFS += -DPCBSKY
UDEFS = -Dat91sam3s8 UDEFS = -Dat91sam3s8
# If REVX board
ifeq ($(REVX), 1)
CPPDEFS += -DREVX
endif
CPPDEFS += -DREVB
else else
ifeq ($(PCB), TARANIS) ifeq ($(PCB), TARANIS)
ARCH = ARM ARCH = ARM
@ -105,6 +116,15 @@ else
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc
EXTRAINCDIRS += ../targets/taranis EXTRAINCDIRS += ../targets/taranis
EXTRAINCDIRS += ../fonts/std EXTRAINCDIRS += ../fonts/std
ifeq ($(PCBREV), REV3)
CPPDEFS += -DREV3
else ifeq ($(PCBREV), REV4a)
CPPDEFS += -DREV4a
else
CPPDEFS += -DREV4
endif
endif endif
endif endif
@ -240,16 +260,9 @@ COBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CXOBJS) ))
CPPOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CPPXOBJS) )) CPPOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CPPXOBJS) ))
DIRS = $(sort $(dir $(AXOBJS) $(CXOBJS) $(CPPXOBJS) ) ) DIRS = $(sort $(dir $(AXOBJS) $(CXOBJS) $(CPPXOBJS) ) )
# If REVX board
ifeq ($(REVX), 1)
CPPDEFS += -DREVX
EXT_MOD=REVB-X
endif
CPPDEFS += -DCPUARM CPPDEFS += -DCPUARM
CPPDEFS += -DREVB
# If serial Debug required # If serial Debug required
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
CPPDEFS += -DDEBUG CPPDEFS += -DDEBUG

View file

@ -49,7 +49,7 @@
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
* Headers * Headers
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -111,7 +111,6 @@ volatile uint8_t Tenms ;
uint8_t EE_timer ; uint8_t EE_timer ;
TCHAR FlashFilename[60] ; TCHAR FlashFilename[60] ;
FATFS g_FATFS ;
FIL FlashFile ; FIL FlashFile ;
DIR Dj ; DIR Dj ;
FILINFO Finfo ; FILINFO Finfo ;
@ -194,7 +193,7 @@ uint32_t isFirmwareStart( uint32_t *block )
{ {
return 0 ; return 0 ;
} }
return 1 ; return 1 ;
} }
#endif #endif
@ -213,7 +212,7 @@ uint32_t isFirmwareStart( uint32_t *block )
{ {
return 0 ; return 0 ;
} }
return 1 ; return 1 ;
} }
#endif #endif
@ -253,16 +252,16 @@ uint32_t program( uint32_t *address, uint32_t *buffer ) // size is 256 bytes
FlashSectorNum = (uint32_t) address ; FlashSectorNum = (uint32_t) address ;
FlashSectorNum >>= 8 ; // page size is 256 bytes FlashSectorNum >>= 8 ; // page size is 256 bytes
FlashSectorNum &= 2047 ; // max page number FlashSectorNum &= 2047 ; // max page number
/* Send data to the sector here */ /* Send data to the sector here */
for ( i = 0 ; i < 64 ; i += 1 ) for ( i = 0 ; i < 64 ; i += 1 )
{ {
*address++ = *buffer++ ; *address++ = *buffer++ ;
} }
/* build the command to send to EEFC */ /* build the command to send to EEFC */
flash_cmd = (0x5A << 24) | (FlashSectorNum << 8) | 0x03 ; //AT91C_MC_FCMD_EWP ; flash_cmd = (0x5A << 24) | (FlashSectorNum << 8) | 0x03 ; //AT91C_MC_FCMD_EWP ;
__disable_irq() ; __disable_irq() ;
/* Call the IAP function with appropriate command */ /* Call the IAP function with appropriate command */
i = IAP_Function( 0, flash_cmd ) ; i = IAP_Function( 0, flash_cmd ) ;
@ -275,7 +274,7 @@ uint32_t readLockBits()
{ {
// Always initialise this here, setting a default doesn't seem to work // Always initialise this here, setting a default doesn't seem to work
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008) ; IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008) ;
uint32_t flash_cmd = (0x5A << 24) | 0x0A ; //AT91C_MC_FCMD_GLB ; uint32_t flash_cmd = (0x5A << 24) | 0x0A ; //AT91C_MC_FCMD_GLB ;
__disable_irq() ; __disable_irq() ;
(void) IAP_Function( 0, flash_cmd ) ; (void) IAP_Function( 0, flash_cmd ) ;
@ -298,7 +297,7 @@ void clearLockBits()
/* Call the IAP function with appropriate command */ /* Call the IAP function with appropriate command */
(void) IAP_Function( 0, flash_cmd ) ; (void) IAP_Function( 0, flash_cmd ) ;
__enable_irq() ; __enable_irq() ;
} }
} }
#endif #endif
@ -335,7 +334,7 @@ void init10msTimer()
ptc->TC_CHANNEL[2].TC_CMR = 0x0009C003 ; // 0000 0000 0000 1001 1100 0000 0000 0011 ptc->TC_CHANNEL[2].TC_CMR = 0x0009C003 ; // 0000 0000 0000 1001 1100 0000 0000 0011
// MCK/128, set @ RA, Clear @ RC waveform // MCK/128, set @ RA, Clear @ RC waveform
ptc->TC_CHANNEL[2].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger) ptc->TC_CHANNEL[2].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
NVIC_EnableIRQ(TC2_IRQn) ; NVIC_EnableIRQ(TC2_IRQn) ;
TC0->TC_CHANNEL[2].TC_IER = TC_IER0_CPCS ; TC0->TC_CHANNEL[2].TC_IER = TC_IER0_CPCS ;
} }
@ -349,7 +348,7 @@ extern "C" void TC2_IRQHandler()
(void) dummy ; // Discard value - prevents compiler warning (void) dummy ; // Discard value - prevents compiler warning
interrupt10ms() ; interrupt10ms() ;
} }
#endif #endif
@ -360,7 +359,7 @@ void init10msTimer()
RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock
TIM14->ARR = 9999 ; // 10mS TIM14->ARR = 9999 ; // 10mS
TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 12MHz TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 12MHz
TIM14->CCER = 0 ; TIM14->CCER = 0 ;
TIM14->CCMR1 = 0 ; TIM14->CCMR1 = 0 ;
TIM14->EGR = 0 ; TIM14->EGR = 0 ;
TIM14->CR1 = 5 ; TIM14->CR1 = 5 ;
@ -380,7 +379,7 @@ void init_hw_timer()
RCC->APB1ENR |= RCC_APB1ENR_TIM13EN ; // Enable clock RCC->APB1ENR |= RCC_APB1ENR_TIM13EN ; // Enable clock
TIM13->ARR = 65535 ; TIM13->ARR = 65535 ;
TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000000 - 1 ; // 0.1uS from 12MHz TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000000 - 1 ; // 0.1uS from 12MHz
TIM13->CCER = 0 ; TIM13->CCER = 0 ;
TIM13->CCMR1 = 0 ; TIM13->CCMR1 = 0 ;
TIM13->EGR = 0 ; TIM13->EGR = 0 ;
TIM13->CR1 = 1 ; TIM13->CR1 = 1 ;
@ -432,13 +431,13 @@ void eraseSector( uint32_t sector )
FLASH->CR &= SECTOR_MASK; FLASH->CR &= SECTOR_MASK;
FLASH->CR |= FLASH_CR_SER | (sector<<3) ; FLASH->CR |= FLASH_CR_SER | (sector<<3) ;
FLASH->CR |= FLASH_CR_STRT; FLASH->CR |= FLASH_CR_STRT;
/* Wait for operation to be completed */ /* Wait for operation to be completed */
waitFlashIdle() ; waitFlashIdle() ;
/* if the erase operation is completed, disable the SER Bit */ /* if the erase operation is completed, disable the SER Bit */
FLASH->CR &= (~FLASH_CR_SER); FLASH->CR &= (~FLASH_CR_SER);
FLASH->CR &= SECTOR_MASK; FLASH->CR &= SECTOR_MASK;
} }
uint32_t program( uint32_t *address, uint32_t *buffer ) // size is 256 bytes uint32_t program( uint32_t *address, uint32_t *buffer ) // size is 256 bytes
@ -488,25 +487,25 @@ uint32_t program( uint32_t *address, uint32_t *buffer ) // size is 256 bytes
} }
// Now program the 256 bytes // Now program the 256 bytes
for (i = 0 ; i < 64 ; i += 1 ) for (i = 0 ; i < 64 ; i += 1 )
{ {
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by word */ be done by word */
// Wait for last operation to be completed // Wait for last operation to be completed
waitFlashIdle() ; waitFlashIdle() ;
FLASH->CR &= CR_PSIZE_MASK; FLASH->CR &= CR_PSIZE_MASK;
FLASH->CR |= FLASH_PSIZE_WORD; FLASH->CR |= FLASH_PSIZE_WORD;
FLASH->CR |= FLASH_CR_PG; FLASH->CR |= FLASH_CR_PG;
*address = *buffer ; *address = *buffer ;
/* Wait for operation to be completed */ /* Wait for operation to be completed */
waitFlashIdle() ; waitFlashIdle() ;
FLASH->CR &= (~FLASH_CR_PG); FLASH->CR &= (~FLASH_CR_PG);
/* Check the written value */ /* Check the written value */
if ( *address != *buffer ) if ( *address != *buffer )
{ {
@ -530,7 +529,7 @@ uint8_t *cpystr( uint8_t *dest, uint8_t *source )
return dest - 1 ; return dest - 1 ;
} }
FRESULT readBinDir( DIR *dj, FILINFO *fno ) FRESULT readBinDir( DIR *dj, FILINFO *fno )
{ {
FRESULT fr ; FRESULT fr ;
@ -621,7 +620,7 @@ FRESULT openFirmwareFile( uint32_t index )
uint8_t flashFile( uint32_t index ) uint8_t flashFile( uint32_t index )
{ {
FRESULT fr ; FRESULT fr ;
lcd_clear() ; lcd_clear() ;
lcd_putsLeft( 0, "\005Flash File" ) ; lcd_putsLeft( 0, "\005Flash File" ) ;
if ( Valid == 0 ) if ( Valid == 0 )
@ -630,7 +629,7 @@ uint8_t flashFile( uint32_t index )
// return 3 if invalid // return 3 if invalid
fr = openFirmwareFile( index ) ; fr = openFirmwareFile( index ) ;
fr = f_close( &FlashFile ) ; fr = f_close( &FlashFile ) ;
Valid = 1 ; Valid = 1 ;
if ( isFirmwareStart( Block_buffer ) == 0 ) if ( isFirmwareStart( Block_buffer ) == 0 )
{ {
@ -650,7 +649,7 @@ uint8_t flashFile( uint32_t index )
{ {
return 3 ; return 3 ;
} }
return 4 ; // return 4 ; //
} }
lcd_putsnAtt( 0, 2*FH, Filenames[index], DISPLAY_CHAR_WIDTH, 0 ) ; lcd_putsnAtt( 0, 2*FH, Filenames[index], DISPLAY_CHAR_WIDTH, 0 ) ;
@ -661,13 +660,13 @@ uint8_t flashFile( uint32_t index )
lcd_putsLeft( 6*FH,"\003[MENU]\013[EXIT]") ; lcd_putsLeft( 6*FH,"\003[MENU]\013[EXIT]") ;
lcd_putsLeft( 5*FH,"\003YES\013NO") ; lcd_putsLeft( 5*FH,"\003YES\013NO") ;
#endif #endif
uint8_t event = getEvent() ; uint8_t event = getEvent() ;
if ( event == EVT_KEY_FIRST(BOOT_KEY_MENU) ) if ( event == EVT_KEY_FIRST(BOOT_KEY_MENU) )
{ {
fr = openFirmwareFile( index ) ; fr = openFirmwareFile( index ) ;
FirmwareSize = FileSize[index] ; FirmwareSize = FileSize[index] ;
if ( fr != FR_OK ) if ( fr != FR_OK )
{ {
return 4 ; // File open error return 4 ; // File open error
@ -756,7 +755,7 @@ extern uint8_t OptrexDisplay ;
#ifdef PCBSKY #ifdef PCBSKY
uint32_t chip_id = CHIPID->CHIPID_CIDR ; uint32_t chip_id = CHIPID->CHIPID_CIDR ;
FlashSize = ( (chip_id >> 8 ) & 0x000F ) == 9 ? 256 : 512 ; FlashSize = ( (chip_id >> 8 ) & 0x000F ) == 9 ? 256 : 512 ;
#endif #endif
#ifdef PCBTARANIS #ifdef PCBTARANIS
@ -774,7 +773,6 @@ extern uint8_t OptrexDisplay ;
#ifdef PCBTARANIS #ifdef PCBTARANIS
// SD card detect pin // SD card detect pin
// configure_pins( SD_PRESENT_GPIO_Pin, PIN_PORTD | PIN_INPUT | PIN_PULLUP ) ; // configure_pins( SD_PRESENT_GPIO_Pin, PIN_PORTD | PIN_INPUT | PIN_PULLUP ) ;
disk_initialize( 0 ) ;
sdInit() ; sdInit() ;
unlockFlash() ; unlockFlash() ;
@ -787,7 +785,7 @@ extern uint8_t OptrexDisplay ;
#ifdef PCBSKY #ifdef PCBSKY
usbMassStorage() ; usbMassStorage() ;
#endif #endif
wdt_reset() ; wdt_reset() ;
if ( Tenms ) if ( Tenms )
@ -804,29 +802,18 @@ extern uint8_t OptrexDisplay ;
} }
} }
Tenms = 0 ; Tenms = 0;
lcd_clear() ; lcd_clear();
#ifdef PCBSKY lcd_putsLeft(0, CENTER "Boot Loader");
lcd_putsLeft( 0, "Boot Loader" ) ; lcd_invert_line(0);
#endif
#ifdef PCBTARANIS
lcd_putsLeft( 0, "\006Boot Loader" ) ;
#endif
if ( sdMounted() )
{ {
#ifdef PCBSKY
lcd_putsLeft( 0, "\014Ready" ) ;
#endif
#ifdef PCBTARANIS
lcd_putsLeft( 0, "\022Ready" ) ;
#endif
if ( usbPlugged() ) if ( usbPlugged() )
{ {
state = ST_USB ; state = ST_USB ;
} }
if ( state == ST_USB ) if ( state == ST_USB )
{ {
#ifdef PCBSKY #ifdef PCBSKY
@ -849,11 +836,12 @@ extern uint8_t OptrexDisplay ;
if ( state == ST_START ) if ( state == ST_START )
{ {
fr = f_mount(0, &g_FATFS) ; sdInit();
fr = FR_OK;
} }
else else
{ {
fr = FR_OK ; fr = FR_OK ;
} }
if ( fr == FR_OK) if ( fr == FR_OK)
@ -865,7 +853,7 @@ extern uint8_t OptrexDisplay ;
} }
if ( state == ST_DIR_CHECK ) if ( state == ST_DIR_CHECK )
{ {
fr = f_chdir( (TCHAR *)"\\firmware" ) ; fr = f_chdir("/firmware") ;
if ( fr == FR_OK ) if ( fr == FR_OK )
{ {
state = ST_OPEN_DIR ; state = ST_OPEN_DIR ;
@ -875,15 +863,15 @@ extern uint8_t OptrexDisplay ;
if ( state == ST_DIR_CHECK ) if ( state == ST_DIR_CHECK )
{ {
#ifdef PCBSKY #ifdef PCBSKY
lcd_putsLeft( 16, "\005No Firmware" ) ; lcd_putsLeft( 2*FH, "\005No Firmware" ) ;
#endif #endif
#ifdef PCBTARANIS #ifdef PCBTARANIS
lcd_putsLeft( 16, "\013No Firmware" ) ; lcd_putsLeft( 2*FH, "\013No Firmware" ) ;
#endif #endif
} }
if ( state == ST_OPEN_DIR ) if ( state == ST_OPEN_DIR )
{ {
fr = f_opendir( &Dj, (TCHAR *) "." ) ; fr = f_opendir(&Dj, ".") ;
if ( fr == FR_OK ) if ( fr == FR_OK )
{ {
state = ST_FILE_LIST ; state = ST_FILE_LIST ;
@ -898,7 +886,7 @@ extern uint8_t OptrexDisplay ;
uint32_t limit = 6 ; uint32_t limit = 6 ;
if ( nameCount < limit ) if ( nameCount < limit )
{ {
limit = nameCount ; limit = nameCount ;
} }
maxhsize = 0 ; maxhsize = 0 ;
for ( i = 0 ; i < limit ; i += 1 ) for ( i = 0 ; i < limit ; i += 1 )
@ -907,7 +895,7 @@ extern uint8_t OptrexDisplay ;
x = strlen( Filenames[i] ) ; x = strlen( Filenames[i] ) ;
if ( x > maxhsize ) if ( x > maxhsize )
{ {
maxhsize = x ; maxhsize = x ;
} }
if ( x > DISPLAY_CHAR_WIDTH ) if ( x > DISPLAY_CHAR_WIDTH )
{ {
@ -963,14 +951,14 @@ extern uint8_t OptrexDisplay ;
{ {
if ( hpos + DISPLAY_CHAR_WIDTH < maxhsize ) if ( hpos + DISPLAY_CHAR_WIDTH < maxhsize )
{ {
hpos += 1 ; hpos += 1 ;
} }
} }
if ( ( event == EVT_KEY_REPT(BOOT_KEY_LEFT)) || ( event == EVT_KEY_FIRST(BOOT_KEY_LEFT) ) ) if ( ( event == EVT_KEY_REPT(BOOT_KEY_LEFT)) || ( event == EVT_KEY_FIRST(BOOT_KEY_LEFT) ) )
{ {
if ( hpos ) if ( hpos )
{ {
hpos -= 1 ; hpos -= 1 ;
} }
} }
if ( event == EVT_KEY_LONG(BOOT_KEY_MENU) ) if ( event == EVT_KEY_LONG(BOOT_KEY_MENU) )
@ -984,7 +972,7 @@ extern uint8_t OptrexDisplay ;
state = ST_REBOOT ; state = ST_REBOOT ;
} }
} }
lcd_invert_line(2*FH+FH*vpos); lcd_invert_line(2+vpos);
// lcd_char_inverse( 0, 2*FH+FH*vpos, DISPLAY_CHAR_WIDTH*FW, 0 ) ; // lcd_char_inverse( 0, 2*FH+FH*vpos, DISPLAY_CHAR_WIDTH*FW, 0 ) ;
} }
if ( state == ST_FLASH_CHECK ) if ( state == ST_FLASH_CHECK )
@ -993,7 +981,7 @@ extern uint8_t OptrexDisplay ;
FirmwareSize = FileSize[vpos] - 32768 ; FirmwareSize = FileSize[vpos] - 32768 ;
if ( i == 1 ) if ( i == 1 )
{ {
state = ST_FILE_LIST ; // Canceled state = ST_FILE_LIST ; // Canceled
} }
if ( i == 2 ) if ( i == 2 )
{ {
@ -1009,7 +997,7 @@ extern uint8_t OptrexDisplay ;
if ( i == 3 ) if ( i == 3 )
{ {
// Invalid file // Invalid file
state = ST_FILE_LIST ; // Canceled state = ST_FILE_LIST ; // Canceled
} }
} }
if ( state == ST_FLASHING ) if ( state == ST_FLASHING )
@ -1024,7 +1012,7 @@ extern uint8_t OptrexDisplay ;
firmwareAddress += 256 ; firmwareAddress += 256 ;
if ( BlockCount > 256 ) if ( BlockCount > 256 )
{ {
BlockCount -= 256 ; BlockCount -= 256 ;
} }
else else
{ {
@ -1061,37 +1049,29 @@ extern uint8_t OptrexDisplay ;
} }
} }
#ifdef PCBTARANIS if ( --TenCount == 0 ) {
if ( --TenCount == 0 ) TenCount = 2 ;
{ lcdRefresh() ;
TenCount = 2 ;
#endif
lcdRefresh() ;
#ifdef PCBTARANIS
} }
#endif
if ( PowerUpDelay < 20 ) // 200 mS if ( PowerUpDelay < 20 ) // 200 mS
{ {
PowerUpDelay += 1 ; PowerUpDelay += 1 ;
} }
else else
{ {
#ifdef PCBSKY
sd_poll_10mS() ;
#endif
#ifdef PCBTARANIS
sdPoll10ms() ; sdPoll10ms() ;
#endif
} }
} }
if ((state < ST_FLASH_CHECK) || (state == ST_FLASH_DONE)) if ((state < ST_FLASH_CHECK) || (state == ST_FLASH_DONE))
{ {
if (pwrCheck() == e_power_off ) { if (pwrCheck() == e_power_off ) {
pwrOff() ; pwrOff() ;
for(;;) for(;;)
{ {
// Wait for power to go off // Wait for power to go off
} }
} }
} }
if ( state < ST_FILE_LIST ) if ( state < ST_FILE_LIST )
@ -1105,12 +1085,11 @@ extern uint8_t OptrexDisplay ;
{ {
if ( (~readKeys() & 0x7E) == 0 ) if ( (~readKeys() & 0x7E) == 0 )
{ {
NVIC_SystemReset() ; NVIC_SystemReset() ;
} }
} }
} }
// stop_timer0() ;
return 0; return 0;
} }

View file

@ -432,12 +432,8 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_CONTRAST: case ITEM_SETUP_CONTRAST:
lcd_putsLeft(y, STR_CONTRAST); lcd_putsLeft(y, STR_CONTRAST);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT);
if(attr) { if (attr) {
#if defined(PCBTARANIS) CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, CONTRAST_MIN, CONTRAST_MAX);
CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, 0, 45);
#else
CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, 10, 45);
#endif
lcdSetContrast(); lcdSetContrast();
} }
break; break;
@ -601,24 +597,16 @@ void menuGeneralSetup(uint8_t event)
#endif #endif
#if defined(MAVLINK) #if defined(MAVLINK)
case ITEM_MAVLINK_BAUD: case ITEM_MAVLINK_BAUD:
g_eeGeneral.mavbaud = selectMenuItem(RADIO_SETUP_2ND_COLUMN, //Y g_eeGeneral.mavbaud = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_MAVLINK_BAUD_LABEL, STR_MAVLINK_BAUDS, PSTR("4800""9600""14400""19200""38400""57600""76800""115200"), g_eeGeneral.mavbaud, 0, 7, attr, event);
y, // Y break;
STR_MAVLINK_BAUD_LABEL, // pm_char *label
STR_MAVLINK_BAUDS, // pm_char *values
// PSTR("4800""9600""14400""19200""38400""57600""76800""115200"),
g_eeGeneral.mavbaud, // value
0, // min
7, // max
attr, // attr
event); // event
break;
#endif #endif
case ITEM_SETUP_RX_CHANNEL_ORD: case ITEM_SETUP_RX_CHANNEL_ORD:
lcd_putsLeft(y, STR_RXCHANNELORD); // RAET->AETR lcd_putsLeft(y, STR_RXCHANNELORD); // RAET->AETR
for (uint8_t i=1; i<=4; i++) for (uint8_t i=1; i<=4; i++) {
putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channel_order(i), attr); putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channel_order(i), attr);
}
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23);
break; break;
@ -629,7 +617,9 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_STICK_MODE: case ITEM_SETUP_STICK_MODE:
lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr); lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr);
for (uint8_t i=0; i<4; i++) putsMixerSource((6+4*i)*FW, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0); for (uint8_t i=0; i<4; i++) {
putsMixerSource((6+4*i)*FW, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0);
}
if (attr && s_editMode>0) { if (attr && s_editMode>0) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3); CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3);
} }

View file

@ -43,12 +43,16 @@
#define xcoord_t uint16_t #define xcoord_t uint16_t
#define CENTER "\015" #define CENTER "\015"
#define CENTER_OFS (7*FW-FW/2) #define CENTER_OFS (7*FW-FW/2)
#define CONTRAST_MIN 0
#define CONTRAST_MAX 45
#else #else
#define LCD_W 128 #define LCD_W 128
#define LCD_H 64 #define LCD_H 64
#define xcoord_t uint8_t #define xcoord_t uint8_t
#define CENTER #define CENTER
#define CENTER_OFS 0 #define CENTER_OFS 0
#define CONTRAST_MIN 10
#define CONTRAST_MAX 45
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)

View file

@ -232,7 +232,7 @@ void SystemInit(void)
#ifdef VECT_TAB_SRAM #ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else #else
#if defined(BOOTLOADER) #if defined(BOOTLOADER) || defined(BOOT)
extern uint32_t g_pfnVectors ; extern uint32_t g_pfnVectors ;
SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */ SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */
#else #else

View file

@ -670,14 +670,23 @@ int8_t SD_ReadSectors(uint8_t *buff, uint32_t sector, uint32_t count)
{ {
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */ if (count == 1) { /* Single block read */
do { if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */
if (!rcvr_datablock(buff, 512)) { if (rcvr_datablock(buff, 512)) {
break; count = 0;
} }
buff += 512; }
} while (--count); }
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */ else { /* Multiple block read */
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
do {
if (!rcvr_datablock(buff, 512)) {
break;
}
buff += 512;
} while (--count);
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
}
} }
release_spi(); release_spi();
@ -695,29 +704,9 @@ DRESULT disk_read (
if (drv || !count) return RES_PARERR; if (drv || !count) return RES_PARERR;
if (Stat & STA_NOINIT) return RES_NOTRDY; if (Stat & STA_NOINIT) return RES_NOTRDY;
if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ SD_ReadSectors(buff, sector, count);
if (count == 1) { /* Single block read */ return RES_OK;
if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */
if (rcvr_datablock(buff, 512)) {
count = 0;
}
}
}
else { /* Multiple block read */
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
do {
if (!rcvr_datablock(buff, 512)) {
break;
}
buff += 512;
} while (--count);
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
}
}
release_spi();
return count ? RES_ERROR : RES_OK;
} }

View file

@ -13,7 +13,7 @@
#define WriteData(x) AspiData(x) #define WriteData(x) AspiData(x)
#define WriteCommand(x) AspiCmd(x) #define WriteCommand(x) AspiCmd(x)
#define CONTRAST_OFS 5 #define CONTRAST_OFS 5
static void LCD_Init() static void LCD_Init()
{ {
@ -22,9 +22,9 @@ static void LCD_Init()
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27 AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
AspiCmd(0x81); //Set Vop AspiCmd(0x81); //Set Vop
#if defined(BOOT) #if defined(BOOT)
AspiCmd(CONTRAST_OFS); AspiCmd(CONTRAST_OFS+25);
#else #else
AspiCmd(g_eeGeneral.contrast+CONTRAST_OFS); //0--255 AspiCmd(CONTRAST_OFS+g_eeGeneral.contrast);
#endif #endif
AspiCmd(0xA6); //inverse display off AspiCmd(0xA6); //inverse display off
AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB

View file

@ -203,14 +203,11 @@ int8_t STORAGE_Read (uint8_t lun,
uint16_t blk_len) uint16_t blk_len)
{ {
if (lun == 1) { if (lun == 1) {
if (fat12Read(buf, blk_addr, blk_len) != 0) { if (fat12Read(buf, blk_addr, blk_len) != 0)
return -1; return -1;
}
} }
else { else {
if (SD_ReadSectors(buf, if (SD_ReadSectors(buf, blk_addr, blk_len) != 0) {
blk_addr,
blk_len) != 0) {
return -1; return -1;
} }
} }
@ -238,9 +235,7 @@ int8_t STORAGE_Write (uint8_t lun,
return -1; return -1;
} }
else { else {
if (SD_WriteSectors(buf, if (SD_WriteSectors(buf, blk_addr, blk_len) != 0)
blk_addr,
blk_len) != 0)
return -1; return -1;
} }