Merge pull request #804 from opentx/kilrah/Bootloader
Kilrah/bootloader
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
/.*project
|
/.*project
|
||||||
/.settings
|
/.settings
|
||||||
/.autotools
|
/.autotools
|
||||||
|
radio/src/bootloader/.dep/
|
||||||
|
radio/src/bootloader/bootloader_ramBoot*
|
||||||
|
*.lbm
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ namespace Open9xGruvin9x {
|
|||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/simpgmspace.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
|
#include "radio/src/fonts.cpp"
|
||||||
#include "radio/src/audio_avr.cpp"
|
#include "radio/src/audio_avr.cpp"
|
||||||
#include "radio/src/buzzer.cpp"
|
#include "radio/src/buzzer.cpp"
|
||||||
#include "radio/src/targets/gruvin9x/somo14d.cpp"
|
#include "radio/src/targets/gruvin9x/somo14d.cpp"
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ namespace Open9xM128 {
|
|||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/simpgmspace.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
|
#include "radio/src/fonts.cpp"
|
||||||
#include "radio/src/audio_avr.cpp"
|
#include "radio/src/audio_avr.cpp"
|
||||||
#include "radio/src/targets/stock/voice.cpp"
|
#include "radio/src/targets/stock/voice.cpp"
|
||||||
#include "radio/src/telemetry/frsky.cpp"
|
#include "radio/src/telemetry/frsky.cpp"
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ namespace Open9xSky9x {
|
|||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/simpgmspace.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
|
#include "radio/src/fonts.cpp"
|
||||||
#include "radio/src/telemetry/frsky.cpp"
|
#include "radio/src/telemetry/frsky.cpp"
|
||||||
#include "radio/src/targets/sky9x/audio_driver.cpp"
|
#include "radio/src/targets/sky9x/audio_driver.cpp"
|
||||||
#include "radio/src/audio_arm.cpp"
|
#include "radio/src/audio_arm.cpp"
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ inline int geteepromsize() {
|
|||||||
#include "radio/src/protocols/ppm_arm.cpp"
|
#include "radio/src/protocols/ppm_arm.cpp"
|
||||||
#include "radio/src/protocols/pxx_arm.cpp"
|
#include "radio/src/protocols/pxx_arm.cpp"
|
||||||
#include "radio/src/protocols/dsm2_arm.cpp"
|
#include "radio/src/protocols/dsm2_arm.cpp"
|
||||||
#include "radio/src/targets/taranis/pwr_driver.cpp"
|
#include "radio/src/targets/taranis/pwr_driver.c"
|
||||||
#include "radio/src/eeprom_common.cpp"
|
#include "radio/src/eeprom_common.cpp"
|
||||||
#include "radio/src/eeprom_conversions.cpp"
|
#include "radio/src/eeprom_conversions.cpp"
|
||||||
#include "radio/src/eeprom_rlc.cpp"
|
#include "radio/src/eeprom_rlc.cpp"
|
||||||
@@ -106,6 +106,7 @@ inline int geteepromsize() {
|
|||||||
#define SDCARD
|
#define SDCARD
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
|
#include "radio/src/fonts.cpp"
|
||||||
#include "radio/src/telemetry/frsky_sport.cpp"
|
#include "radio/src/telemetry/frsky_sport.cpp"
|
||||||
#include "radio/src/targets/taranis/audio_driver.cpp"
|
#include "radio/src/targets/taranis/audio_driver.cpp"
|
||||||
#include "radio/src/audio_arm.cpp"
|
#include "radio/src/audio_arm.cpp"
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ namespace Open9x {
|
|||||||
#include "radio/src/telemetry/frsky.cpp"
|
#include "radio/src/telemetry/frsky.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
|
#include "radio/src/fonts.cpp"
|
||||||
#include "radio/src/targets/stock/voice.cpp"
|
#include "radio/src/targets/stock/voice.cpp"
|
||||||
#include "radio/src/buzzer.cpp"
|
#include "radio/src/buzzer.cpp"
|
||||||
#include "radio/src/translations/tts_en.cpp"
|
#include "radio/src/translations/tts_en.cpp"
|
||||||
|
|||||||
@@ -28,14 +28,20 @@ extern "C" {
|
|||||||
/ object instead of the sector buffer in the individual file object for file
|
/ object instead of the sector buffer in the individual file object for file
|
||||||
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
||||||
|
|
||||||
|
#if defined(BOOT)
|
||||||
|
#define _FS_READONLY 1 /* 0:Read/Write or 1:Read only */
|
||||||
|
#else
|
||||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||||
|
#endif
|
||||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||||
/ f_truncate and useless f_getfree. */
|
/ f_truncate and useless f_getfree. */
|
||||||
|
|
||||||
|
#if defined(BOOT)
|
||||||
|
#define _FS_MINIMIZE 1 /* 0 to 3 */
|
||||||
|
#else
|
||||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||||
|
#endif
|
||||||
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
||||||
/
|
/
|
||||||
/ 0: Full function.
|
/ 0: Full function.
|
||||||
@@ -45,7 +51,11 @@ extern "C" {
|
|||||||
/ 3: f_lseek is removed in addition to 2. */
|
/ 3: f_lseek is removed in addition to 2. */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(BOOT)
|
||||||
|
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
|
||||||
|
#else
|
||||||
#define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */
|
#define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */
|
||||||
|
#endif
|
||||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||||
|
|
||||||
|
|
||||||
@@ -186,7 +196,7 @@ extern "C" {
|
|||||||
/* A header file that defines sync object types on the O/S, such as
|
/* A header file that defines sync object types on the O/S, such as
|
||||||
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
|
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM) && !defined(BOOT)
|
||||||
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
|
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
|
||||||
#define _SYNC_t unsigned char /*OS_MutexID*/ /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
#define _SYNC_t unsigned char /*OS_MutexID*/ /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
||||||
#else
|
#else
|
||||||
|
|||||||
+35
-8
@@ -266,11 +266,16 @@ LUA = NO
|
|||||||
# Values = NO, READONLY, NOMENUS
|
# Values = NO, READONLY, NOMENUS
|
||||||
MENUS_LOCK == NO
|
MENUS_LOCK == NO
|
||||||
|
|
||||||
|
# Include bootloader, for now only for Taranis
|
||||||
|
# Values = YES, NO
|
||||||
|
BOOTLOADER = YES
|
||||||
|
|
||||||
#------- END BUILD OPTIONS ---------------------------
|
#------- END BUILD OPTIONS ---------------------------
|
||||||
|
|
||||||
# Define programs and commands.
|
# Define programs and commands.
|
||||||
SHELL = sh
|
SHELL = sh
|
||||||
IMG2LBM = -python ../util/img2lbm.py
|
IMG2LBM = -python ../util/img2lbm.py
|
||||||
|
BIN2LBM = -python ../util/bin2lbm.py
|
||||||
TRANSLATE = -python ../util/translate.py
|
TRANSLATE = -python ../util/translate.py
|
||||||
VERSION = 1.99
|
VERSION = 1.99
|
||||||
|
|
||||||
@@ -281,7 +286,7 @@ EXTRAINCDIRS =
|
|||||||
|
|
||||||
# MCU name
|
# MCU name
|
||||||
ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X TARANIS))
|
ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X TARANIS))
|
||||||
$(error Sorry, the PCB $(PCB) is not supported yet in openTx)
|
$(error Sorry, the PCB $(PCB) is not supported yet in OpenTX)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GVARS_VARIANT = +1
|
GVARS_VARIANT = +1
|
||||||
@@ -613,7 +618,11 @@ ifeq ($(PCB), TARANIS)
|
|||||||
else
|
else
|
||||||
CPPDEFS = -DREV4
|
CPPDEFS = -DREV4
|
||||||
endif
|
endif
|
||||||
LDSCRIPT = targets/taranis/stm32_flash.ld
|
ifeq ($(BOOTLOADER), YES)
|
||||||
|
LDSCRIPT = targets/taranis/stm32_flash_bl.ld
|
||||||
|
else
|
||||||
|
LDSCRIPT = targets/taranis/stm32_flash.ld
|
||||||
|
endif
|
||||||
TRGT = arm-none-eabi-
|
TRGT = arm-none-eabi-
|
||||||
MCU = cortex-m3
|
MCU = cortex-m3
|
||||||
OPT = 2
|
OPT = 2
|
||||||
@@ -627,12 +636,13 @@ ifeq ($(PCB), TARANIS)
|
|||||||
EXTRAINCDIRS += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc
|
EXTRAINCDIRS += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc
|
||||||
EXTRAINCDIRS += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc
|
EXTRAINCDIRS += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc
|
||||||
BOARDSRC = targets/taranis/board_taranis.cpp
|
BOARDSRC = targets/taranis/board_taranis.cpp
|
||||||
EXTRABOARDSRC += targets/taranis/lcd_driver.cpp targets/taranis/aspi.cpp targets/taranis/i2c.c
|
EXTRABOARDSRC += targets/taranis/lcd_driver.cpp targets/taranis/aspi.c targets/taranis/i2c.c targets/taranis/delays.c
|
||||||
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
|
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
|
||||||
|
SRC += targets/taranis/pwr_driver.c targets/taranis/usb_driver.c
|
||||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp
|
||||||
PULSESSRC = protocols/pulses_arm.cpp protocols/ppm_arm.cpp protocols/pxx_arm.cpp
|
PULSESSRC = protocols/pulses_arm.cpp protocols/ppm_arm.cpp protocols/pxx_arm.cpp
|
||||||
CPPSRC += audio_arm.cpp
|
CPPSRC += audio_arm.cpp
|
||||||
CPPSRC += targets/taranis/pwr_driver.cpp targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/delays.cpp targets/taranis/uart3_driver.cpp targets/taranis/sport_driver.cpp
|
CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/uart3_driver.cpp targets/taranis/sport_driver.cpp
|
||||||
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp
|
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp
|
||||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
||||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c
|
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c
|
||||||
@@ -697,6 +707,11 @@ ifeq ($(PCB), TARANIS)
|
|||||||
CPPSRC += protocols/hubsan.cpp
|
CPPSRC += protocols/hubsan.cpp
|
||||||
CPPSRC += targets/taranis/a7105_driver.cpp
|
CPPSRC += targets/taranis/a7105_driver.cpp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BOOTLOADER), YES)
|
||||||
|
CPPSRC += loadboot.cpp
|
||||||
|
CPPDEFS += -DBOOTLOADER
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC = $(TRGT)gcc
|
CC = $(TRGT)gcc
|
||||||
@@ -728,7 +743,7 @@ else
|
|||||||
TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi")
|
TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPSRC += opentx.cpp $(PULSESSRC) stamp.cpp gui/menus.cpp gui/menu_model.cpp gui/menu_general.cpp gui/view_main.cpp gui/view_statistics.cpp $(EEPROMSRC) lcd.cpp keys.cpp maths.cpp translations.cpp $(TTS_SRC)
|
CPPSRC += opentx.cpp $(PULSESSRC) stamp.cpp gui/menus.cpp gui/menu_model.cpp gui/menu_general.cpp gui/view_main.cpp gui/view_statistics.cpp $(EEPROMSRC) lcd.cpp keys.cpp maths.cpp translations.cpp fonts.cpp $(TTS_SRC)
|
||||||
|
|
||||||
# Debugging format.
|
# Debugging format.
|
||||||
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
|
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
|
||||||
@@ -1082,10 +1097,21 @@ 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 ifeq ($(PCB), TARANIS)
|
||||||
|
build: stamp_header tra lbm bootloader.lbm allsrc.cpp elf remallsrc bin
|
||||||
else
|
else
|
||||||
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
|
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# build bootloader
|
||||||
|
bootloader.lbm: bootloader/bootloader_ramBoot.bin
|
||||||
|
test -z "$$(find $^ -size +32k)"
|
||||||
|
$(BIN2LBM) $^ $@
|
||||||
|
|
||||||
|
.PHONY bootloader/bootloader_ramBoot.bin:
|
||||||
|
@echo "Building bootloader..."
|
||||||
|
$(MAKE) -C bootloader PCB=$(PCB) PCBREV=$(PCBREV)
|
||||||
|
|
||||||
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
|
||||||
lbm: fonts bitmaps/sticks.lbm
|
lbm: fonts bitmaps/sticks.lbm
|
||||||
|
|
||||||
@@ -1237,7 +1263,7 @@ sizeafter:
|
|||||||
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); fi
|
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); fi
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion:
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
FOXINC=-I/usr/local/include/fox-1.6 -I/usr/include/fox-1.6 \
|
FOXINC=-I/usr/local/include/fox-1.6 -I/usr/include/fox-1.6 \
|
||||||
@@ -1277,8 +1303,7 @@ endif
|
|||||||
%.eep: %.elf
|
%.eep: %.elf
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_EEPROM) $@
|
@echo $(MSG_EEPROM) $@
|
||||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||||
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
|
||||||
|
|
||||||
# Create a symbol table from ELF output file.
|
# Create a symbol table from ELF output file.
|
||||||
%.sym: %.elf
|
%.sym: %.elf
|
||||||
@@ -1344,6 +1369,8 @@ clean_list :
|
|||||||
$(REMOVE) *.lst
|
$(REMOVE) *.lst
|
||||||
$(REMOVE) allsrc.cpp
|
$(REMOVE) allsrc.cpp
|
||||||
$(REMOVE) stamp-opentx.h
|
$(REMOVE) stamp-opentx.h
|
||||||
|
$(REMOVE) `find . -name "*.lbm"`
|
||||||
|
$(MAKE) -C bootloader clean
|
||||||
|
|
||||||
#### Install
|
#### Install
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,342 @@
|
|||||||
|
#
|
||||||
|
# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
|
||||||
|
#
|
||||||
|
##############################################################################################
|
||||||
|
#
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Create project
|
||||||
|
#
|
||||||
|
# make clean = Clean project files.
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" and "make all".
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################################
|
||||||
|
# Start of default section
|
||||||
|
#
|
||||||
|
|
||||||
|
TRGT = arm-none-eabi-
|
||||||
|
CC = $(TRGT)gcc
|
||||||
|
CP = $(TRGT)objcopy
|
||||||
|
CLSS = $(TRGT)objdump
|
||||||
|
AS = $(TRGT)as
|
||||||
|
#gcc -x assembler-with-cpp
|
||||||
|
BIN = $(CP) -O ihex
|
||||||
|
BINX = $(CP) -O binary
|
||||||
|
|
||||||
|
OBJDIR = .
|
||||||
|
|
||||||
|
MCU = cortex-m3
|
||||||
|
|
||||||
|
# List all default C defines here, like -D_DEBUG=1
|
||||||
|
DDEFS =
|
||||||
|
|
||||||
|
# List all default ASM defines here, like -D_DEBUG=1
|
||||||
|
DADEFS =
|
||||||
|
|
||||||
|
# List all default directories to look for include files here
|
||||||
|
DINCDIR =
|
||||||
|
|
||||||
|
# List the default directory to look for the libraries here
|
||||||
|
DLIBDIR =
|
||||||
|
|
||||||
|
# List all default libraries here
|
||||||
|
DLIBS =
|
||||||
|
|
||||||
|
MEMORIES = sram
|
||||||
|
|
||||||
|
EXT = STD
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of default section
|
||||||
|
##############################################################################################
|
||||||
|
|
||||||
|
##############################################################################################
|
||||||
|
# Start of user section
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Define project name and Ram/Flash mode here
|
||||||
|
PROJECT = bootloader
|
||||||
|
|
||||||
|
ifeq ($(PCB), TARANIS)
|
||||||
|
RUN_FROM_FLASH = 0
|
||||||
|
else
|
||||||
|
ifeq ($(PCB), X9D)
|
||||||
|
RUN_FROM_FLASH = 0
|
||||||
|
else
|
||||||
|
RUN_FROM_FLASH = 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# PCB revision
|
||||||
|
PCBREV =
|
||||||
|
|
||||||
|
EXTRAINCDIRS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# Define linker script file here
|
||||||
|
#
|
||||||
|
ifeq ($(RUN_FROM_FLASH), 1)
|
||||||
|
ifeq ($(REVX), 1)
|
||||||
|
LDSCRIPT = sam3s8c_boot.ld
|
||||||
|
FULL_PRJ = $(PROJECT)_flash8
|
||||||
|
EXTRAINCDIRS += include
|
||||||
|
# EXTRAINCDIRS += ../
|
||||||
|
else
|
||||||
|
LDSCRIPT = sam3s4c_boot.ld
|
||||||
|
FULL_PRJ = $(PROJECT)_flash4
|
||||||
|
EXTRAINCDIRS += include
|
||||||
|
# EXTRAINCDIRS += ../
|
||||||
|
endif
|
||||||
|
TRGT = arm-none-eabi-
|
||||||
|
CPPDEFS += -DPCBSKY
|
||||||
|
UDEFS = -Dat91sam3s8
|
||||||
|
|
||||||
|
# If REVX board
|
||||||
|
ifeq ($(REVX), 1)
|
||||||
|
CPPDEFS += -DREVX
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPDEFS += -DREVB
|
||||||
|
|
||||||
|
else
|
||||||
|
ifeq ($(PCB), TARANIS)
|
||||||
|
ARCH = ARM
|
||||||
|
LDSCRIPT = ../targets/taranis/stm32_ramBoot.ld
|
||||||
|
TRGT = arm-none-eabi-
|
||||||
|
CPPDEFS += -DHSE_VALUE=12000000
|
||||||
|
CPPDEFS += -DPCBTARANIS
|
||||||
|
FULL_PRJ = $(PROJECT)_ramBoot
|
||||||
|
EXTRAINCDIRS += ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc
|
||||||
|
EXTRAINCDIRS += ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include
|
||||||
|
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc
|
||||||
|
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc
|
||||||
|
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc
|
||||||
|
EXTRAINCDIRS += ../targets/taranis
|
||||||
|
EXTRAINCDIRS += ../fonts/std
|
||||||
|
|
||||||
|
ifeq ($(PCBREV), REV3)
|
||||||
|
CPPDEFS += -DREV3
|
||||||
|
else ifeq ($(PCBREV), REV4a)
|
||||||
|
CPPDEFS += -DREV4a
|
||||||
|
else
|
||||||
|
CPPDEFS += -DREV4
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# List all user C define here, like -D_DEBUG=1
|
||||||
|
|
||||||
|
# Define ASM defines here
|
||||||
|
UADEFS =
|
||||||
|
|
||||||
|
ifeq ($(PCB), TARANIS)
|
||||||
|
SRC = ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c \
|
||||||
|
../targets/taranis/i2c.c \
|
||||||
|
../targets/taranis/delays.c \
|
||||||
|
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c \
|
||||||
|
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c \
|
||||||
|
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c \
|
||||||
|
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c \
|
||||||
|
../FatFs/ff.c \
|
||||||
|
../FatFs/option/ccsbcs.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_core.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd_int.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c \
|
||||||
|
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c \
|
||||||
|
../targets/taranis/usbd_desc.c \
|
||||||
|
../targets/taranis/aspi.c \
|
||||||
|
../targets/taranis/usb_bsp.c \
|
||||||
|
../targets/taranis/usb_driver.c \
|
||||||
|
../targets/taranis/pwr_driver.c
|
||||||
|
|
||||||
|
CPPSRC = ../targets/taranis/lcd_driver.cpp \
|
||||||
|
../targets/taranis/keys_driver.cpp \
|
||||||
|
../targets/taranis/diskio.cpp \
|
||||||
|
../targets/taranis/usbd_usr.cpp \
|
||||||
|
../targets/taranis/usbd_storage_msd.cpp \
|
||||||
|
../lcd.cpp \
|
||||||
|
../keys.cpp \
|
||||||
|
../fonts.cpp \
|
||||||
|
boot.cpp
|
||||||
|
|
||||||
|
# List ASM source files here
|
||||||
|
ASRC = ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
# List C source files here
|
||||||
|
SRC = core_cm3.c \
|
||||||
|
board_lowlevel.c \
|
||||||
|
crt.c \
|
||||||
|
usb/device/core/USBD_UDP.c usb/device/core/USBDDriver.c usb/device/core/USBDCallbacks.c \
|
||||||
|
usb/device/massstorage/MSDDriver.c usb/device/massstorage/MSDDStateMachine.c \
|
||||||
|
usb/device/massstorage/MSDLun.c usb/device/massstorage/MSDDriverDescriptors.c usb/device/massstorage/SBCMethods.c \
|
||||||
|
usb/common/core/USBEndpointDescriptor.c usb/common/core/USBGenericRequest.c \
|
||||||
|
usb/common/core/USBFeatureRequest.c usb/common/core/USBInterfaceRequest.c usb/common/core/USBGetDescriptorRequest.c \
|
||||||
|
usb/common/core/USBSetAddressRequest.c usb/common/core/USBSetConfigurationRequest.c \
|
||||||
|
usb/common/core/USBConfigurationDescriptor.c usb/common/core/USBGenericDescriptor.c \
|
||||||
|
MEDSdcard.c \
|
||||||
|
vectors_sam3s.c
|
||||||
|
|
||||||
|
CPPSRC = lcdboot.cpp \
|
||||||
|
ff.cpp \
|
||||||
|
diskio.cpp \
|
||||||
|
driversboot.cpp \
|
||||||
|
logicioboot.cpp \
|
||||||
|
sdcard_driver.cpp \
|
||||||
|
massstorage.cpp \
|
||||||
|
bootsamEeprom.cpp \
|
||||||
|
ff_lfn.cpp \
|
||||||
|
power.cpp \
|
||||||
|
boot.cpp
|
||||||
|
|
||||||
|
# List ASM source files here
|
||||||
|
ASRC =
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# List all user directories here
|
||||||
|
UINCDIR = ./inc
|
||||||
|
# \
|
||||||
|
# ./cmsis/core \
|
||||||
|
# ./cmsis/device
|
||||||
|
|
||||||
|
# List the user directory to look for the libraries here
|
||||||
|
ULIBDIR =
|
||||||
|
|
||||||
|
# List all user libraries here
|
||||||
|
ULIBS =
|
||||||
|
|
||||||
|
# Define optimisation level here
|
||||||
|
OPT = -Os
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of user defines
|
||||||
|
##############################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
VPATH = $(DIRS)
|
||||||
|
|
||||||
|
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
||||||
|
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
||||||
|
|
||||||
|
ifeq ($(RUN_FROM_FLASH), 0)
|
||||||
|
DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=0
|
||||||
|
else
|
||||||
|
DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ADEFS = $(DADEFS) $(UADEFS)
|
||||||
|
|
||||||
|
AXOBJS = $(ASRC:%.s=%.o)
|
||||||
|
CXOBJS = $(SRC:%.c=%.o)
|
||||||
|
CPPXOBJS = $(CPPSRC:%.cpp=%.o)
|
||||||
|
|
||||||
|
LIBS = $(DLIBS) $(ULIBS)
|
||||||
|
MCFLAGS = -mcpu=$(MCU)
|
||||||
|
|
||||||
|
#ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(OBJDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
|
||||||
|
CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
|
||||||
|
LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch $(LIBDIR)
|
||||||
|
CPPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm $(DEFS)
|
||||||
|
|
||||||
|
CPPFLAGS += $(CPPDEFS)
|
||||||
|
CPFLAGS += $(CPPDEFS)
|
||||||
|
CPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
|
||||||
|
AOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(AXOBJS) ))
|
||||||
|
COBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CXOBJS) ))
|
||||||
|
CPPOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CPPXOBJS) ))
|
||||||
|
DIRS = $(sort $(dir $(AXOBJS) $(CXOBJS) $(CPPXOBJS) ) )
|
||||||
|
|
||||||
|
|
||||||
|
CPPDEFS += -DCPUARM
|
||||||
|
|
||||||
|
# If serial Debug required
|
||||||
|
ifeq ($(DEBUG), 1)
|
||||||
|
CPPDEFS += -DDEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPDEFS += -DBOOT
|
||||||
|
|
||||||
|
# Generate dependency information
|
||||||
|
CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
||||||
|
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
|
||||||
|
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
|
||||||
|
#
|
||||||
|
# makefile rules
|
||||||
|
#
|
||||||
|
|
||||||
|
all: size_before $(OBJS) $(COBJS) $(CPPOBJS) $(FULL_PRJ).elf $(FULL_PRJ).hex $(FULL_PRJ).lss $(FULL_PRJ).bin size
|
||||||
|
|
||||||
|
#begin:
|
||||||
|
# @echo $(AXOBJS) $(CXOBJS) $(CPPXOBJS)
|
||||||
|
# @echo
|
||||||
|
# @echo $(OBJS) $(COBJS) $(CPPOBJS)
|
||||||
|
# @echo
|
||||||
|
# @echo $(DIRS)
|
||||||
|
|
||||||
|
size_before:
|
||||||
|
# arm-none-eabi-size $(FULL_PRJ).elf
|
||||||
|
@if test -f $(FULL_PRJ).elf; then arm-none-eabi-size $(FULL_PRJ).elf; fi
|
||||||
|
|
||||||
|
size:
|
||||||
|
# arm-none-eabi-size $(FULL_PRJ).elf
|
||||||
|
@if test -f $(FULL_PRJ).elf; then arm-none-eabi-size $(FULL_PRJ).elf; fi
|
||||||
|
|
||||||
|
$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp
|
||||||
|
$(CC) -c $(CPPFLAGS) -fno-exceptions -I . $(INCDIR) $< -o $@
|
||||||
|
|
||||||
|
$(COBJS) : $(OBJDIR)/%.o : %.c
|
||||||
|
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
$(AOBJS) : $(OBJDIR)/%.o : %.s
|
||||||
|
$(AS) -c $(ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
%elf: $(AOBJS) $(COBJS) $(CPPOBJS)
|
||||||
|
$(CC) $(AOBJS) $(COBJS) $(CPPOBJS) $(LDFLAGS) $(LIBS) -o $@
|
||||||
|
|
||||||
|
# Create extended listing file from ELF output file.
|
||||||
|
%.lss: %.elf
|
||||||
|
$(CLSS) -h -S $< > $@
|
||||||
|
|
||||||
|
%hex: %elf
|
||||||
|
$(BIN) $< $@
|
||||||
|
|
||||||
|
%bin: %elf
|
||||||
|
$(BINX) $< $@
|
||||||
|
|
||||||
|
# $(PROJECT)_flash8
|
||||||
|
# $(PROJECT)_flash4
|
||||||
|
# $(PROJECT)_ramBootS
|
||||||
|
# $(PROJECT)_ramBootT
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f *.o
|
||||||
|
-rm -f *.elf
|
||||||
|
-rm -f *.map
|
||||||
|
-rm -f *.hex
|
||||||
|
-rm -f *.bin
|
||||||
|
-rm -f *.lss
|
||||||
|
-rm -fR .dep
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Include the dependency files, should be the last of the makefile
|
||||||
|
#
|
||||||
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||||
|
|
||||||
|
# *** EOF ***
|
||||||
@@ -0,0 +1,944 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (c) 2014 by Michael Blandford. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the author nor the names of its contributors may
|
||||||
|
* be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
|
* Other Authors:
|
||||||
|
* - Andre Bernet
|
||||||
|
* - Bertrand Songis
|
||||||
|
* - Bryan J. Rentoul (Gruvin)
|
||||||
|
* - Cameron Weeks
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini
|
||||||
|
* - Thomas Husterer
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* Headers
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
#include "stm32f2xx_flash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "board_taranis.h"
|
||||||
|
#include "../pwr.h"
|
||||||
|
#include "../lcd.h"
|
||||||
|
#include "../keys.h"
|
||||||
|
#include "../sdcard.h"
|
||||||
|
#include "../FatFs/ff.h"
|
||||||
|
#include "../FatFs/diskio.h"
|
||||||
|
#include "../translations/en.h"
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
#define BOOTLOADER_TITLE "Boot Loader - FrSky Taranis"
|
||||||
|
#define BOOT_KEY_UP KEY_PLUS
|
||||||
|
#define BOOT_KEY_DOWN KEY_MINUS
|
||||||
|
#define BOOT_KEY_LEFT KEY_MENU
|
||||||
|
#define BOOT_KEY_RIGHT KEY_PAGE
|
||||||
|
#define BOOT_KEY_MENU KEY_ENTER
|
||||||
|
#define BOOT_KEY_EXIT KEY_EXIT
|
||||||
|
#define DISPLAY_CHAR_WIDTH 35
|
||||||
|
#elif defined(PCBSKY9X)
|
||||||
|
#define BOOTLOADER_TITLE "Boot Loader - Sky9x"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BOOTLOADER_SIZE 0x8000
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
#define FIRMWARE_ADDRESS 0x08000000
|
||||||
|
#elif defined(PCBSKY9X)
|
||||||
|
#define FIRMWARE_ADDRESS 0x00400000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// states
|
||||||
|
enum BootLoaderStates {
|
||||||
|
ST_START,
|
||||||
|
ST_FLASH_MENU,
|
||||||
|
ST_DIR_CHECK,
|
||||||
|
ST_OPEN_DIR,
|
||||||
|
ST_FILE_LIST,
|
||||||
|
ST_FLASH_CHECK,
|
||||||
|
ST_FLASHING,
|
||||||
|
ST_FLASH_DONE,
|
||||||
|
ST_USB,
|
||||||
|
ST_REBOOT,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* Local variables
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
uint32_t FirmwareSize;
|
||||||
|
|
||||||
|
uint32_t Master_frequency;
|
||||||
|
volatile uint8_t Tenms;
|
||||||
|
uint8_t EE_timer;
|
||||||
|
|
||||||
|
TCHAR FlashFilename[60];
|
||||||
|
FIL FlashFile;
|
||||||
|
DIR Dj;
|
||||||
|
FILINFO Finfo;
|
||||||
|
|
||||||
|
TCHAR Filenames[20][50];
|
||||||
|
uint32_t FileSize[20];
|
||||||
|
uint32_t FnStartIndex;
|
||||||
|
uint32_t Valid;
|
||||||
|
|
||||||
|
uint32_t FlashSize;
|
||||||
|
|
||||||
|
uint32_t FlashBlocked = 1;
|
||||||
|
uint32_t LockBits;
|
||||||
|
|
||||||
|
uint32_t Block_buffer[1024];
|
||||||
|
UINT BlockCount;
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
extern int32_t EblockAddress;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint32_t EepromBlocked;
|
||||||
|
|
||||||
|
extern void init_spi(void);
|
||||||
|
extern void writeBlock(void);
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* Global functions
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
// Starts TIMER0 at full speed (MCK/2) for delay timing
|
||||||
|
// @ 36MHz this is 18MHz
|
||||||
|
// This was 6 MHz, we may need to slow it to TIMER_CLOCK2 (MCK/8=4.5 MHz)
|
||||||
|
void start_timer0()
|
||||||
|
{
|
||||||
|
register Tc *ptc;
|
||||||
|
|
||||||
|
PMC->PMC_PCER0 |= 0x00800000L; // Enable peripheral clock to TC0
|
||||||
|
|
||||||
|
ptc = TC0;// Tc block 0 (TC0-2)
|
||||||
|
ptc->TC_BCR = 0;// No sync
|
||||||
|
ptc->TC_BMR = 2;
|
||||||
|
ptc->TC_CHANNEL[0].TC_CMR = 0x00008001;// Waveform mode MCK/8 for 36MHz osc.(Upset be write below)
|
||||||
|
ptc->TC_CHANNEL[0].TC_RC = 0xFFF0;
|
||||||
|
ptc->TC_CHANNEL[0].TC_RA = 0;
|
||||||
|
ptc->TC_CHANNEL[0].TC_CMR = 0x00008040;// 0000 0000 0000 0000 1000 0000 0100 0000, stop at regC, 18MHz
|
||||||
|
ptc->TC_CHANNEL[0].TC_CCR = 5;// Enable clock and trigger it (may only need trigger)
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop_timer0( void )
|
||||||
|
{
|
||||||
|
TC0->TC_CHANNEL[0].TC_CCR = TC_CCR0_CLKDIS; // Disable clock
|
||||||
|
}
|
||||||
|
|
||||||
|
void delay2ms()
|
||||||
|
{
|
||||||
|
TC0->TC_CHANNEL[0].TC_CCR = 5;// Enable clock and trigger it (may only need trigger)
|
||||||
|
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 )// 2mS, Value depends on MCK/2 (used 18MHz)
|
||||||
|
{
|
||||||
|
// Wait
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
uint32_t isFirmwareStart(uint32_t *block)
|
||||||
|
{
|
||||||
|
if ((block[0] & 0xFFFC0000) != 0x20000000) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((block[1] & 0xFFF00000) != 0x08000000) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((block[2] & 0xFFF00000) != 0x08000000) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#elif defined(PCBSKY9X)
|
||||||
|
uint32_t isFirmwareStart( uint32_t *block )
|
||||||
|
{
|
||||||
|
if ((block[0] & 0xFFFE3000) != 0x20000000 ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((block[1] & 0xFFF80000) != 0x00400000) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((block[2] & 0xFFF80000) != 0x00400000) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
|
||||||
|
uint32_t (*IAP_Function)(uint32_t, uint32_t);
|
||||||
|
|
||||||
|
uint32_t program( uint32_t *address, uint32_t *buffer ) // size is 256 bytes
|
||||||
|
{
|
||||||
|
uint32_t FlashSectorNum;
|
||||||
|
uint32_t flash_cmd = 0;
|
||||||
|
uint32_t i;
|
||||||
|
// uint32_t flash_status = 0;
|
||||||
|
// uint32_t EFCIndex = 0; // 0:EEFC0, 1: EEFC1
|
||||||
|
/* Initialize the function pointer (retrieve function address from NMI vector) */
|
||||||
|
|
||||||
|
if ((uint32_t) address == FIRMWARE_START+BOOTLOADER_SIZE) {
|
||||||
|
if (isFirmwareStart(buffer))
|
||||||
|
FlashBlocked = 0;
|
||||||
|
else
|
||||||
|
FlashBlocked = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlashBlocked) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always initialise this here, setting a default doesn't seem to work
|
||||||
|
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
|
||||||
|
FlashSectorNum = (uint32_t) address;
|
||||||
|
FlashSectorNum >>= 8;// page size is 256 bytes
|
||||||
|
FlashSectorNum &= 2047;// max page number
|
||||||
|
|
||||||
|
/* Send data to the sector here */
|
||||||
|
for ( i = 0; i < 64; i += 1 )
|
||||||
|
{
|
||||||
|
*address++ = *buffer++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build the command to send to EEFC */
|
||||||
|
flash_cmd = (0x5A << 24) | (FlashSectorNum << 8) | 0x03; //AT91C_MC_FCMD_EWP ;
|
||||||
|
|
||||||
|
__disable_irq();
|
||||||
|
/* Call the IAP function with appropriate command */
|
||||||
|
i = IAP_Function( 0, flash_cmd );
|
||||||
|
__enable_irq();
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t readLockBits()
|
||||||
|
{
|
||||||
|
// Always initialise this here, setting a default doesn't seem to work
|
||||||
|
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
|
||||||
|
|
||||||
|
uint32_t flash_cmd = (0x5A << 24) | 0x0A;//AT91C_MC_FCMD_GLB ;
|
||||||
|
__disable_irq();
|
||||||
|
(void) IAP_Function( 0, flash_cmd );
|
||||||
|
__enable_irq();
|
||||||
|
return EFC->EEFC_FRR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearLockBits()
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
uint32_t flash_cmd = 0;
|
||||||
|
|
||||||
|
// Always initialise this here, setting a default doesn't seem to work
|
||||||
|
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
|
||||||
|
for ( i = 0; i < 16; i += 1 )
|
||||||
|
{
|
||||||
|
flash_cmd = (0x5A << 24) | ((128*i) << 8) | 0x09; //AT91C_MC_FCMD_CLB ;
|
||||||
|
__disable_irq();
|
||||||
|
/* Call the IAP function with appropriate command */
|
||||||
|
(void) IAP_Function( 0, flash_cmd );
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void interrupt10ms(void)
|
||||||
|
{
|
||||||
|
Tenms |= 1; // 10 mS has passed
|
||||||
|
|
||||||
|
uint8_t enuk = KEY_MENU;
|
||||||
|
uint8_t in = ~readKeys();
|
||||||
|
|
||||||
|
for (int i = 1; i < 7; i++) {
|
||||||
|
uint8_t value = in & (1 << i);
|
||||||
|
keys[enuk].input(value, (EnumKeys) enuk);
|
||||||
|
++enuk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
void init10msTimer()
|
||||||
|
{
|
||||||
|
register Tc *ptc;
|
||||||
|
register uint32_t timer;
|
||||||
|
|
||||||
|
PMC->PMC_PCER0 |= 0x02000000L; // Enable peripheral clock to TC2
|
||||||
|
|
||||||
|
timer = Master_frequency / 12800;// MCK/128 and 100 Hz
|
||||||
|
|
||||||
|
ptc = TC0;// Tc block 0 (TC0-2)
|
||||||
|
ptc->TC_BCR = 0;// No sync
|
||||||
|
ptc->TC_BMR = 0;
|
||||||
|
ptc->TC_CHANNEL[2].TC_CMR = 0x00008000;// Waveform mode
|
||||||
|
ptc->TC_CHANNEL[2].TC_RC = timer;// 10 Hz
|
||||||
|
ptc->TC_CHANNEL[2].TC_RA = timer >> 1;
|
||||||
|
ptc->TC_CHANNEL[2].TC_CMR = 0x0009C003;// 0000 0000 0000 1001 1100 0000 0000 0011
|
||||||
|
// MCK/128, set @ RA, Clear @ RC waveform
|
||||||
|
ptc->TC_CHANNEL[2].TC_CCR = 5;// Enable clock and trigger it (may only need trigger)
|
||||||
|
|
||||||
|
NVIC_EnableIRQ(TC2_IRQn);
|
||||||
|
TC0->TC_CHANNEL[2].TC_IER = TC_IER0_CPCS;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void TC2_IRQHandler()
|
||||||
|
{
|
||||||
|
register uint32_t dummy;
|
||||||
|
|
||||||
|
/* Clear status bit to acknowledge interrupt */
|
||||||
|
dummy = TC0->TC_CHANNEL[2].TC_SR;
|
||||||
|
(void) dummy; // Discard value - prevents compiler warning
|
||||||
|
|
||||||
|
interrupt10ms();
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
void init10msTimer()
|
||||||
|
{
|
||||||
|
// Timer14
|
||||||
|
RCC->APB1ENR |= RCC_APB1ENR_TIM14EN; // Enable clock
|
||||||
|
TIM14->ARR = 9999; // 10mS
|
||||||
|
TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1; // 1uS from 12MHz
|
||||||
|
TIM14->CCER = 0;
|
||||||
|
TIM14->CCMR1 = 0;
|
||||||
|
TIM14->EGR = 0;
|
||||||
|
TIM14->CR1 = 5;
|
||||||
|
TIM14->DIER |= 1;
|
||||||
|
NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void TIM8_TRG_COM_TIM14_IRQHandler()
|
||||||
|
{
|
||||||
|
TIM14->SR &= ~TIM_SR_UIF;
|
||||||
|
interrupt10ms();
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_hw_timer()
|
||||||
|
{
|
||||||
|
// Timer13
|
||||||
|
RCC->APB1ENR |= RCC_APB1ENR_TIM13EN; // Enable clock
|
||||||
|
TIM13->ARR = 65535;
|
||||||
|
TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000000 - 1;// 0.1uS from 12MHz
|
||||||
|
TIM13->CCER = 0;
|
||||||
|
TIM13->CCMR1 = 0;
|
||||||
|
TIM13->EGR = 0;
|
||||||
|
TIM13->CR1 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// delay in units of 0.1 uS up to 6.5535 mS
|
||||||
|
void hw_delay(uint16_t time)
|
||||||
|
{
|
||||||
|
TIM13->CNT = 0;
|
||||||
|
TIM13->EGR = 1; // Re-start counter
|
||||||
|
while ( TIM13->CNT < time) {
|
||||||
|
// wait
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the
|
||||||
|
//Flash memory against possible unwanted operations due, for example, to electric
|
||||||
|
//disturbances. The following sequence is used to unlock this register:
|
||||||
|
//1. Write KEY1 = 0x45670123 in the Flash key register (FLASH_KEYR)
|
||||||
|
//2. Write KEY2 = 0xCDEF89AB in the Flash key register (FLASH_KEYR)
|
||||||
|
//Any wrong sequence will return a bus error and lock up the FLASH_CR register until the
|
||||||
|
//next reset.
|
||||||
|
//The FLASH_CR register can be locked again by software by setting the LOCK bit in the
|
||||||
|
//FLASH_CR register.
|
||||||
|
void unlockFlash()
|
||||||
|
{
|
||||||
|
FLASH->KEYR = 0x45670123;
|
||||||
|
FLASH->KEYR = 0xCDEF89AB;
|
||||||
|
}
|
||||||
|
|
||||||
|
void waitFlashIdle()
|
||||||
|
{
|
||||||
|
while (FLASH->SR & FLASH_FLAG_BSY) {
|
||||||
|
wdt_reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SECTOR_MASK ((uint32_t)0xFFFFFF07)
|
||||||
|
|
||||||
|
void eraseSector(uint32_t sector)
|
||||||
|
{
|
||||||
|
waitFlashIdle();
|
||||||
|
|
||||||
|
FLASH->CR &= CR_PSIZE_MASK;
|
||||||
|
FLASH->CR |= FLASH_PSIZE_WORD;
|
||||||
|
FLASH->CR &= SECTOR_MASK;
|
||||||
|
FLASH->CR |= FLASH_CR_SER | (sector << 3);
|
||||||
|
FLASH->CR |= FLASH_CR_STRT;
|
||||||
|
|
||||||
|
/* Wait for operation to be completed */
|
||||||
|
waitFlashIdle();
|
||||||
|
|
||||||
|
/* if the erase operation is completed, disable the SER Bit */
|
||||||
|
FLASH->CR &= (~FLASH_CR_SER);
|
||||||
|
FLASH->CR &= SECTOR_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t program(uint32_t *address, uint32_t *buffer) // size is 256 bytes
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
if ((uint32_t) address == 0x08008000) {
|
||||||
|
if (isFirmwareStart(buffer)) {
|
||||||
|
FlashBlocked = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
FlashBlocked = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlashBlocked) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((uint32_t) address == 0x08008000) {
|
||||||
|
eraseSector(2);
|
||||||
|
}
|
||||||
|
if ((uint32_t) address == 0x0800C000) {
|
||||||
|
eraseSector(3);
|
||||||
|
}
|
||||||
|
if ((uint32_t) address == 0x08010000) {
|
||||||
|
eraseSector(4);
|
||||||
|
}
|
||||||
|
if ((uint32_t) address == 0x08020000) {
|
||||||
|
eraseSector(5);
|
||||||
|
}
|
||||||
|
if ((uint32_t) address == 0x08040000) {
|
||||||
|
eraseSector(6);
|
||||||
|
}
|
||||||
|
if ((uint32_t) address == 0x08060000) {
|
||||||
|
eraseSector(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now program the 256 bytes
|
||||||
|
|
||||||
|
for (i = 0; i < 64; i += 1) {
|
||||||
|
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
|
||||||
|
be done by word */
|
||||||
|
|
||||||
|
// Wait for last operation to be completed
|
||||||
|
waitFlashIdle();
|
||||||
|
|
||||||
|
FLASH->CR &= CR_PSIZE_MASK;
|
||||||
|
FLASH->CR |= FLASH_PSIZE_WORD;
|
||||||
|
FLASH->CR |= FLASH_CR_PG;
|
||||||
|
|
||||||
|
*address = *buffer;
|
||||||
|
|
||||||
|
/* Wait for operation to be completed */
|
||||||
|
waitFlashIdle();
|
||||||
|
FLASH->CR &= (~FLASH_CR_PG);
|
||||||
|
|
||||||
|
/* Check the written value */
|
||||||
|
if (*address != *buffer) {
|
||||||
|
/* Flash content doesn't match SRAM content */
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* Increment FLASH destination address */
|
||||||
|
address += 1;
|
||||||
|
buffer += 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t *cpystr(uint8_t *dest, uint8_t *source)
|
||||||
|
{
|
||||||
|
while ((*dest++ = *source++))
|
||||||
|
;
|
||||||
|
return dest - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FRESULT readBinDir(DIR *dj, FILINFO *fno)
|
||||||
|
{
|
||||||
|
FRESULT fr;
|
||||||
|
uint32_t loop;
|
||||||
|
do {
|
||||||
|
loop = 0;
|
||||||
|
fr = f_readdir(dj, fno); // First entry
|
||||||
|
|
||||||
|
if (fr != FR_OK || fno->fname[0] == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*fno->lfname == 0) {
|
||||||
|
cpystr((uint8_t *) fno->lfname, (uint8_t *) fno->fname); // Copy 8.3 name
|
||||||
|
}
|
||||||
|
int32_t len = strlen(fno->lfname) - 4;
|
||||||
|
if (len < 0) {
|
||||||
|
loop = 1;
|
||||||
|
}
|
||||||
|
if (fno->lfname[len] != '.') {
|
||||||
|
loop = 1;
|
||||||
|
}
|
||||||
|
if ((fno->lfname[len + 1] != 'b') && (fno->lfname[len + 1] != 'B')) {
|
||||||
|
loop = 1;
|
||||||
|
}
|
||||||
|
if ((fno->lfname[len + 2] != 'i') && (fno->lfname[len + 2] != 'I')) {
|
||||||
|
loop = 1;
|
||||||
|
}
|
||||||
|
if ((fno->lfname[len + 3] != 'n') && (fno->lfname[len + 3] != 'N')) {
|
||||||
|
loop = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (loop);
|
||||||
|
return fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t fillNames(uint32_t index)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
FRESULT fr;
|
||||||
|
Finfo.lfname = Filenames[0];
|
||||||
|
Finfo.lfsize = 48;
|
||||||
|
fr = f_readdir(&Dj, 0); // rewind
|
||||||
|
fr = f_readdir(&Dj, &Finfo); // Skip .
|
||||||
|
fr = f_readdir(&Dj, &Finfo); // Skip ..
|
||||||
|
i = 0;
|
||||||
|
while (i <= index) {
|
||||||
|
fr = readBinDir(&Dj, &Finfo); // First entry
|
||||||
|
FileSize[0] = Finfo.fsize;
|
||||||
|
i += 1;
|
||||||
|
if (fr == FR_NO_FILE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 1; i < 7; i += 1) {
|
||||||
|
Finfo.lfname = Filenames[i];
|
||||||
|
fr = readBinDir(&Dj, &Finfo); // First entry
|
||||||
|
FileSize[i] = Finfo.fsize;
|
||||||
|
if (fr != FR_OK || Finfo.fname[0] == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
FRESULT openFirmwareFile(uint32_t index)
|
||||||
|
{
|
||||||
|
cpystr(cpystr((uint8_t *)FlashFilename, (uint8_t *)FIRMWARES_PATH "/"), (uint8_t *) Filenames[index]);
|
||||||
|
f_open(&FlashFile, FlashFilename, FA_READ);
|
||||||
|
f_lseek(&FlashFile, BOOTLOADER_SIZE);
|
||||||
|
return f_read(&FlashFile, (BYTE *) Block_buffer, 4096, &BlockCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
int menuFlashFile(uint32_t index, uint8_t event)
|
||||||
|
{
|
||||||
|
FRESULT fr;
|
||||||
|
|
||||||
|
lcd_putsLeft(2*FH, INDENT "Flash file " FIRMWARES_PATH "/");
|
||||||
|
lcd_putsnAtt(lcdLastPos, 2*FH, Filenames[index], DISPLAY_CHAR_WIDTH, 0);
|
||||||
|
|
||||||
|
if (Valid == 0) {
|
||||||
|
// Validate file here
|
||||||
|
// return 3 if invalid
|
||||||
|
fr = openFirmwareFile(index);
|
||||||
|
fr = f_close(&FlashFile);
|
||||||
|
Valid = 1;
|
||||||
|
if (isFirmwareStart(Block_buffer) == 0) {
|
||||||
|
Valid = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Valid == 2) {
|
||||||
|
lcd_putsLeft(4*FH, INDENT "Not a valid firmware!");
|
||||||
|
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd_putsLeft(6*FH, INDENT "[Enter Long] to confirm");
|
||||||
|
|
||||||
|
if (event == EVT_KEY_LONG(BOOT_KEY_MENU)) {
|
||||||
|
fr = openFirmwareFile(index);
|
||||||
|
FirmwareSize = FileSize[index];
|
||||||
|
if (fr != FR_OK) {
|
||||||
|
return 0; // File open error
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern Key keys[];
|
||||||
|
|
||||||
|
static uint32_t PowerUpDelay;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
uint8_t index = 0;
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
uint8_t TenCount = 2;
|
||||||
|
#endif
|
||||||
|
uint8_t maxhsize = DISPLAY_CHAR_WIDTH;
|
||||||
|
FRESULT fr;
|
||||||
|
uint32_t state = ST_START;
|
||||||
|
uint32_t nameCount = 0;
|
||||||
|
uint32_t vpos = 0;
|
||||||
|
uint32_t hpos = 0;
|
||||||
|
uint32_t firmwareAddress = FIRMWARE_ADDRESS;
|
||||||
|
uint32_t firmwareWritten = 0;
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
wdt_reset();
|
||||||
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; // Enable portA clock
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pwrInit();
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
MATRIX->CCFG_SYSIO |= 0x000000F0L; // Disable syspins, enable B4,5,6,7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
init_SDcard();
|
||||||
|
PIOC->PIO_PER = PIO_PC25; // Enable bit C25 (USB-detect)
|
||||||
|
start_timer0();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lcdInit();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
extern uint8_t OptrexDisplay;
|
||||||
|
OptrexDisplay = 1;
|
||||||
|
#endif
|
||||||
|
lcd_clear();
|
||||||
|
lcd_putsLeft(0, BOOTLOADER_TITLE);
|
||||||
|
lcd_hline(0, 10, LCD_W);
|
||||||
|
lcdRefresh();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
OptrexDisplay = 0;
|
||||||
|
lcdRefresh();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
keysInit();
|
||||||
|
I2C_EE_Init();
|
||||||
|
init_hw_timer();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__enable_irq();
|
||||||
|
init10msTimer();
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
EblockAddress = -1;
|
||||||
|
init_spi();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
uint32_t chip_id = CHIPID->CHIPID_CIDR;
|
||||||
|
FlashSize = ( (chip_id >> 8 ) & 0x000F ) == 9 ? 256 : 512;
|
||||||
|
#elif defined(PCBTARANIS)
|
||||||
|
FlashSize = 512;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
LockBits = readLockBits();
|
||||||
|
if (LockBits) {
|
||||||
|
clearLockBits();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
// SD card detect pin
|
||||||
|
sdInit();
|
||||||
|
unlockFlash();
|
||||||
|
usbInit();
|
||||||
|
usbStart();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
wdt_reset();
|
||||||
|
|
||||||
|
if (Tenms) {
|
||||||
|
wdt_reset(); // Retrigger hardware watchdog
|
||||||
|
|
||||||
|
if (EE_timer) {
|
||||||
|
if (--EE_timer == 0) {
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
writeBlock();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tenms = 0;
|
||||||
|
|
||||||
|
lcd_clear();
|
||||||
|
lcd_putsLeft(0, BOOTLOADER_TITLE);
|
||||||
|
lcd_hline(0, 10, LCD_W);
|
||||||
|
|
||||||
|
uint8_t event = getEvent();
|
||||||
|
|
||||||
|
if (usbPlugged()) {
|
||||||
|
state = ST_USB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_START) {
|
||||||
|
lcd_putsLeft(2*FH, "\004Flash a firmware from the SD card");
|
||||||
|
lcd_putsLeft(3*FH, "\004Exit");
|
||||||
|
lcd_invert_line(2+vpos);
|
||||||
|
lcd_putsLeft(6*FH, INDENT "Or plug a USB cable for Massstorage");
|
||||||
|
if (event == EVT_KEY_FIRST(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
|
||||||
|
vpos = (vpos+1) & 0x01;
|
||||||
|
}
|
||||||
|
else if (event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
|
||||||
|
if (vpos == 0)
|
||||||
|
state = ST_FLASH_MENU;
|
||||||
|
else
|
||||||
|
state = ST_REBOOT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_USB) {
|
||||||
|
lcd_putsLeft(4*FH, CENTER "\010U S B");
|
||||||
|
if (usbPlugged() == 0) {
|
||||||
|
vpos = 0;
|
||||||
|
state = ST_START;
|
||||||
|
}
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
usbMassStorage();
|
||||||
|
lcd_putc( 0, 6*FH, 'F' );
|
||||||
|
lcd_putc( 6, 6*FH, '0' + FlashBlocked );
|
||||||
|
lcd_putc( 0, 7*FH, 'E' );
|
||||||
|
lcd_putc( 6, 7*FH, '0' + EepromBlocked );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_FLASH_MENU) {
|
||||||
|
sdInit();
|
||||||
|
state = ST_DIR_CHECK;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (state == ST_DIR_CHECK) {
|
||||||
|
fr = f_chdir(FIRMWARES_PATH);
|
||||||
|
if (fr == FR_OK) {
|
||||||
|
state = ST_OPEN_DIR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lcd_putsLeft(2*FH, INDENT "No firmware in " FIRMWARES_PATH " directory");
|
||||||
|
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
|
||||||
|
vpos = 0;
|
||||||
|
state = ST_START;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_OPEN_DIR) {
|
||||||
|
index = 0;
|
||||||
|
fr = f_opendir(&Dj, ".");
|
||||||
|
if (fr == FR_OK) {
|
||||||
|
state = ST_FILE_LIST;
|
||||||
|
nameCount = fillNames(0);
|
||||||
|
hpos = 0;
|
||||||
|
vpos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_FILE_LIST) {
|
||||||
|
uint32_t limit = 6;
|
||||||
|
if (nameCount < limit) {
|
||||||
|
limit = nameCount;
|
||||||
|
}
|
||||||
|
maxhsize = 0;
|
||||||
|
for (uint32_t i=0; i<limit; i++) {
|
||||||
|
uint32_t x;
|
||||||
|
x = strlen(Filenames[i]);
|
||||||
|
if (x > maxhsize) {
|
||||||
|
maxhsize = x;
|
||||||
|
}
|
||||||
|
if (x > DISPLAY_CHAR_WIDTH) {
|
||||||
|
if (hpos + DISPLAY_CHAR_WIDTH > x) {
|
||||||
|
x = x - DISPLAY_CHAR_WIDTH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = hpos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
lcd_putsnAtt(INDENT_WIDTH, 16 + FH * i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event == EVT_KEY_REPT(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
|
||||||
|
if (vpos < limit - 1) {
|
||||||
|
vpos += 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (nameCount > limit) {
|
||||||
|
index += 1;
|
||||||
|
nameCount = fillNames(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event == EVT_KEY_REPT(BOOT_KEY_UP) || event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
|
||||||
|
if (vpos > 0) {
|
||||||
|
vpos -= 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (index) {
|
||||||
|
index -= 1;
|
||||||
|
nameCount = fillNames(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if !defined(PCBTARANIS)
|
||||||
|
else if (event == EVT_KEY_REPT(BOOT_KEY_RIGHT) || event == EVT_KEY_FIRST(BOOT_KEY_RIGHT)) {
|
||||||
|
if (hpos + DISPLAY_CHAR_WIDTH < maxhsize) {
|
||||||
|
hpos += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event == EVT_KEY_REPT(BOOT_KEY_LEFT) || event == EVT_KEY_FIRST(BOOT_KEY_LEFT)) {
|
||||||
|
if (hpos) {
|
||||||
|
hpos -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if (event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
|
||||||
|
// Select file to flash
|
||||||
|
state = ST_FLASH_CHECK;
|
||||||
|
Valid = 0;
|
||||||
|
}
|
||||||
|
else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
|
||||||
|
state = ST_START;
|
||||||
|
vpos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd_invert_line(2 + vpos);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (state == ST_FLASH_CHECK) {
|
||||||
|
int result = menuFlashFile(vpos, event);
|
||||||
|
FirmwareSize = FileSize[vpos] - BOOTLOADER_SIZE;
|
||||||
|
if (result == 0) {
|
||||||
|
// canceled
|
||||||
|
state = ST_FILE_LIST;
|
||||||
|
}
|
||||||
|
else if (result == 1) {
|
||||||
|
// confirmed
|
||||||
|
firmwareAddress = FIRMWARE_ADDRESS + BOOTLOADER_SIZE;
|
||||||
|
firmwareWritten = 0;
|
||||||
|
state = ST_FLASHING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_FLASHING) {
|
||||||
|
// Commit to flashing
|
||||||
|
uint32_t blockOffset = 0;
|
||||||
|
lcd_putsLeft(2*FH, INDENT "Flashing...");
|
||||||
|
while (BlockCount) {
|
||||||
|
program((uint32_t *) firmwareAddress, &Block_buffer[blockOffset]); // size is 256 bytes
|
||||||
|
blockOffset += 64; // 32-bit words (256 bytes)
|
||||||
|
firmwareAddress += 256;
|
||||||
|
if (BlockCount > 256) {
|
||||||
|
BlockCount -= 256;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BlockCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firmwareWritten += 4; // 4K blocks
|
||||||
|
|
||||||
|
lcd_rect(INDENT_WIDTH, 6*FH+4, 202, 3);
|
||||||
|
lcd_hline(INDENT_WIDTH, 6*FH+5, (200*firmwareWritten/(FlashSize-32)), FORCE);
|
||||||
|
|
||||||
|
fr = f_read(&FlashFile, (BYTE *)Block_buffer, sizeof(Block_buffer), &BlockCount);
|
||||||
|
if (BlockCount == 0) {
|
||||||
|
state = ST_FLASH_DONE;
|
||||||
|
}
|
||||||
|
if (firmwareWritten >= FlashSize - 32) {
|
||||||
|
state = ST_FLASH_DONE; // Backstop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_FLASH_DONE) {
|
||||||
|
lcd_putsLeft(2*FH, INDENT "Flashing Complete");
|
||||||
|
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
|
||||||
|
state = ST_START;
|
||||||
|
vpos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event == EVT_KEY_LONG(BOOT_KEY_EXIT)) {
|
||||||
|
state = ST_REBOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--TenCount == 0) {
|
||||||
|
TenCount = 2;
|
||||||
|
lcdRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PowerUpDelay < 20) { // 200 mS
|
||||||
|
PowerUpDelay += 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sdPoll10ms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pwrCheck() == e_power_off && state != ST_FLASHING && state != ST_USB) {
|
||||||
|
pwrOff();
|
||||||
|
for (;;) {
|
||||||
|
// Wait for power to go off
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == ST_REBOOT) {
|
||||||
|
if ((~readKeys() & 0x7E) == 0) {
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -34,11 +34,16 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef eeprom_avr_h
|
#ifndef eeprom_rlc_h
|
||||||
#define eeprom_avr_h
|
#define eeprom_rlc_h
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
// TODO duplicated
|
||||||
|
#ifndef PACK
|
||||||
|
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define blkid_t uint16_t
|
#define blkid_t uint16_t
|
||||||
#if !defined(EESIZE)
|
#if !defined(EESIZE)
|
||||||
@@ -67,7 +72,7 @@
|
|||||||
#define BS 16
|
#define BS 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PACK(struct DirEnt{
|
PACK(struct DirEnt {
|
||||||
blkid_t startBlk;
|
blkid_t startBlk;
|
||||||
uint16_t size:12;
|
uint16_t size:12;
|
||||||
uint16_t typ:4;
|
uint16_t typ:4;
|
||||||
@@ -79,7 +84,7 @@ PACK(struct DirEnt{
|
|||||||
#define EEFS_EXTRA_FIELDS
|
#define EEFS_EXTRA_FIELDS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PACK(struct EeFs{
|
PACK(struct EeFs {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
blkid_t mySize;
|
blkid_t mySize;
|
||||||
blkid_t freeList;
|
blkid_t freeList;
|
||||||
|
|||||||
Executable
+163
@@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Andre Bernet <bernet.andre@gmail.com>
|
||||||
|
* - Andreas Weitl
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
* - Cameron Weeks <th9xer@gmail.com>
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Gabriel Birkus
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michael Blandford
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||||
|
* - 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "opentx.h"
|
||||||
|
|
||||||
|
const pm_uchar font_5x7[] PROGMEM = {
|
||||||
|
#if defined (CPUARM)
|
||||||
|
#include "font_05x07.lbm"
|
||||||
|
#else
|
||||||
|
#include "font_05x07_avr.lbm"
|
||||||
|
#endif
|
||||||
|
#if defined(TRANSLATIONS_DE)
|
||||||
|
#include "font_de_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_CZ)
|
||||||
|
#include "font_cz_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_ES)
|
||||||
|
#include "font_es_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FI)
|
||||||
|
#include "font_fi_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FR)
|
||||||
|
#include "font_fr_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_IT)
|
||||||
|
#include "font_it_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PL)
|
||||||
|
#include "font_pl_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PT)
|
||||||
|
#include "font_pt_05x07.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_SE)
|
||||||
|
#include "font_se_05x07.lbm"
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(BOLD_FONT) && (!defined(CPUM64) || defined(EXTSTD))
|
||||||
|
const pm_uchar font_5x7_B[] PROGMEM = {
|
||||||
|
#include "font_05x07_B_compressed.lbm"
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
|
const pm_uchar font_10x14[] PROGMEM = {
|
||||||
|
#include "font_10x14_compressed.lbm"
|
||||||
|
#if defined(CPUARM)
|
||||||
|
#if defined(TRANSLATIONS_DE)
|
||||||
|
#include "font_de_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_CZ)
|
||||||
|
#include "font_cz_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_ES)
|
||||||
|
#include "font_es_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FI)
|
||||||
|
#include "font_fi_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FR)
|
||||||
|
#include "font_fr_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_IT)
|
||||||
|
#include "font_it_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PL)
|
||||||
|
#include "font_pl_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PT)
|
||||||
|
#include "font_pt_10x14.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_SE)
|
||||||
|
#include "font_se_10x14.lbm"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CPUARM) && !defined(BOOT)
|
||||||
|
const pm_uchar font_3x5[] PROGMEM = {
|
||||||
|
#include "font_03x05.lbm"
|
||||||
|
};
|
||||||
|
|
||||||
|
const pm_uchar font_4x6[] PROGMEM = {
|
||||||
|
#include "font_04x06.lbm"
|
||||||
|
#if defined(TRANSLATIONS_DE)
|
||||||
|
#include "font_de_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_CZ)
|
||||||
|
#include "font_cz_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_ES)
|
||||||
|
#include "font_es_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FI)
|
||||||
|
#include "font_fi_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FR)
|
||||||
|
#include "font_fr_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_IT)
|
||||||
|
#include "font_it_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PL)
|
||||||
|
#include "font_pl_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PT)
|
||||||
|
#include "font_pt_04x06.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_SE)
|
||||||
|
#include "font_se_04x06.lbm"
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
const pm_uchar font_8x10[] PROGMEM = {
|
||||||
|
#include "font_08x10.lbm"
|
||||||
|
#if defined(TRANSLATIONS_DE)
|
||||||
|
#include "font_de_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_CZ)
|
||||||
|
#include "font_cz_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_ES)
|
||||||
|
#include "font_es_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FI)
|
||||||
|
#include "font_fi_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_FR)
|
||||||
|
#include "font_fr_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_IT)
|
||||||
|
#include "font_it_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PL)
|
||||||
|
#include "font_pl_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_PT)
|
||||||
|
#include "font_pt_08x10.lbm"
|
||||||
|
#elif defined(TRANSLATIONS_SE)
|
||||||
|
#include "font_se_08x10.lbm"
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
const pm_uchar font_4x6_extra[] PROGMEM = {
|
||||||
|
#include "font_04x06_extra.lbm"
|
||||||
|
};
|
||||||
|
|
||||||
|
const pm_uchar font_5x7_extra[] PROGMEM = {
|
||||||
|
#include "font_05x07_extra.lbm"
|
||||||
|
};
|
||||||
|
|
||||||
|
const pm_uchar font_10x14_extra[] PROGMEM = {
|
||||||
|
#include "font_10x14_extra.lbm"
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Andre Bernet <bernet.andre@gmail.com>
|
||||||
|
* - Andreas Weitl
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
* - Cameron Weeks <th9xer@gmail.com>
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Gabriel Birkus
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michael Blandford
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||||
|
* - 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 fonts_h
|
||||||
|
#define fonts_h
|
||||||
|
|
||||||
|
extern const pm_uchar font_5x7[];
|
||||||
|
extern const pm_uchar font_10x14[];
|
||||||
|
|
||||||
|
#if defined(BOLD_FONT) && (!defined(CPUM64) || defined(EXTSTD)) && !defined(BOOT)
|
||||||
|
#define BOLD_SPECIFIC_FONT
|
||||||
|
extern const pm_uchar font_5x7_B[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CPUARM)
|
||||||
|
extern const pm_uchar font_3x5[];
|
||||||
|
extern const pm_uchar font_4x6[];
|
||||||
|
extern const pm_uchar font_8x10[];
|
||||||
|
extern const pm_uchar font_5x7_extra[];
|
||||||
|
extern const pm_uchar font_10x14_extra[];
|
||||||
|
extern const pm_uchar font_4x6_extra[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -37,6 +37,7 @@
|
|||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
uint8_t s_evt;
|
uint8_t s_evt;
|
||||||
|
struct t_inactivity inactivity = {0};
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
uint8_t getEvent(bool trim)
|
uint8_t getEvent(bool trim)
|
||||||
@@ -97,7 +98,9 @@ void Key::input(bool val, EnumKeys enuk)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KSTATE_RPTDELAY: // gruvin: delay state before first key repeat
|
case KSTATE_RPTDELAY: // gruvin: delay state before first key repeat
|
||||||
if(m_cnt == KEY_LONG_DELAY) putEvent(EVT_KEY_LONG(enuk));
|
if (m_cnt == KEY_LONG_DELAY) {
|
||||||
|
putEvent(EVT_KEY_LONG(enuk));
|
||||||
|
}
|
||||||
if (m_cnt == 40) {
|
if (m_cnt == 40) {
|
||||||
m_state = 16;
|
m_state = 16;
|
||||||
m_cnt = 0;
|
m_cnt = 0;
|
||||||
@@ -108,17 +111,19 @@ void Key::input(bool val, EnumKeys enuk)
|
|||||||
case 8:
|
case 8:
|
||||||
case 4:
|
case 4:
|
||||||
case 2:
|
case 2:
|
||||||
if(m_cnt >= 48) { //3 6 12 24 48 pulses in every 480ms
|
if (m_cnt >= 48) { //3 6 12 24 48 pulses in every 480ms
|
||||||
m_state >>= 1;
|
m_state >>= 1;
|
||||||
m_cnt = 0;
|
m_cnt = 0;
|
||||||
}
|
}
|
||||||
// no break
|
// no break
|
||||||
case 1:
|
case 1:
|
||||||
if( (m_cnt & (m_state-1)) == 0) putEvent(EVT_KEY_REPT(enuk));
|
if ((m_cnt & (m_state-1)) == 0) {
|
||||||
|
putEvent(EVT_KEY_REPT(enuk));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KSTATE_PAUSE: //pause
|
case KSTATE_PAUSE: //pause
|
||||||
if(m_cnt >= 64) {
|
if (m_cnt >= 64) {
|
||||||
m_state = 8;
|
m_state = 8;
|
||||||
m_cnt = 0;
|
m_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+231
@@ -0,0 +1,231 @@
|
|||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Andre Bernet <bernet.andre@gmail.com>
|
||||||
|
* - Andreas Weitl
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
* - Cameron Weeks <th9xer@gmail.com>
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Gabriel Birkus
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michael Blandford
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||||
|
* - 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 keys_h
|
||||||
|
#define keys_h
|
||||||
|
|
||||||
|
enum EnumKeys {
|
||||||
|
KEY_MENU,
|
||||||
|
KEY_EXIT,
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
KEY_ENTER,
|
||||||
|
KEY_PAGE,
|
||||||
|
KEY_PLUS,
|
||||||
|
KEY_MINUS,
|
||||||
|
#else
|
||||||
|
KEY_DOWN,
|
||||||
|
KEY_UP,
|
||||||
|
KEY_RIGHT,
|
||||||
|
KEY_LEFT,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TRM_BASE,
|
||||||
|
TRM_LH_DWN = TRM_BASE,
|
||||||
|
TRM_LH_UP,
|
||||||
|
TRM_LV_DWN,
|
||||||
|
TRM_LV_UP,
|
||||||
|
TRM_RV_DWN,
|
||||||
|
TRM_RV_UP,
|
||||||
|
TRM_RH_DWN,
|
||||||
|
TRM_RH_UP,
|
||||||
|
|
||||||
|
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
|
BTN_REa,
|
||||||
|
#endif
|
||||||
|
#if ROTARY_ENCODERS > 0
|
||||||
|
BTN_REb,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NUM_KEYS,
|
||||||
|
SW_BASE=NUM_KEYS,
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
SW_SA0=SW_BASE,
|
||||||
|
SW_SA1,
|
||||||
|
SW_SA2,
|
||||||
|
SW_SB0,
|
||||||
|
SW_SB1,
|
||||||
|
SW_SB2,
|
||||||
|
SW_SC0,
|
||||||
|
SW_SC1,
|
||||||
|
SW_SC2,
|
||||||
|
SW_SD0,
|
||||||
|
SW_SD1,
|
||||||
|
SW_SD2,
|
||||||
|
SW_SE0,
|
||||||
|
SW_SE1,
|
||||||
|
SW_SE2,
|
||||||
|
SW_SF0,
|
||||||
|
SW_SF2,
|
||||||
|
SW_SG0,
|
||||||
|
SW_SG1,
|
||||||
|
SW_SG2,
|
||||||
|
SW_SH0,
|
||||||
|
SW_SH2,
|
||||||
|
#else
|
||||||
|
SW_ID0=SW_BASE,
|
||||||
|
SW_ID1,
|
||||||
|
SW_ID2,
|
||||||
|
#if defined(EXTRA_3POS)
|
||||||
|
SW_ID3,
|
||||||
|
SW_ID4,
|
||||||
|
SW_ID5,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SW_THR,
|
||||||
|
SW_RUD,
|
||||||
|
SW_ELE,
|
||||||
|
SW_AIL,
|
||||||
|
SW_GEA,
|
||||||
|
SW_TRN,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#define EVT_KEY_MASK(e) ((e) & 0x1f)
|
||||||
|
|
||||||
|
#define _MSK_KEY_BREAK 0x20
|
||||||
|
#define _MSK_KEY_REPT 0x40
|
||||||
|
#define _MSK_KEY_FIRST 0x60
|
||||||
|
#define _MSK_KEY_LONG 0x80
|
||||||
|
|
||||||
|
#define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK)
|
||||||
|
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST)
|
||||||
|
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT)
|
||||||
|
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG)
|
||||||
|
|
||||||
|
#define IS_KEY_BREAK(evt) (((evt)&0xe0) == _MSK_KEY_BREAK)
|
||||||
|
#define IS_KEY_FIRST(evt) (((evt)&0xe0) == _MSK_KEY_FIRST)
|
||||||
|
#define IS_KEY_LONG(evt) (((evt)&0xe0) == _MSK_KEY_LONG)
|
||||||
|
|
||||||
|
#define EVT_ENTRY 0xbf
|
||||||
|
#define EVT_ENTRY_UP 0xbe
|
||||||
|
#define EVT_MENU_UP 0xbd
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
||||||
|
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
||||||
|
#else
|
||||||
|
#define EVT_ROTARY_BREAK 0xcf
|
||||||
|
#define EVT_ROTARY_LONG 0xce
|
||||||
|
#define EVT_ROTARY_LEFT 0xdf
|
||||||
|
#define EVT_ROTARY_RIGHT 0xde
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
#define IS_ROTARY_LEFT(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
||||||
|
#define IS_ROTARY_RIGHT(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
||||||
|
#define IS_ROTARY_UP(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
||||||
|
#define IS_ROTARY_DOWN(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
||||||
|
#define IS_ROTARY_BREAK(evt) (evt==EVT_KEY_BREAK(KEY_ENTER))
|
||||||
|
#define IS_ROTARY_LONG(evt) (evt==EVT_KEY_LONG(KEY_ENTER))
|
||||||
|
#define IS_ROTARY_EVENT(evt) (0)
|
||||||
|
#define CASE_EVT_ROTARY_BREAK /*case EVT_KEY_BREAK(KEY_ENTER):*/
|
||||||
|
#define CASE_EVT_ROTARY_LONG /*case EVT_KEY_LONG(KEY_ENTER):*/
|
||||||
|
#define CASE_EVT_ROTARY_LEFT case EVT_KEY_FIRST(KEY_MOVE_DOWN): case EVT_KEY_REPT(KEY_MOVE_DOWN):
|
||||||
|
#define CASE_EVT_ROTARY_RIGHT case EVT_KEY_FIRST(KEY_MOVE_UP): case EVT_KEY_REPT(KEY_MOVE_UP):
|
||||||
|
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
|
#define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT)
|
||||||
|
#define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT)
|
||||||
|
#define IS_ROTARY_UP(evt) IS_ROTARY_LEFT(evt)
|
||||||
|
#define IS_ROTARY_DOWN(evt) IS_ROTARY_RIGHT(evt)
|
||||||
|
#define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK)
|
||||||
|
#define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG)
|
||||||
|
#define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e)
|
||||||
|
#define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK:
|
||||||
|
#define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG:
|
||||||
|
#define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT:
|
||||||
|
#define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT:
|
||||||
|
#else
|
||||||
|
#define IS_ROTARY_LEFT(evt) (0)
|
||||||
|
#define IS_ROTARY_RIGHT(evt) (0)
|
||||||
|
#define IS_ROTARY_UP(evt) (0)
|
||||||
|
#define IS_ROTARY_DOWN(evt) (0)
|
||||||
|
#define IS_ROTARY_BREAK(evt) (0)
|
||||||
|
#define IS_ROTARY_LONG(evt) (0)
|
||||||
|
#define IS_ROTARY_EVENT(evt) (0)
|
||||||
|
#define CASE_EVT_ROTARY_BREAK
|
||||||
|
#define CASE_EVT_ROTARY_LONG
|
||||||
|
#define CASE_EVT_ROTARY_LEFT
|
||||||
|
#define CASE_EVT_ROTARY_RIGHT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class Key
|
||||||
|
{
|
||||||
|
#define FILTERBITS 4
|
||||||
|
|
||||||
|
#ifdef SIMU
|
||||||
|
#define FFVAL 1
|
||||||
|
#else
|
||||||
|
#define FFVAL ((1<<FILTERBITS)-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define KSTATE_OFF 0
|
||||||
|
#define KSTATE_RPTDELAY 95 // gruvin: delay state before key repeating starts
|
||||||
|
#define KSTATE_START 97
|
||||||
|
#define KSTATE_PAUSE 98
|
||||||
|
#define KSTATE_KILLED 99
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t m_vals; // key debounce? 4 = 40ms
|
||||||
|
uint8_t m_cnt;
|
||||||
|
uint8_t m_state;
|
||||||
|
public:
|
||||||
|
void input(bool val, EnumKeys enuk);
|
||||||
|
bool state() { return m_vals > 0; }
|
||||||
|
void pauseEvents() { m_state = KSTATE_PAUSE; m_cnt = 0; }
|
||||||
|
void killEvents() { m_state = KSTATE_KILLED; }
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Key keys[NUM_KEYS];
|
||||||
|
|
||||||
|
extern uint8_t s_evt;
|
||||||
|
|
||||||
|
#define putEvent(evt) s_evt = evt
|
||||||
|
|
||||||
|
void clearKeyEvents();
|
||||||
|
void pauseEvents(uint8_t enuk);
|
||||||
|
void killEvents(uint8_t enuk);
|
||||||
|
|
||||||
|
#if defined(CPUARM)
|
||||||
|
uint8_t getEvent(bool trim=false);
|
||||||
|
#else
|
||||||
|
uint8_t getEvent();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t keyDown();
|
||||||
|
|
||||||
|
#endif
|
||||||
+79
-67
@@ -49,42 +49,6 @@ void lcd_clear()
|
|||||||
memset(displayBuf, 0, sizeof(displayBuf));
|
memset(displayBuf, 0, sizeof(displayBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att)
|
|
||||||
{
|
|
||||||
const pm_uchar *q = img;
|
|
||||||
#if LCD_W >= 260
|
|
||||||
xcoord_t w = pgm_read_byte(q++);
|
|
||||||
if (w == 255) w += pgm_read_byte(q++);
|
|
||||||
#else
|
|
||||||
uint8_t w = pgm_read_byte(q++);
|
|
||||||
#endif
|
|
||||||
uint8_t hb = (pgm_read_byte(q++)+7)/8;
|
|
||||||
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false);
|
|
||||||
q += idx*w*hb;
|
|
||||||
for (uint8_t yb = 0; yb < hb; yb++) {
|
|
||||||
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ];
|
|
||||||
for (xcoord_t i=0; i<w; i++){
|
|
||||||
uint8_t b = pgm_read_byte(q);
|
|
||||||
q++;
|
|
||||||
ASSERT_IN_DISPLAY(p);
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
uint8_t val = inv ? ~b : b;
|
|
||||||
if (!(att & GREY(1)))
|
|
||||||
*p = val;
|
|
||||||
if (!(att & GREY(2)))
|
|
||||||
*(p+DISPLAY_PLAN_SIZE) = val;
|
|
||||||
if (!(att & GREY(4)))
|
|
||||||
*(p+2*DISPLAY_PLAN_SIZE) = val;
|
|
||||||
if (!(att & GREY(8)))
|
|
||||||
*(p+3*DISPLAY_PLAN_SIZE) = val;
|
|
||||||
p++;
|
|
||||||
#else
|
|
||||||
*p++ = inv ? ~b : b;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t lcdLastPos;
|
uint8_t lcdLastPos;
|
||||||
uint8_t lcdNextPos;
|
uint8_t lcdNextPos;
|
||||||
|
|
||||||
@@ -92,7 +56,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
{
|
{
|
||||||
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
|
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM) && !defined(BOOT)
|
||||||
const pm_uchar *q = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
|
const pm_uchar *q = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
|
||||||
#else
|
#else
|
||||||
const pm_uchar *q = &font_5x7[(c-0x20)*5];
|
const pm_uchar *q = &font_5x7[(c-0x20)*5];
|
||||||
@@ -114,8 +78,10 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
inv = true;
|
inv = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
unsigned char c_remapped = 0;
|
unsigned char c_remapped = 0;
|
||||||
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(EXTSTD)
|
|
||||||
|
#if defined(BOLD_SPECIFIC_FONT)
|
||||||
if (flags & (DBLSIZE+BOLD)) {
|
if (flags & (DBLSIZE+BOLD)) {
|
||||||
#else
|
#else
|
||||||
if (flags & DBLSIZE) {
|
if (flags & DBLSIZE) {
|
||||||
@@ -131,7 +97,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
c_remapped = c - 'a' + 42;
|
c_remapped = c - 'a' + 42;
|
||||||
else if (c=='_')
|
else if (c=='_')
|
||||||
c_remapped = 4;
|
c_remapped = 4;
|
||||||
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(EXTSTD)
|
#if defined(BOLD_SPECIFIC_FONT)
|
||||||
else if (c!=' ')
|
else if (c!=' ')
|
||||||
flags &= ~BOLD;
|
flags &= ~BOLD;
|
||||||
#endif
|
#endif
|
||||||
@@ -140,7 +106,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
c_remapped = c - 60;
|
c_remapped = c - 60;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(EXTSTD)
|
#if defined(BOLD_SPECIFIC_FONT)
|
||||||
}
|
}
|
||||||
if (flags & DBLSIZE) {
|
if (flags & DBLSIZE) {
|
||||||
#endif
|
#endif
|
||||||
@@ -176,8 +142,9 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM) && !defined(BOOT)
|
||||||
else if (flags & MIDSIZE) {
|
else if (flags & MIDSIZE) {
|
||||||
/* each letter consists of ten top bytes followed by
|
/* each letter consists of ten top bytes followed by
|
||||||
* by ten bottom bytes (20 bytes per * char) */
|
* by ten bottom bytes (20 bytes per * char) */
|
||||||
@@ -275,13 +242,15 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
const uint8_t ym8 = (y & 0x07);
|
const uint8_t ym8 = (y & 0x07);
|
||||||
#if defined(BOLD_FONT) && defined(CPUM64) && !defined(EXTSTD)
|
#if defined(BOLD_FONT)
|
||||||
uint8_t bb = 0;
|
#if defined(BOLD_SPECIFIC_FONT)
|
||||||
if (inv) bb = 0xff;
|
|
||||||
#else
|
|
||||||
if (flags & BOLD) {
|
if (flags & BOLD) {
|
||||||
q = &font_5x7_B[(c_remapped)*5];
|
q = &font_5x7_B[(c_remapped)*5];
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
uint8_t bb = 0;
|
||||||
|
if (inv) bb = 0xff;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
for (int8_t i=0; i<=6; i++) {
|
for (int8_t i=0; i<=6; i++) {
|
||||||
uint8_t b = 0;
|
uint8_t b = 0;
|
||||||
@@ -307,7 +276,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOLD_FONT) && defined(CPUM64) && !defined(EXTSTD)
|
#if defined(BOLD_FONT) && !defined(BOLD_SPECIFIC_FONT)
|
||||||
if (flags & BOLD) {
|
if (flags & BOLD) {
|
||||||
uint8_t a;
|
uint8_t a;
|
||||||
if (inv)
|
if (inv)
|
||||||
@@ -352,13 +321,6 @@ void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c)
|
|||||||
lcd_putcAtt(x, y, c, 0);
|
lcd_putcAtt(x, y, c, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_putsiAtt(xcoord_t x, uint8_t y,const pm_char * s,uint8_t idx, LcdFlags flags)
|
|
||||||
{
|
|
||||||
uint8_t length;
|
|
||||||
length = pgm_read_byte(s++);
|
|
||||||
lcd_putsnAtt(x,y,s+length*idx,length,flags & ~(BSS|ZCHAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlags mode)
|
void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlags mode)
|
||||||
{
|
{
|
||||||
xcoord_t orig_x = x;
|
xcoord_t orig_x = x;
|
||||||
@@ -369,9 +331,11 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
|
|||||||
case BSS:
|
case BSS:
|
||||||
c = *s;
|
c = *s;
|
||||||
break;
|
break;
|
||||||
|
#if !defined(BOOT)
|
||||||
case ZCHAR:
|
case ZCHAR:
|
||||||
c = idx2char(*s);
|
c = idx2char(*s);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
c = pgm_read_byte(s);
|
c = pgm_read_byte(s);
|
||||||
break;
|
break;
|
||||||
@@ -436,6 +400,14 @@ void lcd_putsLeft(uint8_t y, const pm_char * s)
|
|||||||
lcd_puts(0, y, s);
|
lcd_puts(0, y, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
|
void lcd_putsiAtt(xcoord_t x, uint8_t y,const pm_char * s,uint8_t idx, LcdFlags flags)
|
||||||
|
{
|
||||||
|
uint8_t length;
|
||||||
|
length = pgm_read_byte(s++);
|
||||||
|
lcd_putsnAtt(x,y,s+length*idx,length,flags & ~(BSS|ZCHAR));
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val)
|
void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val)
|
||||||
{
|
{
|
||||||
x+=FWNUM*4+1;
|
x+=FWNUM*4+1;
|
||||||
@@ -592,6 +564,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||||||
}
|
}
|
||||||
if (neg) lcd_putcAtt(x, y, '-', flags);
|
if (neg) lcd_putcAtt(x, y, '-', flags);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att)
|
void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att)
|
||||||
@@ -813,6 +786,20 @@ void lcd_vline(xcoord_t x, int8_t y, int8_t h)
|
|||||||
lcd_vlineStip(x, y, h, 0xff);
|
lcd_vlineStip(x, y, h, 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_invert_line(int8_t y)
|
||||||
|
{
|
||||||
|
uint8_t *p = &displayBuf[y * LCD_W];
|
||||||
|
for (xcoord_t x=0; x<LCD_W; x++) {
|
||||||
|
ASSERT_IN_DISPLAY(p);
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
*(p+3*DISPLAY_PLAN_SIZE) ^= 0xff;
|
||||||
|
*(p+2*DISPLAY_PLAN_SIZE) ^= 0xff;
|
||||||
|
*(p+DISPLAY_PLAN_SIZE) ^= 0xff;
|
||||||
|
#endif
|
||||||
|
*p++ ^= 0xff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att)
|
void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att)
|
||||||
{
|
{
|
||||||
lcd_vlineStip(x, y, h, pat);
|
lcd_vlineStip(x, y, h, pat);
|
||||||
@@ -822,6 +809,7 @@ void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlag
|
|||||||
lcd_hlineStip(x, y, w, pat);
|
lcd_hlineStip(x, y, w, pat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att)
|
void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att)
|
||||||
{
|
{
|
||||||
#if defined(CPUM64)
|
#if defined(CPUM64)
|
||||||
@@ -840,20 +828,6 @@ void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, L
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_invert_line(int8_t y)
|
|
||||||
{
|
|
||||||
uint8_t *p = &displayBuf[y * LCD_W];
|
|
||||||
for (xcoord_t x=0; x<LCD_W; x++) {
|
|
||||||
ASSERT_IN_DISPLAY(p);
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
*(p+3*DISPLAY_PLAN_SIZE) ^= 0xff;
|
|
||||||
*(p+2*DISPLAY_PLAN_SIZE) ^= 0xff;
|
|
||||||
*(p+DISPLAY_PLAN_SIZE) ^= 0xff;
|
|
||||||
#endif
|
|
||||||
*p++ ^= 0xff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void lcdDrawTelemetryTopBar()
|
void lcdDrawTelemetryTopBar()
|
||||||
{
|
{
|
||||||
@@ -1329,7 +1303,45 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att)
|
||||||
|
{
|
||||||
|
const pm_uchar *q = img;
|
||||||
|
#if LCD_W >= 260
|
||||||
|
xcoord_t w = pgm_read_byte(q++);
|
||||||
|
if (w == 255) w += pgm_read_byte(q++);
|
||||||
|
#else
|
||||||
|
uint8_t w = pgm_read_byte(q++);
|
||||||
|
#endif
|
||||||
|
uint8_t hb = (pgm_read_byte(q++)+7)/8;
|
||||||
|
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false);
|
||||||
|
q += idx*w*hb;
|
||||||
|
for (uint8_t yb = 0; yb < hb; yb++) {
|
||||||
|
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ];
|
||||||
|
for (xcoord_t i=0; i<w; i++){
|
||||||
|
uint8_t b = pgm_read_byte(q);
|
||||||
|
q++;
|
||||||
|
ASSERT_IN_DISPLAY(p);
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
uint8_t val = inv ? ~b : b;
|
||||||
|
if (!(att & GREY(1)))
|
||||||
|
*p = val;
|
||||||
|
if (!(att & GREY(2)))
|
||||||
|
*(p+DISPLAY_PLAN_SIZE) = val;
|
||||||
|
if (!(att & GREY(4)))
|
||||||
|
*(p+2*DISPLAY_PLAN_SIZE) = val;
|
||||||
|
if (!(att & GREY(8)))
|
||||||
|
*(p+3*DISPLAY_PLAN_SIZE) = val;
|
||||||
|
p++;
|
||||||
|
#else
|
||||||
|
*p++ = inv ? ~b : b;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void lcdSetContrast()
|
void lcdSetContrast()
|
||||||
{
|
{
|
||||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !defined(BOOT)
|
||||||
|
|||||||
+16
-2
@@ -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)
|
||||||
@@ -149,6 +153,12 @@ extern uint8_t lcdNextPos;
|
|||||||
extern volatile uint32_t lcdInputs ;
|
extern volatile uint32_t lcdInputs ;
|
||||||
#endif
|
#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_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_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);
|
void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags mode);
|
||||||
@@ -169,7 +179,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 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 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);
|
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);
|
void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att);
|
||||||
#endif
|
#endif
|
||||||
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
|
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
|
||||||
@@ -249,7 +259,11 @@ void lcdRefresh();
|
|||||||
const pm_char * bmpLoad(bmp_ptr_t &dest, const char *filename, const xcoord_t width, const uint8_t height);
|
const pm_char * bmpLoad(bmp_ptr_t &dest, const char *filename, const xcoord_t width, const uint8_t height);
|
||||||
#endif
|
#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
|
#ifdef SIMU
|
||||||
extern bool lcd_refresh;
|
extern bool lcd_refresh;
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (c) 2014 by Michael Blandford. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the author nor the names of its contributors may
|
||||||
|
* be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
|
* Other Authors:
|
||||||
|
* - Andre Bernet
|
||||||
|
* - Bertrand Songis
|
||||||
|
* - Bryan J. Rentoul (Gruvin)
|
||||||
|
* - Cameron Weeks
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini
|
||||||
|
* - Thomas Husterer
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef PCBSKY
|
||||||
|
#include "AT91SAM3S4.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PCBTARANIS
|
||||||
|
#include "stm32f2xx.h"
|
||||||
|
#include "stm32f2xx_gpio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
void bwdt_reset()
|
||||||
|
{
|
||||||
|
IWDG->KR = 0xAAAA; // reload
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
|
||||||
|
__attribute__ ((section(".bootrodata"), used))
|
||||||
|
void _bootStart(void);
|
||||||
|
|
||||||
|
__attribute__ ((section(".isr_boot_vector"), used))
|
||||||
|
const uint32_t BootVectors[] = { (uint32_t) &_estack,
|
||||||
|
(uint32_t) (void (*)(void)) ((unsigned long) &_bootStart) };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
__attribute__ ((section(".bootrodata.*"), used))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PCBSKY
|
||||||
|
__attribute__ ((section(".bootrodata"), used))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const uint8_t BootCode[] = {
|
||||||
|
#include "bootloader.lbm"
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
|
||||||
|
__attribute__ ((section(".bootrodata"), used))
|
||||||
|
|
||||||
|
void _bootStart()
|
||||||
|
{
|
||||||
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; // Enable portC clock
|
||||||
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN; // Enable portE clock
|
||||||
|
|
||||||
|
GPIOC->PUPDR = 0x00000004;
|
||||||
|
GPIOE->PUPDR = 0x00000040;
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
for (i = 0; i < 50000; i += 1) {
|
||||||
|
bwdt_reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((GPIOE->IDR & 0x00000008) == 0) {
|
||||||
|
if ((GPIOC->IDR & 0x00000002) == 0) {
|
||||||
|
// Bootloader needed
|
||||||
|
const uint8_t *src;
|
||||||
|
uint8_t *dest;
|
||||||
|
uint32_t size;
|
||||||
|
|
||||||
|
bwdt_reset();
|
||||||
|
size = sizeof(BootCode);
|
||||||
|
src = BootCode;
|
||||||
|
dest = (uint8_t *) 0x20000000;
|
||||||
|
|
||||||
|
for (; size; size -= 1) {
|
||||||
|
*dest++ = *src++;
|
||||||
|
}
|
||||||
|
// Could check for a valid copy to RAM here
|
||||||
|
// Go execute bootloader
|
||||||
|
bwdt_reset();
|
||||||
|
|
||||||
|
uint32_t address = *(uint32_t *) 0x20000004;
|
||||||
|
|
||||||
|
((void (*)(void)) (address))(); // Go execute the loaded application
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// run_application() ;
|
||||||
|
asm(" mov.w r1, #134217728");
|
||||||
|
// 0x8000000
|
||||||
|
asm(" add.w r1, #32768");
|
||||||
|
// 0x8000
|
||||||
|
|
||||||
|
asm(" movw r0, #60680");
|
||||||
|
// 0xED08
|
||||||
|
asm(" movt r0, #57344");
|
||||||
|
// 0xE000
|
||||||
|
asm(" str r1, [r0, #0]");
|
||||||
|
// Set the VTOR
|
||||||
|
|
||||||
|
asm("ldr r0, [r1, #0]");
|
||||||
|
// Stack pointer value
|
||||||
|
asm("msr msp, r0");
|
||||||
|
// Set it
|
||||||
|
asm("ldr r0, [r1, #4]");
|
||||||
|
// Reset address
|
||||||
|
asm("mov.w r1, #1");
|
||||||
|
asm("orr r0, r1");
|
||||||
|
// Set lsbit
|
||||||
|
asm("bx r0");
|
||||||
|
// Execute application
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -45,7 +45,6 @@ int16_t anas [NUM_INPUTS] = {0};
|
|||||||
int16_t trims[NUM_STICKS] = {0};
|
int16_t trims[NUM_STICKS] = {0};
|
||||||
int32_t chans[NUM_CHNOUT] = {0};
|
int32_t chans[NUM_CHNOUT] = {0};
|
||||||
BeepANACenter bpanaCenter = 0;
|
BeepANACenter bpanaCenter = 0;
|
||||||
struct t_inactivity inactivity = {0};
|
|
||||||
|
|
||||||
int24_t act [MAX_MIXERS] = {0};
|
int24_t act [MAX_MIXERS] = {0};
|
||||||
SwOn swOn [MAX_MIXERS]; // TODO better name later...
|
SwOn swOn [MAX_MIXERS]; // TODO better name later...
|
||||||
|
|||||||
+8
-197
@@ -297,83 +297,6 @@ extern void boardInit();
|
|||||||
|
|
||||||
#define NUM_STICKS 4
|
#define NUM_STICKS 4
|
||||||
|
|
||||||
enum EnumKeys {
|
|
||||||
KEY_MENU,
|
|
||||||
KEY_EXIT,
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
KEY_ENTER,
|
|
||||||
KEY_PAGE,
|
|
||||||
KEY_PLUS,
|
|
||||||
KEY_MINUS,
|
|
||||||
#else
|
|
||||||
KEY_DOWN,
|
|
||||||
KEY_UP,
|
|
||||||
KEY_RIGHT,
|
|
||||||
KEY_LEFT,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TRM_BASE,
|
|
||||||
TRM_LH_DWN = TRM_BASE,
|
|
||||||
TRM_LH_UP,
|
|
||||||
TRM_LV_DWN,
|
|
||||||
TRM_LV_UP,
|
|
||||||
TRM_RV_DWN,
|
|
||||||
TRM_RV_UP,
|
|
||||||
TRM_RH_DWN,
|
|
||||||
TRM_RH_UP,
|
|
||||||
|
|
||||||
#if ROTARY_ENCODERS > 0 || defined(ROTARY_ENCODER_NAVIGATION)
|
|
||||||
BTN_REa,
|
|
||||||
#endif
|
|
||||||
#if ROTARY_ENCODERS > 0
|
|
||||||
BTN_REb,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NUM_KEYS,
|
|
||||||
SW_BASE=NUM_KEYS,
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
SW_SA0=SW_BASE,
|
|
||||||
SW_SA1,
|
|
||||||
SW_SA2,
|
|
||||||
SW_SB0,
|
|
||||||
SW_SB1,
|
|
||||||
SW_SB2,
|
|
||||||
SW_SC0,
|
|
||||||
SW_SC1,
|
|
||||||
SW_SC2,
|
|
||||||
SW_SD0,
|
|
||||||
SW_SD1,
|
|
||||||
SW_SD2,
|
|
||||||
SW_SE0,
|
|
||||||
SW_SE1,
|
|
||||||
SW_SE2,
|
|
||||||
SW_SF0,
|
|
||||||
SW_SF2,
|
|
||||||
SW_SG0,
|
|
||||||
SW_SG1,
|
|
||||||
SW_SG2,
|
|
||||||
SW_SH0,
|
|
||||||
SW_SH2,
|
|
||||||
#else
|
|
||||||
SW_ID0=SW_BASE,
|
|
||||||
SW_ID1,
|
|
||||||
SW_ID2,
|
|
||||||
#if defined(EXTRA_3POS)
|
|
||||||
SW_ID3,
|
|
||||||
SW_ID4,
|
|
||||||
SW_ID5,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SW_THR,
|
|
||||||
SW_RUD,
|
|
||||||
SW_ELE,
|
|
||||||
SW_AIL,
|
|
||||||
SW_GEA,
|
|
||||||
SW_TRN,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define NUM_SWITCHES 8
|
#define NUM_SWITCHES 8
|
||||||
@@ -587,35 +510,6 @@ extern uint8_t stickMode;
|
|||||||
|
|
||||||
extern uint8_t channel_order(uint8_t x);
|
extern uint8_t channel_order(uint8_t x);
|
||||||
|
|
||||||
class Key
|
|
||||||
{
|
|
||||||
#define FILTERBITS 4
|
|
||||||
|
|
||||||
#ifdef SIMU
|
|
||||||
#define FFVAL 1
|
|
||||||
#else
|
|
||||||
#define FFVAL ((1<<FILTERBITS)-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define KSTATE_OFF 0
|
|
||||||
#define KSTATE_RPTDELAY 95 // gruvin: delay state before key repeating starts
|
|
||||||
#define KSTATE_START 97
|
|
||||||
#define KSTATE_PAUSE 98
|
|
||||||
#define KSTATE_KILLED 99
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint8_t m_vals; // key debounce? 4 = 40ms
|
|
||||||
uint8_t m_cnt;
|
|
||||||
uint8_t m_state;
|
|
||||||
public:
|
|
||||||
void input(bool val, EnumKeys enuk);
|
|
||||||
bool state() { return m_vals > 0; }
|
|
||||||
void pauseEvents() { m_state = KSTATE_PAUSE; m_cnt = 0; }
|
|
||||||
void killEvents() { m_state = KSTATE_KILLED; }
|
|
||||||
};
|
|
||||||
|
|
||||||
extern Key keys[NUM_KEYS];
|
|
||||||
|
|
||||||
enum BaseCurves {
|
enum BaseCurves {
|
||||||
CURVE_NONE,
|
CURVE_NONE,
|
||||||
CURVE_X_GT0,
|
CURVE_X_GT0,
|
||||||
@@ -630,77 +524,9 @@ enum BaseCurves {
|
|||||||
#define THRCHK_DEADBAND 16
|
#define THRCHK_DEADBAND 16
|
||||||
|
|
||||||
#if defined(FSPLASH) || defined(XSPLASH)
|
#if defined(FSPLASH) || defined(XSPLASH)
|
||||||
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03)))
|
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03)))
|
||||||
#else
|
#else
|
||||||
#define SPLASH_TIMEOUT (4*100) // 4 seconds
|
#define SPLASH_TIMEOUT (4*100) // 4 seconds
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EVT_KEY_MASK(e) ((e) & 0x1f)
|
|
||||||
|
|
||||||
#define _MSK_KEY_BREAK 0x20
|
|
||||||
#define _MSK_KEY_REPT 0x40
|
|
||||||
#define _MSK_KEY_FIRST 0x60
|
|
||||||
#define _MSK_KEY_LONG 0x80
|
|
||||||
|
|
||||||
#define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK)
|
|
||||||
#define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST)
|
|
||||||
#define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT)
|
|
||||||
#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG)
|
|
||||||
|
|
||||||
#define IS_KEY_BREAK(evt) (((evt)&0xe0) == _MSK_KEY_BREAK)
|
|
||||||
#define IS_KEY_FIRST(evt) (((evt)&0xe0) == _MSK_KEY_FIRST)
|
|
||||||
#define IS_KEY_LONG(evt) (((evt)&0xe0) == _MSK_KEY_LONG)
|
|
||||||
|
|
||||||
#define EVT_ENTRY 0xbf
|
|
||||||
#define EVT_ENTRY_UP 0xbe
|
|
||||||
#define EVT_MENU_UP 0xbd
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
#define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)
|
|
||||||
#define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER)
|
|
||||||
#else
|
|
||||||
#define EVT_ROTARY_BREAK 0xcf
|
|
||||||
#define EVT_ROTARY_LONG 0xce
|
|
||||||
#define EVT_ROTARY_LEFT 0xdf
|
|
||||||
#define EVT_ROTARY_RIGHT 0xde
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
#define IS_ROTARY_LEFT(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
|
||||||
#define IS_ROTARY_RIGHT(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
|
||||||
#define IS_ROTARY_UP(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS))
|
|
||||||
#define IS_ROTARY_DOWN(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS))
|
|
||||||
#define IS_ROTARY_BREAK(evt) (evt==EVT_KEY_BREAK(KEY_ENTER))
|
|
||||||
#define IS_ROTARY_LONG(evt) (evt==EVT_KEY_LONG(KEY_ENTER))
|
|
||||||
#define IS_ROTARY_EVENT(evt) (0)
|
|
||||||
#define CASE_EVT_ROTARY_BREAK /*case EVT_KEY_BREAK(KEY_ENTER):*/
|
|
||||||
#define CASE_EVT_ROTARY_LONG /*case EVT_KEY_LONG(KEY_ENTER):*/
|
|
||||||
#define CASE_EVT_ROTARY_LEFT case EVT_KEY_FIRST(KEY_MOVE_DOWN): case EVT_KEY_REPT(KEY_MOVE_DOWN):
|
|
||||||
#define CASE_EVT_ROTARY_RIGHT case EVT_KEY_FIRST(KEY_MOVE_UP): case EVT_KEY_REPT(KEY_MOVE_UP):
|
|
||||||
#elif defined(ROTARY_ENCODER_NAVIGATION)
|
|
||||||
#define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT)
|
|
||||||
#define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT)
|
|
||||||
#define IS_ROTARY_UP(evt) IS_ROTARY_LEFT(evt)
|
|
||||||
#define IS_ROTARY_DOWN(evt) IS_ROTARY_RIGHT(evt)
|
|
||||||
#define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK)
|
|
||||||
#define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG)
|
|
||||||
#define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e)
|
|
||||||
#define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK:
|
|
||||||
#define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG:
|
|
||||||
#define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT:
|
|
||||||
#define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT:
|
|
||||||
#else
|
|
||||||
#define IS_ROTARY_LEFT(evt) (0)
|
|
||||||
#define IS_ROTARY_RIGHT(evt) (0)
|
|
||||||
#define IS_ROTARY_UP(evt) (0)
|
|
||||||
#define IS_ROTARY_DOWN(evt) (0)
|
|
||||||
#define IS_ROTARY_BREAK(evt) (0)
|
|
||||||
#define IS_ROTARY_LONG(evt) (0)
|
|
||||||
#define IS_ROTARY_EVENT(evt) (0)
|
|
||||||
#define CASE_EVT_ROTARY_BREAK
|
|
||||||
#define CASE_EVT_ROTARY_LONG
|
|
||||||
#define CASE_EVT_ROTARY_LEFT
|
|
||||||
#define CASE_EVT_ROTARY_RIGHT
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
@@ -734,6 +560,7 @@ struct t_inactivity
|
|||||||
uint16_t counter;
|
uint16_t counter;
|
||||||
uint8_t sum;
|
uint8_t sum;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct t_inactivity inactivity;
|
extern struct t_inactivity inactivity;
|
||||||
|
|
||||||
#if defined(PXX)
|
#if defined(PXX)
|
||||||
@@ -754,25 +581,8 @@ void str2zchar(char *dest, const char *src, int size);
|
|||||||
void zchar2str(char *dest, const char *src, int size);
|
void zchar2str(char *dest, const char *src, int size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern uint8_t s_evt;
|
#include "keys.h"
|
||||||
#define putEvent(evt) s_evt = evt
|
#include "pwr.h"
|
||||||
void clearKeyEvents();
|
|
||||||
void pauseEvents(uint8_t enuk);
|
|
||||||
void killEvents(uint8_t enuk);
|
|
||||||
#if defined(CPUARM)
|
|
||||||
uint8_t getEvent(bool trim);
|
|
||||||
#else
|
|
||||||
uint8_t getEvent();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t keyDown();
|
|
||||||
|
|
||||||
enum PowerState {
|
|
||||||
e_power_on,
|
|
||||||
e_power_trainer,
|
|
||||||
e_power_usb,
|
|
||||||
e_power_off
|
|
||||||
};
|
|
||||||
|
|
||||||
bool switchState(EnumKeys enuk);
|
bool switchState(EnumKeys enuk);
|
||||||
uint8_t trimDown(uint8_t idx);
|
uint8_t trimDown(uint8_t idx);
|
||||||
@@ -1111,7 +921,7 @@ template<class t> void swap(t & a, t & b) { t tmp = b; b = a; a = tmp; }
|
|||||||
uint16_t isqrt32(uint32_t n);
|
uint16_t isqrt32(uint32_t n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM) && !defined(BOOT)
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <CoOS.h>
|
#include <CoOS.h>
|
||||||
@@ -1514,6 +1324,7 @@ enum AUDIO_SOUNDS {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "translations.h"
|
#include "translations.h"
|
||||||
|
#include "fonts.h"
|
||||||
|
|
||||||
#if defined(HAPTIC)
|
#if defined(HAPTIC)
|
||||||
#include "haptic.h"
|
#include "haptic.h"
|
||||||
@@ -1632,7 +1443,7 @@ extern union ReusableBuffer reusableBuffer;
|
|||||||
void checkFlashOnBeep();
|
void checkFlashOnBeep();
|
||||||
|
|
||||||
#if defined(FRSKY) || defined(CPUARM)
|
#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);
|
void putsTelemetryValue(xcoord_t x, uint8_t y, lcdint_t val, uint8_t unit, uint8_t att);
|
||||||
#else
|
#else
|
||||||
#define convertUnit(...)
|
#define convertUnit(...)
|
||||||
|
|||||||
Executable
+47
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Andre Bernet <bernet.andre@gmail.com>
|
||||||
|
* - Andreas Weitl
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
* - Cameron Weeks <th9xer@gmail.com>
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Gabriel Birkus
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michael Blandford
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||||
|
* - 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 pwr_h
|
||||||
|
#define pwr_h
|
||||||
|
|
||||||
|
enum PowerState {
|
||||||
|
e_power_on,
|
||||||
|
e_power_trainer,
|
||||||
|
e_power_usb,
|
||||||
|
e_power_off
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
#define SYSTEM_SUBDIR "SYSTEM" // no trailing slash = important
|
#define SYSTEM_SUBDIR "SYSTEM" // no trailing slash = important
|
||||||
#define BITMAPS_PATH ROOT_PATH "BMP"
|
#define BITMAPS_PATH ROOT_PATH "BMP"
|
||||||
#define SCRIPTS_PATH ROOT_PATH "SCRIPTS"
|
#define SCRIPTS_PATH ROOT_PATH "SCRIPTS"
|
||||||
|
#define FIRMWARES_PATH ROOT_PATH "FIRMWARES"
|
||||||
|
|
||||||
#define MODELS_EXT ".bin"
|
#define MODELS_EXT ".bin"
|
||||||
#define LOGS_EXT ".csv"
|
#define LOGS_EXT ".csv"
|
||||||
@@ -62,6 +63,7 @@ extern const pm_char * openLogs();
|
|||||||
extern void closeLogs();
|
extern void closeLogs();
|
||||||
extern void writeLogs();
|
extern void writeLogs();
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
inline const pm_char *SDCARD_ERROR(FRESULT result)
|
inline const pm_char *SDCARD_ERROR(FRESULT result)
|
||||||
{
|
{
|
||||||
if (result == FR_NOT_READY)
|
if (result == FR_NOT_READY)
|
||||||
@@ -69,6 +71,7 @@ inline const pm_char *SDCARD_ERROR(FRESULT result)
|
|||||||
else
|
else
|
||||||
return STR_SDCARD_ERROR;
|
return STR_SDCARD_ERROR;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define O9X_FOURCC 0x3378396F // o9x for Taranis
|
#define O9X_FOURCC 0x3378396F // o9x for Taranis
|
||||||
|
|||||||
@@ -638,6 +638,7 @@ void lcdRefresh()
|
|||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void usbStart() { }
|
void usbStart() { }
|
||||||
|
int usbPlugged() { return false; }
|
||||||
void USART_DeInit(USART_TypeDef* ) { }
|
void USART_DeInit(USART_TypeDef* ) { }
|
||||||
ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct) { return SUCCESS; }
|
ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct) { return SUCCESS; }
|
||||||
ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct) { return SUCCESS; }
|
ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct) { return SUCCESS; }
|
||||||
|
|||||||
@@ -71,9 +71,15 @@ SECTIONS
|
|||||||
*/
|
*/
|
||||||
.text :
|
.text :
|
||||||
{
|
{
|
||||||
_stext = .; /* Provide the name for the start of this section */
|
FILL(0xFFFF)
|
||||||
|
|
||||||
CREATE_OBJECT_SYMBOLS
|
CREATE_OBJECT_SYMBOLS
|
||||||
|
|
||||||
|
*(.bootrodata)
|
||||||
|
*(.bootrodata.*)
|
||||||
|
|
||||||
|
. = ALIGN(32768); /* Align the start of the exidx part */
|
||||||
|
_stext = .; /* Provide the name for the start of this section */
|
||||||
KEEP(*(.vectors))
|
KEEP(*(.vectors))
|
||||||
|
|
||||||
*(.text)
|
*(.text)
|
||||||
@@ -129,11 +135,8 @@ SECTIONS
|
|||||||
|
|
||||||
. = ALIGN(4); /* Align the end of the section */
|
. = ALIGN(4); /* Align the end of the section */
|
||||||
} > RAM
|
} > RAM
|
||||||
_ebss = .; /* Provide the name for the end of this section */
|
_ebss = .; /* Provide the name for the end of this section */
|
||||||
|
|
||||||
. = ALIGN(4); /* Align the end of the section */
|
|
||||||
__end = .;
|
|
||||||
_end = .;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The ".stack" section is our stack.
|
* The ".stack" section is our stack.
|
||||||
|
|||||||
+6
-1
@@ -232,7 +232,12 @@ 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
|
||||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
#if defined(BOOTLOADER) || defined(BOOT)
|
||||||
|
extern uint32_t g_pfnVectors ;
|
||||||
|
SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */
|
||||||
|
#else
|
||||||
|
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -113,8 +113,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f2xx_spi.h"
|
#include "../inc/stm32f2xx_spi.h"
|
||||||
#include "stm32f2xx_rcc.h"
|
#include "../inc/stm32f2xx_rcc.h"
|
||||||
|
|
||||||
/** @addtogroup STM32F2xx_StdPeriph_Driver
|
/** @addtogroup STM32F2xx_StdPeriph_Driver
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../opentx.h"
|
#include "board_taranis.h"
|
||||||
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
**********send command to lcd**************
|
**********send command to lcd**************
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
#ifndef _ASPI_H_
|
#ifndef _ASPI_H_
|
||||||
#define _ASPI_H_
|
#define _ASPI_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
||||||
|
|
||||||
#define __no_operation __NOP
|
#define __no_operation __NOP
|
||||||
@@ -33,5 +37,9 @@
|
|||||||
void AspiCmd(u8 Command_Byte);
|
void AspiCmd(u8 Command_Byte);
|
||||||
void AspiData(u8 Para_data);
|
void AspiData(u8 Para_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "../../opentx.h"
|
#include "../../opentx.h"
|
||||||
|
|
||||||
bool dacIdle = true;
|
int dacIdle = 1;
|
||||||
|
|
||||||
void setSampleRate(uint32_t frequency)
|
void setSampleRate(uint32_t frequency)
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ void dacInit()
|
|||||||
bool dacQueue(AudioBuffer *buffer)
|
bool dacQueue(AudioBuffer *buffer)
|
||||||
{
|
{
|
||||||
if (dacIdle) {
|
if (dacIdle) {
|
||||||
dacIdle = false;
|
dacIdle = 0;
|
||||||
DMA1_Stream5->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
DMA1_Stream5->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
||||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||||
DMA1_Stream5->M0AR = CONVERT_PTR(buffer->data);
|
DMA1_Stream5->M0AR = CONVERT_PTR(buffer->data);
|
||||||
@@ -111,6 +111,20 @@ bool dacQueue(AudioBuffer *buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dacStart()
|
||||||
|
{
|
||||||
|
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||||
|
DMA1_Stream5->CR |= DMA_SxCR_CIRC | DMA_SxCR_EN ; // Enable DMA channel
|
||||||
|
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||||
|
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
||||||
|
}
|
||||||
|
|
||||||
|
void dacStop()
|
||||||
|
{
|
||||||
|
DMA1_Stream5->CR &= ~DMA_SxCR_CIRC ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sound routines
|
// Sound routines
|
||||||
void audioInit()
|
void audioInit()
|
||||||
{
|
{
|
||||||
@@ -149,7 +163,7 @@ extern "C" void DMA1_Stream5_IRQHandler()
|
|||||||
DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag
|
DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dacIdle = true;
|
dacIdle = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -37,25 +37,14 @@
|
|||||||
#ifndef audio_driver_h
|
#ifndef audio_driver_h
|
||||||
#define audio_driver_h
|
#define audio_driver_h
|
||||||
|
|
||||||
extern void audioInit( void ) ;
|
void audioInit( void ) ;
|
||||||
extern void audioEnd( void ) ;
|
void audioEnd( void ) ;
|
||||||
|
void dacStart();
|
||||||
|
void dacStop();
|
||||||
|
|
||||||
extern void setSampleRate(uint32_t frequency);
|
extern void setSampleRate(uint32_t frequency);
|
||||||
|
|
||||||
extern bool dacIdle;
|
extern int dacIdle;
|
||||||
|
|
||||||
inline void dacStart()
|
|
||||||
{
|
|
||||||
DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
|
||||||
DMA1_Stream5->CR |= DMA_SxCR_CIRC | DMA_SxCR_EN ; // Enable DMA channel
|
|
||||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
|
||||||
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void dacStop()
|
|
||||||
{
|
|
||||||
DMA1_Stream5->CR &= ~DMA_SxCR_CIRC ;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VOLUME_LEVEL_MAX 23
|
#define VOLUME_LEVEL_MAX 23
|
||||||
#define VOLUME_LEVEL_DEF 12
|
#define VOLUME_LEVEL_DEF 12
|
||||||
|
|||||||
@@ -44,22 +44,6 @@ extern "C" {
|
|||||||
|
|
||||||
volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define
|
volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define
|
||||||
|
|
||||||
#define PIN_MODE_MASK 0x0003
|
|
||||||
#define PIN_INPUT 0x0000
|
|
||||||
#define PIN_OUTPUT 0x0001
|
|
||||||
#define PIN_PERIPHERAL 0x0002
|
|
||||||
#define PIN_ANALOG 0x0003
|
|
||||||
#define PIN_PULL_MASK 0x000C
|
|
||||||
#define PIN_PULLUP 0x0004
|
|
||||||
#define PIN_NO_PULLUP 0x0000
|
|
||||||
#define PIN_PULLDOWN 0x0008
|
|
||||||
#define PIN_NO_PULLDOWN 0x0000
|
|
||||||
#define PIN_PERI_MASK 0x00F0
|
|
||||||
#define PIN_PUSHPULL 0x0000
|
|
||||||
#define PIN_ODRAIN 0x8000
|
|
||||||
#define PIN_PORT_MASK 0x0700
|
|
||||||
#define PIN_SPEED_MASK 0x6000
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
void configure_pins( uint32_t pins, uint16_t config )
|
void configure_pins( uint32_t pins, uint16_t config )
|
||||||
{
|
{
|
||||||
@@ -106,32 +90,6 @@ void configure_pins( uint32_t pins, uint16_t config )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool usbPlugged(void)
|
|
||||||
{
|
|
||||||
return GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
|
||||||
extern "C" {
|
|
||||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
|
||||||
|
|
||||||
void OTG_FS_IRQHandler(void)
|
|
||||||
{
|
|
||||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbInit()
|
|
||||||
{
|
|
||||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbStart()
|
|
||||||
{
|
|
||||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void watchdogInit(unsigned int duration)
|
void watchdogInit(unsigned int duration)
|
||||||
{
|
{
|
||||||
IWDG->KR = 0x5555 ; // Unlock registers
|
IWDG->KR = 0x5555 ; // Unlock registers
|
||||||
|
|||||||
@@ -37,6 +37,10 @@
|
|||||||
#ifndef board_taranis_h
|
#ifndef board_taranis_h
|
||||||
#define board_taranis_h
|
#define board_taranis_h
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h"
|
||||||
@@ -45,17 +49,23 @@
|
|||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_usart.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_usart.h"
|
||||||
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
|
||||||
extern "C" {
|
|
||||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h"
|
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h"
|
||||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h"
|
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h"
|
||||||
#include "usbd_desc.h"
|
#include "usbd_desc.h"
|
||||||
#include "usb_conf.h"
|
#include "usb_conf.h"
|
||||||
#include "usbd_conf.h"
|
#include "usbd_conf.h"
|
||||||
}
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "aspi.h"
|
#include "aspi.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOT)
|
||||||
#include "audio_driver.h"
|
#include "audio_driver.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PERI1_FREQUENCY 30000000
|
#define PERI1_FREQUENCY 30000000
|
||||||
#define PERI2_FREQUENCY 60000000
|
#define PERI2_FREQUENCY 60000000
|
||||||
@@ -65,6 +75,22 @@ extern "C" {
|
|||||||
#define JACK_PPM_OUT()
|
#define JACK_PPM_OUT()
|
||||||
#define JACK_PPM_IN()
|
#define JACK_PPM_IN()
|
||||||
|
|
||||||
|
#define PIN_MODE_MASK 0x0003
|
||||||
|
#define PIN_INPUT 0x0000
|
||||||
|
#define PIN_OUTPUT 0x0001
|
||||||
|
#define PIN_PERIPHERAL 0x0002
|
||||||
|
#define PIN_ANALOG 0x0003
|
||||||
|
#define PIN_PULL_MASK 0x000C
|
||||||
|
#define PIN_PULLUP 0x0004
|
||||||
|
#define PIN_NO_PULLUP 0x0000
|
||||||
|
#define PIN_PULLDOWN 0x0008
|
||||||
|
#define PIN_NO_PULLDOWN 0x0000
|
||||||
|
#define PIN_PERI_MASK 0x00F0
|
||||||
|
#define PIN_PUSHPULL 0x0000
|
||||||
|
#define PIN_ODRAIN 0x8000
|
||||||
|
#define PIN_PORT_MASK 0x0700
|
||||||
|
#define PIN_SPEED_MASK 0x6000
|
||||||
|
|
||||||
void configure_pins( uint32_t pins, uint16_t config );
|
void configure_pins( uint32_t pins, uint16_t config );
|
||||||
|
|
||||||
#define strcpy_P strcpy
|
#define strcpy_P strcpy
|
||||||
@@ -75,7 +101,7 @@ extern uint16_t sessionTimer;
|
|||||||
#define SLAVE_MODE() (g_model.trainerMode == 1)
|
#define SLAVE_MODE() (g_model.trainerMode == 1)
|
||||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET)
|
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET)
|
||||||
|
|
||||||
void delaysInit();
|
void delaysInit(void);
|
||||||
|
|
||||||
#define DEBUG_BAUDRATE 115200
|
#define DEBUG_BAUDRATE 115200
|
||||||
#define SPORT_BAUDRATE 57600
|
#define SPORT_BAUDRATE 57600
|
||||||
@@ -97,11 +123,11 @@ void delay_01us(uint16_t nb);
|
|||||||
#define SD_GET_SIZE_MB() (0)
|
#define SD_GET_SIZE_MB() (0)
|
||||||
#define SD_GET_BLOCKNR() (0)
|
#define SD_GET_BLOCKNR() (0)
|
||||||
#define SD_GET_SPEED() (0)
|
#define SD_GET_SPEED() (0)
|
||||||
void sdInit();
|
void sdInit(void);
|
||||||
void sdDone();
|
void sdDone(void);
|
||||||
void sdPoll10ms();
|
void sdPoll10ms(void);
|
||||||
#define sdMountPoll()
|
#define sdMountPoll()
|
||||||
uint32_t sdMounted();
|
uint32_t sdMounted(void);
|
||||||
#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_Pin)
|
#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_Pin)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -116,15 +142,15 @@ void init_dsm2( uint32_t module_index );
|
|||||||
void disable_dsm2( uint32_t module_index );
|
void disable_dsm2( uint32_t module_index );
|
||||||
|
|
||||||
// Trainer driver
|
// Trainer driver
|
||||||
void init_trainer_ppm();
|
void init_trainer_ppm(void);
|
||||||
void stop_trainer_ppm();
|
void stop_trainer_ppm(void);
|
||||||
void init_trainer_capture();
|
void init_trainer_capture(void);
|
||||||
void stop_trainer_capture();
|
void stop_trainer_capture(void);
|
||||||
|
|
||||||
// Keys driver
|
// Keys driver
|
||||||
void keysInit();
|
void keysInit(void);
|
||||||
uint32_t readKeys();
|
uint32_t readKeys(void);
|
||||||
uint32_t readTrims();
|
uint32_t readTrims(void);
|
||||||
#define TRIMS_PRESSED() (readTrims())
|
#define TRIMS_PRESSED() (readTrims())
|
||||||
#define KEYS_PRESSED() (~readKeys())
|
#define KEYS_PRESSED() (~readKeys())
|
||||||
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & ((2<<KEY_PLUS) + (2<<KEY_MINUS))) == ((2<<KEY_PLUS) + (2<<KEY_MINUS)))
|
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & ((2<<KEY_PLUS) + (2<<KEY_MINUS))) == ((2<<KEY_PLUS) + (2<<KEY_MINUS)))
|
||||||
@@ -141,8 +167,8 @@ void watchdogInit(unsigned int duration);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ADC driver
|
// ADC driver
|
||||||
void adcInit();
|
void adcInit(void);
|
||||||
void adcRead();
|
void adcRead(void);
|
||||||
extern volatile uint16_t Analog_values[];
|
extern volatile uint16_t Analog_values[];
|
||||||
#if defined(REV3)
|
#if defined(REV3)
|
||||||
#define BATT_SCALE 120
|
#define BATT_SCALE 120
|
||||||
@@ -150,10 +176,14 @@ extern volatile uint16_t Analog_values[];
|
|||||||
#define BATT_SCALE 150
|
#define BATT_SCALE 150
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// Power driver
|
// Power driver
|
||||||
void pwrInit();
|
void pwrInit(void);
|
||||||
uint32_t pwrCheck();
|
uint32_t pwrCheck(void);
|
||||||
void pwrOff();
|
void pwrOff(void);
|
||||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||||
#define INTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_INT_RF_PWR)
|
#define INTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_INT_RF_PWR)
|
||||||
#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR)
|
#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR)
|
||||||
@@ -167,11 +197,15 @@ void pwrOff();
|
|||||||
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
|
||||||
|
|
||||||
// USB driver
|
// USB driver
|
||||||
|
int usbPlugged(void);
|
||||||
#define BOOTLOADER_REQUEST() (0)
|
#define BOOTLOADER_REQUEST() (0)
|
||||||
#define usbBootloader()
|
#define usbBootloader()
|
||||||
void usbInit(void);
|
void usbInit(void);
|
||||||
void usbStart(void);
|
void usbStart(void);
|
||||||
bool usbPlugged(void);
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// EEPROM driver
|
// EEPROM driver
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../opentx.h"
|
#include "board_taranis.h"
|
||||||
|
|
||||||
void delaysInit(void)
|
void delaysInit(void)
|
||||||
{
|
{
|
||||||
@@ -35,9 +35,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../FatFs/diskio.h"
|
#include "board_taranis.h"
|
||||||
#include "../FatFs/ff.h"
|
#include "../../FatFs/diskio.h"
|
||||||
#include "../CoOS/kernel/CoOS.h"
|
#include "../../FatFs/ff.h"
|
||||||
|
#include "../../CoOS/kernel/CoOS.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
/* Definitions for MMC/SDC command */
|
/* Definitions for MMC/SDC command */
|
||||||
@@ -93,6 +94,7 @@ uint32_t transSpeed; */
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Lock / unlock functions */
|
/* Lock / unlock functions */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
#if !defined(BOOT)
|
||||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||||
{
|
{
|
||||||
*mutex = CoCreateMutex();
|
*mutex = CoCreateMutex();
|
||||||
@@ -114,6 +116,7 @@ int ff_del_syncobj (_SYNC_t mutex)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const DWORD socket_state_mask_cp = (1 << 0);
|
static const DWORD socket_state_mask_cp = (1 << 0);
|
||||||
static const DWORD socket_state_mask_wp = (1 << 1);
|
static const DWORD socket_state_mask_wp = (1 << 1);
|
||||||
@@ -124,7 +127,6 @@ DSTATUS Stat = STA_NOINIT; /* Disk status */
|
|||||||
static volatile
|
static volatile
|
||||||
DWORD Timer1, Timer2; /* 100Hz decrement timers */
|
DWORD Timer1, Timer2; /* 100Hz decrement timers */
|
||||||
|
|
||||||
static
|
|
||||||
BYTE CardType; /* Card type flags */
|
BYTE CardType; /* Card type flags */
|
||||||
|
|
||||||
enum speed_setting { INTERFACE_SLOW, INTERFACE_FAST };
|
enum speed_setting { INTERFACE_SLOW, INTERFACE_FAST };
|
||||||
@@ -178,12 +180,10 @@ static void card_power(BYTE on)
|
|||||||
on=on;
|
on=on;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (STM32_SD_DISK_IOCTRL == 1)
|
|
||||||
static int chk_power(void)
|
static int chk_power(void)
|
||||||
{
|
{
|
||||||
return 1; /* fake powered */
|
return 1; /* fake powered */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Transmit/Receive a byte to MMC via SPI (Platform dependent) */
|
/* Transmit/Receive a byte to MMC via SPI (Platform dependent) */
|
||||||
@@ -433,30 +433,29 @@ void power_on (void)
|
|||||||
static
|
static
|
||||||
void power_off (void)
|
void power_off (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
|
||||||
if (!(Stat & STA_NOINIT)) {
|
if (!(Stat & STA_NOINIT)) {
|
||||||
SELECT();
|
SELECT();
|
||||||
wait_ready();
|
wait_ready();
|
||||||
release_spi();
|
release_spi();
|
||||||
}
|
}
|
||||||
|
|
||||||
SPI_I2S_DeInit(SPI_SD);
|
SPI_I2S_DeInit(SPI_SD);
|
||||||
SPI_Cmd(SPI_SD, DISABLE);
|
SPI_Cmd(SPI_SD, DISABLE);
|
||||||
RCC_APBPeriphClockCmd_SPI_SD(RCC_APBPeriph_SPI_SD, DISABLE);
|
RCC_APBPeriphClockCmd_SPI_SD(RCC_APBPeriph_SPI_SD, DISABLE);
|
||||||
|
|
||||||
//All SPI-Pins to input with weak internal pull-downs
|
//All SPI-Pins to input with weak internal pull-downs
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_SCK | GPIO_Pin_SPI_SD_MISO | GPIO_Pin_SPI_SD_MOSI;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SPI_SD_SCK | GPIO_Pin_SPI_SD_MISO
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
| GPIO_Pin_SPI_SD_MOSI;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||||
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
GPIO_Init(GPIO_SPI_SD, &GPIO_InitStructure);
|
||||||
|
|
||||||
card_power(0);
|
card_power(0);
|
||||||
|
|
||||||
Stat |= STA_NOINIT; /* Set STA_NOINIT */
|
Stat |= STA_NOINIT; /* Set STA_NOINIT */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@@ -501,7 +500,6 @@ BOOL rcvr_datablock (
|
|||||||
/* Send a data packet to MMC */
|
/* Send a data packet to MMC */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _FS_READONLY == 0
|
|
||||||
static
|
static
|
||||||
BOOL xmit_datablock (
|
BOOL xmit_datablock (
|
||||||
const BYTE *buff, /* 512 byte data block to be transmitted */
|
const BYTE *buff, /* 512 byte data block to be transmitted */
|
||||||
@@ -537,8 +535,6 @@ BOOL xmit_datablock (
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif /* _READONLY */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@@ -655,7 +651,6 @@ DSTATUS disk_initialize (
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Get Disk Status */
|
/* Get Disk Status */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DSTATUS disk_status (
|
DSTATUS disk_status (
|
||||||
BYTE drv /* Physical drive number (0) */
|
BYTE drv /* Physical drive number (0) */
|
||||||
)
|
)
|
||||||
@@ -665,7 +660,6 @@ DSTATUS disk_status (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Read Sector(s) */
|
/* Read Sector(s) */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@@ -675,14 +669,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();
|
||||||
@@ -700,29 +703,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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -731,8 +714,6 @@ DRESULT disk_read (
|
|||||||
/* Write Sector(s) */
|
/* Write Sector(s) */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _FS_READONLY == 0
|
|
||||||
|
|
||||||
// TODO quick & dirty
|
// TODO quick & dirty
|
||||||
int8_t SD_WriteSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
int8_t SD_WriteSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
||||||
{
|
{
|
||||||
@@ -752,6 +733,8 @@ int8_t SD_WriteSectors(uint8_t *buff, uint32_t sector, uint32_t count)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if _FS_READONLY == 0
|
||||||
|
|
||||||
DRESULT disk_write (
|
DRESULT disk_write (
|
||||||
BYTE drv, /* Physical drive number (0) */
|
BYTE drv, /* Physical drive number (0) */
|
||||||
const BYTE *buff, /* Pointer to the data to be written */
|
const BYTE *buff, /* Pointer to the data to be written */
|
||||||
@@ -793,7 +776,6 @@ DRESULT disk_write (
|
|||||||
/* Miscellaneous Functions */
|
/* Miscellaneous Functions */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if (STM32_SD_DISK_IOCTRL == 1)
|
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl (
|
||||||
BYTE drv, /* Physical drive number (0) */
|
BYTE drv, /* Physical drive number (0) */
|
||||||
BYTE ctrl, /* Control code */
|
BYTE ctrl, /* Control code */
|
||||||
@@ -919,7 +901,6 @@ DRESULT disk_ioctl (
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif /* _USE_IOCTL != 0 */
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@@ -966,7 +947,16 @@ FATFS g_FATFS_Obj;
|
|||||||
FIL g_telemetryFile = {0};
|
FIL g_telemetryFile = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sdInit()
|
#if defined(BOOT)
|
||||||
|
void sdInit(void)
|
||||||
|
{
|
||||||
|
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||||
|
f_chdir("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// TODO shouldn't be there!
|
||||||
|
void sdInit(void)
|
||||||
{
|
{
|
||||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||||
referenceSystemAudioFiles();
|
referenceSystemAudioFiles();
|
||||||
@@ -989,6 +979,7 @@ void sdDone()
|
|||||||
f_mount(0, 0); // unmount SD
|
f_mount(0, 0); // unmount SD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t sdMounted()
|
uint32_t sdMounted()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -307,7 +307,9 @@
|
|||||||
#define STM32_SD_DISK_IOCTRL_FORCE 0
|
#define STM32_SD_DISK_IOCTRL_FORCE 0
|
||||||
|
|
||||||
//DMA
|
//DMA
|
||||||
#define STM32_SD_USE_DMA //Enable the DMA for SD
|
#if !defined(BOOT)
|
||||||
|
#define STM32_SD_USE_DMA //Enable the DMA for SD
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef STM32_SD_USE_DMA
|
#ifdef STM32_SD_USE_DMA
|
||||||
#define DMA_Channel_SPI_SD_RX DMA1_Stream3
|
#define DMA_Channel_SPI_SD_RX DMA1_Stream3
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../opentx.h"
|
#include "board_taranis.h"
|
||||||
|
|
||||||
#define I2C_delay() delay_01us(100);
|
#define I2C_delay() delay_01us(100);
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ static void I2C_GPIO_Configuration(void)
|
|||||||
SCL_H;
|
SCL_H;
|
||||||
}
|
}
|
||||||
|
|
||||||
short I2C_START()
|
short I2C_START(void)
|
||||||
{
|
{
|
||||||
SDA_H;
|
SDA_H;
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
@@ -59,7 +59,7 @@ short I2C_START()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2C_STOP()
|
void I2C_STOP(void)
|
||||||
{
|
{
|
||||||
SCL_L;
|
SCL_L;
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
@@ -71,7 +71,7 @@ void I2C_STOP()
|
|||||||
I2C_delay();
|
I2C_delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2C_ACK()
|
void I2C_ACK(void)
|
||||||
{
|
{
|
||||||
SCL_L;
|
SCL_L;
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
@@ -82,7 +82,8 @@ void I2C_ACK()
|
|||||||
SCL_L;
|
SCL_L;
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
}
|
}
|
||||||
void I2C_NO_ACK()
|
|
||||||
|
void I2C_NO_ACK(void)
|
||||||
{
|
{
|
||||||
SCL_L;
|
SCL_L;
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
@@ -94,7 +95,7 @@ void I2C_NO_ACK()
|
|||||||
I2C_delay();
|
I2C_delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
short I2C_WAIT_ACK()
|
short I2C_WAIT_ACK(void)
|
||||||
{
|
{
|
||||||
short i=50;
|
short i=50;
|
||||||
SCL_L;
|
SCL_L;
|
||||||
@@ -103,7 +104,7 @@ short I2C_WAIT_ACK()
|
|||||||
I2C_delay();
|
I2C_delay();
|
||||||
SCL_H;
|
SCL_H;
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
while(i) {
|
while (i) {
|
||||||
if(SDA_read) {
|
if(SDA_read) {
|
||||||
I2C_delay();
|
I2C_delay();
|
||||||
i--;
|
i--;
|
||||||
@@ -138,7 +139,7 @@ void I2C_SEND_DATA(char SendByte)
|
|||||||
I2C_delay();
|
I2C_delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
char I2C_READ()
|
char I2C_READ(void)
|
||||||
{
|
{
|
||||||
short i=8;
|
short i=8;
|
||||||
char ReceiveByte=0;
|
char ReceiveByte=0;
|
||||||
@@ -158,7 +159,7 @@ char I2C_READ()
|
|||||||
return ReceiveByte;
|
return ReceiveByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2C_EE_Init()
|
void I2C_EE_Init(void)
|
||||||
{
|
{
|
||||||
/* GPIO Periph clock enable */
|
/* GPIO Periph clock enable */
|
||||||
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
|
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
#define WP_H do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
|
#define WP_H do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
|
||||||
#define WP_L do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)
|
#define WP_L do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void I2C_EE_Init(void);
|
void I2C_EE_Init(void);
|
||||||
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr);
|
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr);
|
||||||
@@ -42,7 +46,11 @@ void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRe
|
|||||||
void I2C_EE_WaitEepromStandbyState(void);
|
void I2C_EE_WaitEepromStandbyState(void);
|
||||||
|
|
||||||
void I2C_set_volume(register uint8_t volume);
|
void I2C_set_volume(register uint8_t volume);
|
||||||
uint8_t I2C_read_volume();
|
uint8_t I2C_read_volume(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __I2C_EE_H */
|
#endif /* __I2C_EE_H */
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../opentx.h"
|
#include "../../opentx.h"
|
||||||
|
|
||||||
#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()
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,11 @@ static void LCD_Init()
|
|||||||
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
||||||
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
|
||||||
AspiCmd(g_eeGeneral.contrast+CONTRAST_OFS); //0--255
|
#if defined(BOOT)
|
||||||
|
AspiCmd(CONTRAST_OFS+25);
|
||||||
|
#else
|
||||||
|
AspiCmd(CONTRAST_OFS+g_eeGeneral.contrast);
|
||||||
|
#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
|
||||||
AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22
|
AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22
|
||||||
|
|||||||
@@ -34,26 +34,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../opentx.h"
|
#include "board_taranis.h"
|
||||||
|
#include "../../pwr.h"
|
||||||
void pwrOff()
|
|
||||||
{
|
|
||||||
GPIO_ResetBits(GPIOPWR,PIN_MCU_PWR);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pwrCheck()
|
|
||||||
{
|
|
||||||
#if defined(SIMU)
|
|
||||||
return e_power_on;
|
|
||||||
#else
|
|
||||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
|
||||||
return e_power_on;
|
|
||||||
else if (usbPlugged())
|
|
||||||
return e_power_usb;
|
|
||||||
else
|
|
||||||
return e_power_off;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void pwrInit()
|
void pwrInit()
|
||||||
{
|
{
|
||||||
@@ -101,5 +83,25 @@ void pwrInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Soft power ON
|
// Soft power ON
|
||||||
GPIO_SetBits(GPIOPWR,PIN_MCU_PWR);
|
GPIO_SetBits(GPIOPWR, PIN_MCU_PWR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pwrOff()
|
||||||
|
{
|
||||||
|
GPIO_ResetBits(GPIOPWR, PIN_MCU_PWR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO enums should be UPPERCASE
|
||||||
|
uint32_t pwrCheck()
|
||||||
|
{
|
||||||
|
#if defined(SIMU)
|
||||||
|
return e_power_on;
|
||||||
|
#else
|
||||||
|
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||||
|
return e_power_on;
|
||||||
|
else if (usbPlugged())
|
||||||
|
return e_power_usb;
|
||||||
|
else
|
||||||
|
return e_power_off;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
/*
|
||||||
|
*****************************************************************************
|
||||||
|
**
|
||||||
|
** File : stm32_flash.ld
|
||||||
|
**
|
||||||
|
** Abstract : Linker script for STM32F205 Device with
|
||||||
|
** 0.5MByte FLASH, 128KByte SRAM
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
**
|
||||||
|
** Environment : Atollic TrueSTUDIO(R)
|
||||||
|
**
|
||||||
|
** Distribution: The file is distributed “as is,” without any warranty
|
||||||
|
** of any kind.
|
||||||
|
**
|
||||||
|
** (c)Copyright Atollic AB.
|
||||||
|
** You may use this file as-is or modify it according to the needs of your
|
||||||
|
** project. Distribution of this file (unmodified or modified) is not
|
||||||
|
** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
|
||||||
|
** rights to distribute the assembled, compiled & linked contents of this
|
||||||
|
** file as part of an application binary file, provided that it is built
|
||||||
|
** using the Atollic TrueSTUDIO(R) toolchain.
|
||||||
|
**
|
||||||
|
*****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Entry Point */
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
/* Highest address of the user mode stack */
|
||||||
|
_estack = 0x20020000; /* end of 128K SRAM */
|
||||||
|
|
||||||
|
/* Generate a link error if heap and stack don't fit into RAM */
|
||||||
|
_Min_Heap_Size = 0; /* required amount of heap */
|
||||||
|
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||||
|
|
||||||
|
/* Specify the memory areas */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||||
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||||
|
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Define output sections */
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
/* The startup code goes first into FLASH */
|
||||||
|
|
||||||
|
/* The program code and other data goes into FLASH */
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
FILL(0xFFFF)
|
||||||
|
|
||||||
|
CREATE_OBJECT_SYMBOLS
|
||||||
|
|
||||||
|
KEEP(*(.isr_boot_vector)) /* Startup code */
|
||||||
|
*(.bootrodata)
|
||||||
|
*(.bootrodata.*)
|
||||||
|
|
||||||
|
. = ALIGN(32768); /* Align the start of the main program */
|
||||||
|
_stext = .; /* Provide the name for the start of this section */
|
||||||
|
. = ALIGN(4);
|
||||||
|
KEEP(*(.isr_vector)) /* Startup code */
|
||||||
|
*(.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 */
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
__bss_end__ = _ebss;
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
PROVIDE ( end = _ebss );
|
||||||
|
PROVIDE ( _end = _ebss );
|
||||||
|
|
||||||
|
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||||
|
._user_heap_stack :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
. = . + _Min_Heap_Size;
|
||||||
|
. = . + _Min_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
|
||||||
|
|
||||||
|
/* Remove information from the standard libraries */
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
libc.a ( * )
|
||||||
|
libm.a ( * )
|
||||||
|
libgcc.a ( * )
|
||||||
|
}
|
||||||
|
|
||||||
|
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
*****************************************************************************
|
||||||
|
**
|
||||||
|
** File : stm32_flashboot.ld
|
||||||
|
**
|
||||||
|
** Abstract : Linker script for STM32F205 Device with
|
||||||
|
** 0.5MByte FLASH, 128KByte SRAM
|
||||||
|
**
|
||||||
|
** 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 = 0x20020000; /* end of 128K SRAM */
|
||||||
|
|
||||||
|
/* Generate a link error if heap and stack don't fit into RAM */
|
||||||
|
_Min_Heap_Size = 0; /* required amount of heap */
|
||||||
|
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||||
|
|
||||||
|
/* Specify the memory areas */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||||
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||||
|
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
*(.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 */
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
|
||||||
|
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM
|
||||||
|
.ARM : {
|
||||||
|
__exidx_start = .;
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
__exidx_end = .;
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
.preinit_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP (*(.preinit_array*))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
} >RAM
|
||||||
|
.init_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP (*(SORT(.init_array.*)))
|
||||||
|
KEEP (*(.init_array*))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
} >RAM
|
||||||
|
.fini_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP (*(.fini_array*))
|
||||||
|
KEEP (*(SORT(.fini_array.*)))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
__bss_end__ = _ebss;
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
PROVIDE ( end = _ebss );
|
||||||
|
PROVIDE ( _end = _ebss );
|
||||||
|
|
||||||
|
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||||
|
._user_heap_stack :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
. = . + _Min_Heap_Size;
|
||||||
|
. = . + _Min_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
|
||||||
|
|
||||||
|
/* Remove information from the standard libraries */
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
libc.a ( * )
|
||||||
|
libm.a ( * )
|
||||||
|
libgcc.a ( * )
|
||||||
|
}
|
||||||
|
|
||||||
|
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||||
|
}
|
||||||
Executable
+61
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Authors (alphabetical order)
|
||||||
|
* - Andre Bernet <bernet.andre@gmail.com>
|
||||||
|
* - Andreas Weitl
|
||||||
|
* - Bertrand Songis <bsongis@gmail.com>
|
||||||
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||||
|
* - Cameron Weeks <th9xer@gmail.com>
|
||||||
|
* - Erez Raviv
|
||||||
|
* - Gabriel Birkus
|
||||||
|
* - Jean-Pierre Parisy
|
||||||
|
* - Karl Szmutny
|
||||||
|
* - Michael Blandford
|
||||||
|
* - Michal Hlavinka
|
||||||
|
* - Pat Mackenzie
|
||||||
|
* - Philip Moss
|
||||||
|
* - Rob Thomson
|
||||||
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||||
|
* - 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "board_taranis.h"
|
||||||
|
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
|
||||||
|
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h"
|
||||||
|
|
||||||
|
int usbPlugged(void)
|
||||||
|
{
|
||||||
|
return GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||||
|
|
||||||
|
void OTG_FS_IRQHandler(void)
|
||||||
|
{
|
||||||
|
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void usbInit()
|
||||||
|
{
|
||||||
|
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void usbStart()
|
||||||
|
{
|
||||||
|
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
|
||||||
|
}
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "../opentx.h"
|
#include "../../opentx.h"
|
||||||
#include "../FatFs/diskio.h"
|
#include "../../FatFs/diskio.h"
|
||||||
#include "board_taranis.h"
|
#include "board_taranis.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -35,8 +35,6 @@ extern "C" {
|
|||||||
#include "usbd_msc_mem.h"
|
#include "usbd_msc_mem.h"
|
||||||
#include "usb_conf.h"
|
#include "usb_conf.h"
|
||||||
|
|
||||||
void eeprom_read_block (void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
|
||||||
|
|
||||||
#define STORAGE_LUN_NBR 2
|
#define STORAGE_LUN_NBR 2
|
||||||
#define BLOCKSIZE 512
|
#define BLOCKSIZE 512
|
||||||
|
|
||||||
@@ -205,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "../opentx.h"
|
#include "../../opentx.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "usbd_usr.h"
|
#include "usbd_usr.h"
|
||||||
@@ -119,7 +119,9 @@ void USBD_USR_DeviceConnected (void)
|
|||||||
*/
|
*/
|
||||||
void USBD_USR_DeviceDisconnected (void)
|
void USBD_USR_DeviceDisconnected (void)
|
||||||
{
|
{
|
||||||
|
#if !defined(BOOT)
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-125
@@ -114,9 +114,9 @@ const pm_char STR_OPEN9X[] PROGMEM =
|
|||||||
ISTR(VTRAINERMODES)
|
ISTR(VTRAINERMODES)
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAVLINK)
|
#if defined(MAVLINK)
|
||||||
ISTR(MAVLINK_BAUDS)
|
ISTR(MAVLINK_BAUDS)
|
||||||
ISTR(MAVLINK_AC_MODES)
|
ISTR(MAVLINK_AC_MODES)
|
||||||
ISTR(MAVLINK_AP_MODES)
|
ISTR(MAVLINK_AP_MODES)
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -578,126 +578,4 @@ const pm_char STR_VIEW_TEXT[] PROGMEM = "View text";
|
|||||||
const pm_char STR_ABOUT_PARENTS_4[] PROGMEM = TR_ABOUT_PARENTS_4;
|
const pm_char STR_ABOUT_PARENTS_4[] PROGMEM = TR_ABOUT_PARENTS_4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const pm_uchar font_5x7[] PROGMEM = {
|
|
||||||
#if defined (CPUARM)
|
|
||||||
#include "font_05x07.lbm"
|
|
||||||
#else
|
|
||||||
#include "font_05x07_avr.lbm"
|
|
||||||
#endif
|
|
||||||
#if defined(TRANSLATIONS_DE)
|
|
||||||
#include "font_de_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_CZ)
|
|
||||||
#include "font_cz_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_ES)
|
|
||||||
#include "font_es_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FI)
|
|
||||||
#include "font_fi_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FR)
|
|
||||||
#include "font_fr_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_IT)
|
|
||||||
#include "font_it_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PL)
|
|
||||||
#include "font_pl_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PT)
|
|
||||||
#include "font_pt_05x07.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_SE)
|
|
||||||
#include "font_se_05x07.lbm"
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined(CPUM64) || defined(EXTSTD)
|
|
||||||
const pm_uchar font_5x7_B[] PROGMEM = {
|
|
||||||
#include "font_05x07_B_compressed.lbm"
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const pm_uchar font_10x14[] PROGMEM = {
|
|
||||||
#include "font_10x14_compressed.lbm"
|
|
||||||
#if defined(CPUARM)
|
|
||||||
#if defined(TRANSLATIONS_DE)
|
|
||||||
#include "font_de_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_CZ)
|
|
||||||
#include "font_cz_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_ES)
|
|
||||||
#include "font_es_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FI)
|
|
||||||
#include "font_fi_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FR)
|
|
||||||
#include "font_fr_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_IT)
|
|
||||||
#include "font_it_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PL)
|
|
||||||
#include "font_pl_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PT)
|
|
||||||
#include "font_pt_10x14.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_SE)
|
|
||||||
#include "font_se_10x14.lbm"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(CPUARM)
|
|
||||||
const pm_uchar font_3x5[] PROGMEM = {
|
|
||||||
#include "font_03x05.lbm"
|
|
||||||
};
|
|
||||||
|
|
||||||
const pm_uchar font_4x6[] PROGMEM = {
|
|
||||||
#include "font_04x06.lbm"
|
|
||||||
#if defined(TRANSLATIONS_DE)
|
|
||||||
#include "font_de_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_CZ)
|
|
||||||
#include "font_cz_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_ES)
|
|
||||||
#include "font_es_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FI)
|
|
||||||
#include "font_fi_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FR)
|
|
||||||
#include "font_fr_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_IT)
|
|
||||||
#include "font_it_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PL)
|
|
||||||
#include "font_pl_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PT)
|
|
||||||
#include "font_pt_04x06.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_SE)
|
|
||||||
#include "font_se_04x06.lbm"
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
const pm_uchar font_8x10[] PROGMEM = {
|
|
||||||
#include "font_08x10.lbm"
|
|
||||||
#if defined(TRANSLATIONS_DE)
|
|
||||||
#include "font_de_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_CZ)
|
|
||||||
#include "font_cz_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_ES)
|
|
||||||
#include "font_es_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FI)
|
|
||||||
#include "font_fi_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_FR)
|
|
||||||
#include "font_fr_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_IT)
|
|
||||||
#include "font_it_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PL)
|
|
||||||
#include "font_pl_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_PT)
|
|
||||||
#include "font_pt_08x10.lbm"
|
|
||||||
#elif defined(TRANSLATIONS_SE)
|
|
||||||
#include "font_se_08x10.lbm"
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
const pm_uchar font_4x6_extra[] PROGMEM = {
|
|
||||||
#include "font_04x06_extra.lbm"
|
|
||||||
};
|
|
||||||
|
|
||||||
const pm_uchar font_5x7_extra[] PROGMEM = {
|
|
||||||
#include "font_05x07_extra.lbm"
|
|
||||||
};
|
|
||||||
|
|
||||||
const pm_uchar font_10x14_extra[] PROGMEM = {
|
|
||||||
#include "font_10x14_extra.lbm"
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,9 +73,9 @@
|
|||||||
#define EOFS(x) ( OFS_##x + sizeof(TR_##x) )
|
#define EOFS(x) ( OFS_##x + sizeof(TR_##x) )
|
||||||
|
|
||||||
#if LCD_W >= 212
|
#if LCD_W >= 212
|
||||||
#define TR(x,y) y
|
#define TR(x, y) y
|
||||||
#else
|
#else
|
||||||
#define TR(x,y) x
|
#define TR(x, y) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The non-0-terminated-strings
|
// The non-0-terminated-strings
|
||||||
@@ -547,21 +547,6 @@ extern const pm_char STR_RESET_BTN[];
|
|||||||
#define STR_UPDATE_LIST STR_DELAYDOWN
|
#define STR_UPDATE_LIST STR_DELAYDOWN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const pm_uchar font_5x7[];
|
|
||||||
extern const pm_uchar font_10x14[];
|
|
||||||
#if !defined(CPUM64) || defined(EXTSTD)
|
|
||||||
extern const pm_uchar font_5x7_B[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CPUARM)
|
|
||||||
extern const pm_uchar font_3x5[];
|
|
||||||
extern const pm_uchar font_4x6[];
|
|
||||||
extern const pm_uchar font_8x10[];
|
|
||||||
extern const pm_uchar font_5x7_extra[];
|
|
||||||
extern const pm_uchar font_10x14_extra[];
|
|
||||||
extern const pm_uchar font_4x6_extra[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern const pm_char STR_WARNING[];
|
extern const pm_char STR_WARNING[];
|
||||||
extern const pm_char STR_EEPROMWARN[];
|
extern const pm_char STR_EEPROMWARN[];
|
||||||
extern const pm_char STR_THROTTLEWARN[];
|
extern const pm_char STR_THROTTLEWARN[];
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
fileout = sys.argv[2]
|
||||||
|
|
||||||
|
fr = open(filename, "rb")
|
||||||
|
fw = open(fileout, "w")
|
||||||
|
|
||||||
|
st = fr.read(16)
|
||||||
|
|
||||||
|
while st:
|
||||||
|
for b in st:
|
||||||
|
fw.write("0x%02x," % ord(b))
|
||||||
|
fw.write("\n")
|
||||||
|
st = fr.read(16)
|
||||||
|
|
||||||
|
fw.write("\n")
|
||||||
|
fw.close()
|
||||||
Reference in New Issue
Block a user