diff --git a/radio/bootloader/Makefile b/radio/bootloader/Makefile index 886d06bb2..9f406db8b 100644 --- a/radio/bootloader/Makefile +++ b/radio/bootloader/Makefile @@ -105,6 +105,7 @@ else EXTRAINCDIRS += ../src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc EXTRAINCDIRS += ../src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc EXTRAINCDIRS += ../src/targets/taranis + EXTRAINCDIRS += ../src/fonts/std endif endif @@ -137,14 +138,15 @@ SRC = system_stm32f2xx.c \ ../src/targets/taranis/aspi.c \ ../src/targets/taranis/usb_bsp.c -CPPSRC = lcd_driver.cpp \ +CPPSRC = ../src/targets/taranis/lcd_driver.cpp \ driversboot.cpp \ logicioboot.cpp \ ff.cpp \ ../src/targets/taranis/diskio.cpp \ ../src/targets/taranis/usbd_usr.cpp \ usbd_storage_msd.cpp \ - lcdboot.cpp \ + ../src/lcd.cpp \ + ../src/translations.cpp \ power.cpp \ boot.cpp diff --git a/radio/bootloader/boot.cpp b/radio/bootloader/boot.cpp index 1c3dd2673..b8a186455 100644 --- a/radio/bootloader/boot.cpp +++ b/radio/bootloader/boot.cpp @@ -63,7 +63,7 @@ #include "stm32f2xx_flash.h" #include "../src/targets/taranis/i2c.h" #include "hal.h" -#include "timers.h" +// #include "timers.h" extern "C" { #include "usb_dcd_int.h" @@ -75,8 +75,11 @@ extern "C" { #endif +#include "board_taranis.h" +#include "../src/lcd.h" + #include "radio.h" -#include "lcd.h" +// #include "lcd.h" #include "ff.h" #include "diskio.h" #include "drivers.h" @@ -405,7 +408,7 @@ void init10msTimer() // Timer14 RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock TIM14->ARR = 9999 ; // 10mS - TIM14->PSC = (Peri1_frequency*Timer_mult1) / 1000000 - 1 ; // 1uS from 12MHz + TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 12MHz TIM14->CCER = 0 ; TIM14->CCMR1 = 0 ; TIM14->EGR = 0 ; @@ -425,7 +428,7 @@ void init_hw_timer() // Timer13 RCC->APB1ENR |= RCC_APB1ENR_TIM13EN ; // Enable clock TIM13->ARR = 65535 ; - TIM13->PSC = (Peri1_frequency*Timer_mult1) / 10000000 - 1 ; // 0.1uS from 12MHz + TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000000 - 1 ; // 0.1uS from 12MHz TIM13->CCER = 0 ; TIM13->CCMR1 = 0 ; TIM13->EGR = 0 ; @@ -669,7 +672,7 @@ uint8_t flashFile( uint32_t index ) FRESULT fr ; lcd_clear() ; - lcd_puts_Pleft( 0, "\005Flash File" ) ; + lcd_putsLeft( 0, "\005Flash File" ) ; if ( Valid == 0 ) { // Validate file here @@ -685,11 +688,11 @@ uint8_t flashFile( uint32_t index ) } if ( Valid == 2 ) { - lcd_puts_Pleft( 3*FH,"NOT A VALID FIRMWARE") ; + lcd_putsLeft( 3*FH,"NOT A VALID FIRMWARE") ; #ifdef PCBTARANIS - lcd_puts_Pleft( 6*FH,"\015[EXIT]") ; + lcd_putsLeft( 6*FH,"\015[EXIT]") ; #else - lcd_puts_Pleft( 6*FH,"\007[EXIT]") ; + lcd_putsLeft( 6*FH,"\007[EXIT]") ; #endif uint8_t event = getEvent() ; if ( event == EVT_KEY_FIRST(BOOT_KEY_EXIT) ) @@ -698,14 +701,14 @@ uint8_t flashFile( uint32_t index ) } return 4 ; // } - lcd_putsn_P( 0, 2*FH, Filenames[index], DISPLAY_CHAR_WIDTH ) ; + lcd_putsnAtt( 0, 2*FH, Filenames[index], DISPLAY_CHAR_WIDTH, 0 ) ; #ifdef PCBTARANIS - lcd_puts_Pleft( 6*FH,"\010[ENTER]\021[EXIT]") ; - lcd_puts_Pleft( 5*FH,"\010YES\021NO") ; + lcd_putsLeft( 6*FH,"\010[ENTER]\021[EXIT]") ; + lcd_putsLeft( 5*FH,"\010YES\021NO") ; #else - lcd_puts_Pleft( 6*FH,"\003[MENU]\013[EXIT]") ; - lcd_puts_Pleft( 5*FH,"\003YES\013NO") ; + lcd_putsLeft( 6*FH,"\003[MENU]\013[EXIT]") ; + lcd_putsLeft( 5*FH,"\003YES\013NO") ; #endif uint8_t event = getEvent() ; @@ -770,19 +773,19 @@ int main() start_timer0() ; #endif - lcd_init() ; + lcdInit() ; #ifdef PCBSKY extern uint8_t OptrexDisplay ; OptrexDisplay = 1 ; #endif lcd_clear() ; #ifdef PCBTARANIS - lcd_puts_Pleft( 0, "\006Boot Loader" ) ; + lcd_putsLeft( 0, "\006Boot Loader" ) ; #endif - refreshDisplay() ; + lcdRefresh() ; #ifdef PCBSKY OptrexDisplay = 0 ; - refreshDisplay() ; + lcdRefresh() ; #endif #ifdef PCBTARANIS @@ -853,19 +856,19 @@ extern uint8_t OptrexDisplay ; Tenms = 0 ; lcd_clear() ; #ifdef PCBSKY - lcd_puts_Pleft( 0, "Boot Loader" ) ; + lcd_putsLeft( 0, "Boot Loader" ) ; #endif #ifdef PCBTARANIS - lcd_puts_Pleft( 0, "\006Boot Loader" ) ; + lcd_putsLeft( 0, "\006Boot Loader" ) ; #endif if ( sdMounted() ) { #ifdef PCBSKY - lcd_puts_Pleft( 0, "\014Ready" ) ; + lcd_putsLeft( 0, "\014Ready" ) ; #endif #ifdef PCBTARANIS - lcd_puts_Pleft( 0, "\022Ready" ) ; + lcd_putsLeft( 0, "\022Ready" ) ; #endif if ( usbPlugged() ) @@ -876,10 +879,10 @@ extern uint8_t OptrexDisplay ; if ( state == ST_USB ) { #ifdef PCBSKY - lcd_puts_Pleft( 3*FH, "\010BUSY" ) ; + lcd_putsLeft( 3*FH, "\010BUSY" ) ; #endif #ifdef PCBTARANIS - lcd_puts_Pleft( 3*FH, "\016BUSY" ) ; + lcd_putsLeft( 3*FH, "\016BUSY" ) ; #endif if ( usbPlugged() == 0 ) { @@ -921,10 +924,10 @@ extern uint8_t OptrexDisplay ; if ( state == ST_DIR_CHECK ) { #ifdef PCBSKY - lcd_puts_Pleft( 16, "\005No Firmware" ) ; + lcd_putsLeft( 16, "\005No Firmware" ) ; #endif #ifdef PCBTARANIS - lcd_puts_Pleft( 16, "\013No Firmware" ) ; + lcd_putsLeft( 16, "\013No Firmware" ) ; #endif } if ( state == ST_OPEN_DIR ) @@ -970,7 +973,7 @@ extern uint8_t OptrexDisplay ; { x = 0 ; } - lcd_putsn_P( 0, 16+FH*i, &Filenames[i][x], DISPLAY_CHAR_WIDTH ) ; + lcd_putsnAtt( 0, 16+FH*i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0 ) ; } { uint8_t event = getEvent() ; @@ -1030,7 +1033,8 @@ extern uint8_t OptrexDisplay ; state = ST_REBOOT ; } } - lcd_char_inverse( 0, 2*FH+FH*vpos, DISPLAY_CHAR_WIDTH*FW, 0 ) ; + lcd_invert_line(2*FH+FH*vpos); + // lcd_char_inverse( 0, 2*FH+FH*vpos, DISPLAY_CHAR_WIDTH*FW, 0 ) ; } if ( state == ST_FLASH_CHECK ) { @@ -1061,7 +1065,7 @@ extern uint8_t OptrexDisplay ; { // Commit to flashing uint32_t blockOffset = 0 ; - lcd_puts_Pleft( 3*FH, "Flashing" ) ; + lcd_putsLeft( 3*FH, "Flashing" ) ; while ( BlockCount ) { program( (uint32_t *)firmwareAddress, &Block_buffer[blockOffset] ) ; // size is 256 bytes @@ -1098,7 +1102,7 @@ extern uint8_t OptrexDisplay ; if ( state == ST_FLASH_DONE ) { uint8_t event = getEvent() ; - lcd_puts_Pleft( 3*FH, "Flashing Complete" ) ; + lcd_putsLeft( 3*FH, "Flashing Complete" ) ; if ( event == EVT_KEY_FIRST(BOOT_KEY_EXIT) ) { state = ST_FILE_LIST ; @@ -1111,7 +1115,7 @@ extern uint8_t OptrexDisplay ; { TenCount = 2 ; #endif - refreshDisplay() ; + lcdRefresh() ; #ifdef PCBTARANIS } #endif diff --git a/radio/bootloader/include/Media.h b/radio/bootloader/include/Media.h deleted file mode 100644 index ef0a22586..000000000 --- a/radio/bootloader/include/Media.h +++ /dev/null @@ -1,288 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. - * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL 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. - * ---------------------------------------------------------------------------- - */ - -//------------------------------------------------------------------------------ -/// \unit -/// !Purpose -/// -/// Generic Media type, which provides transparent access to all types of -/// memories. -/// -/// \note The physical or HW related media operations (physical device -/// connection & protection detecting, PIO configurations and interface -/// driver initialization) are excluded. -/// -/// !Usage -/// -# Do PIO initialization for peripheral interfaces. -/// -# Initialize peripheral interface driver & device driver. -/// -# Initialize specific media interface and link to this initialized driver. -/// -//------------------------------------------------------------------------------ - -#ifndef MEDIA_H -#define MEDIA_H - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//! \brief Operation result code returned by media methods -#define MED_STATUS_SUCCESS 0x00 -#define MED_STATUS_ERROR 0x01 -#define MED_STATUS_BUSY 0x02 -#define MED_STATUS_PROTECTED 0x04 - -//! \brief Media statuses -#define MED_STATE_READY 0x00 /// Media is ready for access -#define MED_STATE_BUSY 0x01 /// Media is busy - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ -typedef struct _Media Media; - -typedef void (*MediaCallback)(void *argument, - unsigned char status, - unsigned int transferred, - unsigned int remaining); - -typedef unsigned char (*Media_write)(Media *media, - unsigned int address, - void *data, - unsigned int length, - MediaCallback callback, - void *argument); - -typedef unsigned char (*Media_read)(Media *media, - unsigned int address, - void *data, - unsigned int length, - MediaCallback callback, - void *argument); - -typedef unsigned char (*Media_cancelIo)(Media *media); - -typedef unsigned char (*Media_lock)(Media *media, - unsigned int start, - unsigned int end, - unsigned int *pActualStart, - unsigned int *pActualEnd); - -typedef unsigned char (*Media_unlock)(Media *media, - unsigned int start, - unsigned int end, - unsigned int *pActualStart, - unsigned int *pActualEnd); - -typedef unsigned char (*Media_ioctl)(Media *media, - unsigned char ctrl, - void *buff); - -typedef unsigned char (*Media_flush)(Media *media); - -typedef void (*Media_handler)(Media *media); - -//! \brief Media transfer -//! \see TransferCallback -typedef struct { - - void *data; //!< Pointer to the data buffer - unsigned int address; //!< Address where to read/write the data - unsigned int length; //!< Size of the data to read/write - MediaCallback callback; //!< Callback to invoke when the transfer done - void *argument; //!< Callback argument - -} MEDTransfer; - -//! \brief Media object -//! \see MEDTransfer -struct _Media { - - Media_write write; //!< Write method - Media_read read; //!< Read method - Media_cancelIo cancelIo; //!< Cancel pending IO method - Media_lock lock; //!< lock method if possible - Media_unlock unlock; //!< unlock method if possible - Media_flush flush; //!< Flush method - Media_handler handler; //!< Interrupt handler - unsigned int blockSize; //!< Block size in bytes (1, 512, 1K, 2K ...) - unsigned int baseAddress; //!< Base address of media in number of blocks - unsigned int size; //!< Size of media in number of blocks - MEDTransfer transfer; //!< Current transfer operation - void *interface; //!< Pointer to the physical interface used - unsigned char bReserved:4, - mappedRD:1, //!< Mapped to memory space to read - mappedWR:1, //!< Mapped to memory space to write -#ifdef __cplusplus - protectd:1, //!< Protected media? -#else - protected:1, //!< Protected media? -#endif - removable:1; //!< Removable/Fixed media? - unsigned char state; //!< Status of media - unsigned short reserved; -}; - -/// Available medias. -extern Media medias[]; - -/// Number of medias which are effectively used. -/// Defined by Media, shared usage by USB MSD & FS ... -extern unsigned int numMedias; - -//------------------------------------------------------------------------------ -// Inline Functions -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//! \brief Writes data on a media -//! \param media Pointer to a Media instance -//! \param address Address at which to write -//! \param data Pointer to the data to write -//! \param length Size of the data buffer -//! \param callback Optional pointer to a callback function to invoke when -//! the write operation terminates -//! \param argument Optional argument for the callback function -//! \return Operation result code -//! \see TransferCallback -//------------------------------------------------------------------------------ -static inline unsigned char MED_Write(Media *media, - unsigned int address, - void *data, - unsigned int length, - MediaCallback callback, - void *argument) -{ - return media->write(media, address, data, length, callback, argument); -} - -//------------------------------------------------------------------------------ -//! \brief Reads a specified amount of data from a media -//! \param media Pointer to a Media instance -//! \param address Address of the data to read -//! \param data Pointer to the buffer in which to store the retrieved -//! data -//! \param length Length of the buffer -//! \param callback Optional pointer to a callback function to invoke when -//! the operation is finished -//! \param argument Optional pointer to an argument for the callback -//! \return Operation result code -//! \see TransferCallback -//------------------------------------------------------------------------------ -static inline unsigned char MED_Read(Media *media, - unsigned int address, - void *data, - unsigned int length, - MediaCallback callback, - void *argument) -{ - return media->read(media, address, data, length, callback, argument); -} - -//------------------------------------------------------------------------------ -//! \brief Locks all the regions in the given address range. -//! \param media Pointer to a Media instance -/// \param start Start address of lock range. -/// \param end End address of lock range. -/// \param pActualStart Start address of the actual lock range (optional). -/// \param pActualEnd End address of the actual lock range (optional). -/// \return 0 if successful; otherwise returns an error code. -//------------------------------------------------------------------------------ -static inline unsigned char MED_Lock(Media *media, - unsigned int start, - unsigned int end, - unsigned int *pActualStart, - unsigned int *pActualEnd) -{ - if( media->lock ) { - return media->lock(media, start, end, pActualStart, pActualEnd); - } - else { - return MED_STATUS_SUCCESS; - } -} - -//------------------------------------------------------------------------------ -//! \brief Unlocks all the regions in the given address range -//! \param media Pointer to a Media instance -/// \param start Start address of unlock range. -/// \param end End address of unlock range. -/// \param pActualStart Start address of the actual unlock range (optional). -/// \param pActualEnd End address of the actual unlock range (optional). -/// \return 0 if successful; otherwise returns an error code. -//------------------------------------------------------------------------------ -static inline unsigned char MED_Unlock(Media *media, - unsigned int start, - unsigned int end, - unsigned int *pActualStart, - unsigned int *pActualEnd) -{ - if( media->unlock ) { - return media->unlock(media, start, end, pActualStart, pActualEnd); - } - else { - return MED_STATUS_SUCCESS; - } -} - -//------------------------------------------------------------------------------ -//! \brief -//! \param media Pointer to the Media instance to use -//------------------------------------------------------------------------------ -static inline unsigned char MED_Flush(Media *media) -{ - if (media->flush) { - - return media->flush(media); - } - else { - - return MED_STATUS_SUCCESS; - } -} - -//------------------------------------------------------------------------------ -//! \brief Invokes the interrupt handler of the specified media -//! \param media Pointer to the Media instance to use -//------------------------------------------------------------------------------ -static inline void MED_Handler(Media *media) -{ - if (media->handler) { - - media->handler(media); - } -} - -//------------------------------------------------------------------------------ -// Exported functions -//------------------------------------------------------------------------------ - -extern void MED_HandleAll(Media *medias, unsigned char numMedias); - -#endif // _MEDIA_H - diff --git a/radio/bootloader/include/eeprom_rlc.h b/radio/bootloader/include/eeprom_rlc.h deleted file mode 100644 index d758b7fc5..000000000 --- a/radio/bootloader/include/eeprom_rlc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Authors (alphabetical order) - * - Andre Bernet - * - Andreas Weitl - * - Bertrand Songis - * - Bryan J. Rentoul (Gruvin) - * - Cameron Weeks - * - Erez Raviv - * - Gabriel Birkus - * - Jean-Pierre Parisy - * - Karl Szmutny - * - Michael Blandford - * - Michal Hlavinka - * - Pat Mackenzie - * - Philip Moss - * - Rob Thomson - * - Romolo Manfredini - * - Thomas Husterer - * - * opentx is based on code named - * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, - * er9x by Erez Raviv: http://code.google.com/p/er9x/, - * and the original (and ongoing) project by - * Thomas Husterer, th9x: http://code.google.com/p/th9x/ - * - * 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. - * - */ - -#ifndef eeprom_rlc_h -#define eeprom_rlc_h - -#include - -#if !defined(EESIZE) - #define EESIZE (32*1024) -#endif - -//uint32_t ee32_check_finished( void ) ; - -#endif diff --git a/radio/bootloader/include/myeeprom.h b/radio/bootloader/include/myeeprom.h deleted file mode 100644 index 269c29d99..000000000 --- a/radio/bootloader/include/myeeprom.h +++ /dev/null @@ -1,527 +0,0 @@ -/* - * Author - Erez Raviv - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * 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. - * - */ -#ifndef eeprom_h -#define eeprom_h - -#include - - -//eeprom data -//#define EE_VERSION 2 -#define MAX_MODELS 32 -#define MAX_MIXERS 32 -#define MAX_SKYMIXERS 48 -#define MAX_CURVE5 8 -#define MAX_CURVE9 8 -#define MDVERS_r9 1 -#define MDVERS_r14 2 -#define MDVERS_r22 3 -#define MDVERS_r77 4 -#define MDVERS_r85 5 -#define MDVERS_r261 6 -#define MDVERS_r352 7 -#define MDVERS_r365 8 -#define MDVERS_r668 9 -#define MDVERS_e119 10 -#define MDVERS 11 - -#define MDSKYVERS 2 - -#define NUM_VOICE 8 - -//OBSOLETE - USE ONLY MDVERS NOW -//#define GENERAL_MYVER_r261 3 -//#define GENERAL_MYVER_r365 4 -//#define GENERAL_MYVER 5 - - -// eeprom ver <9 => mdvers == 1 -// eeprom ver >9 => mdvers ==2 - -#define WARN_THR_BIT 0x01 -#define WARN_BEP_BIT 0x80 -#define WARN_SW_BIT 0x02 -#define WARN_MEM_BIT 0x04 -#define WARN_BVAL_BIT 0x38 - -#define WARN_THR (!(g_eeGeneral.warnOpts & WARN_THR_BIT)) -#define WARN_BEP (!(g_eeGeneral.warnOpts & WARN_BEP_BIT)) -#define WARN_SW (!(g_eeGeneral.warnOpts & WARN_SW_BIT)) -#define WARN_MEM (!(g_eeGeneral.warnOpts & WARN_MEM_BIT)) -#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) - -// Bits in stickGain -#define STICK_LV_GAIN 0x40 -#define STICK_LH_GAIN 0x10 -#define STICK_RV_GAIN 0x04 -#define STICK_RH_GAIN 0x01 - -#define GENERAL_OWNER_NAME_LEN 10 -#define MODEL_NAME_LEN 10 - -#define MAX_GVARS 7 - -#define MAX_PHASES 6 - -#ifndef PACK -#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) -#endif - -PACK(typedef struct t_TrainerMix { - uint8_t srcChn:3; //0-7 = ch1-8 - int8_t swtch:5; - int8_t studWeight:6; - uint8_t mode:2; //off,add-mode,subst-mode -}) TrainerMix; // - -PACK(typedef struct t_TrainerData { - int16_t calib[4]; - TrainerMix mix[4]; -}) TrainerData; - -PACK(typedef struct t_EEGeneral { - uint8_t myVers; - int16_t calibMid[7]; - int16_t calibSpanNeg[7]; - int16_t calibSpanPos[7]; - uint16_t chkSum; - uint8_t currModel; //0..15 - uint8_t contrast; - uint8_t vBatWarn; - int8_t vBatCalib; - int8_t lightSw; - TrainerData trainer; - uint8_t view; - uint8_t disableThrottleWarning:1; - uint8_t disableSwitchWarning:1; - uint8_t disableMemoryWarning:1; - uint8_t beeperVal:3; - uint8_t reserveWarning:1; - uint8_t disableAlarmWarning:1; - uint8_t stickMode; - int8_t inactivityTimer; - uint8_t throttleReversed:1; - uint8_t minuteBeep:1; - uint8_t preBeep:1; - uint8_t flashBeep:1; - uint8_t disableSplashScreen:1; - uint8_t disablePotScroll:1; - uint8_t stickScroll:1 ; - uint8_t frskyinternalalarm:1; - uint8_t filterInput; - uint8_t lightAutoOff; - uint8_t templateSetup; //RETA order according to chout_ar array - int8_t PPM_Multiplier; - uint8_t FRSkyYellow:4; - uint8_t FRSkyOrange:4; - uint8_t FRSkyRed:4; //mike please check these are correct - uint8_t hideNameOnSplash:1; - uint8_t optrexDisplay:1; - uint8_t unexpectedShutdown:1; - uint8_t spare:1; - uint8_t speakerPitch; - uint8_t hapticStrength; - uint8_t speakerMode; - uint8_t lightOnStickMove; - char ownerName[GENERAL_OWNER_NAME_LEN]; - uint8_t switchWarningStates; - uint8_t volume ; - uint8_t bright ; // backlight - uint8_t stickGain; - uint8_t mAh_alarm ; - uint16_t mAh_used ; - uint16_t run_time ; - int8_t current_calib ; - uint8_t bt_baudrate ; - uint8_t rotaryDivisor ; - uint8_t crosstrim:1; - uint8_t spare9:7; - int8_t rtcCal ; - int16_t x9dcalibMid ; // X9D - int16_t x9dcalibSpanNeg ; // X9D - int16_t x9dcalibSpanPos ; // X9D - uint8_t stickReverse ; - uint8_t language ; -}) EEGeneral; - - - - - -//eeprom modelspec -//expo[3][2][2] //[Norm/Dr][expo/weight][R/L] - -PACK(typedef struct t_ExpoData { - int8_t expo[3][2][2]; - int8_t drSw1; - int8_t drSw2; -}) ExpoData; - - -PACK(typedef struct t_LimitData { - int8_t min; - int8_t max; - bool revert; - int16_t offset; -}) LimitData; - -#define MLTPX_ADD 0 -#define MLTPX_MUL 1 -#define MLTPX_REP 2 - -PACK(typedef struct t_MixData { - uint8_t destCh; // 1..NUM_CHNOUT - uint8_t srcRaw; // - int8_t weight; - int8_t swtch; - uint8_t curve; //0=symmetrisch 1=no neg 2=no pos - uint8_t delayUp:4; - uint8_t delayDown:4; - uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle) - uint8_t speedDown:4; // 0 nichts - uint8_t carryTrim:1; - uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace - uint8_t mixWarn:2; // mixer warning - uint8_t enableFmTrim:1; - uint8_t mixres:1; - int8_t sOffset; - int8_t res; -}) MixData; - - -PACK(typedef struct t_CSwData { // Custom Switches data - int8_t v1; //input - int8_t v2; //offset - uint8_t func:4; - uint8_t andsw:4; -}) CSwData; - -PACK(typedef struct t_SafetySwData { // Custom Switches data - union opt - { - struct ss - { - int8_t swtch:6; - uint8_t mode:2; - int8_t val; - } ss ; - struct vs - { - uint8_t vswtch:5 ; - uint8_t vmode:3 ; // ON, OFF, BOTH, 15Secs, 30Secs, 60Secs, Varibl - uint8_t vval; - } vs ; - } opt ; -}) SafetySwData; - -PACK(typedef struct t_FrSkyChannelData { - uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. - uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. - uint8_t alarms_level:4; - uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>) - uint8_t type:2; // 0=volts, 1=raw, 2=volts*2, 3=Amps -}) FrSkyChannelData; - -PACK(typedef struct t_FrSkyData { - FrSkyChannelData channels[2]; -}) FrSkyData; - -PACK(typedef struct t_FrSkyalarms -{ - uint8_t frskyAlarmType ; - uint8_t frskyAlarmLimit ; - uint8_t frskyAlarmSound ; -}) FrSkyAlData; - -PACK(typedef struct t_FrSkyAlarmData { - FrSkyAlData alarmData[8] ; -}) FrSkyAlarmData; - -PACK(typedef struct t_TimerMode -{ - uint8_t tmrModeA:7 ; // timer trigger source -> off, abs, stk, stk%, cx% - uint8_t tmrDir:1 ; // Timer direction - int8_t tmrModeB ; // timer trigger source -> !sw, none, sw, m_sw - uint16_t tmrVal ; -}) TimerMode ; - -//PACK(typedef struct t_swVoice { -// uint8_t swtch:5 ; -// uint8_t mode:3 ; // ON, OFF, BOTH, 15Secs, 30Secs, 60Secs -// uint8_t val ; -//}) old_voiceSwData ; - - -PACK(typedef struct t_ModelData { - char name[MODEL_NAME_LEN]; // 10 must be first for eeLoadModelName - uint8_t modelVoice ; // Index to model name voice (261+value) - uint8_t RxNum ; // was timer trigger source, now RxNum for model match - uint8_t sparex:1; // was tmrDir, now use tmrVal>0 => count down - uint8_t traineron:1; // 0 disable trainer, 1 allow trainer - uint8_t spare22:1 ; // Start timer2 using throttle - uint8_t FrSkyUsrProto:1 ; // Protocol in FrSky User Data, 0=FrSky Hub, 1=WS HowHigh - uint8_t FrSkyGpsAlt:1 ; // Use Gps Altitude as main altitude reading - uint8_t FrSkyImperial:1 ; // Convert FrSky values to imperial units - uint8_t FrSkyAltAlarm:2; - uint8_t version ; - uint8_t spare_u8 ; // Was timerval - uint8_t protocol; - int8_t ppmNCH; - uint8_t thrTrim:1; // Enable Throttle Trim - uint8_t numBlades:2; // RPM scaling - uint8_t spare10:1; - uint8_t thrExpo:1; // Enable Throttle Expo - uint8_t spare11:3; - int8_t trimInc; // Trim Increments - int8_t ppmDelay; - int8_t trimSw; - uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7 - uint8_t pulsePol:1; - uint8_t extendedLimits:1; - uint8_t swashInvertELE:1; - uint8_t swashInvertAIL:1; - uint8_t swashInvertCOL:1; - uint8_t swashType:3; - uint8_t swashCollectiveSource; - uint8_t swashRingValue; - int8_t ppmFrameLength; //0=22.5 (10msec-30msec) 0.5msec increments - MixData mixData[MAX_MIXERS]; - LimitData limitData[NUM_CHNOUT]; - ExpoData expoData[4]; - int8_t trim[4]; - int8_t curves5[MAX_CURVE5][5]; - int8_t curves9[MAX_CURVE9][9]; - CSwData customSw[NUM_CSW]; -// uint8_t rxnum; - uint8_t frSkyVoltThreshold ; - uint8_t bt_telemetry; - uint8_t numVoice; // 0-16, rest are Safety switches - SafetySwData safetySw[NUM_CHNOUT]; - FrSkyData frsky; - TimerMode timer[2] ; - FrSkyAlarmData frskyAlarms ; -// Add 6 bytes for custom telemetry screen - uint8_t customDisplayIndex[6] ; -}) ModelData; - -#define TOTAL_EEPROM_USAGE (sizeof(ModelData)*MAX_MODELS + sizeof(EEGeneral)) - - -extern EEGeneral g_eeGeneral; -extern ModelData g_oldmodel; - -PACK(typedef struct t_PhaseData { - int16_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead - int8_t swtch; // swtch of phase[0] is not used - char name[6]; - uint8_t fadeIn:4; - uint8_t fadeOut:4; - uint16_t spare ; // Future expansion -}) PhaseData; - -PACK(typedef struct te_MixData { - uint8_t destCh; // 1..NUM_CHNOUT - uint8_t srcRaw; // - int8_t weight; - int8_t swtch; - int8_t curve; //0=symmetrisch 1=no neg 2=no pos - uint8_t delayUp; - uint8_t delayDown; - uint8_t speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle) - uint8_t speedDown; // 0 nichts - uint8_t carryTrim:1; - uint8_t mltpx:2; // multiplex method 0=+ 1=* 2=replace - uint8_t lateOffset:1; // Add offset later - uint8_t mixWarn:2; // mixer warning - uint8_t enableFmTrim:1; - uint8_t differential:1 ; - int8_t sOffset; - uint8_t res[4]; -}) SKYMixData; - -PACK(typedef struct te_CSwData { // Custom Switches data - int8_t v1; //input - int8_t v2; //offset - uint8_t func; - int8_t andsw; - uint8_t res ; -}) SKYCSwData; - -PACK(typedef struct te_SafetySwData { // Safety Switches data - union opt - { - struct ss - { - int8_t swtch ; - uint8_t mode ; - int8_t val ; - uint8_t res ; - } ss ; - struct vs - { - uint8_t vswtch ; - uint8_t vmode ; // ON, OFF, BOTH, 15Secs, 30Secs, 60Secs, Varibl - uint8_t vval; - uint8_t vres ; - } vs ; - } opt ; -}) SKYSafetySwData; - -PACK(typedef struct te_FrSkyChannelData { - uint8_t ratio ; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. - uint8_t offset ; // - uint8_t gain ; // - uint8_t alarms_value[2] ; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. - uint8_t alarms_level ; - uint8_t alarms_greater ; // 0=LT(<), 1=GT(>) - uint8_t type ; // 0=volts, 1=raw, 2=volts*2, 3=Amps -}) SKYFrSkyChannelData; - -PACK(typedef struct te_FrSkyData { - SKYFrSkyChannelData channels[2]; -}) SKYFrSkyData; - -PACK(typedef struct te_swVoice { - uint8_t swtch ; - uint8_t mode ; // ON, OFF, BOTH, 15Secs, 30Secs, 60Secs - uint8_t val ; - uint8_t vres ; -}) voiceSwData ; - -PACK(typedef struct t_FunctionData { // Function data - int8_t swtch ; //input - uint8_t func ; - uint8_t param[6] ; - uint8_t spare1 ; - uint8_t spare2 ; -}) FunctionData; - -PACK(typedef struct t_Vario -{ - uint8_t varioSource ; - int8_t swtch ; - uint8_t sinkTones:1 ; - uint8_t spare:1 ; - uint8_t param:6 ; -}) VarioData ; - -PACK(typedef struct t_gvar { - int8_t gvar ; - uint8_t gvsource ; -// int8_t gvswitch ; -}) GvarData ; - -PACK(typedef struct te_ModelData { - char name[MODEL_NAME_LEN]; // 10 must be first for eeLoadModelName - uint8_t modelVoice ; // Index to model name voice (261+value) - uint8_t RxNum ; // was timer trigger source, now RxNum for model match - uint8_t telemetryRxInvert:1 ; // was tmrDir, now use tmrVal>0 => count down - uint8_t traineron:1; // 0 disable trainer, 1 allow trainer - uint8_t spare15:1 ; - uint8_t FrSkyUsrProto:1 ; // Protocol in FrSky User Data, 0=FrSky Hub, 1=WS HowHigh - uint8_t FrSkyGpsAlt:1 ; // Use Gps Altitude as main altitude reading - uint8_t FrSkyImperial:1 ; // Convert FrSky values to imperial units - uint8_t FrSkyAltAlarm:2; - uint8_t modelVersion ; - uint8_t protocol:4 ; - uint8_t country:2 ; - uint8_t sub_protocol:2 ; - int8_t ppmNCH; - uint8_t thrTrim:1; // Enable Throttle Trim - uint8_t xnumBlades:2; // RPM scaling, now elsewhere as uint8_t - uint8_t extendedTrims:1; // Only applies to phases - uint8_t thrExpo:1; // Enable Throttle Expo - uint8_t frskyComPort:1; - uint8_t spare11:2; - int8_t trimInc; // Trim Increments - int8_t ppmDelay; - int8_t trimSw; - uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7 - uint8_t pulsePol:1; - uint8_t extendedLimits:1; - uint8_t swashInvertELE:1; - uint8_t swashInvertAIL:1; - uint8_t swashInvertCOL:1; - uint8_t swashType:3; - uint8_t swashCollectiveSource; - uint8_t swashRingValue; - int8_t ppmFrameLength; //0=22.5 (10msec-30msec) 0.5msec increments - SKYMixData mixData[MAX_SKYMIXERS]; - LimitData limitData[NUM_SKYCHNOUT]; - ExpoData expoData[4]; - int8_t trim[4]; - int8_t curves5[MAX_CURVE5][5]; - int8_t curves9[MAX_CURVE9][9]; - int8_t curvexy[18]; - SKYCSwData customSw[NUM_SKYCSW]; -// uint8_t rxnum; - uint8_t frSkyVoltThreshold ; - uint8_t bt_telemetry; - uint8_t numVoice; // 0-16, rest are Safety switches - SKYSafetySwData safetySw[NUM_SKYCHNOUT]; - voiceSwData voiceSwitches[NUM_VOICE] ; - SKYFrSkyData frsky; - TimerMode timer[2] ; - FrSkyAlarmData frskyAlarms ; -// Add 6 bytes for custom telemetry screen - uint8_t customDisplayIndex[6] ; - FunctionData functionData[NUM_FSW]; - PhaseData phaseData[MAX_PHASES] ; - GvarData gvars[MAX_GVARS] ; - uint8_t numBlades ; // RPM scaling - uint8_t startChannel ; // for main output 0 = ch1 - uint8_t startPPM2channel ; // for PPM2 output 0 follow - int8_t ppm2NCH ; - uint8_t sub_trim_limit ; - uint8_t FASoffset ; // 0.0 to 1.5 - VarioData varioData ; - uint8_t anaVolume ; // analog volume control - int8_t pxxFailsafe[16] ; - int8_t logSwitch ; - uint8_t logRate ; - // X9D ext module - uint8_t xprotocol:4 ; - uint8_t xcountry:2 ; - uint8_t xsub_protocol:2 ; - int8_t xppmNCH ; - int8_t xppmDelay ; - uint8_t xpulsePol ; - int8_t xppmFrameLength; //0=22.5 (10msec-30msec) 0.5msec increments - uint8_t xstartChannel ; // for output 0 = ch1 - uint8_t pxxRxNum ; - int8_t dsmMode ; - uint8_t xPxxRxNum ; // For external module - uint16_t modelswitchWarningStates ; // Enough bits for Taranis - int8_t enRssiOrange:2 ; - int8_t rssiOrange:6 ; - uint8_t enRssiRed:2 ; - int8_t rssiRed:6 ; -// uint8_t spare24:6 ; -// uint8_t curentSource ; -// uint8_t altSource ; -}) SKYModelData; - - -extern SKYModelData g_model; - - - - -#endif -/*eof*/ - - - diff --git a/radio/bootloader/include/timers.h b/radio/bootloader/include/timers.h deleted file mode 100644 index d617d0df4..000000000 --- a/radio/bootloader/include/timers.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* Copyright (c) 2012 by Michael Blandford. All rights reserved. -* -* 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. -* -* -****************************************************************************/ - - - - -void init5msTimer( void ) ; -void stop5msTimer( void ) ; - -#ifdef PCBSKY -extern void start_timer0( void ) ; -extern void stop_timer0( void ) ; -extern void init_pwm( void ) ; -#endif - -#ifdef PCBTARANIS -extern uint32_t Peri1_frequency ; -extern uint32_t Peri2_frequency ; -extern uint32_t Timer_mult1 ; -extern uint32_t Timer_mult2 ; -extern void init_hw_timer( void ) ; -extern void hw_delay( uint16_t time ) ; -extern void init_main_ppm( void ) ; -extern void disable_main_ppm( void ) ; -extern void init_trainer_ppm( void ) ; -extern void init_trainer_capture( void ) ; -extern void setupPulsesPXX(uint8_t module) ; -extern void setupPulses( unsigned int port ) ; -extern void setupPulsesPpm( void ) ; - -#endif - - diff --git a/radio/bootloader/lcd_driver.cpp b/radio/bootloader/lcd_driver.cpp deleted file mode 100644 index dd36230db..000000000 --- a/radio/bootloader/lcd_driver.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/** - ****************************************************************************** - * @file Project/lcd/lcd.c - * @author X9D Application Team - * @Hardware version V0.2 - * @date 11-July-2012 - * @brief This file provides LCD Init and botom drivers. - * * - ****************************************************************************** -*/ - -#include "radio.h" - -#include "stm32f2xx.h" -#include "stm32f2xx_gpio.h" -#include "stm32f2xx_rcc.h" -#include "hal.h" -#include "../src/targets/taranis/aspi.h" - -#include "timers.h" -#include "lcd.h" -#include "logicio.h" - -#define WriteData(x) AspiData(x) -#define WriteCommand(x) AspiCmd(x) -#define CONTRAST_OFS 5 - -#define __no_operation __NOP - - -extern uint8_t DisplayBuf[] ; - -void Set_Address(uint8_t x, uint8_t y) -{ - WriteCommand(x&0x0F); //Set Column Address LSB CA[3:0] - WriteCommand((x>>4)|0x10); //Set Column Address MSB CA[7:4] - - WriteCommand((y&0x0F)|0x60); //Set Row Address LSB RA [3:0] - WriteCommand(((y>>4)&0x0F)|0x70); //Set Row Address MSB RA [7:4] -} - -void refreshDisplay() -{ - for (uint32_t y=0; y>3)*DISPLAY_W]; - uint8_t mask = (1 << (y%8)); - GPIO_TypeDef *gpiod = GPIOD ; - Set_Address(0, y); - AspiCmd(0xAF); - - gpiod->BSRRL = PIN_LCD_CLK ; // Clock high - gpiod->BSRRL = PIN_LCD_A0 ; // A0 high - gpiod->BSRRH = PIN_LCD_NCS ; // CS low - - for (uint32_t x=0; xBSRRL = PIN_LCD_MOSI ; - } - else - { - gpiod->BSRRH = PIN_LCD_MOSI ; - } - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x40) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x20) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x10) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x08) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x04) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x02) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - - if(data&0x01) - { - gpiod->BSRRL = PIN_LCD_MOSI | PIN_LCD_CLK ; - } - else - { - *(uint32_t *)&gpiod->BSRRL = (PIN_LCD_MOSI<<16) | PIN_LCD_CLK ; - } - __no_operation() ; - gpiod->BSRRH = PIN_LCD_CLK ; // Clock low - __no_operation() ; - gpiod->BSRRL = PIN_LCD_CLK ; // Clock high - - } - gpiod->BSRRL = PIN_LCD_NCS ; - gpiod->BSRRL = PIN_LCD_A0 ; - WriteData(0); - } -} - -uint16_t BacklightBrightness ; - -void backlight_on() -{ - TIM10->CCR1 = 100 - BacklightBrightness ; -} - -void backlight_off() -{ - TIM10->CCR1 = 0 ; -} - -void backlight_set( uint16_t brightness ) -{ - BacklightBrightness = brightness ; - TIM10->CCR1 = 100 - BacklightBrightness ; -} - - -/**Init the Backlight GPIO */ -static void LCD_BL_Config() -{ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE); - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin =GPIO_Pin_BL; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOBL, &GPIO_InitStructure); - - GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL ,GPIO_AF_TIM10); - - RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock - TIM10->ARR = 100 ; - TIM10->PSC = (Peri2_frequency*Timer_mult2) / 10000 - 1 ; // 100uS from 30MHz - TIM10->CCMR1 = 0x60 ; // PWM - TIM10->CCER = 1 ; - - BacklightBrightness = 80 ; - TIM10->CCR1 = BacklightBrightness ; - TIM10->EGR = 0 ; - TIM10->CR1 = 1 ; -} - -/** Init the anolog spi gpio -*/ -static void LCD_Hardware_Init() -{ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE); - - GPIO_InitTypeDef GPIO_InitStructure; - - /*!< Configure lcd CLK\ MOSI\ A0pin in output pushpull mode *************/ - GPIO_InitStructure.GPIO_Pin =PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIO_LCD, &GPIO_InitStructure); - - /*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/ - GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS | PIN_LCD_RST ; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; - - GPIO_Init(GPIO_LCD, &GPIO_InitStructure); -} - -static void LCD_Init() -{ - LCD_BL_Config() ; - /*Hardware Reset need delay*/ - /*LCD_RST_LOW(); - Delay(50); - LCD_RST_HIGH();*/ - - AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC - AspiCmd(0x2b); //Panel loading set ,Internal VLCD. - AspiCmd(0xEA); //set bias=1/10 :Command table NO.27 - AspiCmd(0x81); //Set Vop - AspiCmd(25+CONTRAST_OFS); //0--255 - AspiCmd(0xA6); //inverse display off - AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB - AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22 - AspiCmd(0xA0); //line rates,25.2 Klps - AspiCmd(0xC8); //SET N-LINE INVERSION - AspiCmd(0x1D); //Disable NIV - AspiCmd(0xF1); //Set CEN - AspiCmd(0x3F); // 1/64DUTY - AspiCmd(0x84); //Disable Partial Display - AspiCmd(0xC4); //MY=1,MX=0 - AspiCmd(0x89); //WA=1,column (CA) increment (+1) first until CA reaches CA boundary, then RA will increment by (+1). - - AspiCmd(0xF8); //Set Window Program Enable ,inside modle - AspiCmd(0xF4); //starting column address of RAM program window. - AspiCmd(0x00); - AspiCmd(0xF5); //starting row address of RAM program window. - AspiCmd(0x60); - AspiCmd(0xF6); //ending column address of RAM program window. - AspiCmd(0x47); - AspiCmd(0xF7); //ending row address of RAM program window. - AspiCmd(0x9F); - - AspiCmd(0xAF); //dc2=1,IC into exit SLEEP MODE, dc3=1 gray=ON ���ҽ� ,dc4=1 Green Enhanc mode disabled ��ɫ��ǿģʽ�� - -} - -static void Delay(volatile unsigned int ms) -{ - volatile u8 i; - while(ms != 0) - { - for(i=0;i<250;i++) {} - for(i=0;i<75;i++) {} - ms--; - } -} - -void lcd_init() -{ - GPIO_TypeDef *gpiod = GPIOD ; - - LCD_BL_Config(); - LCD_Hardware_Init(); - - gpiod->BSRRL = PIN_LCD_RST ; // RST high - Delay(5); - - gpiod->BSRRH = PIN_LCD_RST ; // RST low - Delay(120); //11ms - - gpiod->BSRRL = PIN_LCD_RST ; // RST high - Delay(2500); - - AspiCmd(0xE2); - Delay(2500); - - LCD_Init(); - Delay(120); - AspiCmd(0xAF); //dc2=1, IC into exit SLEEP MODE, dc3=1 gray=ON, dc4=1 Green Enhanc mode disabled -} - -void lcdSetRefVolt(uint8_t val) -{ - AspiCmd(0x81); //Set Vop - AspiCmd(val+CONTRAST_OFS); //0--255 -} diff --git a/radio/bootloader/usbd_storage_msd.cpp b/radio/bootloader/usbd_storage_msd.cpp index 4aa3804d3..2552e02be 100644 --- a/radio/bootloader/usbd_storage_msd.cpp +++ b/radio/bootloader/usbd_storage_msd.cpp @@ -27,7 +27,7 @@ /* Includes ------------------------------------------------------------------*/ #include "radio.h" -#include "eeprom_rlc.h" +#include "../src/eeprom_rlc.h" #include #include //#include diff --git a/radio/src/eeprom_rlc.h b/radio/src/eeprom_rlc.h index db285a6fe..76bf5cdff 100644 --- a/radio/src/eeprom_rlc.h +++ b/radio/src/eeprom_rlc.h @@ -34,11 +34,16 @@ * */ -#ifndef eeprom_avr_h -#define eeprom_avr_h +#ifndef eeprom_rlc_h +#define eeprom_rlc_h #include +// TODO duplicated +#ifndef PACK +#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) +#endif + #if defined(PCBTARANIS) #define blkid_t uint16_t #if !defined(EESIZE) @@ -67,7 +72,7 @@ #define BS 16 #endif -PACK(struct DirEnt{ +PACK(struct DirEnt { blkid_t startBlk; uint16_t size:12; uint16_t typ:4; @@ -79,7 +84,7 @@ PACK(struct DirEnt{ #define EEFS_EXTRA_FIELDS #endif -PACK(struct EeFs{ +PACK(struct EeFs { uint8_t version; blkid_t mySize; blkid_t freeList; diff --git a/radio/src/lcd.cpp b/radio/src/lcd.cpp index 0bfd78820..f65811a0a 100644 --- a/radio/src/lcd.cpp +++ b/radio/src/lcd.cpp @@ -49,6 +49,7 @@ void lcd_clear() memset(displayBuf, 0, sizeof(displayBuf)); } +#if !defined(BOOT) void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att) { const pm_uchar *q = img; @@ -84,6 +85,7 @@ void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags } } } +#endif uint8_t lcdLastPos; uint8_t lcdNextPos; @@ -177,7 +179,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) } } -#if defined(CPUARM) +#if defined(CPUARM) && !defined(BOOT) else if (flags & MIDSIZE) { /* each letter consists of ten top bytes followed by * by ten bottom bytes (20 bytes per * char) */ @@ -329,7 +331,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) LCD_BYTE_FILTER(r, ~mask, b >> (8-ym8)); } -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) && !defined(BOOT) if (inv) { if (ym8) lcd_mask(p, 0x01 << (ym8-1), FORCE); else if (y) { @@ -369,9 +371,11 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag case BSS: c = *s; break; +#if !defined(BOOT) case ZCHAR: c = idx2char(*s); break; +#endif default: c = pgm_read_byte(s); break; @@ -854,6 +858,7 @@ void lcd_invert_line(int8_t y) } } +#if !defined(BOOT) #if defined(PCBTARANIS) void lcdDrawTelemetryTopBar() { @@ -885,6 +890,7 @@ void lcdDrawTelemetryTopBar() lcd_invert_line(0); } #endif +#endif void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2) { @@ -929,6 +935,7 @@ void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2 lcd_outdezNAtt(lcdNextPos, y, qr.rem, att2|LEADING0|LEFT, 2); } +#if !defined(BOOT) // TODO to be optimized with putsTelemetryValue void putsVolts(xcoord_t x, uint8_t y, uint16_t volts, LcdFlags att) { @@ -1175,7 +1182,7 @@ void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, Lc } #endif -#if defined(FRSKY) || defined(CPUARM) +#if (defined(FRSKY) || defined(CPUARM)) && !defined(BOOT) void putsTelemetryValue(xcoord_t x, uint8_t y, lcdint_t val, uint8_t unit, uint8_t att) { convertUnit(val, unit); @@ -1333,3 +1340,4 @@ void lcdSetContrast() { lcdSetRefVolt(g_eeGeneral.contrast); } +#endif diff --git a/radio/src/lcd.h b/radio/src/lcd.h index 5becc5c57..29dcf4b16 100644 --- a/radio/src/lcd.h +++ b/radio/src/lcd.h @@ -149,6 +149,12 @@ extern uint8_t lcdNextPos; extern volatile uint32_t lcdInputs ; #endif +#if defined(BOOT) +// TODO quick & dirty :( +typedef const unsigned char pm_uchar; +typedef const char pm_char; +#endif + void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c); void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags mode); void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags mode); @@ -169,7 +175,7 @@ void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att); void putsSwitches(xcoord_t x, uint8_t y, int8_t swtch, LcdFlags att=0); void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att=0); void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) && !defined(BOOT) void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att); #endif void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); @@ -249,7 +255,11 @@ void lcdRefresh(); const pm_char * bmpLoad(bmp_ptr_t &dest, const char *filename, const xcoord_t width, const uint8_t height); #endif -#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6)) +#if defined(BOOT) + #define BLINK_ON_PHASE (0) +#else + #define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6)) +#endif #ifdef SIMU extern bool lcd_refresh; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 9534ae9e1..22c49abe5 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1513,9 +1513,7 @@ enum AUDIO_SOUNDS { #include "targets/gruvin9x/somo14d.h" #endif -#if !defined(BOOT) #include "translations.h" -#endif #if defined(HAPTIC) #include "haptic.h" @@ -1634,7 +1632,7 @@ extern union ReusableBuffer reusableBuffer; void checkFlashOnBeep(); #if defined(FRSKY) || defined(CPUARM) -FORCEINLINE void convertUnit(getvalue_t & val, uint8_t & unit); +void convertUnit(getvalue_t & val, uint8_t & unit); // TODO check FORCEINLINE on stock void putsTelemetryValue(xcoord_t x, uint8_t y, lcdint_t val, uint8_t unit, uint8_t att); #else #define convertUnit(...) diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 991fb952b..5b8c2a6bd 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -9,7 +9,7 @@ ****************************************************************************** */ -#include "../opentx.h" +#include "../../opentx.h" #define WriteData(x) AspiData(x) #define WriteCommand(x) AspiCmd(x) @@ -21,7 +21,11 @@ static void LCD_Init() AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC AspiCmd(0xEA); //set bias=1/10 :Command table NO.27 AspiCmd(0x81); //Set Vop +#if defined(BOOT) + AspiCmd(CONTRAST_OFS); +#else AspiCmd(g_eeGeneral.contrast+CONTRAST_OFS); //0--255 +#endif AspiCmd(0xA6); //inverse display off AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22