Horus bootloader (#5455)

Horus bootloader
This commit is contained in:
Raphael Coeffic
2017-12-19 12:13:59 +01:00
committed by Bertrand Songis
parent 908adb4d2b
commit 0d7832b208
54 changed files with 1772 additions and 1038 deletions
+12 -3
View File
@@ -31,7 +31,10 @@ if (PCB STREQUAL X10)
../common/arm/stm32/adc_driver.cpp
pwm_driver.cpp
)
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} x10_bitmaps)
set(BITMAPS_TARGET x10_bitmaps)
set(FONTS_TARGET x10_fonts)
set(LCD_DRIVER lcd_driver.cpp)
set(LUA_EXPORT lua_export_x10)
elseif (PCB STREQUAL X12S)
set(FLAVOUR x12s)
@@ -52,11 +55,16 @@ elseif (PCB STREQUAL X12S)
adc_driver.cpp
gps_driver.cpp
)
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} x12s_bitmaps)
set(BITMAPS_TARGET x12s_bitmaps)
set(FONTS_TARGET x12s_fonts)
set(LCD_DRIVER lcd_driver.cpp)
set(LUA_EXPORT lua_export_x12s)
add_definitions(-DPCBREV=${PCBREV})
endif()
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} ${BITMAPS_TARGET})
add_definitions(-DPCBHORUS -DSTM32F429_439xx -DSDRAM -DCOLORLCD -DPPM_PIN_UART -DPPM_PIN_TIMER)
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
@@ -119,11 +127,12 @@ set(TARGET_SRC
set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC}
sdio_sd.c
lcd_driver.cpp
${LCD_DRIVER}
backlight_driver.cpp
pwr_driver.cpp
sdram_driver.c
startup_stm32f42_43xxx.s
../common/arm/loadboot.cpp
)
add_definitions(-DBLUETOOTH)
+29 -29
View File
@@ -24,44 +24,44 @@ void backlightInit()
{
// PIN init
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = BL_GPIO_PIN;
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(BL_GPIO, &GPIO_InitStructure);
GPIO_PinAFConfig(BL_GPIO, BL_GPIO_PinSource, BL_GPIO_AF);
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource, BACKLIGHT_GPIO_AF);
// TIMER init
#if defined(PCBX12S)
if (IS_HORUS_PROD()) {
BL_TIMER->ARR = 100;
BL_TIMER->PSC = BL_TIMER_FREQ / 10000 - 1; // 1kHz
BL_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
BL_TIMER->CCER = TIM_CCER_CC4E;
BL_TIMER->CCR4 = 0;
BL_TIMER->EGR = 0;
BL_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
BACKLIGHT_TIMER->ARR = 100;
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 10000 - 1; // 1kHz
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
BACKLIGHT_TIMER->CCER = TIM_CCER_CC4E;
BACKLIGHT_TIMER->CCR4 = 0;
BACKLIGHT_TIMER->EGR = 0;
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
}
else {
BL_TIMER->ARR = 100;
BL_TIMER->PSC = BL_TIMER_FREQ / 10000 - 1; // 1kHz
BL_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2; // PWM
BL_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC1NE;
BL_TIMER->CCR1 = 100;
BL_TIMER->EGR = 1;
BL_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
BL_TIMER->BDTR |= TIM_BDTR_MOE;
BACKLIGHT_TIMER->ARR = 100;
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 10000 - 1; // 1kHz
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2; // PWM
BACKLIGHT_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC1NE;
BACKLIGHT_TIMER->CCR1 = 100;
BACKLIGHT_TIMER->EGR = 1;
BACKLIGHT_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
BACKLIGHT_TIMER->BDTR |= TIM_BDTR_MOE;
}
#elif defined(PCBX10)
BL_TIMER->ARR = 100;
BL_TIMER->PSC = BL_TIMER_FREQ / 1000000 - 1; // 10kHz (same as FrOS)
BL_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3PE; // PWM mode 1
BL_TIMER->CCER = TIM_CCER_CC3E | TIM_CCER_CC3NE;
BL_TIMER->CCR3 = 100;
BL_TIMER->EGR = TIM_EGR_UG;
BL_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
BL_TIMER->BDTR |= TIM_BDTR_MOE;
BACKLIGHT_TIMER->ARR = 100;
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 1000000 - 1; // 10kHz (same as FrOS)
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3PE; // PWM mode 1
BACKLIGHT_TIMER->CCER = TIM_CCER_CC3E | TIM_CCER_CC3NE;
BACKLIGHT_TIMER->CCR3 = 100;
BACKLIGHT_TIMER->EGR = TIM_EGR_UG;
BACKLIGHT_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
BACKLIGHT_TIMER->BDTR |= TIM_BDTR_MOE;
#endif
}
@@ -69,12 +69,12 @@ void backlightEnable(uint8_t dutyCycle)
{
#if defined(PCBX12S)
if (IS_HORUS_PROD()) {
BL_TIMER->CCR4 = dutyCycle;
BACKLIGHT_TIMER->CCR4 = dutyCycle;
}
else {
BL_TIMER->CCR1 = BACKLIGHT_LEVEL_MAX - dutyCycle;
BACKLIGHT_TIMER->CCR1 = BACKLIGHT_LEVEL_MAX - dutyCycle;
}
#elif defined(PCBX10)
BL_TIMER->CCR3 = BACKLIGHT_LEVEL_MAX - dutyCycle;
BACKLIGHT_TIMER->CCR3 = BACKLIGHT_LEVEL_MAX - dutyCycle;
#endif
}
+18 -19
View File
@@ -42,7 +42,7 @@ void watchdogInit(unsigned int duration)
// Start TIMER7 at 2000000Hz
void init2MhzTimer()
{
TIMER_2MHz_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1; // 0.5 uS, 2 MHz
TIMER_2MHz_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1; // 0.5 uS, 2 MHz
TIMER_2MHz_TIMER->ARR = 65535;
TIMER_2MHz_TIMER->CR2 = 0;
TIMER_2MHz_TIMER->CR1 = TIM_CR1_CEN;
@@ -51,15 +51,15 @@ void init2MhzTimer()
// Starts TIMER at 1000Hz
void init1msTimer()
{
INTERRUPT_1MS_TIMER->ARR = 999; // 1mS
INTERRUPT_1MS_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1; // 1uS from 30MHz
INTERRUPT_1MS_TIMER->CCER = 0;
INTERRUPT_1MS_TIMER->CCMR1 = 0;
INTERRUPT_1MS_TIMER->EGR = 0;
INTERRUPT_1MS_TIMER->CR1 = 5;
INTERRUPT_1MS_TIMER->DIER |= 1;
NVIC_EnableIRQ(INTERRUPT_1MS_IRQn);
NVIC_SetPriority(INTERRUPT_1MS_IRQn, 7);
INTERRUPT_xMS_TIMER->ARR = 999; // 1mS in uS
INTERRUPT_xMS_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1; // 1uS
INTERRUPT_xMS_TIMER->CCER = 0;
INTERRUPT_xMS_TIMER->CCMR1 = 0;
INTERRUPT_xMS_TIMER->EGR = 0;
INTERRUPT_xMS_TIMER->CR1 = 5;
INTERRUPT_xMS_TIMER->DIER |= 1;
NVIC_EnableIRQ(INTERRUPT_xMS_IRQn);
NVIC_SetPriority(INTERRUPT_xMS_IRQn, 7);
}
// TODO use the same than board_sky9x.cpp
@@ -90,9 +90,9 @@ void interrupt1ms()
DEBUG_TIMER_STOP(debugTimerRotEnc);
}
extern "C" void INTERRUPT_1MS_IRQHandler()
extern "C" void INTERRUPT_xMS_IRQHandler()
{
INTERRUPT_1MS_TIMER->SR &= ~TIM_SR_UIF;
INTERRUPT_xMS_TIMER->SR &= ~TIM_SR_UIF;
interrupt1ms();
DEBUG_INTERRUPT(INT_1MS);
}
@@ -135,10 +135,10 @@ void boardInit()
PCBREV_RCC_AHB1Periph |
LED_RCC_AHB1Periph |
LCD_RCC_AHB1Periph |
BL_RCC_AHB1Periph |
BACKLIGHT_RCC_AHB1Periph |
SD_RCC_AHB1Periph |
AUDIO_RCC_AHB1Periph |
KEYS_RCC_AHB1Periph_GPIO |
KEYS_RCC_AHB1Periph |
ADC_RCC_AHB1Periph |
SERIAL_RCC_AHB1Periph |
TELEMETRY_RCC_AHB1Periph |
@@ -149,11 +149,10 @@ void boardInit()
INTMODULE_RCC_AHB1Periph |
EXTMODULE_RCC_AHB1Periph |
GPS_RCC_AHB1Periph |
SPORT_UPDATE_RCC_AHB1Periph |
BL_RCC_AHB1Periph,
SPORT_UPDATE_RCC_AHB1Periph,
ENABLE);
RCC_APB1PeriphClockCmd(INTERRUPT_1MS_RCC_APB1Periph |
RCC_APB1PeriphClockCmd(INTERRUPT_xMS_RCC_APB1Periph |
ADC_RCC_APB1Periph |
TIMER_2MHz_RCC_APB1Periph |
AUDIO_RCC_APB1Periph |
@@ -164,7 +163,7 @@ void boardInit()
INTMODULE_RCC_APB1Periph |
EXTMODULE_RCC_APB1Periph |
GPS_RCC_APB1Periph |
BL_RCC_APB1Periph,
BACKLIGHT_RCC_APB1Periph,
ENABLE);
RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph |
@@ -173,7 +172,7 @@ void boardInit()
INTMODULE_RCC_APB2Periph |
EXTMODULE_RCC_APB2Periph |
BT_RCC_APB2Periph |
BL_RCC_APB2Periph,
BACKLIGHT_RCC_APB2Periph,
ENABLE);
pwrInit();
+3 -2
View File
@@ -82,7 +82,7 @@ extern "C" {
#endif
#define FLASHSIZE 0x200000
#define BOOTLOADER_SIZE 0x8000
#define BOOTLOADER_SIZE 0x20000
#define FIRMWARE_ADDRESS 0x08000000
#define MB *1024*1024
@@ -160,6 +160,7 @@ uint32_t sdMounted(void);
#define sdDone()
#define SD_CARD_PRESENT() true
#endif
#if defined(DISK_CACHE)
#include "diskio.h"
DRESULT __disk_read(BYTE drv, BYTE * buff, DWORD sector, UINT count);
@@ -446,7 +447,7 @@ void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t
void lcdStoreBackupBuffer(void);
int lcdRestoreBackupBuffer(void);
void lcdSetContrast();
#define lcdOff(...)
#define lcdOff() backlightEnable(0) /* just disable the backlight */
#define lcdSetRefVolt(...)
#define lcdRefreshWait(...)
@@ -0,0 +1,172 @@
#include "opentx.h"
#include "../../common/arm/stm32/bootloader/boot.h"
#include "../../common/arm/stm32/bootloader/bin_files.h"
#define SELECTED_COLOR (INVERS | TEXT_COLOR)
#include "bmp_plug_usb.lbm"
#include "bmp_usb_plugged.lbm"
const uint8_t LBM_FLASH[] = {
#include "icon_flash.lbm"
};
const uint8_t LBM_EXIT[] = {
#include "icon_exit.lbm"
};
const uint8_t LBM_SD[] = {
#include "icon_sd.lbm"
};
const uint8_t LBM_FILE[] = {
#include "icon_file.lbm"
};
const uint8_t LBM_ERROR[] = {
#include "icon_error.lbm"
};
const uint8_t LBM_OK[] = {
#include "icon_ok.lbm"
};
void bootloaderInitScreen()
{
lcdColorTable[TEXT_COLOR_INDEX] = BLACK;
lcdColorTable[TEXT_BGCOLOR_INDEX] = WHITE;
lcdColorTable[LINE_COLOR_INDEX] = RED;
lcdColorTable[BARGRAPH1_COLOR_INDEX] = RED;
lcdColorTable[BARGRAPH2_COLOR_INDEX] = RGB(73, 219, 62); // green
backlightEnable(BACKLIGHT_LEVEL_MAX);
}
static void bootloaderDrawTitle(unsigned int x, const char* text)
{
lcdDrawText(x, 28, text);
lcdDrawSolidFilledRect(28, 56, 422, 2, TEXT_COLOR);
}
static void bootloaderDrawFooter()
{
lcdDrawSolidFilledRect(28, 234, 422, 2, TEXT_COLOR);
}
void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
{
// clear screen
lcdDrawSolidFilledRect(0, 0, LCD_W-1, LCD_H-1, TEXT_BGCOLOR);
if (st == ST_START) {
bootloaderDrawTitle(88, "HORUS BOOTLOADER");
lcdDrawBitmapPattern(90, 72, LBM_FLASH, TEXT_COLOR);
lcdDrawText(124, 75, "Write Firmware");
lcdDrawBitmapPattern(90, 107, LBM_EXIT, TEXT_COLOR);
lcdDrawText(124, 110, "Exit");
lcdDrawSolidRect(119, (opt == 0) ? 72 : 107, 270, 26, 2, LINE_COLOR);
lcd->drawBitmap(60, 166, &BMP_PLUG_USB);
lcdDrawText(195, 175, "Or plug in a USB cable");
lcdDrawText(195, 200, "for mass storage");
bootloaderDrawFooter();
lcdDrawText( 36, 242, "Current Firmware:");
lcdDrawText(200, 242, getOtherVersion(nullptr));
}
else if (st == ST_USB) {
lcd->drawBitmap(136, 98, &BMP_USB_PLUGGED);
lcdDrawText(195, 128, "USB Connected");
}
else if (st == ST_FILE_LIST || st == ST_DIR_CHECK || st == ST_FLASH_CHECK ||
st == ST_FLASHING || st == ST_FLASH_DONE) {
bootloaderDrawTitle(126, "SD>FIRMWARE");
lcdDrawBitmapPattern(87, 16, LBM_SD, TEXT_COLOR);
if (st == ST_FLASHING || st == ST_FLASH_DONE) {
LcdFlags color = BARGRAPH1_COLOR; // red
if (st == ST_FLASH_DONE) {
color = BARGRAPH2_COLOR/* green */;
opt = 100; // Completed > 100%
}
lcdDrawRect(70, 120, 340, 31, 2);
lcdDrawSolidFilledRect(74, 124, (332 * opt) / 100, 23, color);
}
else if (st == ST_DIR_CHECK) {
if (opt == FR_NO_PATH) {
lcdDrawText(90, 168, "Directory is missing");
}
else {
lcdDrawText(90, 168, "Directory is empty");
}
lcdDrawBitmapPattern(356, 158, LBM_ERROR, BARGRAPH1_COLOR);
}
else if (st == ST_FLASH_CHECK) {
bootloaderDrawFilename(str, 0, true);
if (opt == FC_ERROR) {
lcdDrawText(94, 168, STR_INVALID_FIRMWARE);
lcdDrawBitmapPattern(356, 158, LBM_ERROR, BARGRAPH1_COLOR);
}
else if (opt == FC_OK) {
VersionTag tag;
extractFirmwareVersion(&tag);
lcdDrawText(168, 158, "Version:", RIGHT);
lcdDrawText(174, 158, tag.version);
lcdDrawText(168, 178, "Radio:", RIGHT);
lcdDrawText(174, 178, tag.flavour);
lcdDrawBitmapPattern(356, 158, LBM_OK, BARGRAPH2_COLOR);
}
}
bootloaderDrawFooter();
if ( st != ST_DIR_CHECK && (st != ST_FLASH_CHECK || opt == FC_OK)) {
lcdDrawBitmapPattern(28, 242, LBM_FLASH, TEXT_COLOR);
if (st == ST_FILE_LIST) {
lcdDrawText(56, 244, "[ENT] to select file");
}
else if (st == ST_FLASH_CHECK && opt == FC_OK) {
lcdDrawText(56, 244, "Hold [ENT] long to flash");
}
else if (st == ST_FLASHING) {
lcdDrawText(56, 244, "Writing Firmware ...");
}
else if (st == ST_FLASH_DONE) {
lcdDrawText(56, 244, "Writing Completed");
}
}
if (st != ST_FLASHING) {
lcdDrawBitmapPattern(305, 242, LBM_EXIT, TEXT_COLOR);
lcdDrawText(335, 244, "[RTN] to exit");
}
}
}
void bootloaderDrawFilename(const char* str, uint8_t line, bool selected)
{
lcdDrawBitmapPattern(94, 76 + (line * 25), LBM_FILE, TEXT_COLOR);
lcdDrawText(124, 75 + (line * 25), str);
if (selected) {
lcdDrawSolidRect(119, 72 + (line * 25), 278, 26, 2, LINE_COLOR);
}
}
+9
View File
@@ -313,6 +313,14 @@ FATFS g_FATFS_Obj __DMA; // initialized in boardInit()
FIL g_telemetryFile = {};
#endif
#if defined(BOOT)
void sdInit(void)
{
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
f_chdir("/");
}
}
#else
void sdInit()
{
TRACE("sdInit");
@@ -359,6 +367,7 @@ void sdDone()
f_mount(NULL, "", 0); // unmount SD
}
}
#endif
uint32_t sdMounted()
{
+37 -32
View File
@@ -22,7 +22,7 @@
#define _HAL_H_
// Keys
#define KEYS_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOH | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ)
#define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOH | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ)
#if defined(PCBX12S)
#define KEYS_GPIO_REG_PGUP GPIOC->IDR
#define KEYS_GPIO_PIN_PGUP GPIO_Pin_13 // PC.13
@@ -246,8 +246,11 @@
// Power
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ
#define PWR_GPIO GPIOJ
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
#define PWR_SWITCH_GPIO_REG PWR_GPIO->IDR
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
#define PWR_ON_GPIO_MODER GPIO_MODER_MODER1
#define PWR_ON_GPIO_MODER_OUT GPIO_MODER_MODER1_0
#if defined(PCBX10)
#define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOH
@@ -327,6 +330,7 @@
// LCD
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ | RCC_AHB1Periph_GPIOK | RCC_AHB1Periph_DMA2D)
#define LCD_RCC_APB1Periph 0
#define LCD_RCC_APB2Periph RCC_APB2Periph_LTDC
#if defined(PCBX12S)
#define LCD_GPIO_NRST GPIOF
@@ -340,39 +344,40 @@
// Backlight
#if defined(PCBX12S)
#define BL_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
#define BL_GPIO GPIOA
#define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
#define BACKLIGHT_GPIO GPIOA
#if PCBREV >= 13
#define BL_TIMER TIM5
#define BL_GPIO_PIN GPIO_Pin_3 // PA.03
#define BL_GPIO_PinSource GPIO_PinSource3
#define BL_RCC_APB1Periph RCC_APB1Periph_TIM5
#define BL_RCC_APB2Periph 0
#define BL_GPIO_AF GPIO_AF_TIM5
#define BL_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
#define BACKLIGHT_TIMER TIM5
#define BACKLIGHT_GPIO_PIN GPIO_Pin_3 // PA.03
#define BACKLIGHT_GPIO_PinSource GPIO_PinSource3
#define BACKLIGHT_RCC_APB1Periph RCC_APB1Periph_TIM5
#define BACKLIGHT_RCC_APB2Periph 0
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM5
#define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
#else
#define BL_TIMER TIM8
#define BL_GPIO_PIN GPIO_Pin_5 // PA.05
#define BL_GPIO_PinSource GPIO_PinSource5
#define BL_RCC_APB1Periph 0
#define BL_RCC_APB2Periph RCC_APB2Periph_TIM8
#define BL_GPIO_AF GPIO_AF_TIM8
#define BL_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
#define BACKLIGHT_TIMER TIM8
#define BACKLIGHT_GPIO_PIN GPIO_Pin_5 // PA.05
#define BACKLIGHT_GPIO_PinSource GPIO_PinSource5
#define BACKLIGHT_RCC_APB1Periph 0
#define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM8
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM8
#define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
#endif
#elif defined(PCBX10)
#define BL_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
#define BL_GPIO GPIOB
#define BL_TIMER TIM8
#define BL_GPIO_PIN GPIO_Pin_1 // PB.01
#define BL_GPIO_PinSource GPIO_PinSource1
#define BL_RCC_APB1Periph 0
#define BL_RCC_APB2Periph RCC_APB2Periph_TIM8
#define BL_GPIO_AF GPIO_AF_TIM8
#define BL_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
#define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
#define BACKLIGHT_GPIO GPIOB
#define BACKLIGHT_TIMER TIM8
#define BACKLIGHT_GPIO_PIN GPIO_Pin_1 // PB.01
#define BACKLIGHT_GPIO_PinSource GPIO_PinSource1
#define BACKLIGHT_RCC_APB1Periph 0
#define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM8
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM8
#define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
#endif
// SD
#define SD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
#define SD_RCC_APB1Periph 0
#define SD_PRESENT_GPIO GPIOC
#define SD_PRESENT_GPIO_PIN GPIO_Pin_5 // PC.05
#define SD_SDIO_DMA_STREAM DMA2_Stream3
@@ -607,11 +612,11 @@
#define TRAINER_DMA_FLAG_TC DMA_IT_TCIF2
#define TRAINER_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
// 1ms Interrupt
#define INTERRUPT_1MS_RCC_APB1Periph RCC_APB1Periph_TIM14
#define INTERRUPT_1MS_TIMER TIM14
#define INTERRUPT_1MS_IRQn TIM8_TRG_COM_TIM14_IRQn
#define INTERRUPT_1MS_IRQHandler TIM8_TRG_COM_TIM14_IRQHandler
// Xms Interrupt
#define INTERRUPT_xMS_RCC_APB1Periph RCC_APB1Periph_TIM14
#define INTERRUPT_xMS_TIMER TIM14
#define INTERRUPT_xMS_IRQn TIM8_TRG_COM_TIM14_IRQn
#define INTERRUPT_xMS_IRQHandler TIM8_TRG_COM_TIM14_IRQHandler
// 2MHz Timer
#define TIMER_2MHz_RCC_APB1Periph RCC_APB1Periph_TIM7
+1 -1
View File
@@ -211,12 +211,12 @@ void readKeysAndTrims()
} \
break
#if !defined(BOOT)
uint8_t keyState(uint8_t index)
{
return keys[index].state();
}
#if !defined(BOOT)
uint32_t switchState(uint8_t index)
{
uint32_t xxx = 0;
+186
View File
@@ -0,0 +1,186 @@
/*
*****************************************************************************
**
** File : stm32f4_flash.ld
**
** Abstract : Linker script for STM32F439 Device with
** 2MByte FLASH, 192KByte SRAM, 64KByte CCM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
*****************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20030000; /* end of 192K RAM */
_heap_end = 0xD0800000; /* end of 8192K SDRAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0; /* required amount of heap */
_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */
/* Main stack end */
_main_stack_start = _estack - _Main_Stack_Size;
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
SDRAM(xrw) : ORIGIN = 0xD0000000, LENGTH = 8192K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
KEEP(*(.version))
KEEP(*(.bootversiondata))
. = ALIGN(4); /* Align the start of the text part */
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
.ARM.extab :
{ *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = .;
/* Initialized data sections goes into RAM, load LMA copy after code */
.data : AT ( _sidata )
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >CCM
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
/* __bss_start__ = _sbss; */
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
} >CCM
/* Non-zeroed data section */
. = ALIGN(4);
.noinit (NOLOAD) :
{
*(.noinit)
} >CCM
/* collect all uninitialized .ccm sections */
.ram (NOLOAD) :
{
. = ALIGN(4);
_sram = .;
*(.ram)
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
. = . + _Min_Heap_Size;
. = . + _Main_Stack_Size;
. = ALIGN(4);
} >RAM
/* MEMORY_bank1 section, code must be located here explicitly */
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
.memory_b1_text :
{
*(.mb1text) /* .mb1text sections (code) */
*(.mb1text*) /* .mb1text* sections (code) */
*(.mb1rodata) /* read-only data (constants) */
*(.mb1rodata*)
} >MEMORY_B1
.sdram (NOLOAD) :
{
*(.sdram)
*(.sdram*)
*(.sdram_rodata)
*(.sdram_rodata*)
. = ALIGN(4);
_eram = .;
} >SDRAM
PROVIDE ( end = _eram );
PROVIDE ( _end = _eram );
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
+6 -1
View File
@@ -52,6 +52,11 @@ SECTIONS
CREATE_OBJECT_SYMBOLS
KEEP(*(.bootloader)) /* Bootloader code */
. = 0x20000; /* Set the start of the main program */
_stext = .; /* Provide the name for the start of this section */
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
KEEP(*(.fwversiondata))
*(.text) /* .text sections (code) */
@@ -60,7 +65,7 @@ SECTIONS
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))