Switch to CMake - Taranis bootloader added. Tests done.

This commit is contained in:
Bertrand Songis
2015-12-23 18:39:02 +01:00
parent 356faefb6d
commit d02d0f26db
14 changed files with 215 additions and 120 deletions
+21
View File
@@ -35,6 +35,27 @@
*/
// ADC driver
enum Analogs {
STICK1,
STICK2,
STICK3,
STICK4,
POT1,
POT2,
POT3,
POT_LAST = POT3,
#if defined(TELEMETRY_MOD_14051) || defined(TELEMETRY_MOD_14051_SWAPPED)
// When the mod is applied, ADC7 is connected to 14051's X pin and TX_VOLTAGE
// is connected to 14051's X0 pin (one of the multiplexed inputs). TX_VOLTAGE
// value is filled in by processMultiplexAna().
// This shifts TX_VOLTAGE from 7 to 8 and makes X14051 take the 7th position
// corresponding to ADC7.
X14051,
#endif
TX_VOLTAGE,
NUMBER_ANALOG
};
void adcInit();
void adcPrepareBandgap();
void getADC();
+19
View File
@@ -217,6 +217,25 @@ void watchdogInit(unsigned int duration);
#endif
// ADC driver
enum Analogs {
STICK1,
STICK2,
STICK3,
STICK4,
POT1,
POT2,
POT3,
POT_LAST=POT3,
SLIDER1,
SLIDER2,
SLIDER3,
SLIDER4,
TX_VOLTAGE,
MOUSE1,
MOUSE2,
NUMBER_ANALOG
};
void adcInit(void);
void adcRead(void);
uint16_t getAnalogValue(uint32_t value);
+15
View File
@@ -228,6 +228,21 @@ void disable_dsm2(uint32_t port);
#define isBacklightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100)
// ADC driver
enum Analogs {
STICK1,
STICK2,
STICK3,
STICK4,
POT1,
POT2,
POT3,
POT_LAST = POT3,
TX_VOLTAGE,
#if !defined(REVA)
TX_CURRENT,
#endif
NUMBER_ANALOG
};
void adcInit();
void adcRead(void);
inline uint16_t getAnalogValue(uint32_t value);
+25
View File
@@ -155,6 +155,7 @@ extern "C" {
#endif
void delaysInit(void);
void delay_01us(uint16_t nb);
void delay(uint32_t ms);
#ifdef __cplusplus
}
#endif
@@ -250,8 +251,32 @@ void watchdogInit(unsigned int duration);
#endif
// ADC driver
enum Analogs {
STICK1,
STICK2,
STICK3,
STICK4,
POT1,
POT2,
POT3,
#if defined(REV9E)
POT4,
POT_LAST = POT4,
#else
POT_LAST = POT3,
#endif
SLIDER1,
SLIDER2,
#if defined(REV9E)
SLIDER3,
SLIDER4,
#endif
TX_VOLTAGE,
NUMBER_ANALOG
};
void adcInit(void);
void adcRead(void);
extern uint16_t adcValues[NUMBER_ANALOG];
uint16_t getAnalogValue(uint32_t value);
#define BATT_SCALE 150
@@ -0,0 +1,67 @@
if(PCBREV STREQUAL REV9E)
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../system_stm32f4xx.c
../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s
../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c
../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/misc.c
)
else()
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../system_stm32f2xx.c
../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c
../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/misc.c
)
endif()
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../../../gui/taranis/lcd.cpp
../../../gui/taranis/fonts.cpp
../../../keys.cpp
../../../strhelpers.cpp
../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_core.c
../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_dcd.c
../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_dcd_int.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Core/src/usbd_core.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Core/src/usbd_ioreq.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Core/src/usbd_req.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c
../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
../../../${FATFS_DIR}/ff.c
../../../${FATFS_DIR}/option/ccsbcs.c
../lcd_driver.cpp
../configure_pins.cpp
../keys_driver.cpp
../i2c_driver.cpp
../flash_driver.cpp
../diskio.cpp
../usbd_usr.cpp
../usbd_storage_msd.cpp
../delays.c
../usbd_desc.c
../aspi.c
../usb_bsp.c
../usb_driver.c
../pwr_driver.c
init.c
boot.cpp
)
remove_definitions(-DUSB_JOYSTICK -DUSB_SERIAL -DDEBUG)
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.elf ${BOOTLOADER_SRC})
add_dependencies(bootloader.elf taranis_fonts firmware_translations)
+7
View File
@@ -55,3 +55,10 @@ void delay_01us(uint16_t nb)
while(TIM13->CNT < nb);
TIM13->CR1 = 0x02;
}
void delay(uint32_t ms)
{
while(ms--) {
delay_01us(10000);
}
}
+7 -17
View File
@@ -27,16 +27,6 @@
bool lcdInitFinished = false;
void lcdInitFinish();
/*
delaysInit() must be called before the first call to this function!
*/
static void Delay(uint32_t ms)
{
while(ms--) {
delay_01us(10000);
}
}
#if defined(REVPLUS)
// New hardware SPI driver for LCD
@@ -71,7 +61,7 @@ void initLcdSpi()
static void LCD_Init()
{
WriteCommand(0x2F); //Internal pump control
Delay(20);
delay(20);
WriteCommand(0x24); //Temperature compensation
WriteCommand(0xE9); //set bias=1/10
WriteCommand(0x81); //Set Vop
@@ -106,7 +96,7 @@ static void LCD_Init()
static void LCD_Init()
{
AspiCmd(0x2B); //Panel loading set ,Internal VLCD.
Delay(20);
delay(20);
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
AspiCmd(0x81); //Set Vop
@@ -349,7 +339,7 @@ void lcdOff()
to re-init LCD without any delay
*/
AspiCmd(0xAE); //LCD sleep
Delay(3); //wait for caps to drain
delay(3); //wait for caps to drain
}
/*
@@ -357,7 +347,7 @@ void lcdOff()
soon as possible after the reset because LCD takes a lot of
time to properly power-on.
Make sure that Delay() is functional before calling this function!
Make sure that delay() is functional before calling this function!
*/
void lcdInit()
{
@@ -367,7 +357,7 @@ void lcdInit()
//reset LCD module
LCD_RST_LOW();
Delay(1); // only 3 us needed according to data-sheet, we use 1 ms
delay(1); // only 3 us needed according to data-sheet, we use 1 ms
LCD_RST_HIGH();
}
@@ -404,13 +394,13 @@ void lcdInitFinish()
#if !defined(BOOT)
while(g_tmr10ms < (RESET_WAIT_DELAY_MS/10)) {}; //wait measured from the power-on
#else
Delay(RESET_WAIT_DELAY_MS);
delay(RESET_WAIT_DELAY_MS);
#endif
}
LCD_Init();
AspiCmd(0xAF); //dc2=1, IC into exit SLEEP MODE, dc3=1 gray=ON, dc4=1 Green Enhanc mode disabled
Delay(20); //needed for internal DC-DC converter startup
delay(20); //needed for internal DC-DC converter startup
}
void lcdSetRefVolt(uint8_t val)
+1 -6
View File
@@ -65,12 +65,7 @@
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
#if defined(BOOT)
#define USBD_PID 0x5720
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Bootloader"
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
#define USBD_INTERFACE_FS_STRING "MSC Interface"
#elif defined(USB_JOYSTICK)
#if defined(USB_JOYSTICK)
#define USBD_PID 0x5710
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick"
#define USBD_CONFIGURATION_FS_STRING "HID Config"