Merge remote-tracking branch 'origin/next' into bsongis/9XR-PRO_port

Conflicts:
	companion/src/eeprominterface.cpp
	companion/src/eeprominterface.h
	companion/src/firmwares/opentx/opentxeeprom.cpp
	companion/src/firmwares/opentx/opentxinterface.cpp
	companion/src/firmwares/opentx/opentxinterface.h
	companion/src/mdichild.cpp
	radio/src/Makefile
This commit is contained in:
bsongis
2014-05-11 22:48:48 +02:00
477 changed files with 116230 additions and 71400 deletions
+5 -1
View File
@@ -6,7 +6,6 @@
/snapshot_*.png
/*.sh
/*.bat
/*.o
/*.bin
/*.bin.*
/*.hex
@@ -16,3 +15,8 @@
/SOUNDS
/LOGS
/allsrc.cpp
/BMP
/traces
/MODELS
/FIRMWARES
/EEPROMS
+13 -3
View File
@@ -28,14 +28,20 @@ extern "C" {
/ object instead of the sector buffer in the individual file object for file
/ 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 */
#endif
/* 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,
/ f_truncate and useless f_getfree. */
#if defined(BOOT)
#define _FS_MINIMIZE 1 /* 0 to 3 */
#else
#define _FS_MINIMIZE 0 /* 0 to 3 */
#endif
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
/
/ 0: Full function.
@@ -45,7 +51,11 @@ extern "C" {
/ 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 */
#endif
/* 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
/ 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 _SYNC_t unsigned char /*OS_MutexID*/ /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
#else
+65 -28
View File
@@ -97,10 +97,9 @@ NAVIGATION = NO
# Values = YES, NO
AUTOSWITCH = NO
# Swap Stick Inputs for AIL,ELE,RUD,THR
# Used in some scenarios where stick/pot entries
# cannot be changed by soldering the pots.
# Stock sticks replaced by FrSky ones
# Values = YES, NO
FRSKY_STICKS = NO
# Sources automatic selection
# Values = YES, NO
@@ -126,6 +125,13 @@ CORRECT_NEGATIVE_VALUES = YES
# Values = YES, NO
ARITHMETIC_OVERFLOW_CHECK = NO
# increases resolution for throttle statistics and throttle counting, in very rare cases.
# this will be only true if an output channel is used for throttle calculation, and this chanenel has changed limits, e.g. -90% to +80%
# if you use standard limits for throttle or directly the throttle stick you do not need to bother about this option
# not valid for ARM based transmitters like Taranis, They do not have this rounding issue at all
# Values = YES, NO
ACCURAT_THROTTLE_STATS = NO
# HAPTIC Mods
# Values = YES, NO
HAPTIC = NO
@@ -264,15 +270,16 @@ LUA = NO
# Menu Lock modes
# Values = NO, READONLY, NOMENUS
MENUS_LOCK == NO
MENUS_LOCK = NO
#------- END BUILD OPTIONS ---------------------------
# Define programs and commands.
SHELL = sh
IMG2LBM = -python ../util/img2lbm.py
BIN2LBM = -python ../util/bin2lbm.py
TRANSLATE = -python ../util/translate.py
VERSION = 2.0
VERSION = 1.99
SRC =
CPPSRC =
@@ -281,7 +288,7 @@ EXTRAINCDIRS =
# MCU name
ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X 9XRPRO TARANIS))
$(error Sorry, the PCB $(PCB) is not supported yet in openTx)
$(error Sorry, the PCB $(PCB) is not supported yet in OpenTX)
endif
GVARS_VARIANT = +1
@@ -616,10 +623,13 @@ ifeq ($(PCB), TARANIS)
CPPDEFS = -DREV3
else ifeq ($(PCBREV), REV4a)
CPPDEFS = -DREV4a
else ifeq ($(PCBREV), REVPLUS)
CPPDEFS = -DREVPLUS
HAPTIC = YES
else
CPPDEFS = -DREV4
endif
LDSCRIPT = targets/taranis/stm32_flash.ld
LDSCRIPT = targets/taranis/stm32_flash_bl.ld
TRGT = arm-none-eabi-
MCU = cortex-m3
OPT = 2
@@ -627,19 +637,26 @@ ifeq ($(PCB), TARANIS)
SDCARD = YES
THR_TRACE = YES
EXT = FRSKY
AUTOSWITCH = YES
AUTOSOURCE = YES
DBLKEYS = YES
PPM_LIMITS_SYMETRICAL = YES
PPM_CENTER_ADJUSTABLE = YES
DSM2 = PPM
CPPDEFS += -DPCBTARANIS -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DPXX
INCDIRS += targets/taranis CoOS/kernel CoOS/portable
EXTRAINCDIRS += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/include
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
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/flash_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 += targets/taranis/pwr_driver.c targets/taranis/usb_driver.c
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp
PULSESSRC = protocols/pulses_arm.cpp protocols/ppm_arm.cpp protocols/pxx_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 += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.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 loadboot.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/STM32F2xx_StdPeriph_Driver/src/misc.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
@@ -651,18 +668,14 @@ ifeq ($(PCB), TARANIS)
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_usart.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
SRC += targets/taranis/usb_bsp.c targets/taranis/usbd_desc.c
SRC += targets/taranis/usb_bsp.c targets/taranis/usbd_desc.c targets/taranis/usbd_hid_joystick.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_core.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd_int.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
EXTRABOARDSRC += targets/taranis/usbd_usr.cpp targets/taranis/usbd_storage_msd.cpp
EXTRABOARDSRC += targets/taranis/usbd_usr.cpp
SRC += targets/sky9x/syscalls.c
ifneq ($(LUA), NO)
@@ -703,6 +716,13 @@ ifeq ($(PCB), TARANIS)
CPPSRC += protocols/hubsan.cpp
CPPSRC += targets/taranis/a7105_driver.cpp
endif
ifeq ($(HAPTIC), YES)
CPPDEFS += -DHAPTIC
CPPSRC += haptic.cpp
CPPSRC += targets/taranis/haptic_driver.cpp
endif
endif
CC = $(TRGT)gcc
@@ -734,7 +754,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")
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.
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
@@ -791,8 +811,8 @@ ifeq ($(AUTOSOURCE), YES)
CPPDEFS += -DAUTOSOURCE
endif
ifeq ($(TARANIS_STICKS), YES)
CPPDEFS += -DTARANIS_STICKS
ifeq ($(FRSKY_STICKS), YES)
CPPDEFS += -DFRSKY_STICKS
endif
@@ -864,6 +884,9 @@ ifeq ($(ARITHMETIC_OVERFLOW_CHECK), YES)
CPPDEFS += -DPREVENT_ARITHMETIC_OVERFLOW
endif
ifeq ($(ACCURAT_THROTTLE_STATS), YES)
CPPDEFS += -DACCURAT_THROTTLE_TIMER
endif
# EXTENSIONS (for Telemetry protocols)
ifneq ($(EXT), $(filter $(EXT), STD FRSKY ARDUPILOT NMEA JETI MAVLINK TELEMETREZ))
@@ -946,7 +969,7 @@ endif
ifeq ($(SDCARD), YES)
CPPDEFS += -DSDCARD
CPPSRC += logs.cpp
CPPSRC += logs.cpp strhelpers.cpp
endif
RUN_FROM_FLASH = 1
@@ -985,8 +1008,10 @@ ifeq ($(HELI), YES)
endif
ifeq ($(TEMPLATES), YES)
CPPDEFS += -DTEMPLATES
CPPSRC += templates.cpp
ifneq ($(PCB), TARANIS)
CPPDEFS += -DTEMPLATES
CPPSRC += templates.cpp
endif
endif
ifeq ($(PXX), YES)
@@ -1062,7 +1087,7 @@ MSG_CLEANING = Cleaning project:
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ARMCPPFLAGS = -c -mcpu=$(MCU) -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O$(OPT) $(CPPFLAGS) $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS)
ARMCPPFLAGS = -c -mcpu=$(MCU) -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O$(OPT) $(CPPFLAGS) -fdata-sections -ffunction-sections $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS)
AVRCPPFLAGS = -mmcu=$(MCU) -I. -x c++ -O$(OPT) $(CPPFLAGS) $(INCFLAGS) $(EXTRAINCFLAGS) $(GENDEPFLAGS) -fwhole-program
ifeq ($(ARCH), AVR)
@@ -1088,10 +1113,21 @@ all: begin gccversion sizebefore build sizeafter end
# Change the build target to build a HEX file or a library.
ifeq ($(ARCH), AVR)
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
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
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
lbm: fonts bitmaps/sticks.lbm
@@ -1243,7 +1279,7 @@ sizeafter:
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); fi
# Display compiler version information.
gccversion :
gccversion:
@$(CC) --version
FOXINC=-I/usr/local/include/fox-1.6 -I/usr/include/fox-1.6 \
@@ -1283,8 +1319,7 @@ endif
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@@ -1323,7 +1358,7 @@ OBJS = $(TMP:.s=.o)
@echo
@echo $(MSG_COMPILING) $@
$(CC) $(ARMCPPFLAGS) $< -o allsrc.o
$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@
$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections -o $@
endif
# Target: clean project.
@@ -1350,6 +1385,8 @@ clean_list :
$(REMOVE) *.lst
$(REMOVE) allsrc.cpp
$(REMOVE) stamp-opentx.h
$(REMOVE) `find . -name "*.lbm"`
$(MAKE) -C bootloader clean
#### Install
+11 -21
View File
@@ -274,7 +274,7 @@ void referenceSystemAudioFiles()
for (int i=0; i<AU_FRSKY_FIRST; i++) {
getSystemAudioFile(path, i);
if (!strcmp(filename, fn)) {
if (!strcasecmp(filename, fn)) {
availableAudioFiles |= MASK_SYSTEM_AUDIO_FILE(i);
break;
}
@@ -324,7 +324,7 @@ void getSwitchAudioFile(char * filename, int index)
str += 5;
}
else {
str += 1;
*(str+1) = 0;
}
strcat(str, SOUNDS_EXT);
}
@@ -333,7 +333,7 @@ void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
{
char * str = getModelPath(filename);
int len = STR_VSWITCHES[0];
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_CSW-1)], len);
strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH-1)], len);
str += len;
strcpy(str, suffixes[event]);
strcat(str, SOUNDS_EXT);
@@ -369,10 +369,10 @@ void referenceModelAudioFiles()
if (len < 5 || strcasecmp(fn+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
// Phases Audio Files <phasename>-[on|off].wav
for (int i=0; i<MAX_PHASES && !found; i++) {
for (int i=0; i<MAX_FLIGHT_MODES && !found; i++) {
for (int event=0; event<2; event++) {
getPhaseAudioFile(path, i, event);
if (!strcmp(filename, fn)) {
if (!strcasecmp(filename, fn)) {
sdAvailablePhaseAudioFiles |= MASK_PHASE_AUDIO_FILE(i, event);
found = true;
break;
@@ -383,17 +383,17 @@ void referenceModelAudioFiles()
// Switches Audio Files <switchname>-[up|mid|down].wav
for (int i=0; i<SWSRC_LAST_SWITCH+NUM_XPOTS*XPOTS_MULTIPOS_COUNT && !found; i++) {
getSwitchAudioFile(path, i);
if (!strcmp(filename, fn)) {
if (!strcasecmp(filename, fn)) {
sdAvailableSwitchAudioFiles |= MASK_SWITCH_AUDIO_FILE(i);
found = true;
}
}
// Logical Switches Audio Files <switchname>-[on|off].wav
for (int i=0; i<NUM_CSW && !found; i++) {
for (int i=0; i<NUM_LOGICAL_SWITCH && !found; i++) {
for (int event=0; event<2; event++) {
getLogicalSwitchAudioFile(path, i, event);
if (!strcmp(filename, fn)) {
if (!strcasecmp(filename, fn)) {
sdAvailableLogicalSwitchAudioFiles |= MASK_LOGICAL_SWITCH_AUDIO_FILE(i, event);
found = true;
break;
@@ -788,7 +788,7 @@ void AudioQueue::pause(uint16_t len)
bool AudioQueue::isPlaying(uint8_t id)
{
if (normalContext.fragment.id == id || backgroundContext.fragment.id == id)
if (normalContext.fragment.id == id || (isFunctionActive(FUNCTION_BACKGND_MUSIC) && backgroundContext.fragment.id == id))
return true;
uint8_t i = ridx;
@@ -879,16 +879,6 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
strcpy(fragment.file, filename);
fragment.id = id;
}
else if (flags & PLAY_NOW) {
AudioFragment & fragment = priorityContext.fragment;
if (fragment.type == FRAGMENT_EMPTY) {
priorityContext.clear();
fragment.type = FRAGMENT_FILE;
strcpy(fragment.file, filename);
fragment.repeat = flags & 0x0f;
fragment.id = id;
}
}
else {
uint8_t next_widx = (widx + 1) % AUDIO_QUEUE_LENGTH;
if (next_widx != ridx) {
@@ -922,13 +912,13 @@ void AudioQueue::stopPlay(uint8_t id)
void AudioQueue::stopSD()
{
sdAvailableSystemAudioFiles = 0;
reset();
stopAll();
playTone(0, 0, 100, PLAY_NOW); // insert a 100ms pause
}
#endif
void AudioQueue::reset()
void AudioQueue::stopAll()
{
CoEnterMutexSection(audioMutex);
widx = ridx; // clean the queue
+8 -5
View File
@@ -161,6 +161,8 @@ class AudioQueue {
void stopPlay(uint8_t id);
void stopAll();
void pause(uint16_t tLen);
void stopSD();
@@ -177,8 +179,6 @@ class AudioQueue {
return ridx == widx;
}
void reset();
inline AudioBuffer * getNextFilledBuffer()
{
if (buffers[bufferRIdx].state == AUDIO_BUFFER_PLAYING) {
@@ -251,7 +251,7 @@ void audioStart();
#if defined(VOICE)
#define AUDIO_ERROR_MESSAGE(e) audioEvent(e)
#define AUDIO_TIMER_MINUTE(t) playDuration(t, 0)
#define AUDIO_TIMER_MINUTE(t) playDuration(t, 0, 0)
#else
#define AUDIO_ERROR_MESSAGE(e) audioEvent(AU_ERROR)
#define AUDIO_TIMER_MINUTE(t) audioDefevent(AU_WARNING1)
@@ -317,12 +317,15 @@ void pushPrompt(uint16_t prompt, uint8_t id=0);
#define PLAY_FUNCTION(x, ...) void x(__VA_ARGS__, uint8_t id)
#define PUSH_NUMBER_PROMPT(p) pushPrompt((p), id)
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a), id)
#define PLAY_DURATION(d) playDuration((d), id)
#define PLAY_DURATION(d, att) playDuration((d), (att), id)
#define PLAY_DURATION_ATT , uint8_t flags
#define PLAY_TIME 1
#define IS_PLAY_TIME() (flags&PLAY_TIME)
#define IS_PLAYING(id) audioQueue.isPlaying((id))
#define PLAY_VALUE(v, id) playValue((v), (id))
#define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id))
#define STOP_PLAY(id) audioQueue.stopPlay((id))
#define AUDIO_RESET() audioQueue.reset()
#define AUDIO_RESET() audioQueue.stopAll()
#if defined(SDCARD)
extern tmr10ms_t timeAutomaticPromptsSilence;
+346
View File
@@ -0,0 +1,346 @@
#
# !!!! 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 ifeq ($(PCBREV), REVPLUS)
CPPDEFS += -DREVPLUS
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/flash_driver.cpp \
../targets/taranis/diskio.cpp \
../targets/taranis/usbd_usr.cpp \
../targets/taranis/usbd_storage_msd.cpp \
../lcd.cpp \
../keys.cpp \
../fonts.cpp \
../strhelpers.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 ***
+803
View File
@@ -0,0 +1,803 @@
/****************************************************************************
* 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>
#include "board_taranis.h"
#include "../eeprom_rlc.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 " Taranis BootLoader - v1.0"
#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 "Sky9x Boot Loader - v1.0"
#endif
const uint8_t bootloaderVersion[] __attribute__ ((section(".version"), used)) =
{
'B', 'O', 'O', 'T', '1', '0'
};
// 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_RESTORE_MENU,
ST_USB,
ST_REBOOT,
};
enum MemoryTypes {
MEM_FLASH,
MEM_EEPROM
};
#define BLOCK_LEN 4096
/*----------------------------------------------------------------------------
* Local variables
*----------------------------------------------------------------------------*/
uint32_t FirmwareSize;
uint32_t firmwareAddress = FIRMWARE_ADDRESS;
uint32_t firmwareWritten = 0;
uint32_t eepromAddress = 0;
uint32_t eepromWritten = 0;
TCHAR backupFilename[60];
uint32_t Master_frequency;
volatile uint8_t Tenms;
uint8_t EE_timer;
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 LockBits;
uint32_t Block_buffer[1024];
UINT BlockCount;
uint32_t memoryType;
uint32_t unlocked = 0;
#if defined(PCBSKY9X)
extern int32_t EblockAddress;
#endif
extern uint32_t EepromBlocked;
extern void init_spi(void);
extern void writeBlock(void);
extern void usbPluggedIn();
/*----------------------------------------------------------------------------
* 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
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
}
}
#endif
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) {
strAppend(fno->lfname, 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;
}
const char *getBinaryPath()
{
if (memoryType == MEM_FLASH)
return FIRMWARES_PATH;
else
return EEPROMS_PATH;
}
FRESULT openBinaryFile(uint32_t index)
{
TCHAR filename[60];
FRESULT fr;
memset(Block_buffer, 0, sizeof(Block_buffer));
strAppend(strAppend(strAppend(filename, getBinaryPath()), "/"), Filenames[index]);
if ((fr = f_open(&FlashFile, filename, FA_READ)) != FR_OK) {
return fr;
}
if (memoryType == MEM_FLASH) {
if ((fr = f_lseek(&FlashFile, BOOTLOADER_SIZE)) != FR_OK) {
return fr;
}
}
fr = f_read(&FlashFile, (BYTE *)Block_buffer, BLOCK_LEN, &BlockCount);
if (BlockCount == BLOCK_LEN)
return fr;
else
return FR_INVALID_OBJECT;
}
uint32_t isValidBufferStart(const void * buffer)
{
if (memoryType == MEM_FLASH)
return isFirmwareStart(buffer);
else
return isEepromStart(buffer);
}
int menuFlashFile(uint32_t index, uint8_t event)
{
FRESULT fr;
lcd_putsLeft(4*FH, "\012Hold [ENT] to start writing");
if (Valid == 0) {
// Validate file here
if ((fr = openBinaryFile(index))) {
Valid = 2;
}
else {
if ((fr = f_close(&FlashFile))) {
Valid = 2;
}
else {
Valid = 1;
}
if (!isValidBufferStart(Block_buffer)) {
Valid = 2;
}
}
}
if (Valid == 2) {
if (memoryType == MEM_FLASH)
lcd_putsLeft(4*FH, "\011Not a valid firmware file! ");
else
lcd_putsLeft(4*FH, "\011Not a valid EEPROM file! ");
if (event == EVT_KEY_BREAK(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
return 0;
}
return -1;
}
if (event == EVT_KEY_LONG(BOOT_KEY_MENU)) {
fr = openBinaryFile(index);
return (fr == FR_OK && isValidBufferStart(Block_buffer));
}
else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
return 0;
}
return -1;
}
extern Key keys[];
static uint32_t PowerUpDelay;
void writeFlashBlock()
{
uint32_t blockOffset = 0;
while (BlockCount) {
writeFlash((uint32_t *)firmwareAddress, &Block_buffer[blockOffset]);
blockOffset += FLASH_PAGESIZE/4; // 32-bit words
firmwareAddress += FLASH_PAGESIZE;
if (BlockCount > FLASH_PAGESIZE) {
BlockCount -= FLASH_PAGESIZE;
}
else {
BlockCount = 0;
}
}
}
void writeEepromBlock()
{
eeWriteBlockCmp((uint8_t *)Block_buffer, eepromAddress, BlockCount);
eepromAddress += BlockCount;
}
int main()
{
uint8_t index = 0;
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;
#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_invert_line(0);
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)
LockBits = readLockBits();
if (LockBits) {
clearLockBits();
}
#endif
#if defined(PCBTARANIS)
// SD card detect pin
sdInit();
usbInit();
usbStart();
#endif
for (;;) {
wdt_reset();
if (Tenms) {
if (EE_timer) {
if (--EE_timer == 0) {
#if defined(PCBSKY9X)
writeBlock();
#endif
}
}
Tenms = 0;
lcd_clear();
lcd_putsLeft(0, BOOTLOADER_TITLE);
lcd_invert_line(0);
uint8_t event = getEvent();
if (state != ST_USB) {
if (usbPlugged()) {
state = ST_USB;
if (!unlocked) {
unlocked = 1;
unlockFlash();
}
usbPluggedIn();
}
}
if (state == ST_START) {
lcd_putsLeft(2*FH, "\010Write Firmware");
lcd_putsLeft(3*FH, "\010Restore EEPROM");
lcd_putsLeft(4*FH, "\010Exit");
lcd_invert_line(2+vpos);
lcd_putsLeft(7*FH, INDENT "Or plug in a USB cable for mass storage");
if (event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
vpos == 2 ? vpos = 0 : vpos = vpos+1;
}
else if (event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
vpos == 0 ? vpos = 2 : vpos = vpos-1;
}
else if (event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
switch (vpos) {
case 0:
state = ST_FLASH_MENU;
break;
case 1:
state = ST_RESTORE_MENU;
break;
default:
state = ST_REBOOT;
}
}
}
if (state == ST_USB) {
lcd_putsLeft(4*FH, "\026USB Connected");
if (usbPlugged() == 0) {
vpos = 0;
if (unlocked) {
lockFlash();
unlocked = 0;
}
state = ST_START;
}
#if defined(PCBSKY9X)
usbMassStorage();
#endif
}
if (state == ST_FLASH_MENU || state == ST_RESTORE_MENU) {
sdInit();
memoryType = (state == ST_RESTORE_MENU ? MEM_EEPROM : MEM_FLASH);
state = ST_DIR_CHECK;
}
else if (state == ST_DIR_CHECK) {
fr = f_chdir(getBinaryPath());
if (fr == FR_OK) {
state = ST_OPEN_DIR;
}
else {
lcd_putsLeft(2*FH, INDENT "Directory is missing!");
if (event == EVT_KEY_BREAK(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(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_BREAK(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;
eepromAddress = 0;
eepromWritten = 0;
state = ST_FLASHING;
}
}
else if (state == ST_FLASHING) {
// commit to flashing
lcd_putsLeft(4*FH, "\032Writing...");
if (!unlocked && (memoryType == MEM_FLASH)) {
unlocked = 1;
unlockFlash();
}
int progress;
if (memoryType == MEM_FLASH) {
writeFlashBlock();
firmwareWritten += sizeof(Block_buffer);
progress = (200*firmwareWritten) / FirmwareSize;
}
else {
writeEepromBlock();
eepromWritten += sizeof(Block_buffer);
progress = (200*eepromWritten) / EESIZE;
}
lcd_rect( 3, 6*FH+4, 204, 7);
lcd_hline(5, 6*FH+6, progress, FORCE);
lcd_hline(5, 6*FH+7, progress, FORCE);
lcd_hline(5, 6*FH+8, progress, FORCE);
fr = f_read(&FlashFile, (BYTE *)Block_buffer, sizeof(Block_buffer), &BlockCount);
if (BlockCount == 0) {
state = ST_FLASH_DONE; // EOF
}
if (firmwareWritten >= FLASHSIZE - BOOTLOADER_SIZE) {
state = ST_FLASH_DONE; // Backstop
}
if (eepromWritten >= EESIZE) {
state = ST_FLASH_DONE; // Backstop
}
}
if (state == ST_FLASH_DONE) {
if (unlocked) {
lockFlash();
unlocked = 0;
}
lcd_putsLeft(4*FH, "\024Writing Complete");
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
state = ST_START;
vpos = 0;
}
}
if (event == EVT_KEY_LONG(BOOT_KEY_EXIT)) {
state = ST_REBOOT;
}
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;
}
+4 -2
View File
@@ -51,12 +51,14 @@
#define TRACE_WARNING(...) do { printf("-W- " __VA_ARGS__); fflush(stdout); } while(0)
#define TRACE_WARNING_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
#define TRACE_ERROR(...) do { printf("-E- " __VA_ARGS__); fflush(stdout); } while(0)
inline void dump(unsigned char *data, unsigned int size)
inline void dump(void * data, unsigned int size)
{
unsigned char *uchar_data = (unsigned char *)data;
printf("DUMP %d bytes ...\n\r", size);
unsigned int i = 0, j=0;
while (i*32+j < size) {
printf("%.2X ", data[i*32+j]);
printf("%.2X ", uchar_data[i*32+j]);
j++;
if (j==32) {
i++; j=0;
+1
View File
@@ -56,6 +56,7 @@ bool eeModelExists(uint8_t id);
void eeLoadModelName(uint8_t id, char *name);
void eeLoadModel(uint8_t id);
bool eeConvert();
void ConvertModel(int id, int version);
#if defined(CPUARM)
extern ModelHeader modelHeaders[MAX_MODELS];
+225 -110
View File
@@ -36,6 +36,7 @@
#include "opentx.h"
#if defined(PCBTARANIS)
PACK(typedef struct {
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn;
@@ -47,6 +48,18 @@ PACK(typedef struct {
uint8_t spare[2];
int8_t curveParam;
}) ExpoData_v215;
#else
PACK(typedef struct {
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn;
int8_t swtch;
uint16_t phases;
int8_t weight;
uint8_t curveMode;
char name[LEN_EXPOMIX_NAME];
int8_t curveParam;
}) ExpoData_v215;
#endif
#if defined(PCBTARANIS)
#define LIMITDATA_V215_EXTRA char name[LEN_CHANNEL_NAME];
@@ -140,6 +153,7 @@ PACK(typedef struct {
int8_t andsw;
}) LogicalSwitchData_v215;
#if defined(PCBTARANIS)
PACK(typedef struct {
int8_t swtch;
uint8_t func;
@@ -154,6 +168,22 @@ PACK(typedef struct {
uint8_t mode:2;
uint8_t active:6;
}) CustomFnData_v215;
#else
PACK(typedef struct {
int8_t swtch;
uint8_t func;
PACK(union {
char name[6];
struct {
int16_t val;
int16_t ext1;
int16_t ext2;
} composite;
}) param;
uint8_t mode:2;
uint8_t active:6;
}) CustomFnData_v215;
#endif
PACK(typedef struct {
FrSkyChannelData channels[2];
@@ -192,10 +222,10 @@ PACK(typedef struct {
int16_t curves[16];
int8_t points[NUM_POINTS];
LogicalSwitchData_v215 customSw[NUM_CSW];
LogicalSwitchData_v215 customSw[NUM_LOGICAL_SWITCH];
CustomFnData_v215 funcSw[32];
SwashRingData swashR;
PhaseData_v215 phaseData[MAX_PHASES];
PhaseData_v215 phaseData[MAX_FLIGHT_MODES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5ms increments
uint8_t thrTraceSrc;
@@ -302,6 +332,9 @@ void ConvertGeneralSettings_215_to_216(EEGeneral &settings)
int ConvertTelemetrySource_215_to_216(int source)
{
// TELEM_TX_TIME and 5 spare added
if (source >= TELEM_TX_TIME)
source += 6;
// TELEM_RSSI_TX added
if (source >= TELEM_RSSI_TX)
source += 1;
@@ -312,14 +345,14 @@ int ConvertTelemetrySource_215_to_216(int source)
if (source >= TELEM_A3)
source += 2;
// ASpd and dTE added + 5 reserve
if (source >= TELEM_ASPD)
if (source >= TELEM_ASPEED)
source += 7;
// A3 and A4 MIN added
if (source >= TELEM_MIN_A3)
source += 2;
// Cel- Cels- and Vfas- added
if (source >= TELEM_MIN_CELL)
source += 3;
// ASpd+ Cel- Cels- and Vfas- added
if (source >= TELEM_MAX_ASPEED)
source += 4;
// 5 reserve added
if (source >= TELEM_RESERVE6)
source += 5;
@@ -339,7 +372,7 @@ int ConvertSource_215_to_216(int source, bool insertZero=false)
if (source > MIXSRC_POT2)
source += 1;
// PPM9-PPM16 added
if (source > MIXSRC_FIRST_PPM+7)
if (source > MIXSRC_FIRST_TRAINER+7)
source += 8;
// 4 GVARS added
if (source > MIXSRC_GVAR1+4)
@@ -357,14 +390,25 @@ int ConvertSwitch_215_to_216(int swtch)
return -ConvertSwitch_215_to_216(-swtch);
else if (swtch <= SWSRC_LAST_SWITCH)
return swtch;
else
return swtch + (2*4) + (3*6); // 4 trims and 2 * 6-pos added as switches
else if (swtch > SWSRC_LAST_SWITCH + 32 + 1) {
swtch -= (SWSRC_LAST_SWITCH + 32 + 1);
if (swtch > SWSRC_ON)
swtch = 0;
return swtch;
}
else {
swtch += (2*4) + (3*6); // 4 trims and 2 * 6-pos added as switches
return swtch;
}
}
#else
int ConvertSource_215_to_216(int source, bool insertZero=false)
{
if (insertZero)
source += 1;
// PPM9-PPM16 added
if (source > MIXSRC_FIRST_TRAINER+7)
source += 8;
// 4 GVARS added
if (source > MIXSRC_GVAR1+4)
source += 4;
@@ -377,13 +421,31 @@ int ConvertSource_215_to_216(int source, bool insertZero=false)
int ConvertSwitch_215_to_216(int swtch)
{
if (swtch <= SWSRC_LAST_SWITCH)
if (swtch < 0)
return -ConvertSwitch_215_to_216(-swtch);
else if (swtch <= SWSRC_LAST_SWITCH)
return swtch;
else
return swtch + (2*4) + 1; // 4 trims and REa added
else {
swtch += (2*4) + 1; // 4 trims and REa added
if (swtch > SWSRC_ON)
swtch -= (9+32+1);
if (swtch > SWSRC_ON)
swtch = SWSRC_ON;
return swtch;
}
}
#endif
int16_t ConvertGVAR_215_to_216(int16_t var)
{
if (var <= -508)
return var + 512 - 4096;
else if (var >= 507)
return var - 512 + 4096;
else
return var;
}
void ConvertModel_215_to_216(ModelData &model)
{
// Virtual inputs added instead of Expo/DR
@@ -392,7 +454,7 @@ void ConvertModel_215_to_216(ModelData &model)
// Curves: structure changed, 32 curves
// Limits: min and max with PREC1
// Custom Functions: play repeat * 5
// Custom Switches: better precision for x when A comes from telemetry
// Logical Switches: better precision for x when A comes from telemetry
// Main View: altitude in top bar
// Mixes: GVARS in weight moved from 512 to 4096 and -512 to -4096, because GVARS may be used in limits [-1250:1250]
// Switches: two 6-pos pots added, REa added to Sky9x
@@ -427,65 +489,94 @@ void ConvertModel_215_to_216(ModelData &model)
g_model.extendedLimits = oldModel.extendedLimits;
g_model.extendedTrims = oldModel.extendedTrims;
g_model.throttleReversed = oldModel.throttleReversed;
#if defined(PCBTARANIS)
g_model.beepANACenter = (oldModel.beepANACenter & 0x3f) | ((oldModel.beepANACenter & 0xc0) << 1);
#else
g_model.beepANACenter = oldModel.beepANACenter;
#endif
for (uint8_t i=0; i<64; i++) {
MixData & mix = g_model.mixData[i];
MixData * mix = &g_model.mixData[i];
MixData_v215 * oldMix = &oldModel.mixData[i];
#if defined(PCBTARANIS)
mix.destCh = oldModel.mixData[i].destCh;
mix.phases = oldModel.mixData[i].phases;
mix.mltpx = oldModel.mixData[i].mltpx;
mix.weight = oldModel.mixData[i].weight;
mix.swtch = ConvertSwitch_215_to_216(oldModel.mixData[i].swtch);
if (oldModel.mixData[i].curveMode==0/*differential*/) {
mix.curve.type = CURVE_REF_DIFF;
mix.curve.value = oldModel.mixData[i].curveParam;
mix->destCh = oldMix->destCh;
mix->phases = oldMix->phases;
mix->mltpx = oldMix->mltpx;
if (oldMix->carryTrim == TRIM_OFF) mix->carryTrim = TRIM_OFF;
mix->weight = ConvertGVAR_215_to_216(oldMix->weight);
mix->swtch = ConvertSwitch_215_to_216(oldMix->swtch);
if (oldMix->curveMode==0/*differential*/) {
mix->curve.type = CURVE_REF_DIFF;
mix->curve.value = oldMix->curveParam;
}
else if (oldModel.mixData[i].curveParam <= 6) {
mix.curve.type = CURVE_REF_FUNC;
mix.curve.value = oldModel.mixData[i].curveParam;
else if (oldMix->curveParam <= 6) {
mix->curve.type = CURVE_REF_FUNC;
mix->curve.value = oldMix->curveParam;
}
else {
mix.curve.type = CURVE_REF_CUSTOM;
mix.curve.value = oldModel.mixData[i].curveParam - 6;
mix->curve.type = CURVE_REF_CUSTOM;
mix->curve.value = oldMix->curveParam - 6;
}
mix->mixWarn = oldMix->mixWarn;
mix->delayUp = oldMix->delayUp;
mix->delayDown = oldMix->delayDown;
mix->speedUp = oldMix->speedUp;
mix->speedDown = oldMix->speedDown;
mix->srcRaw = oldMix->srcRaw;
if (mix->srcRaw > 4 || oldMix->noExpo)
mix->srcRaw = ConvertSource_215_to_216(mix->srcRaw);
mix->offset = ConvertGVAR_215_to_216(oldMix->offset);
memcpy(mix->name, oldMix->name, LEN_EXPOMIX_NAME);
if (!GV_IS_GV_VALUE(mix->weight, 500, 500) && !GV_IS_GV_VALUE(mix->offset, 500, 500)) {
mix->offset = divRoundClosest(mix->offset * mix->weight, 100);
}
mix.mixWarn = oldModel.mixData[i].mixWarn;
mix.delayUp = oldModel.mixData[i].delayUp;
mix.delayDown = oldModel.mixData[i].delayDown;
mix.speedUp = oldModel.mixData[i].speedUp;
mix.speedDown = oldModel.mixData[i].speedDown;
mix.srcRaw = oldModel.mixData[i].srcRaw;
if (mix.srcRaw > 4 || oldModel.mixData[i].noExpo)
mix.srcRaw = ConvertSource_215_to_216(mix.srcRaw);
mix.offset = oldModel.mixData[i].offset;
memcpy(mix.name, oldModel.mixData[i].name, LEN_EXPOMIX_NAME);
#else
memcpy(&mix, &oldModel.mixData[i], sizeof(mix));
mix->destCh = oldMix->destCh;
mix->mixWarn = oldMix->mixWarn;
mix->phases = oldMix->phases;
mix->curveMode = oldMix->curveMode;
mix->noExpo = oldMix->noExpo;
mix->carryTrim = oldMix->carryTrim;
mix->mltpx = oldMix->mltpx;
mix->weight = oldMix->weight;
mix->swtch = ConvertSwitch_215_to_216(oldMix->swtch);
mix->curveParam = oldMix->curveParam;
mix->delayUp = oldMix->delayUp;
mix->delayDown = oldMix->delayDown;
mix->speedUp = oldMix->speedUp;
mix->speedDown = oldMix->speedDown;
mix->srcRaw = ConvertSource_215_to_216(oldMix->srcRaw);
mix->offset = oldMix->offset;
memcpy(mix->name, oldMix->name, LEN_EXPOMIX_NAME);
#endif
if (mix.weight <= -508)
mix.weight = mix.weight + 512 - 4096;
else if (mix.weight >= 507)
mix.weight = mix.weight - 512 + 4096;
else
mix.offset = mix.offset * mix.weight / 100;
}
for (uint8_t i=0; i<32; i++) {
#if defined(PCBTARANIS)
g_model.limitData[i].min = 10 * oldModel.limitData[i].min;
g_model.limitData[i].max = 10 * oldModel.limitData[i].max;
#else
g_model.limitData[i].min = oldModel.limitData[i].min;
g_model.limitData[i].max = oldModel.limitData[i].max;
#endif
g_model.limitData[i].ppmCenter = oldModel.limitData[i].ppmCenter;
g_model.limitData[i].offset = oldModel.limitData[i].offset;
g_model.limitData[i].symetrical = oldModel.limitData[i].symetrical;
g_model.limitData[i].revert = oldModel.limitData[i].revert;
#if defined(PCBTARANIS)
memcpy(&g_model.limitData[i].name, &oldModel.limitData[i].name, LEN_CHANNEL_NAME);
memcpy(g_model.limitData[i].name, oldModel.limitData[i].name, LEN_CHANNEL_NAME);
#endif
}
int indexes[NUM_STICKS] = { 0, 0, 0, 0 };
for (uint8_t i=0; i<32; i++) {
if (oldModel.expoData[i].mode) {
#if defined(PCBTARANIS)
uint8_t chn = oldModel.expoData[i].chn;
if (!oldModel.expoData[i].swtch && !oldModel.expoData[i].phases) {
int indexes[NUM_STICKS] = { 0, 0, 0, 0 };
#endif
for (uint8_t i=0; i<32; i++) {
ExpoData * expo = &g_model.expoData[i];
ExpoData_v215 * oldExpo = &oldModel.expoData[i];
if (oldExpo->mode) {
#if defined(PCBTARANIS)
uint8_t chn = oldExpo->chn;
if (!oldExpo->swtch && !oldExpo->phases) {
indexes[chn] = -1;
}
else if (indexes[chn] != -1) {
@@ -494,26 +585,36 @@ void ConvertModel_215_to_216(ModelData &model)
for (uint8_t j=chn+1; j<NUM_STICKS; j++) {
indexes[j] = i+1;
}
g_model.expoData[i].srcRaw = MIXSRC_Rud+chn;
g_model.expoData[i].chn = chn;
g_model.expoData[i].swtch = ConvertSwitch_215_to_216(oldModel.expoData[i].swtch);
g_model.expoData[i].phases = oldModel.expoData[i].phases;
g_model.expoData[i].weight = oldModel.expoData[i].weight;
memcpy(&g_model.expoData[i].name, &oldModel.expoData[i].name, LEN_EXPOMIX_NAME);
if (oldModel.expoData[i].curveMode==0/*expo*/) {
g_model.expoData[i].curve.type = CURVE_REF_EXPO;
g_model.expoData[i].curve.value = oldModel.expoData[i].curveParam;
expo->srcRaw = MIXSRC_Rud+chn;
expo->chn = chn;
expo->mode = oldExpo->mode;
expo->swtch = ConvertSwitch_215_to_216(oldExpo->swtch);
expo->phases = oldExpo->phases;
expo->weight = oldExpo->weight;
memcpy(expo->name, oldExpo->name, LEN_EXPOMIX_NAME);
if (oldExpo->curveMode==0/*expo*/) {
if (oldExpo->curveParam) {
expo->curve.type = CURVE_REF_EXPO;
expo->curve.value = oldExpo->curveParam;
}
}
else if (oldModel.expoData[i].curveParam <= 6) {
g_model.expoData[i].curve.type = CURVE_REF_FUNC;
g_model.expoData[i].curve.value = oldModel.expoData[i].curveParam;
else if (oldExpo->curveParam <= 6) {
expo->curve.type = CURVE_REF_FUNC;
expo->curve.value = oldExpo->curveParam;
}
else {
g_model.expoData[i].curve.type = CURVE_REF_CUSTOM;
g_model.expoData[i].curve.value = oldModel.expoData[i].curveParam - 7;
expo->curve.type = CURVE_REF_CUSTOM;
expo->curve.value = oldExpo->curveParam - 7;
}
#else
memcpy(&g_model.expoData[i], &oldModel.expoData[i], sizeof(g_model.expoData[i]));
expo->mode = oldExpo->mode;
expo->chn = oldExpo->chn;
expo->curveMode = oldExpo->curveMode;
expo->swtch = oldExpo->swtch;
expo->phases = oldExpo->phases;
expo->weight = oldExpo->weight;
memcpy(expo->name, oldExpo->name, LEN_EXPOMIX_NAME);
expo->curveParam = oldExpo->curveParam;
#endif
}
else {
@@ -524,13 +625,14 @@ void ConvertModel_215_to_216(ModelData &model)
for (int i=NUM_STICKS-1; i>=0; i--) {
int idx = indexes[i];
if (idx >= 0) {
ExpoData *expo = expoAddress(idx);
ExpoData * expo = expoAddress(idx);
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
memclear(expo, sizeof(ExpoData));
expo->srcRaw = MIXSRC_Rud + i;
expo->chn = i;
expo->weight = 100;
expo->curve.type = CURVE_REF_EXPO;
expo->mode = 3;
}
for (int c=0; c<4; c++) {
g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[1+STR_VSRCRAW[0]*(i+1)+c]);
@@ -567,7 +669,6 @@ void ConvertModel_215_to_216(ModelData &model)
sw.delay = oldModel.customSw[i].delay * 5;
sw.duration = oldModel.customSw[i].duration * 5;
sw.andsw = ConvertSwitch_215_to_216(oldModel.customSw[i].andsw);
#if defined(PCBTARANIS)
uint8_t cstate = cswFamily(sw.func);
if (cstate == LS_FAMILY_BOOL) {
sw.v1 = ConvertSwitch_215_to_216(sw.v1);
@@ -623,7 +724,6 @@ void ConvertModel_215_to_216(ModelData &model)
sw.v2 = ConvertSource_215_to_216(sw.v2);
}
}
#endif
}
for (uint8_t i=0; i<32; i++) {
CustomFnData & fn = g_model.funcSw[i];
@@ -703,33 +803,42 @@ void ConvertModel_215_to_216(ModelData &model)
g_model.swashR.collectiveSource = ConvertSource_215_to_216(g_model.swashR.collectiveSource);
for (uint8_t i=0; i<9; i++) {
memcpy(&g_model.phaseData[i], &oldModel.phaseData[i], sizeof(oldModel.phaseData[i])); // the last 4 gvars will remain blank
g_model.phaseData[i].swtch = ConvertSwitch_215_to_216(oldModel.phaseData[i].swtch);
if (i==0 || oldModel.phaseData[i].swtch) {
memcpy(&g_model.phaseData[i], &oldModel.phaseData[i], sizeof(oldModel.phaseData[i])); // the last 4 gvars will remain blank
g_model.phaseData[i].swtch = ConvertSwitch_215_to_216(oldModel.phaseData[i].swtch);
#if defined(PCBTARANIS)
for (uint8_t t=0; t<4; t++) {
int trim = oldModel.phaseData[i].trim[t];
if (trim > 500) {
trim -= 501;
if (trim >= i)
trim += 1;
g_model.phaseData[i].trim[t].mode = 2*trim;
g_model.phaseData[i].trim[t].value = 0;
for (uint8_t t=0; t<4; t++) {
int trim = oldModel.phaseData[i].trim[t];
if (trim > 500) {
trim -= 501;
if (trim >= i)
trim += 1;
g_model.phaseData[i].trim[t].mode = 2*trim;
g_model.phaseData[i].trim[t].value = 0;
}
else {
g_model.phaseData[i].trim[t].mode = 2*i;
g_model.phaseData[i].trim[t].value = trim;
}
}
else {
g_model.phaseData[i].trim[t].mode = 2*i;
g_model.phaseData[i].trim[t].value = trim;
}
}
#endif
}
}
g_model.thrTraceSrc = oldModel.thrTraceSrc;
#if defined(PCBTARANIS)
// S3 added
if (g_model.thrTraceSrc >= THROTTLE_SOURCE_S3)
g_model.thrTraceSrc += 1;
#endif
g_model.switchWarningStates = oldModel.switchWarningStates >> 1;
g_model.nSwToWarn = (oldModel.switchWarningStates & 0x01) ? 0xFF : 0;
for (uint8_t i=0; i<5; i++) {
memcpy(g_model.gvars[i].name, oldModel.gvar_names[i], LEN_GVAR_NAME);
}
memcpy(&g_model.frsky, &oldModel.frsky, sizeof(oldModel.frsky));
memcpy(&g_model.frsky, &oldModel.frsky, 2*sizeof(FrSkyChannelData));
// gap for A3-A4
memcpy(((uint8_t *)&g_model.frsky) + 4*sizeof(FrSkyChannelData), ((uint8_t *)&oldModel.frsky) + 2*sizeof(FrSkyChannelData), sizeof(oldModel.frsky) - 2*sizeof(FrSkyChannelData));
for (int i=0; i<3; i++) {
if (g_model.frsky.screensType & (1<<i)) {
// gauges
@@ -758,6 +867,22 @@ void ConvertModel_215_to_216(ModelData &model)
memcpy(g_model.moduleData, oldModel.moduleData, sizeof(g_model.moduleData));
}
void ConvertModel(int id, int version)
{
loadModel(id);
if (version == 215) {
version = 216;
ConvertModel_215_to_216(g_model);
}
uint8_t currModel = g_eeGeneral.currModel;
g_eeGeneral.currModel = id;
s_eeDirtyMsk = EE_MODEL;
eeCheck(true);
g_eeGeneral.currModel = currModel;
}
bool eeConvert()
{
const char *msg = NULL;
@@ -779,47 +904,37 @@ bool eeConvert()
ALERT(STR_EEPROMWARN, msg, AU_BAD_EEPROM);
// Message
MESSAGE(STR_EEPROMWARN, PSTR("EEPROM Converting"), NULL, AU_EEPROM_FORMATTING); // TODO translations
MESSAGE(STR_EEPROMWARN, STR_EEPROM_CONVERTING, NULL, AU_EEPROM_FORMATTING); // TODO translations
// General Settings conversion
#if defined(PCBTARANIS)
theFile.openRlc(0);
theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral));
#else
#pragma message("TODO openRlc for sky9x")
#endif
if (g_eeGeneral.version == 215) ConvertGeneralSettings_215_to_216(g_eeGeneral);
loadGeneralSettings();
int version = conversionVersionStart;
if (version == 215) {
version = 216;
ConvertGeneralSettings_215_to_216(g_eeGeneral);
}
s_eeDirtyMsk = EE_GENERAL;
eeCheck(true);
#if LCD_W >= 212
lcd_rect(60, 6*FH+4, 132, 3);
#else
lcd_rect(10, 6*FH+4, 102, 3);
#endif
// Models conversion
uint8_t currModel = g_eeGeneral.currModel;
for (uint8_t id=0; id<MAX_MODELS; id++) {
#if LCD_W >= 212
lcd_hline(61, 6*FH+5, 10+id*2, FORCE);
// lcd_putsnAtt(61, 7*FH)
#else
lcd_hline(11, 6*FH+5, 10+(id*3)/2, FORCE);
#endif
lcdRefresh();
if (eeModelExists(id)) {
// TODO loadModel without anything else
#if defined(PCBTARANIS)
theFile.openRlc(FILE_MODEL(id));
theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
#else
#pragma message("TODO openRlc for sky9x")
#endif
int version = conversionVersionStart;
if (version == 215) {
version = 216;
ConvertModel_215_to_216(g_model);
}
g_eeGeneral.currModel = id;
s_eeDirtyMsk = EE_MODEL;
eeCheck(true);
ConvertModel(id, conversionVersionStart);
}
}
g_eeGeneral.currModel = currModel;
return true;
}
+34 -16
View File
@@ -317,20 +317,28 @@ uint32_t get_current_block_number( uint32_t block_no, uint16_t *p_size, uint32_t
return block_no ;
}
// For conversions ...
void loadGeneralSettings()
{
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
uint16_t size = min<int>(File_system[0].size, sizeof(g_eeGeneral));
if (size) {
read32_eeprom_data((File_system[0].block_no << 12) + sizeof(struct t_eeprom_header), (uint8_t *)&g_eeGeneral, size);
}
}
void loadModel(int index)
{
memset(&g_model, 0, sizeof(g_model));
int size = min<int>(File_system[index+1].size, sizeof(g_model));
if (size > 256) { // if loaded a fair amount
read32_eeprom_data((File_system[index+1].block_no << 12) + sizeof(struct t_eeprom_header), (uint8_t *)&g_model, size) ;
}
}
bool eeLoadGeneral()
{
uint16_t size = File_system[0].size;
memset(&g_eeGeneral, 0, sizeof(EEGeneral));
if (size > sizeof(EEGeneral)) {
size = sizeof(EEGeneral) ;
}
if (size) {
read32_eeprom_data( ( File_system[0].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&g_eeGeneral, size) ;
}
loadGeneralSettings();
if (g_eeGeneral.version != EEPROM_VER) {
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
if (!eeConvert())
@@ -359,9 +367,10 @@ void eeLoadModel(uint8_t id)
memset(&g_model, 0, sizeof(g_model));
#if defined(SIMU)
if (size > 0 && size != sizeof(g_model)) {
printf("Model data read=%d bytes vs %d bytes\n", size, (int)sizeof(ModelData));
}
if (sizeof(struct t_eeprom_header) + sizeof(g_model) > 4096)
TRACE("Model data size can't exceed %d bytes (%d bytes)", int(4096-sizeof(struct t_eeprom_header)), (int)sizeof(g_model));
else if (size > 0 && size != sizeof(g_model))
TRACE("Model data read=%d bytes vs %d bytes\n", size, (int)sizeof(ModelData));
#endif
if (size > sizeof(g_model)) {
@@ -744,7 +753,8 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
return SDCARD_ERROR(result);
}
if (*(uint32_t*)&buf[0] != O9X_FOURCC || (uint8_t)buf[4] != EEPROM_VER || buf[5] != 'M') {
uint8_t version = (uint8_t)buf[4];
if (*(uint32_t*)&buf[0] != O9X_FOURCC || version < FIRST_CONV_EEPROM_VER || version > EEPROM_VER || buf[5] != 'M') {
f_close(&restoreFile);
return STR_INCOMPATIBLE;
}
@@ -775,6 +785,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
Eeprom32_process_state = E32_BLANKCHECK;
eeWaitFinished();
#if defined(CPUARM)
if (version < EEPROM_VER) {
eeCheck(true);
ConvertModel(i_fileDst, version);
loadModel(g_eeGeneral.currModel);
}
#endif
return NULL;
}
#endif
+3
View File
@@ -101,5 +101,8 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc);
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
#endif
void loadGeneralSettings();
void loadModel(int index);
#endif
+29 -3
View File
@@ -494,7 +494,7 @@ void RlcFile::nextWriteStep()
}
if (s_write_err == ERR_FULL) {
s_global_warning = STR_EEPROMOVERFLOW;
POPUP_WARNING(STR_EEPROMOVERFLOW);
m_write_step = 0;
m_write_len = 0;
m_cur_rlc_len = 0;
@@ -663,7 +663,8 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
return SDCARD_ERROR(result);
}
if (*(uint32_t*)&buf[0] != O9X_FOURCC || (uint8_t)buf[4] != EEPROM_VER || buf[5] != 'M') {
uint8_t version = (uint8_t)buf[4];
if (*(uint32_t*)&buf[0] != O9X_FOURCC || version < FIRST_CONV_EEPROM_VER || version > EEPROM_VER || buf[5] != 'M') {
f_close(&g_oLogFile);
return STR_INCOMPATIBLE;
}
@@ -702,6 +703,14 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
f_close(&g_oLogFile);
#if defined(CPUARM)
if (version < EEPROM_VER) {
eeCheck(true);
ConvertModel(i_fileDst, version);
loadModel(g_eeGeneral.currModel);
}
#endif
#if defined(CPUARM)
eeLoadModelHeader(i_fileDst, &modelHeaders[i_fileDst]);
#endif
@@ -760,7 +769,7 @@ void RlcFile::nextRlcWriteStep()
return;
}
}
else{
else {
m_rlc_buf+=cnt0;
m_rlc_len-=cnt0+cnt;
m_cur_rlc_len=cnt;
@@ -868,6 +877,23 @@ void RlcFile::DisplayProgressBar(uint8_t x)
#define CHECK_EEPROM_VARIANT() (1)
#endif
// For conversions ...
#if defined(CPUARM)
void loadGeneralSettings()
{
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
theFile.openRlc(FILE_GENERAL);
theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral));
}
void loadModel(int index)
{
memset(&g_model, 0, sizeof(g_model));
theFile.openRlc(FILE_MODEL(index));
theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
}
#endif
bool eeLoadGeneral()
{
theFile.openRlc(FILE_GENERAL);
+39 -4
View File
@@ -34,11 +34,16 @@
*
*/
#ifndef eeprom_avr_h
#define eeprom_avr_h
#ifndef eeprom_rlc_h
#define eeprom_rlc_h
#include <inttypes.h>
// TODO duplicated
#ifndef PACK
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#if defined(PCBTARANIS)
#define blkid_t uint16_t
#if !defined(EESIZE)
@@ -67,7 +72,7 @@
#define BS 16
#endif
PACK(struct DirEnt{
PACK(struct DirEnt {
blkid_t startBlk;
uint16_t size:12;
uint16_t typ:4;
@@ -79,7 +84,7 @@ PACK(struct DirEnt{
#define EEFS_EXTRA_FIELDS
#endif
PACK(struct EeFs{
PACK(struct EeFs {
uint8_t version;
blkid_t mySize;
blkid_t freeList;
@@ -236,4 +241,34 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc);
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
#endif
// For conversions
#if defined(CPUARM)
void loadGeneralSettings();
void loadModel(int index);
#endif
// For EEPROM backup/restore
#if defined(CPUARM)
inline bool isEepromStart(const void * buffer)
{
// OpenTX EEPROM
{
const EeFs * eeprom = (const EeFs *)buffer;
if (eeprom->version==EEFS_VERS && eeprom->mySize==sizeof(eeFs) && eeprom->bs==BS)
return true;
}
// ersky9x EEPROM
{
const uint8_t * eeprom = (const uint8_t *)buffer;
uint8_t size = eeprom[1] ;
uint8_t bs = eeprom[3] ;
if (size==0x80 && bs==0x80)
return true;
}
return false;
}
#endif
#endif
+163
View File
@@ -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
+57
View File
@@ -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
+72 -33
View File
@@ -42,7 +42,10 @@
void doMixerCalculations();
#define MODEL_RESET() memset(&g_model, 0, sizeof(g_model))
#define MODEL_RESET() \
memset(&g_model, 0, sizeof(g_model)); \
extern bool s_mixer_first_run_done; \
s_mixer_first_run_done = false;
#define MIXER_RESET() \
memset(channelOutputs, 0, sizeof(channelOutputs)); \
@@ -62,6 +65,7 @@ uint16_t anaIn(uint8_t chan)
return 0;
}
#if !defined(PCBTARANIS)
TEST(Trims, greaterTrimLink)
{
MODEL_RESET();
@@ -88,6 +92,7 @@ TEST(Trims, infiniteChainedTrims)
setTrimValue(3, 0, TRIM_EXTENDED_MAX+3); // link to FP2 trim
EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, 2), 0), 32);
}
#endif
TEST(outdezNAtt, test_unsigned)
{
@@ -565,16 +570,18 @@ TEST(Mixer, SlowOnSwitch)
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].swtch = SWSRC_THR;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedDown = 10;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
s_mixer_first_run_done = true;
perOut(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
simuSetSwitch(0, 1);
CHECK_SLOW_MOVEMENT(0, +1, 250);
simuSetSwitch(0, 0);
simuSetSwitch(0, -1);
CHECK_SLOW_MOVEMENT(0, -1, 250);
}
@@ -587,11 +594,12 @@ TEST(Mixer, SlowUpOnSwitch)
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].swtch = SWSRC_THR;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = 0;
simuSetSwitch(0, 0);
perOut(e_perout_mode_normal, 0);
s_mixer_first_run_done = true;
EXPECT_EQ(chans[0], 0);
simuSetSwitch(0, 1);
@@ -605,70 +613,79 @@ TEST(Mixer, SlowUpOnSwitch)
simuSetSwitch(0, 1);
CHECK_SLOW_MOVEMENT(0, +1, 100);
}
#endif
TEST(Mixer, SlowOnPhase)
{
MODEL_RESET();
MIXER_RESET();
g_model.phaseData[1].swtch = SWSRC_THR;
g_model.phaseData[1].swtch = TR(SWSRC_THR, SWSRC_SA0);
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].phases = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedDown = 10;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
s_perout_flight_phase = 0;
s_mixer_first_run_done = true;
s_perout_flight_mode = 0;
perOut(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
CHECK_SLOW_MOVEMENT(0, +1, 250);
s_perout_flight_phase = 1;
s_perout_flight_mode = 1;
CHECK_SLOW_MOVEMENT(0, -1, 250);
}
#if !defined(CPUARM)
TEST(Mixer, SlowOnSwitchAndPhase)
{
MODEL_RESET();
MIXER_RESET();
g_model.phaseData[1].swtch = SWSRC_THR;
g_model.phaseData[1].swtch = TR(SWSRC_THR, SWSRC_SA0);
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].swtch = SWSRC_THR;
g_model.mixData[0].swtch = TR(SWSRC_THR, SWSRC_SA0);
#if defined(CPUARM)
g_model.mixData[0].phases = 0x2 + 0x4 + 0x8 + 0x10 + 0x20 + 0x40 + 0x80 + 0x100 /*only enabled in phase 0*/;
#else
g_model.mixData[0].phases = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedDown = 10;
#endif
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
s_mixer_first_run_done = true;
perOut(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
simuSetSwitch(0, 1);
s_perout_flight_phase = 0;
s_perout_flight_mode = 0;
CHECK_SLOW_MOVEMENT(0, +1, 250);
simuSetSwitch(0, 0);
s_perout_flight_phase = 1;
simuSetSwitch(0, -1);
s_perout_flight_mode = 1;
CHECK_SLOW_MOVEMENT(0, -1, 250);
}
#endif
#if !defined(PCBTARANIS)
TEST(Mixer, SlowOnSwitchSource)
{
MODEL_RESET();
MIXER_RESET();
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_THR;
g_model.mixData[0].srcRaw = TR(MIXSRC_THR, MIXSRC_SA);
g_model.mixData[0].weight = 100;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedDown = 10;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
simuSetSwitch(0, 0);
s_mixer_first_run_done = true;
simuSetSwitch(0, -1);
CHECK_SLOW_MOVEMENT(0, -1, 250);
EXPECT_EQ(chans[0], -CHANNEL_MAX);
@@ -676,6 +693,22 @@ TEST(Mixer, SlowOnSwitchSource)
CHECK_SLOW_MOVEMENT(0, +1, 500);
}
TEST(Mixer, SlowDisabledOnStartup)
{
MODEL_RESET();
MIXER_RESET();
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
perOut(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], CHANNEL_MAX);
}
#if !defined(PCBTARANIS)
TEST(Mixer, SlowAndDelayOnReplace3POSSource)
{
MODEL_RESET();
@@ -685,9 +718,11 @@ TEST(Mixer, SlowAndDelayOnReplace3POSSource)
g_model.mixData[0].srcRaw = MIXSRC_3POS;
g_model.mixData[0].weight = 100;
g_model.mixData[0].delayUp = 10;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedDown = 10;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
s_mixer_first_run_done = true;
simuSetSwitch(3, -1);
CHECK_SLOW_MOVEMENT(0, -1, 250);
EXPECT_EQ(chans[0], -CHANNEL_MAX);
@@ -717,7 +752,7 @@ TEST(Mixer, SlowOnSwitchReplace)
g_model.mixData[1].srcRaw = MIXSRC_MAX;
g_model.mixData[1].weight = 100;
g_model.mixData[1].swtch = SWSRC_THR;
g_model.mixData[1].speedDown = 10;
g_model.mixData[1].speedDown = SLOW_STEP*5;
simuSetSwitch(0, 0);
perOut(e_perout_mode_normal, 1);
@@ -745,16 +780,19 @@ TEST(Mixer, NoTrimOnInactiveMix)
g_model.mixData[0].srcRaw = MIXSRC_Thr;
g_model.mixData[0].weight = 100;
g_model.mixData[0].swtch = SWSRC_THR;
g_model.mixData[0].speedUp = 10;
g_model.mixData[0].speedDown = 10;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
setTrimValue(0, 2, 256);
s_mixer_first_run_done = true;
simuSetSwitch(0, 1);
CHECK_SLOW_MOVEMENT(0, 1, 100);
simuSetSwitch(0, 0);
simuSetSwitch(0, -1);
CHECK_SLOW_MOVEMENT(0, -1, 100);
}
#endif
TEST(Mixer, SlowOnMultiply)
{
@@ -768,20 +806,21 @@ TEST(Mixer, SlowOnMultiply)
g_model.mixData[1].mltpx = MLTPX_MUL;
g_model.mixData[1].srcRaw = MIXSRC_MAX;
g_model.mixData[1].weight = 100;
g_model.mixData[1].swtch = SWSRC_THR;
g_model.mixData[1].speedUp = 10;
g_model.mixData[1].speedDown = 10;
g_model.mixData[1].swtch = TR(SWSRC_THR, SWSRC_SA0);
g_model.mixData[1].speedUp = SLOW_STEP*5;
g_model.mixData[1].speedDown = SLOW_STEP*5;
s_mixer_first_run_done = true;
simuSetSwitch(0, 1);
CHECK_SLOW_MOVEMENT(0, 1, 250);
simuSetSwitch(0, 0);
simuSetSwitch(0, -1);
CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250);
simuSetSwitch(0, 1);
CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250);
}
#endif
TEST(Curves, LinearIntpol)
{
+185 -65
View File
@@ -110,33 +110,25 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = {
#endif
#if !defined(CPUM64)
void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr)
{
lcd_putc(RADIO_SETUP_2ND_COLUMN+(value*4*FW)/max, y, '$');
lcd_hline(RADIO_SETUP_2ND_COLUMN, y+3, 5*FW-1, SOLID);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, 5*FW-1, FH-1);
}
#define SLIDER_5POS(y, value, label, event, attr) { \
int8_t tmp = value; \
displaySlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \
value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \
}
#elif defined(GRAPHICS)
void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr)
{
lcd_putc(RADIO_SETUP_2ND_COLUMN+2*FW+(value*FW), y, '$');
lcd_hline(RADIO_SETUP_2ND_COLUMN, y+3, 5*FW-1, SOLID);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, 5*FW-1, FH-1);
}
#define SLIDER_5POS(y, value, label, event, attr) { \
int8_t tmp = value; \
display5posSlider(RADIO_SETUP_2ND_COLUMN, y, tmp, attr); \
value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \
}
#define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT)
#else
#define SLIDER_5POS(y, value, label, event, attr) value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, STR_VBEEPLEN, value, -2, +2, attr, event)
#define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT)
#endif
#if defined(SPLASH) && !defined(FSPLASH)
#define IF_SPLASH_PARAM(x) x,
#else
#define IF_SPLASH_PARAM(x)
#endif
enum menuGeneralSetupItems {
@@ -152,11 +144,11 @@ enum menuGeneralSetupItems {
IF_CPUARM(ITEM_SETUP_BACKGROUND_VOLUME)
ITEM_SETUP_BEEP_LENGTH,
IF_AUDIO(ITEM_SETUP_SPEAKER_PITCH)
IF_CPUARM(ITEM_SETUP_VARIO_LABEL)
IF_CPUARM(ITEM_SETUP_VARIO_VOLUME)
IF_CPUARM(ITEM_SETUP_VARIO_PITCH)
IF_CPUARM(ITEM_SETUP_VARIO_RANGE)
IF_CPUARM(ITEM_SETUP_VARIO_REPEAT)
IF_VARIO_CPUARM(ITEM_SETUP_VARIO_LABEL)
IF_VARIO_CPUARM(ITEM_SETUP_VARIO_VOLUME)
IF_VARIO_CPUARM(ITEM_SETUP_VARIO_PITCH)
IF_VARIO_CPUARM(ITEM_SETUP_VARIO_RANGE)
IF_VARIO_CPUARM(ITEM_SETUP_VARIO_REPEAT)
IF_HAPTIC(ITEM_SETUP_HAPTIC_LABEL)
IF_HAPTIC(ITEM_SETUP_HAPTIC_MODE)
IF_HAPTIC(ITEM_SETUP_HAPTIC_LENGTH)
@@ -174,12 +166,11 @@ enum menuGeneralSetupItems {
ITEM_SETUP_BACKLIGHT_MODE,
ITEM_SETUP_BACKLIGHT_DELAY,
IF_CPUARM(ITEM_SETUP_BRIGHTNESS)
IF_REVPLUS(ITEM_SETUP_BACKLIGHT_COLOR)
CASE_PWM_BACKLIGHT(ITEM_SETUP_BACKLIGHT_BRIGHTNESS_OFF)
CASE_PWM_BACKLIGHT(ITEM_SETUP_BACKLIGHT_BRIGHTNESS_ON)
ITEM_SETUP_FLASH_BEEP,
#if defined(SPLASH) && !defined(FSPLASH)
ITEM_SETUP_DISABLE_SPLASH,
#endif
IF_SPLASH_PARAM(ITEM_SETUP_DISABLE_SPLASH)
IF_GPS(ITEM_SETUP_TIMEZONE)
IF_GPS(ITEM_SETUP_GPSFORMAT)
IF_PXX(ITEM_SETUP_COUNTRYCODE)
@@ -193,6 +184,12 @@ enum menuGeneralSetupItems {
ITEM_SETUP_MAX
};
#if defined(FRSKY_STICKS)
#define COL_TX_MODE 0
#else
#define COL_TX_MODE LABEL(TX_MODE)
#endif
void menuGeneralSetup(uint8_t event)
{
#if defined(RTCLOCK)
@@ -215,7 +212,7 @@ void menuGeneralSetup(uint8_t event)
}
#endif
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) IF_VOICE(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) 0, IF_AUDIO(0) IF_CPUARM(LABEL(VARIO)) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_PCBSKY9X(0) CASE_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, IF_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/});
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) IF_VOICE(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) 0, IF_AUDIO(0) IF_VARIO_CPUARM(LABEL(VARIO)) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_PCBSKY9X(0) CASE_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, IF_CPUARM(0) IF_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH_PARAM(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, COL_TX_MODE, CASE_PCBTARANIS(0) 1/*to force edit mode*/});
uint8_t sub = m_posVert - 1;
@@ -380,7 +377,7 @@ void menuGeneralSetup(uint8_t event)
break;
#endif
#if defined(CPUARM)
#if defined(CPUARM) && defined(VARIO)
case ITEM_SETUP_VARIO_LABEL:
lcd_putsLeft(y, STR_VARIO);
break;
@@ -388,19 +385,19 @@ void menuGeneralSetup(uint8_t event)
SLIDER_5POS(y, g_eeGeneral.varioVolume, TR_SPEAKER_VOLUME, event, attr);
break;
case ITEM_SETUP_VARIO_PITCH:
lcd_putsLeft(y, "\001Pitch at Zero");
lcd_putsLeft(y, STR_PITCH_AT_ZERO);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT);
lcd_putsAtt(lcdLastPos, y, "Hz", attr);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioPitch, -40, 40);
break;
case ITEM_SETUP_VARIO_RANGE:
lcd_putsLeft(y, "\001Pitch at Max");
lcd_putsLeft(y, STR_PITCH_AT_MAX);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT);
lcd_putsAtt(lcdLastPos, y, "Hz", attr);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRange, -80, 80);
break;
case ITEM_SETUP_VARIO_REPEAT:
lcd_putsLeft(y, "\001Repeat at Zero");
lcd_putsLeft(y, STR_REPEAT_AT_ZERO);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT);
lcd_putsAtt(lcdLastPos, y, "ms", attr);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRepeat, -30, 50);
@@ -432,12 +429,8 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_CONTRAST:
lcd_putsLeft(y, STR_CONTRAST);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT);
if(attr) {
#if defined(PCBTARANIS)
CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, 0, 45);
#else
CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, 10, 45);
#endif
if (attr) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, CONTRAST_MIN, CONTRAST_MAX);
lcdSetContrast();
}
break;
@@ -529,6 +522,14 @@ void menuGeneralSetup(uint8_t event)
break;
#endif
#if defined(PCBTARANIS) && defined(REVPLUS)
case ITEM_SETUP_BACKLIGHT_COLOR:
lcd_putsLeft(y, STR_BLCOLOR);
displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 100, attr);
if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 100, EE_GENERAL | NO_INCDEC_MARKS);
break;
#endif
#if defined(PWM_BACKLIGHT)
case ITEM_SETUP_BACKLIGHT_BRIGHTNESS_OFF:
lcd_putsLeft(y, STR_BLOFFBRIGHTNESS);
@@ -546,8 +547,20 @@ void menuGeneralSetup(uint8_t event)
#if defined(SPLASH) && !defined(FSPLASH)
case ITEM_SETUP_DISABLE_SPLASH:
{
#if defined(PCBTARANIS)
lcd_putsLeft(y, STR_SPLASHSCREEN);
if (SPLASH_NEEDED()) {
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, SPLASH_TIMEOUT/100, attr|LEFT);
lcd_putc(lcdLastPos, y, 's');
}
else {
lcd_putsiAtt(RADIO_SETUP_2ND_COLUMN, y, STR_MMMINV, 0, attr);
}
if (attr) g_eeGeneral.splashMode = -checkIncDecGen(event, -g_eeGeneral.splashMode, -3, 4);
#else
uint8_t b = 1-g_eeGeneral.splashMode;
g_eeGeneral.splashMode = 1 - onoffMenuItem(b, RADIO_SETUP_2ND_COLUMN, y, STR_SPLASHSCREEN, attr, event);
#endif
break;
}
#endif
@@ -601,24 +614,16 @@ void menuGeneralSetup(uint8_t event)
#endif
#if defined(MAVLINK)
case ITEM_MAVLINK_BAUD:
g_eeGeneral.mavbaud = selectMenuItem(RADIO_SETUP_2ND_COLUMN, //Y
y, // Y
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;
case ITEM_MAVLINK_BAUD:
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);
break;
#endif
case ITEM_SETUP_RX_CHANNEL_ORD:
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);
}
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23);
break;
@@ -629,7 +634,9 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_STICK_MODE:
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) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3);
}
@@ -679,6 +686,103 @@ inline bool isFilenameLower(bool isfile, const char * fn, const char * line)
return (!isfile && line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) < 0);
}
#if defined(PCBTARANIS)
void backupEeprom()
{
char filename[60];
uint8_t buffer[1024];
FIL file;
lcd_clear();
lcd_putsLeft(4*FH, STR_WRITING);
lcd_rect(3, 6*FH+4, 204, 7);
lcdRefresh();
eeCheck(true);
// create the directory if needed...
DIR folder;
FRESULT result = f_opendir(&folder, EEPROMS_PATH);
if (result != FR_OK) {
if (result == FR_NO_PATH)
result = f_mkdir(EEPROMS_PATH);
if (result != FR_OK) {
POPUP_WARNING(SDCARD_ERROR(result));
return;
}
}
// prepare the filename...
char * tmp = strAppend(filename, EEPROMS_PATH "/eeprom");
tmp = strAppendDate(tmp, true);
strAppend(tmp, EEPROM_EXT);
// open the file for writing...
f_open(&file, filename, FA_WRITE | FA_CREATE_ALWAYS);
for (int i=0; i<EESIZE; i+=1024) {
UINT count;
eeprom_read_block(buffer, i, 1024);
f_write(&file, buffer, 1024, &count);
lcd_hline(5, 6*FH+6, (200*i)/EESIZE, FORCE);
lcd_hline(5, 6*FH+7, (200*i)/EESIZE, FORCE);
lcd_hline(5, 6*FH+8, (200*i)/EESIZE, FORCE);
lcdRefresh();
SIMU_SLEEP(100/*ms*/);
}
f_close(&file);
}
#endif
#if defined(PCBTARANIS)
void flashBootloader(const char * filename)
{
FIL file;
f_open(&file, filename, FA_READ);
uint8_t buffer[1024];
UINT count;
lcd_clear();
lcd_putsLeft(4*FH, STR_WRITING);
lcd_rect(3, 6*FH+4, 204, 7);
lcdRefresh();
static uint8_t unlocked = 0;
if (!unlocked) {
unlocked = 1;
unlockFlash();
}
for (int i=0; i<BOOTLOADER_SIZE; i+=1024) {
watchdogSetTimeout(100/*1s*/);
if (f_read(&file, buffer, 1024, &count) != FR_OK || count != 1024) {
POPUP_WARNING(STR_SDCARD_ERROR);
break;
}
if (i==0 && !isBootloaderStart((uint32_t *)buffer)) {
POPUP_WARNING(STR_INCOMPATIBLE);
break;
}
for (int j=0; j<1024; j+=FLASH_PAGESIZE) {
writeFlash(CONVERT_UINT_PTR(FIRMWARE_ADDRESS+i+j), (uint32_t *)(buffer+j));
lcd_hline(5, 6*FH+6, (200*i)/BOOTLOADER_SIZE, FORCE);
lcd_hline(5, 6*FH+7, (200*i)/BOOTLOADER_SIZE, FORCE);
lcd_hline(5, 6*FH+8, (200*i)/BOOTLOADER_SIZE, FORCE);
lcdRefresh();
SIMU_SLEEP(30/*ms*/);
}
}
if (unlocked) {
lockFlash();
unlocked = 0;
}
f_close(&file);
}
#endif
void onSdManagerMenu(const char *result)
{
TCHAR lfn[_MAX_LFN + 1];
@@ -688,7 +792,7 @@ void onSdManagerMenu(const char *result)
pushMenu(menuGeneralSdManagerInfo);
}
else if (result == STR_SD_FORMAT) {
POPUP_CONFIRMATION(PSTR("Confirm Format?"));
POPUP_CONFIRMATION(STR_CONFIRM_FORMAT);
}
else if (result == STR_DELETE_FILE) {
f_getcwd(lfn, _MAX_LFN);
@@ -727,6 +831,19 @@ void onSdManagerMenu(const char *result)
memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap));
eeDirty(EE_MODEL);
}
else if (result == STR_VIEW_TEXT) {
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, "/");
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
pushMenuTextView(lfn);
}
else if (result == STR_FLASH_BOOTLOADER) {
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, "/");
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
flashBootloader(lfn);
}
#endif
#if defined(LUA)
else if (result == STR_EXECUTE_FILE) {
f_getcwd(lfn, _MAX_LFN);
@@ -734,13 +851,6 @@ void onSdManagerMenu(const char *result)
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
luaExec(lfn);
}
#endif
else if (result == STR_VIEW_TEXT) {
f_getcwd(lfn, _MAX_LFN);
strcat(lfn, "/");
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
pushMenuTextView(lfn);
}
#endif
}
@@ -841,6 +951,7 @@ void menuGeneralSdManager(uint8_t _event)
else */ if (!strcasecmp(ext, SOUNDS_EXT)) {
MENU_ADD_ITEM(STR_PLAY_FILE);
}
#endif
#if defined(PCBTARANIS)
else if (!strcasecmp(ext, BITMAPS_EXT) && !READ_ONLY()) {
MENU_ADD_ITEM(STR_ASSIGN_BITMAP);
@@ -848,12 +959,14 @@ void menuGeneralSdManager(uint8_t _event)
else if (!strcasecmp(ext, TEXT_EXT)) {
MENU_ADD_ITEM(STR_VIEW_TEXT);
}
else if (!strcasecmp(ext, FIRMWARE_EXT) && !READ_ONLY()) {
MENU_ADD_ITEM(STR_FLASH_BOOTLOADER);
}
#endif
#if defined(LUA)
else if (!strcasecmp(ext, SCRIPTS_EXT)) {
MENU_ADD_ITEM(STR_EXECUTE_FILE);
}
#endif
#endif
if (!READ_ONLY()) {
MENU_ADD_ITEM(STR_DELETE_FILE);
@@ -991,10 +1104,10 @@ void menuGeneralTrainer(uint8_t event)
uint8_t y;
bool slave = SLAVE_MODE();
MENU(STR_MENUTRAINER, menuTabDiag, e_Trainer, slave ? 1 : 7, {0, 2, 2, 2, 2, 0/*, 0*/});
MENU(STR_MENUTRAINER, menuTabDiag, e_Trainer, (slave ? 1 : 7), {0, 2, 2, 2, 2, 0/*, 0*/});
if (slave) { // i am the slave
lcd_puts(7*FW, 3*FH, STR_SLAVE);
if (slave) {
lcd_puts(7*FW, 4*FH, STR_SLAVE);
}
else {
uint8_t attr;
@@ -1039,7 +1152,8 @@ void menuGeneralTrainer(uint8_t event)
lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, 6*FH+1, g_eeGeneral.PPM_Multiplier+10, attr|PREC1);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40);
attr = (m_posVert==6) ? blink : 0;
attr = (m_posVert==6) ? INVERS : 0;
if (attr) s_editMode = 0;
lcd_putsAtt(0*FW, 1+7*FH, STR_CAL, attr);
for (uint8_t i=0; i<4; i++) {
uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2;
@@ -1051,11 +1165,10 @@ void menuGeneralTrainer(uint8_t event)
}
if (attr) {
if (event==EVT_KEY_FIRST(KEY_MENU)){
s_editMode = -1;
if (event==EVT_KEY_LONG(KEY_ENTER)){
memcpy(g_eeGeneral.trainer.calib, g_ppmIns, sizeof(g_eeGeneral.trainer.calib));
eeDirty(EE_GENERAL);
AUDIO_KEYPAD_UP();
AUDIO_WARNING1();
}
}
}
@@ -1076,6 +1189,13 @@ void menuGeneralVersion(uint8_t event)
lcd_putsLeft(6*FH, PSTR("CoPr: ---"));
}
#endif
#if defined(PCBTARANIS)
lcd_putsLeft(7*FH, STR_EEBACKUP);
if (event == EVT_KEY_LONG(KEY_ENTER)) {
backupEeprom();
}
#endif
}
void displayKeyState(uint8_t x, uint8_t y, EnumKeys key)
@@ -1223,10 +1343,10 @@ void menuGeneralHardware(uint8_t event)
putsMixerSource(sizeof(TR_TYPE)*FW, y, MIXSRC_FIRST_POT+idx);
uint8_t potType = (g_eeGeneral.potsType & mask) >> shift;
if (potType == POT_TYPE_NONE && i < 2)
potType = 1;
potType = POT_TYPE_POT;
potType = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_TYPE, STR_POTTYPES, potType, 0, POT_TYPE_MAX, attr, event);
if (potType == POT_TYPE_POT && i < 2)
potType = 0;
potType = POT_TYPE_NONE;
g_eeGeneral.potsType &= ~mask;
g_eeGeneral.potsType |= (potType << shift);
break;
File diff suppressed because it is too large Load Diff
+112 -45
View File
@@ -123,13 +123,13 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
else if (DBLKEYS_PRESSED_RGT_UP(in)) {
newval = (i_max > 100 ? 100 : i_max);
#if defined(CPUARM)
if(i_flags & DBLKEYS_1000) newval *= 10;
if (i_flags & DBLKEYS_1000) newval *= 10;
#endif
}
else if (DBLKEYS_PRESSED_LFT_DWN(in)) {
newval = (i_min < -100 ? -100 : i_min);
#if defined(CPUARM)
if(i_flags & DBLKEYS_1000) newval *= 10;
if (i_flags & DBLKEYS_1000) newval *= 10;
#endif
}
else if (DBLKEYS_PRESSED_UP_DWN(in))
@@ -141,7 +141,6 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
#endif
if (dblkey) {
killEvents(KEY_UP);
killEvents(KEY_DOWN);
@@ -165,7 +164,12 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
#endif
#if defined(CPUARM)
do {
newval++;
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
newval+=10;
}
else {
newval++;
}
} while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
if (newval > i_max) {
newval = val;
@@ -185,7 +189,12 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
#endif
#if defined(CPUARM)
do {
newval--;
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
newval-=10;
}
else {
newval--;
}
} while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min);
if (newval < i_min) {
newval = val;
@@ -316,7 +325,7 @@ void title(const pm_char * s)
#if defined(PCBTARANIS)
#define MAXCOL_RAW(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#define MAXCOL(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (uint8_t)-1 : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE)))
#define MAXCOL(row) (MAXCOL_RAW(row) >= HIDDEN_ROW ? MAXCOL_RAW(row) : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE)))
#define COLATTR(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (const uint8_t)0 : (const uint8_t)(MAXCOL_RAW(row) & NAVIGATION_LINE_BY_LINE))
#else
#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
@@ -344,16 +353,21 @@ bool modelHasNotes()
return (f_stat(filename, &info) == FR_OK);
}
void pushModelNotes()
{
char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/";
char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
pushMenuTextView(filename);
}
void onLongMenuPress(const char *result)
{
if (result == STR_VIEW_CHANNELS) {
pushMenu(menuChannelsView);
}
else if (result == STR_VIEW_NOTES) {
char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/";
char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
pushMenuTextView(filename);
pushModelNotes();
}
}
#endif
@@ -585,34 +599,39 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
}
#if defined(CPUARM)
if (l_posVert<1) s_pgOfs=0;
if (l_posVert<1) {
s_pgOfs=0;
}
else if (menuTab && horTab) {
vertpos_t realPosVert = l_posVert;
vertpos_t realPgOfs = s_pgOfs;
vertpos_t realMaxrow = maxrow;
for (vertpos_t i=1; i<=maxrow; i++) {
if (MAXCOL(i) == HIDDEN_ROW) {
realMaxrow--;
if (i < l_posVert)
realPosVert--;
if (i < s_pgOfs)
realPgOfs--;
if (maxrow > LCD_LINES-1) {
while (1) {
vertpos_t line = s_pgOfs+1;
for (int numLines=0; line<=maxrow && numLines<LCD_LINES-1; line++) {
if (MAXCOL(line) != HIDDEN_ROW) {
numLines++;
}
}
int max = line - s_pgOfs - 1;
if (l_posVert > max+s_pgOfs) {
s_pgOfs++;
}
else if (l_posVert < 1+s_pgOfs) {
s_pgOfs--;
}
else {
break;
}
}
}
if (realPosVert>(LCD_LINES-1)+realPgOfs) realPgOfs = realPosVert-(LCD_LINES-1);
else if (realPosVert<1+realPgOfs) realPgOfs = realPosVert-1;
s_pgOfs = realPgOfs;
for (vertpos_t i=1; i<=realPgOfs; i++) {
if (MAXCOL(i) == HIDDEN_ROW) {
s_pgOfs++;
}
}
maxrow = realMaxrow;
}
else {
uint8_t max = menuTab ? LCD_LINES-1 : LCD_LINES-2;
if (l_posVert>max+s_pgOfs) s_pgOfs = l_posVert-max;
else if (l_posVert<1+s_pgOfs) s_pgOfs = l_posVert-1;
if (l_posVert>max+s_pgOfs) {
s_pgOfs = l_posVert-max;
}
else if (l_posVert<1+s_pgOfs) {
s_pgOfs = l_posVert-1;
}
}
#if LCD_W >= 212
@@ -630,8 +649,9 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
m_posHorz = l_posHorz;
if (s_pgOfs > 0) {
l_posVert--;
if (l_posVert == s_pgOfs && CURSOR_NOT_ALLOWED_IN_ROW(l_posVert))
if (l_posVert == s_pgOfs && CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)) {
s_pgOfs = l_posVert-1;
}
}
return true;
}
@@ -1027,7 +1047,6 @@ uint8_t s_warning_info_len;
// uint8_t s_warning_info_att not needed now
uint8_t s_warning_type;
uint8_t s_warning_result = 0;
const pm_char * s_global_warning = NULL;
#if defined(CPUARM)
int16_t s_warning_input_value;
@@ -1112,10 +1131,26 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t
{
lcd_putsColumnLeft(x, y, STR_SWITCH);
putsSwitches(x, y, value, attr);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST, SWSRC_LAST);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_SHORT_LIST, SWSRC_LAST_SHORT_LIST);
return value;
}
#if !defined(CPUM64)
void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr)
{
lcd_putc(x+(value*4*FW)/max, y, '$');
lcd_hline(x, y+3, 5*FW-1, SOLID);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1);
}
#elif defined(GRAPHICS)
void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr)
{
lcd_putc(x+2*FW+(value*FW), y, '$');
lcd_hline(x, y+3, 5*FW-1, SOLID);
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1);
}
#endif
#if defined(GVARS)
#if defined(CPUARM)
int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event)
@@ -1124,16 +1159,19 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m
#endif
{
uint16_t delta = GV_GET_GV1_VALUE(max);
bool invers = (attr & INVERS);
bool invers = (attr & INVERS);
// TRACE("gvarMenuItem(val=%d min=%d max=%d)", value, min, max);
if (invers && event == EVT_KEY_LONG(KEY_ENTER)) {
s_editMode = !s_editMode;
#if defined(CPUARM)
if (attr & PREC1)
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase)*10 : delta);
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_mode)*10 : delta);
else
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_mode) : delta);
#else
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_phase) : delta);
value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, s_perout_flight_mode) : delta);
#endif
eeDirty(EE_MODEL);
}
@@ -1337,7 +1375,15 @@ bool isSourceAvailable(int source)
{
#if defined(PCBTARANIS)
if (source>=MIXSRC_FIRST_INPUT && source<=MIXSRC_LAST_INPUT) {
return ZEXIST(g_model.inputNames[source-MIXSRC_FIRST_INPUT]);
int input = source - MIXSRC_FIRST_INPUT;
for (int i=0; i<MAX_EXPOS; i++) {
ExpoData * expo = expoAddress(i);
if (!EXPO_VALID(expo))
break;
if (expo->chn == input)
return true;
}
return false;
}
#endif
@@ -1372,7 +1418,7 @@ bool isSourceAvailable(int source)
return false;
}
if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_CSW) {
if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_LOGICAL_SWITCH) {
LogicalSwitchData * cs = cswAddress(source-MIXSRC_SW1);
return (cs->func != LS_FUNC_NONE);
}
@@ -1398,12 +1444,20 @@ bool isTelemetrySourceAvailable(int source)
return false;
#endif
#if !defined(RTCLOCK)
if (source == TELEM_TX_TIME)
return false;
#endif
if (source >= TELEM_RESERVE1 && source <= TELEM_RESERVE5)
return false;
if (source >= TELEM_RESERVE6 && source <= TELEM_RESERVE10)
return false;
if (source >= TELEM_RESERVE11 && source <= TELEM_RESERVE15)
return false;
if (source == TELEM_DTE)
return false;
@@ -1421,7 +1475,7 @@ bool isInputSourceAvailable(int source)
if (source>=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH)
return true;
if (source>=MIXSRC_FIRST_PPM && source<=MIXSRC_LAST_PPM)
if (source>=MIXSRC_FIRST_TRAINER && source<=MIXSRC_LAST_TRAINER)
return true;
if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM)
@@ -1465,14 +1519,27 @@ bool isSwitchAvailable(int swtch)
return false;
}
if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) {
LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_CSW);
if (swtch < 0) {
swtch = -swtch;
}
if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) {
LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_LOGICAL_SWITCH);
return (cs->func != LS_FUNC_NONE);
}
return true;
}
bool isThrottleSourceAvailable(int source)
{
#if defined(PCBTARANIS)
if (source == THROTTLE_SOURCE_S3 && !IS_POT_AVAILABLE(POT3))
return false;
#endif
return true;
}
bool isLogicalSwitchFunctionAvailable(int function)
{
return function != LS_FUNC_RANGE;
+19 -3
View File
@@ -138,6 +138,20 @@ void menuStatisticsView(uint8_t event);
void menuStatisticsDebug(uint8_t event);
void menuAboutView(uint8_t event);
#if !defined(CPUM64)
void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr);
#elif defined(GRAPHICS)
void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr);
#define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT)
#else
#define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT)
#endif
#if defined(PCBTARANIS)
void menuMainViewChannelsMonitor(uint8_t event);
void menuChannelsView(uint8_t event);
#endif
#if defined(NAVIGATION_POT1)
extern int16_t p1valdiff;
#else
@@ -165,6 +179,7 @@ extern int8_t s_editMode; // global editmode
#define INCDEC_SWITCH 0x08
#define INCDEC_SOURCE 0x10
#define DBLKEYS_1000 0x20
#define INCDEC_REP10 0x40
// mawrow special values
#define TITLE_ROW ((uint8_t)-1)
@@ -202,6 +217,7 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
#endif
#if defined(CPUARM)
bool isThrottleSourceAvailable(int source);
bool isLogicalSwitchFunctionAvailable(int function);
bool isAssignableFunctionAvailable(int function);
bool isSwitchAvailable(int swtch);
@@ -336,8 +352,6 @@ extern uint8_t s_warning_info_len;
extern uint8_t s_warning_result;
extern uint8_t s_warning_type;
extern const pm_char * s_global_warning;
#define WARNING_LINE_X 16
#define WARNING_LINE_Y 3*FH
#if LCD_W >= 212
@@ -401,6 +415,7 @@ void displayWarning(uint8_t event);
void menuChannelsView(uint8_t event);
void pushMenuTextView(const char *filename);
bool modelHasNotes();
void pushModelNotes();
#endif
#define LABEL(...) (uint8_t)-1
@@ -429,7 +444,8 @@ bool modelHasNotes();
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; }
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
#elif defined(ROTARY_ENCODER_NAVIGATION)
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else m_posHorz = 0; }
void repeatLastCursorMove(uint8_t event);
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else repeatLastCursorMove(event); }
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
#else
void repeatLastCursorMove(uint8_t event);
+59 -54
View File
@@ -58,7 +58,7 @@
#define TIMER2_Y 45
#define TIMERS_R 193
#define REBOOT_X (LCD_W-FW)
#define VSWITCH_X(i) (((i>=NUM_CSW*3/4) ? BITMAP_X+28 : ((i>=NUM_CSW/2) ? BITMAP_X+25 : ((i>=NUM_CSW/4) ? 21 : 18))) + 3*i)
#define VSWITCH_X(i) (((i>=NUM_LOGICAL_SWITCH*3/4) ? BITMAP_X+28 : ((i>=NUM_LOGICAL_SWITCH/2) ? BITMAP_X+25 : ((i>=NUM_LOGICAL_SWITCH/4) ? 21 : 18))) + 3*i)
#define VSWITCH_Y (LCD_H-9)
#define BAR_HEIGHT (31-9)
#define TRIM_LH_X (32+9)
@@ -275,7 +275,7 @@ void displayTopBar()
/* Altitude */
if (g_model.frsky.altitudeDisplayed && TELEMETRY_BARO_ALT_AVAILABLE()) {
LCD_ICON(altitude_icon_x, BAR_Y, ICON_ALTITUDE);
putsTelemetryValue(altitude_icon_x+2*FW-1, BAR_Y+1, TELEMETRY_RELATIVE_BARO_ALT_BP, UNIT_SPEED, LEFT);
putsTelemetryValue(altitude_icon_x+2*FW-1, BAR_Y+1, TELEMETRY_RELATIVE_BARO_ALT_BP, UNIT_DIST, LEFT);
}
}
@@ -305,11 +305,6 @@ void displayTopBar()
x -= 12;
}
/* SD ICON, not really needed
if (sdMounted()) {
LCD_NOTIF_ICON(x, ICON_SD);
} */
/* Audio volume */
if (requiredSpeakerVolume == 0)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER0);
@@ -323,11 +318,7 @@ void displayTopBar()
/* RTC time */
struct gtm t;
gettime(&t);
if (t.tm_sec % 2) {
lcd_putcAtt(BAR_TIME_X+1, BAR_Y+1, ':', 0);
}
lcd_outdezNAtt(BAR_TIME_X+1, BAR_Y+1, t.tm_hour, LEADING0, 2);
lcd_outdezNAtt(BAR_TIME_X+3*FWNUM-1, BAR_Y+1, t.tm_min, LEADING0, 2);
putsTime(BAR_TIME_X+1, BAR_Y+1, t, TIMEBLINK);
/* The background */
lcd_filled_rect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY_DEFAULT|ROUND);
@@ -349,7 +340,7 @@ void displayTimers()
// Main timer
if (g_model.timers[0].mode) {
TimerState & timerState = timersStates[0];
putsTime(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTimer(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTimerMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SMLSIZE);
if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) {
@@ -362,7 +353,7 @@ void displayTimers()
// Second timer
if (g_model.timers[1].mode) {
TimerState & timerState = timersStates[1];
putsTime(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTimer(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTimerMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SMLSIZE);
if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) {
@@ -379,7 +370,7 @@ void displayTimers()
if (g_model.timers[0].mode) {
TimerState & timerState = timersStates[0];
uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0);
putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att);
putsTimer(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att);
putsTimerMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode);
}
}
@@ -460,6 +451,17 @@ void onMainViewMenu(const char *result)
else if (result == STR_RESET_TIMER2) {
resetTimer(1);
}
#if defined(PCBTARANIS)
else if (result == STR_VIEW_NOTES) {
pushModelNotes();
}
else if (result == STR_RESET_SUBMENU) {
MENU_ADD_ITEM(STR_RESET_FLIGHT);
MENU_ADD_ITEM(STR_RESET_TIMER1);
MENU_ADD_ITEM(STR_RESET_TIMER2);
MENU_ADD_ITEM(STR_RESET_TELEMETRY);
}
#endif
#if defined(FRSKY)
else if (result == STR_RESET_TELEMETRY) {
resetTelemetry();
@@ -488,13 +490,8 @@ void menuMainView(uint8_t event)
uint8_t view_base = view & 0x0f;
#endif
uint8_t _event = event;
if (s_global_warning) {
event = 0;
}
switch(event) {
switch(event)
{
case EVT_ENTRY:
killEvents(KEY_EXIT);
killEvents(KEY_UP);
@@ -531,12 +528,24 @@ void menuMainView(uint8_t event)
#if defined(NAVIGATION_MENUS)
case EVT_KEY_CONTEXT_MENU:
killEvents(event);
#if defined(PCBTARANIS)
if (modelHasNotes()) {
MENU_ADD_ITEM(STR_VIEW_NOTES);
}
#endif
#if defined(PCBTARANIS)
MENU_ADD_ITEM(STR_RESET_SUBMENU);
#else
MENU_ADD_ITEM(STR_RESET_TIMER1);
MENU_ADD_ITEM(STR_RESET_TIMER2);
#if defined(FRSKY)
MENU_ADD_ITEM(STR_RESET_TELEMETRY);
#endif
MENU_ADD_ITEM(STR_RESET_FLIGHT);
#endif
MENU_ADD_ITEM(STR_STATISTICS);
#if defined(CPUARM)
MENU_ADD_ITEM(STR_ABOUT_US);
@@ -614,16 +623,13 @@ void menuMainView(uint8_t event)
return;
case EVT_KEY_FIRST(KEY_EXIT):
if (s_global_warning) {
s_global_warning = NULL;
}
#if defined(GVARS) && !defined(PCBSTD)
else if (s_gvar_timer > 0) {
if (s_gvar_timer > 0) {
s_gvar_timer = 0;
}
#endif
#if !defined(PCBTARANIS)
else if (view == VIEW_TIMER2) {
if (view == VIEW_TIMER2) {
resetTimer(1);
}
#endif
@@ -640,7 +646,7 @@ void menuMainView(uint8_t event)
{
// Flight Phase Name
uint8_t phase = s_perout_flight_phase;
uint8_t phase = s_perout_flight_mode;
lcd_putsnAtt(PHASE_X, PHASE_Y, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR|PHASE_FLAGS);
// Model Name
@@ -701,16 +707,22 @@ void menuMainView(uint8_t event)
doMainScreenGraphics();
}
else {
// Custom Switches
uint8_t sw = 0;
for (uint8_t line=0; line<4; line++) {
for (uint8_t col=0; col<8; col++) {
uint8_t x = LCD_W/2+7*FW+col*FW;
uint8_t y = LCD_H/2-7+line*8;
lcd_putcAtt(x, y, sw>=9 ? 'A'+sw-9 : '1'+sw, SMLSIZE);
if (getSwitch(SWSRC_SW1+sw))
lcd_filled_rect(x-1, y-1, 6, 8);
sw++;
// Logical Switches
lcd_puts(TRIM_RH_X - TRIM_LEN/2 + 5, 6*FH-1, "LS 1-32");
for (uint8_t sw=0; sw<NUM_LOGICAL_SWITCH; sw++) {
div_t qr = div(sw, 10);
uint8_t y = 13 + 11 * qr.quot;
uint8_t x = TRIM_RH_X - TRIM_LEN + qr.rem*5 + (qr.rem >= 5 ? 3 : 0);
LogicalSwitchData * cs = cswAddress(sw);
if (cs->func == LS_FUNC_NONE) {
lcd_hline(x, y+6, 4);
lcd_hline(x, y+7, 4);
}
else if (getSwitch(SWSRC_SW1+sw)) {
lcd_filled_rect(x, y, 4, 8);
}
else {
lcd_rect(x, y, 4, 8);
}
}
}
@@ -800,31 +812,31 @@ void menuMainView(uint8_t event)
}
#endif // PCBGRUVIN9X && ROTARY_ENCODERS
// Custom Switches
// Logical Switches
#if defined(PCBSKY9X)
for (uint8_t i=0; i<NUM_CSW; i++) {
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) {
int8_t len = getSwitch(SWSRC_SW1+i) ? BAR_HEIGHT : 1;
uint8_t x = VSWITCH_X(i);
lcd_vline(x-1, VSWITCH_Y-len, len);
lcd_vline(x, VSWITCH_Y-len, len);
}
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2
for (uint8_t i=0; i<NUM_CSW; i++)
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-2) + (i/3>1 ? 3*FW+6 : 0), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0);
#elif defined(PCBGRUVIN9X)
for (uint8_t i=0; i<NUM_CSW; i++)
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-2) + (i/3>1 ? 3*FW : 0), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0);
#elif !defined(PCBSTD)
for (uint8_t i=0; i<NUM_CSW; i++)
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++)
putsSwitches(2*FW-2 + (i/3)*(4*FW-1), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0);
#else
for (uint8_t i=0; i<NUM_CSW; i++)
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++)
putsSwitches(2*FW-2 + (i/3)*(5*FW), 4*FH+1 + (i%3)*FH, SWSRC_SW1+i, getSwitch(SWSRC_SW1+i) ? INVERS : 0);
#endif
}
}
else { // timer2
putsTime(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE);
putsTimer(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE);
putsTimerMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode);
// lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s
}
@@ -837,15 +849,8 @@ void menuMainView(uint8_t event)
}
#endif
if (s_global_warning) {
s_warning = s_global_warning;
displayWarning(_event);
if (!s_warning) s_global_warning = NULL;
s_warning = NULL;
}
#if defined(GVARS) && !defined(PCBSTD)
else if (s_gvar_timer > 0) {
if (s_gvar_timer > 0) {
s_gvar_timer--;
#if LCD_W >= 212
lcd_filled_rect(BITMAP_X, BITMAP_Y, 64, 32, SOLID, ERASE);
@@ -853,13 +858,13 @@ void menuMainView(uint8_t event)
putsStrIdx(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, s_gvar_last+1);
lcd_putsnAtt(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR);
lcd_putsAtt(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("[\010]"), BOLD);
lcd_outdezAtt(BITMAP_X+5*FW+FW/2, BITMAP_Y+2*FH+3, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
lcd_outdezAtt(BITMAP_X+5*FW+FW/2, BITMAP_Y+2*FH+3, GVAR_VALUE(s_gvar_last, s_perout_flight_mode), BOLD);
#else
s_warning = STR_GLOBAL_VAR;
displayBox();
lcd_putsnAtt(16, 5*FH, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR);
lcd_putsAtt(16+7*FW, 5*FH, PSTR("[\010]"), BOLD);
lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_phase), BOLD);
lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, s_perout_flight_mode), BOLD);
s_warning = NULL;
#endif
}
+9 -9
View File
@@ -58,16 +58,16 @@ void menuStatisticsView(uint8_t event)
}
lcd_puts( 1*FW, FH*0, STR_TOTTM1TM2THRTHP);
putsTime( 5*FW+5*FWNUM+1, FH*1, timersStates[0].val, 0, 0);
putsTime( 12*FW+5*FWNUM+1, FH*1, timersStates[1].val, 0, 0);
putsTimer( 5*FW+5*FWNUM+1, FH*1, timersStates[0].val, 0, 0);
putsTimer( 12*FW+5*FWNUM+1, FH*1, timersStates[1].val, 0, 0);
putsTime( 5*FW+5*FWNUM+1, FH*2, s_timeCumThr, 0, 0);
putsTime( 12*FW+5*FWNUM+1, FH*2, s_timeCum16ThrP/16, 0, 0);
putsTimer( 5*FW+5*FWNUM+1, FH*2, s_timeCumThr, 0, 0);
putsTimer( 12*FW+5*FWNUM+1, FH*2, s_timeCum16ThrP/16, 0, 0);
putsTime( 12*FW+5*FWNUM+1, FH*0, s_timeCumTot, 0, 0);
putsTimer( 12*FW+5*FWNUM+1, FH*0, s_timeCumTot, 0, 0);
#if defined(PCBTARANIS)
putsTime(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + sessionTimer, 0, 0);
putsTimer(21*FW+5*FWNUM+1, 0*FH, g_eeGeneral.globalTimer + sessionTimer, 0, 0);
#endif
#if defined(THRTRACE)
@@ -102,7 +102,7 @@ void menuStatisticsDebug(uint8_t event)
switch(event)
{
#if defined(CPUARM)
case EVT_KEY_LONG(KEY_MENU):
case EVT_KEY_LONG(KEY_ENTER):
g_eeGeneral.mAhUsed = 0;
g_eeGeneral.globalTimer = 0;
eeDirty(EE_GENERAL);
@@ -114,7 +114,7 @@ void menuStatisticsDebug(uint8_t event)
AUDIO_KEYPAD_UP();
break;
#endif
case EVT_KEY_FIRST(KEY_MENU):
case EVT_KEY_FIRST(KEY_ENTER):
#if !defined(CPUARM)
g_tmr1Latency_min = 0xff;
g_tmr1Latency_max = 0;
@@ -147,7 +147,7 @@ void menuStatisticsDebug(uint8_t event)
lcd_putsLeft(2*FH, STR_CPU_MAH);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 2*FH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, PREC1);
putsTime(17*FW+5*FWNUM+1, 2*FH, g_eeGeneral.globalTimer + sessionTimer, 0, 0);
putsTimer(17*FW+5*FWNUM+1, 2*FH, g_eeGeneral.globalTimer + sessionTimer, 0, 0);
#endif
#if defined(PCBSKY9X)
+16
View File
@@ -171,6 +171,7 @@ uint8_t barCoord(int16_t value, int16_t min, int16_t max)
void menuTelemetryFrsky(uint8_t event)
{
if (event == EVT_KEY_FIRST(KEY_EXIT)) {
killEvents(event);
chainMenu(menuMainView);
return;
}
@@ -382,6 +383,21 @@ void menuTelemetryFrsky(uint8_t event)
lcd_outdezNAtt(LCD_W, y, TELEMETRY_CELL_VOLTAGE(k), attr, 4);
y += 1*FH;
}
#if defined(PCBTARANIS)
if (frskyData.hub.cellsCount > 6) {
y = 1*FH;
for (uint8_t k=6; k<frskyData.hub.cellsCount && k<12; k++) {
#if defined(GAUGES)
uint8_t attr = (barsThresholds[THLD_CELL] && frskyData.hub.cellVolts[k] < barsThresholds[THLD_CELL]) ? BLINK|PREC2 : PREC2;
#else
uint8_t attr = PREC2;
#endif
lcd_outdezNAtt(LCD_W-3*FW-2, y, TELEMETRY_CELL_VOLTAGE(k), attr, 4);
y += 1*FH;
}
lcd_vline(LCD_W-6*FW-4, 8, 47);
} else
#endif
lcd_vline(LCD_W-3*FW-2, 8, 47);
}
#endif
+10 -2
View File
@@ -37,7 +37,7 @@
#include "../opentx.h"
#define TEXT_FILENAME_MAXLEN 40
#define TEXT_FILE_MAXSIZE 1000
#define TEXT_FILE_MAXSIZE 2048
char s_text_file[TEXT_FILENAME_MAXLEN];
char s_text_screen[LCD_LINES-1][LCD_COLS+1];
@@ -72,15 +72,23 @@ void readTextFile(int & lines_count)
escape_chars[escape-1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
escape = 0;
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
escape = 0;
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
s_text_screen[current_line-s_pgOfs][line_length++] = c;
}
@@ -127,7 +135,7 @@ void menuTextView(uint8_t event)
}
for (int i=0; i<LCD_LINES-1; i++) {
lcd_puts(0, i*FH+FH+1, s_text_screen[i]);
lcd_putsAtt(0, i*FH+FH+1, s_text_screen[i], FIXEDWIDTH);
}
char *title = s_text_file;
+4 -4
View File
@@ -54,20 +54,20 @@ void hapticQueue::heartbeat()
#else
if (buzzTimeLeft > 0) {
buzzTimeLeft--; // time gets counted down
#if defined(PCBSKY9X)
#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS))
hapticOn(g_eeGeneral.hapticStrength * 20);
#else
if (hapticTick-- > 0) {
HAPTIC_ON; // haptic output 'high'
HAPTIC_ON();
}
else {
HAPTIC_OFF; // haptic output 'high'
HAPTIC_OFF();
hapticTick = g_eeGeneral.hapticStrength;
}
#endif
}
else {
HAPTIC_OFF; // haptic output 'high'
HAPTIC_OFF();
if (buzzPause > 0) {
buzzPause--;
}
+10 -5
View File
@@ -37,6 +37,7 @@
#include "opentx.h"
uint8_t s_evt;
struct t_inactivity inactivity = {0};
#if defined(CPUARM)
uint8_t getEvent(bool trim)
@@ -97,7 +98,9 @@ void Key::input(bool val, EnumKeys enuk)
break;
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) {
m_state = 16;
m_cnt = 0;
@@ -108,17 +111,19 @@ void Key::input(bool val, EnumKeys enuk)
case 8:
case 4:
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_cnt = 0;
}
// no break
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;
case KSTATE_PAUSE: //pause
if(m_cnt >= 64) {
if (m_cnt >= 64) {
m_state = 8;
m_cnt = 0;
}
@@ -158,7 +163,7 @@ void clearKeyEvents()
// loop until all keys are up
#if defined(SIMU)
while (keyDown() && main_thread_running) sleep(1/*ms*/);
while (keyDown()) SIMU_SLEEP(1/*ms*/);
#elif defined(PCBSTD) && defined(ROTARY_ENCODER_NAVIGATION) && !defined(TELEMETREZ)
while (keyDown()) { wdt_reset(); rotencPoll(); }
#else
+232
View File
@@ -0,0 +1,232 @@
/*
* 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 IS_KEY_REPT(evt) (((evt)&0xe0) == _MSK_KEY_REPT)
#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
+145 -91
View File
@@ -49,42 +49,6 @@ void lcd_clear()
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 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 ];
#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];
#else
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;
}
#if !defined(BOOT)
unsigned char c_remapped = 0;
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(EXTSTD)
#if defined(BOLD_SPECIFIC_FONT)
if (flags & (DBLSIZE+BOLD)) {
#else
if (flags & DBLSIZE) {
@@ -131,16 +97,16 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
c_remapped = c - 'a' + 42;
else if (c=='_')
c_remapped = 4;
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(EXTSTD)
#if defined(BOLD_SPECIFIC_FONT)
else if (c!=' ')
flags &= ~BOLD;
#endif
#if defined(CPUARM)
else if ((c>= 128) && (flags & DBLSIZE))
if ((c>= 128) && (flags & DBLSIZE))
c_remapped = c - 60;
#endif
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(EXTSTD)
#if defined(BOLD_SPECIFIC_FONT)
}
if (flags & DBLSIZE) {
#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) {
/* each letter consists of ten top bytes followed by
* 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
else {
const uint8_t ym8 = (y & 0x07);
#if defined(BOLD_FONT) && defined(CPUM64) && !defined(EXTSTD)
uint8_t bb = 0;
if (inv) bb = 0xff;
#else
#if defined(BOLD_FONT)
#if defined(BOLD_SPECIFIC_FONT)
if (flags & BOLD) {
q = &font_5x7_B[(c_remapped)*5];
}
#else
uint8_t bb = 0;
if (inv) bb = 0xff;
#endif
#endif
for (int8_t i=0; i<=6; i++) {
uint8_t b = 0;
@@ -307,7 +276,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
continue;
}
#if defined(BOLD_FONT) && defined(CPUM64) && !defined(EXTSTD)
#if defined(BOLD_FONT) && !defined(BOLD_SPECIFIC_FONT)
if (flags & BOLD) {
uint8_t a;
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);
}
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)
{
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:
c = *s;
break;
#if !defined(BOOT)
case ZCHAR:
c = idx2char(*s);
break;
#endif
default:
c = pgm_read_byte(s);
break;
@@ -403,8 +367,14 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
#endif
if (y >= LCD_H) break;
}
#if defined(CPUARM)
else if (c == 0x1D) { // TAB
x |= 0x3F;
x += 1;
}
#endif
else {
x += (c*FW/2); //EXTENDED SPACE
x += (c*FW/2); // EXTENDED SPACE
}
s++;
}
@@ -436,6 +406,14 @@ void lcd_putsLeft(uint8_t y, const pm_char * 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)
{
x+=FWNUM*4+1;
@@ -592,6 +570,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
}
if (neg) lcd_putcAtt(x, y, '-', flags);
}
#endif
#if defined(PCBTARANIS)
void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att)
@@ -813,6 +792,20 @@ void lcd_vline(xcoord_t x, int8_t y, int8_t h)
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)
{
lcd_vlineStip(x, y, h, pat);
@@ -822,6 +815,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);
}
#if !defined(BOOT)
void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att)
{
#if defined(CPUM64)
@@ -840,20 +834,6 @@ void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, L
#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)
void lcdDrawTelemetryTopBar()
{
@@ -862,12 +842,12 @@ void lcdDrawTelemetryTopBar()
putsVBat(16*FW+1,0,att);
if (g_model.timers[0].mode) {
att = (timersStates[0].val<0 ? BLINK : 0);
putsTime(22*FW+5*FWNUM+3, 0, timersStates[0].val, att, att);
putsTimer(22*FW+5*FWNUM+3, 0, timersStates[0].val, att, att);
lcd_putsiAtt(18*FW+2, 1, STR_VTELEMCHNS, TELEM_TM1, SMLSIZE);
}
if (g_model.timers[1].mode) {
att = (timersStates[1].val<0 ? BLINK : 0);
putsTime(31*FW+5*FWNUM+3, 0, timersStates[1].val, att, att);
putsTimer(31*FW+5*FWNUM+3, 0, timersStates[1].val, att, att);
lcd_putsiAtt(27*FW+2, 1, STR_VTELEMCHNS, TELEM_TM2, SMLSIZE);
}
lcd_invert_line(0);
@@ -880,13 +860,25 @@ void lcdDrawTelemetryTopBar()
putsVBat(14*FW,0,att);
if (g_model.timers[0].mode) {
att = (timersStates[0].val<0 ? BLINK : 0);
putsTime(17*FW+5*FWNUM+1, 0, timersStates[0].val, att, att);
putsTimer(17*FW+5*FWNUM+1, 0, timersStates[0].val, att, att);
}
lcd_invert_line(0);
}
#endif
void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2)
#if defined(CPUARM) && defined(RTCLOCK)
void putsTime(xcoord_t x, uint8_t y, struct gtm t, LcdFlags att)
{
LcdFlags att2 = (att & (INVERS|BLINK)) | LEADING0;
lcd_outdezNAtt(x, y, t.tm_hour, att2, 2);
if (!(att&TIMEBLINK) || (t.tm_sec%2)) {
lcd_putcAtt(x, y, ':', att);
}
lcd_outdezNAtt(x+3*FWNUM-2, y, t.tm_min, att2, 2);
}
#endif
void putsTimer(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2)
{
div_t qr;
@@ -984,16 +976,16 @@ void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att)
#if defined(PCBTARANIS)
else if (idx < MIXSRC_SW1)
lcd_putsiAtt(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1, att);
else if (idx <= MIXSRC_LAST_CSW)
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH)
putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
#else
if (idx < MIXSRC_THR)
lcd_putsiAtt(x, y, STR_VSRCRAW, idx, att);
else if (idx < MIXSRC_FIRST_PPM)
else if (idx < MIXSRC_FIRST_TRAINER)
putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1/*+EXTRA_3POS*/), att);
#endif
else if (idx < MIXSRC_CH1)
putsStrIdx(x, y, STR_PPM, idx-MIXSRC_FIRST_PPM+1, att);
putsStrIdx(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
else if (idx <= MIXSRC_LAST_CH) {
putsStrIdx(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
#if defined(PCBTARANIS)
@@ -1037,17 +1029,22 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
if (idx == SWSRC_OFF)
return lcd_putsiAtt(x, y, STR_OFFON, 0, att);
if (idx < 0) {
lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/);
lcd_putcAtt(x-2, y, '!', att);
idx = -idx;
}
#if defined(CPUARM) && defined(FLIGHT_MODES)
if (idx >= SWSRC_FIRST_FLIGHT_MODE)
putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
else
#endif
lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att);
}
#if defined(FLIGHT_MODES)
void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
{
if (idx==0) { lcd_putsiAtt(x, y, STR_MMMINV, 0, att); return; }
if (idx < 0) { lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/); idx = -idx; }
if (idx < 0) { lcd_putcAtt(x-2, y, '!', att); idx = -idx; }
if (att & CONDENSED)
lcd_outdezNAtt(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
else
@@ -1062,12 +1059,12 @@ void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att)
switch (curve.type) {
case CURVE_REF_DIFF:
lcd_putcAtt(x, y, 'D', att);
lcd_outdezAtt(x+FW, y, curve.value, LEFT|att);
GVAR_MENU_ITEM(x+FW, y, curve.value, -100, 100, LEFT|att, 0, 0);
break;
case CURVE_REF_EXPO:
lcd_putcAtt(x, y, 'E', att);
lcd_outdezAtt(x+FW, y, curve.value, LEFT|att);
GVAR_MENU_ITEM(x+FW, y, curve.value, -100, 100, LEFT|att, 0, 0);
break;
case CURVE_REF_FUNC:
@@ -1083,10 +1080,12 @@ void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att)
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
{
if (idx == 0) return lcd_putsiAtt(x, y, STR_MMMINV, 0, att);
if (idx == 0) {
return lcd_putsiAtt(x, y, STR_MMMINV, 0, att);
}
if (idx < 0) {
lcd_putcAtt(x-1*FW, y, '!', att);
lcd_putcAtt(x-3, y, '!', att);
idx = -idx;
}
@@ -1199,10 +1198,20 @@ const pm_uint8_t bchunit_ar[] PROGMEM = {
void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, uint8_t att)
{
switch (channel) {
#if defined(CPUARM) && defined(RTCLOCK)
case TELEM_TX_TIME-1:
{
gtm t;
t.tm_hour = val / 60;
t.tm_min = val % 60;
putsTime(x+2*FWNUM, y, t, att);
break;
}
#endif
case TELEM_TM1-1:
case TELEM_TM2-1:
att &= ~NO_UNIT;
putsTime(x, y, val, att, att);
putsTimer(x, y, val, att, att);
break;
#if defined(FRSKY)
case TELEM_MIN_A1-1:
@@ -1216,7 +1225,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
{
lcdint_t converted_value = applyChannelRatio(channel, val);
if (g_model.frsky.channels[channel].type >= UNIT_RAW) {
converted_value /= 10;
converted_value = div10_and_round(converted_value);
}
else {
#if !defined(PCBTARANIS)
@@ -1224,7 +1233,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
att |= PREC2;
}
else {
converted_value /= 10;
converted_value = div10_and_round(converted_value);
att |= PREC1;
}
#else
@@ -1266,11 +1275,18 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
case TELEM_ACCx-1:
case TELEM_ACCy-1:
case TELEM_ACCz-1:
case TELEM_VSPD-1:
case TELEM_ASPD-1:
putsTelemetryValue(x, y, val, UNIT_RAW, att|PREC2);
break;
case TELEM_VSPEED-1:
putsTelemetryValue(x, y, div10_and_round(val), UNIT_RAW, att|PREC1);
break;
case TELEM_ASPEED-1:
case TELEM_MAX_ASPEED-1:
putsTelemetryValue(x, y, val, UNIT_KTS, att);
break;
#if defined(CPUARM)
case TELEM_SWR-1:
#endif
@@ -1281,7 +1297,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
#if defined(FRSKY_SPORT)
case TELEM_ALT-1:
putsTelemetryValue(x, y, val/10, UNIT_DIST, att|PREC1);
putsTelemetryValue(x, y, div10_and_round(val), UNIT_DIST, att|PREC1);
break;
#elif defined(WS_HOW_HIGH)
case TELEM_ALT-1:
@@ -1304,7 +1320,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
if (channel >= TELEM_MIN_ALT-1 && channel <= TELEM_MAX_ALT-1)
unit = 0;
if (channel == TELEM_HDG-1)
unit = UNIT_HDG;
unit = 3;
putsTelemetryValue(x, y, val, pgm_read_byte(bchunit_ar+unit), att);
break;
}
@@ -1317,7 +1333,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
case TELEM_TM1-1:
case TELEM_TM2-1:
att &= ~NO_UNIT;
putsTime(x, y, val, att, att);
putsTimer(x, y, val, att, att);
break;
case TELEM_TX_VOLTAGE-1:
@@ -1329,7 +1345,45 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
}
#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()
{
lcdSetRefVolt(g_eeGeneral.contrast);
}
#endif // !defined(BOOT)
+23 -5
View File
@@ -43,12 +43,16 @@
#define xcoord_t uint16_t
#define CENTER "\015"
#define CENTER_OFS (7*FW-FW/2)
#define CONTRAST_MIN 0
#define CONTRAST_MAX 45
#else
#define LCD_W 128
#define LCD_H 64
#define xcoord_t uint8_t
#define CENTER
#define CENTER_OFS 0
#define CONTRAST_MIN 10
#define CONTRAST_MAX 45
#endif
#if defined(CPUARM)
@@ -109,6 +113,7 @@
#define SMLSIZE 0x0200
#define TINSIZE 0x0400
#define STREXPANDED 0x0800
#define TIMEBLINK 0x1000
#else
#define MIDSIZE DBLSIZE
#define SMLSIZE 0x00
@@ -149,6 +154,12 @@ extern uint8_t lcdNextPos;
extern volatile uint32_t lcdInputs ;
#endif
#if defined(BOOT)
// TODO quick & dirty :(
typedef const unsigned char pm_uchar;
typedef const char pm_char;
#endif
void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c);
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags mode);
void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags mode);
@@ -168,8 +179,8 @@ void putsStrIdx(xcoord_t x, uint8_t y, const pm_char *str, uint8_t idx, LcdFlags
void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att);
void putsSwitches(xcoord_t x, uint8_t y, int8_t swtch, LcdFlags att=0);
void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att=0);
void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
#if defined(PCBTARANIS)
void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
#if defined(PCBTARANIS) && !defined(BOOT)
void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att);
#endif
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
@@ -192,7 +203,8 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
#define putstime_t int16_t
#endif
void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2);
void putsTime(xcoord_t x, uint8_t y, struct gtm t, LcdFlags att);
void putsTimer(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2);
#define SOLID 0xff
#define DOTTED 0x55
@@ -249,7 +261,11 @@ void lcdRefresh();
const pm_char * bmpLoad(bmp_ptr_t &dest, const char *filename, const xcoord_t width, const uint8_t height);
#endif
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
#if defined(BOOT)
#define BLINK_ON_PHASE (0)
#else
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
#endif
#ifdef SIMU
extern bool lcd_refresh;
@@ -281,5 +297,7 @@ void lcdRefresh();
#define LCD_BYTE_FILTER(p, keep, add) LCD_BYTE_FILTER_PLAN(p, keep, add)
#endif
char * strAppend(char * dest, const char * source);
char * strAppendDate(char * str, bool time=false);
#endif
/*eof*/
+151
View File
@@ -0,0 +1,151 @@
/****************************************************************************
* 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
*
****************************************************************************/
#if !defined(SIMU)
#include <stdint.h>
#if defined(PCBSKY9X)
#include "AT91SAM3S4.h"
#elif defined(PCBTARANIS)
#include "stm32f2xx.h"
#include "stm32f2xx_gpio.h"
#endif
#if defined(PCBTARANIS)
void bwdt_reset()
{
IWDG->KR = 0xAAAA; // reload
}
__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) };
__attribute__ ((section(".bootrodata.*"), used))
#elif defined(PCBSKY9X)
__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
#endif
+7 -22
View File
@@ -95,28 +95,13 @@ const pm_char * openLogs()
len = sizeof(LOGS_PATH) + PSIZE(TR_MODEL) + 2;
}
char * tmp = &filename[len];
#if defined(RTCLOCK)
filename[len] = '-';
struct gtm utm;
gettime(&utm);
div_t qr = div(utm.tm_year+1900, 10);
filename[len+4] = '0' + qr.rem;
qr = div(qr.quot, 10);
filename[len+3] = '0' + qr.rem;
qr = div(qr.quot, 10);
filename[len+2] = '0' + qr.rem;
filename[len+1] = '0' + qr.quot;
filename[len+5] = '-';
qr = div(utm.tm_mon+1, 10);
filename[len+7] = '0' + qr.rem;
filename[len+6] = '0' + qr.quot;
filename[len+8] = '-';
qr = div(utm.tm_mday, 10);
filename[len+10] = '0' + qr.rem;
filename[len+9] = '0' + qr.quot;
tmp = strAppendDate(&filename[len]);
#endif
strcpy_P(&filename[len+11], STR_LOGS_EXT);
strcpy_P(tmp, STR_LOGS_EXT);
result = f_open(&g_oLogFile, filename, FA_OPEN_ALWAYS | FA_WRITE);
if (result != FR_OK) {
@@ -142,7 +127,7 @@ const pm_char * openLogs()
f_puts(TELEMETRY_GPS_SPEED_UNIT, &g_oLogFile);
f_puts("),GPS Alt,Baro Alt(", &g_oLogFile);
f_puts(TELEMETRY_BARO_ALT_UNIT, &g_oLogFile);
f_puts("),Vertical Speed,Temp1,Temp2,RPM,Fuel,Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,Current,Consumption,Vfas,AccelX,AccelY,AccelZ,", &g_oLogFile);
f_puts("),Vertical Speed,Temp1,Temp2,RPM,Fuel," TELEMETRY_CELLS_LABEL "Current,Consumption,Vfas,AccelX,AccelY,AccelZ,", &g_oLogFile);
}
#endif
@@ -197,7 +182,7 @@ void writeLogs()
if (result != NULL) {
if (result != error_displayed) {
error_displayed = result;
s_global_warning = result;
POPUP_WARNING(result);
}
return;
}
@@ -294,7 +279,7 @@ void writeLogs()
if (result<0 && !error_displayed) {
error_displayed = STR_SDCARD_ERROR;
s_global_warning = STR_SDCARD_ERROR;
POPUP_WARNING(STR_SDCARD_ERROR);
}
}
}
+118 -40
View File
@@ -47,6 +47,7 @@ extern "C" {
}
#endif
#define lua_registernumber(L, n, i) (lua_pushnumber(L, (i)), lua_setglobal(L, (n)))
#define lua_registerint(L, n, i) (lua_pushinteger(L, (i)), lua_setglobal(L, (n)))
#define lua_pushtablenil(L, k) (lua_pushstring(L, (k)), lua_pushnil(L), lua_settable(L, -3))
#define lua_pushtableboolean(L, k, v) (lua_pushstring(L, (k)), lua_pushboolean(L, (v)), lua_settable(L, -3))
@@ -89,11 +90,63 @@ static int luaGetTime(lua_State *L)
return 1;
}
static void luaGetValueAndPush(int src)
{
/*
Hint about dividers are taken from putsTelemetryChannel()
*/
if (!TELEMETRY_STREAMING() && src>=MIXSRC_FIRST_TELEM && src<=MIXSRC_LAST_TELEM) {
//telemetry not working, return zero for telemetry sources
lua_pushinteger(L, (int)0);
return;
}
switch (src) {
case MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE:
case MIXSRC_FIRST_TELEM-1+TELEM_VFAS:
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_VFAS:
case MIXSRC_FIRST_TELEM-1+TELEM_CELLS_SUM:
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_CELLS_SUM:
case MIXSRC_FIRST_TELEM-1+TELEM_CURRENT:
case MIXSRC_FIRST_TELEM-1+TELEM_MAX_CURRENT:
case MIXSRC_FIRST_TELEM-1+TELEM_VSPEED:
//theese need to be divided by 10
lua_pushnumber(L, getValue(src)/10.0);
break;
case MIXSRC_FIRST_TELEM-1+TELEM_A1:
case MIXSRC_FIRST_TELEM-1+TELEM_A2:
//convert raw A1/2 values to calibrated values
lua_pushnumber(L, applyChannelRatio(src-(MIXSRC_FIRST_TELEM-1+TELEM_A1), getValue(src))/100.0);
break;
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1:
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_A2:
//convert raw A1/2 values to calibrated values
lua_pushnumber(L, applyChannelRatio(src-(MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1), getValue(src))/100.0);
break;
case MIXSRC_FIRST_TELEM-1+TELEM_CELL:
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_CELL:
case MIXSRC_FIRST_TELEM-1+TELEM_ALT:
case MIXSRC_FIRST_TELEM-1+TELEM_ACCx:
case MIXSRC_FIRST_TELEM-1+TELEM_ACCy:
case MIXSRC_FIRST_TELEM-1+TELEM_ACCz:
//theese need to be divided by 100
lua_pushnumber(L, getValue(src)/100.0);
break;
//TODO: add other values that need special treatment
default:
lua_pushinteger(L, getValue(src));
}
}
static int luaGetValue(lua_State *L)
{
if (lua_isnumber(L, 1)) {
int src = luaL_checkinteger(L, 1);
lua_pushinteger(L, getValue(src));
luaGetValueAndPush(src);
return 1;
}
else {
@@ -102,36 +155,25 @@ static int luaGetValue(lua_State *L)
lua_pushnumber(L, double(frskyData.hub.baroAltitude)/100);
return 1;
}
else if (!strcmp(what, "latitude")) {
if (frskyData.hub.gpsFix)
else if (frskyData.hub.gpsFix) {
if (!strcmp(what, "latitude")) {
lua_pushnumber(L, gpsToDouble(frskyData.hub.gpsLatitudeNS=='S', frskyData.hub.gpsLatitude_bp, frskyData.hub.gpsLatitude_ap));
else
lua_pushnil(L);
return 1;
}
else if (!strcmp(what, "longitude")) {
if (frskyData.hub.gpsFix)
return 1;
}
else if (!strcmp(what, "longitude")) {
lua_pushnumber(L, gpsToDouble(frskyData.hub.gpsLongitudeEW=='W', frskyData.hub.gpsLongitude_bp, frskyData.hub.gpsLongitude_ap));
else
lua_pushnil(L);
return 1;
}
else if (!strcmp(what, "pilot latitude")) {
if (frskyData.hub.gpsFix)
return 1;
}
else if (!strcmp(what, "pilot latitude")) {
lua_pushnumber(L, pilotLatitude);
else
lua_pushnil(L);
return 1;
}
else if (!strcmp(what, "pilot longitude")) {
if (frskyData.hub.gpsFix)
return 1;
}
else if (!strcmp(what, "pilot longitude")) {
lua_pushnumber(L, pilotLongitude);
else
lua_pushnil(L);
return 1;
return 1;
}
}
}
return 0;
}
@@ -142,6 +184,16 @@ static int luaPlayFile(lua_State *L)
return 0;
}
static int luaPlayNumber(lua_State *L)
{
int number = luaL_checkinteger(L, 1);
int unit = luaL_checkinteger(L, 2);
int att = luaL_checkinteger(L, 3);
playNumber(number, unit, att, 0);
return 0;
}
static int luaLcdLock(lua_State *L)
{
lcd_locked = true;
@@ -517,7 +569,7 @@ static int luaModelDeleteMix(lua_State *L)
static int luaModelGetLogicalSwitch(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
if (idx < NUM_CSW) {
if (idx < NUM_LOGICAL_SWITCH) {
LogicalSwitchData * sw = cswAddress(idx);
lua_newtable(L);
lua_pushtablenumber(L, "function", sw->func);
@@ -537,7 +589,7 @@ static int luaModelGetLogicalSwitch(lua_State *L)
static int luaModelSetLogicalSwitch(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
if (idx < NUM_CSW) {
if (idx < NUM_LOGICAL_SWITCH) {
LogicalSwitchData * sw = cswAddress(idx);
luaL_checktype(L, -1, LUA_TTABLE);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
@@ -637,9 +689,9 @@ static int luaModelGetOutput(lua_State *L)
lua_pushtableboolean(L, "symetrical", limit->symetrical);
lua_pushtableboolean(L, "revert", limit->revert);
if (limit->curve)
lua_pushtablenil(L, "curve");
else
lua_pushtablenumber(L, "curve", limit->curve-1);
else
lua_pushtablenil(L, "curve");
}
else {
lua_pushnil(L);
@@ -689,6 +741,29 @@ static int luaModelSetOutput(lua_State *L)
return 0;
}
static int luaModelGetGlobalVariable(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
int phase = luaL_checkunsigned(L, 2);
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS)
lua_pushinteger(L, g_model.phaseData[phase].gvars[idx]);
else
lua_pushnil(L);
return 1;
}
static int luaModelSetGlobalVariable(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
int phase = luaL_checkunsigned(L, 2);
int value = luaL_checkinteger(L, 3);
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_LIMIT && value <= GVAR_LIMIT) {
g_model.phaseData[phase].gvars[idx] = value;
}
return 0;
}
static int luaPopupInput(lua_State *L)
{
uint8_t event = luaL_checkinteger(L, 2);
@@ -797,6 +872,8 @@ static const luaL_Reg modelLib[] = {
{ "setCustomFunction", luaModelSetCustomFunction },
{ "getOutput", luaModelGetOutput },
{ "setOutput", luaModelSetOutput },
{ "getGlobalVariable", luaModelGetGlobalVariable },
{ "setGlobalVariable", luaModelSetGlobalVariable },
{ NULL, NULL } /* sentinel */
};
@@ -824,18 +901,19 @@ void luaInit()
// Init lua
luaL_openlibs(L);
// Push openTX libs
// Push OpenTX libs
lua_registerlib(L, "model", modelLib);
lua_registerlib(L, "lcd", lcdLib);
// Push openTX functions
// Push OpenTX functions
lua_register(L, "getTime", luaGetTime);
lua_register(L, "getVersion", luaGetVersion);
lua_register(L, "getValue", luaGetValue);
lua_register(L, "playFile", luaPlayFile);
lua_register(L, "playNumber", luaPlayNumber);
lua_register(L, "popupInput", luaPopupInput);
// Push openTX constants
// Push OpenTX constants
lua_registerint(L, "DBLSIZE", DBLSIZE);
lua_registerint(L, "MIDSIZE", MIDSIZE);
lua_registerint(L, "SMLSIZE", SMLSIZE);
@@ -844,11 +922,11 @@ void luaInit()
lua_registerint(L, "VALUE", 0);
lua_registerint(L, "SOURCE", 1);
lua_registerint(L, "REPLACE", MLTPX_REP);
lua_registerint(L, "MIX_Rud", MIXSRC_Rud);
lua_registerint(L, "MIX_Ele", MIXSRC_Ele);
lua_registerint(L, "MIX_Thr", MIXSRC_Thr);
lua_registerint(L, "MIX_Ail", MIXSRC_Ail);
lua_registerint(L, "SW_Last", SWSRC_LAST_CSW);
lua_registerint(L, "STICK_RUDDER", MIXSRC_Rud);
lua_registerint(L, "STICK_ELEVATOR", MIXSRC_Ele);
lua_registerint(L, "STICK_THROTTLE", MIXSRC_Thr);
lua_registerint(L, "STICK_AILERON", MIXSRC_Ail);
lua_registerint(L, "SWITCH_LAST", SWSRC_LAST_LOGICAL_SWITCH);
lua_registerint(L, "EVT_MENU_BREAK", EVT_KEY_BREAK(KEY_MENU));
lua_registerint(L, "EVT_PAGE_BREAK", EVT_KEY_BREAK(KEY_PAGE));
lua_registerint(L, "EVT_ENTER_BREAK", EVT_KEY_BREAK(KEY_ENTER));
@@ -1064,12 +1142,12 @@ void luaTask(uint8_t evt)
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
for (int j=0; j<sid.inputsCount; j++) {
if (sid.inputs[j].type == 1)
lua_pushinteger(L, (uint8_t)sd.inputs[j]);
luaGetValueAndPush((uint8_t)sd.inputs[j]);
else
lua_pushinteger(L, sd.inputs[j]);
lua_pushinteger(L, sd.inputs[j] + sid.inputs[j].def);
}
if (lua_pcall(L, sid.inputsCount, sid.outputsCount, 0) == 0) {
for (int j=0; j<sid.outputsCount; j++) {
for (int j=sid.outputsCount-1; j>=0; j--) {
if (!lua_isnumber(L, -1)) {
sid.state = (instructionsPercent > 100 ? SCRIPT_KILLED : SCRIPT_SYNTAX_ERROR);
TRACE("Script %10s disabled", sd.file);
+5 -3
View File
@@ -11,6 +11,8 @@
#include <limits.h>
#include <stddef.h>
#include "debug.h"
#define USE_FATFS
/*
@@ -223,9 +225,9 @@
#define luai_writestringerror(s,p) \
(fprintf(stderr, (s), (p)), fflush(stderr))
#else
#define luai_writestring(s,l)
#define luai_writeline()
#define luai_writestringerror(s,p)
#define luai_writestring(s,l) TRACE_DEBUG_WP("%s", s);
#define luai_writeline() TRACE_DEBUG_WP("\n");
#define luai_writestringerror(s,p) TRACE_DEBUG_WP(s, p);
#endif
+24 -1
View File
@@ -36,6 +36,29 @@
#include "opentx.h"
/*
Division by 10 and rounding or fixed point arithmetic values
Examples:
value -> result
105 -> 11
104 -> 10
-205 -> -21
-204 -> -20
*/
getvalue_t div10_and_round(getvalue_t value)
{
if (value >= 0 ) {
value += 5;
}
else {
value -= 5;
}
return value/10;
}
#if defined(FRSKY)
uint16_t getChannelRatio(uint8_t channel)
{
@@ -114,7 +137,7 @@ void getGpsDistance()
}
#endif
#if defined(CPUARM)
#if defined(CPUARM) && defined(VARIO)
void varioWakeup()
{
+194 -124
View File
@@ -52,15 +52,18 @@
#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 )
#if defined(PCBTARANIS)
#define EEPROM_VER 216
#define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER 215
#elif defined(PCBSKY9X)
#define EEPROM_VER 216
#define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER 215
#elif defined(CPUM2560) || defined(CPUM2561)
#define EEPROM_VER 216
#define EEPROM_VER 216
#define FIRST_CONV_EEPROM_VER EEPROM_VER
#elif defined(CPUM128)
#define EEPROM_VER 216
#define EEPROM_VER 216
#else
#define EEPROM_VER 216
#define EEPROM_VER 216
#endif
#ifndef PACK
@@ -70,58 +73,58 @@
#if defined(PCBTARANIS)
#define MAX_MODELS 60
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
#define MAX_PHASES 9
#define MAX_FLIGHT_MODES 9
#define MAX_MIXERS 64
#define MAX_EXPOS 64
#define NUM_CSW 32 // number of custom switches
#define NUM_LOGICAL_SWITCH 32 // number of custom switches
#define NUM_CFN 64 // number of functions assigned to switches
#define MAX_SCRIPTS 7
#define MAX_INPUTS 32
#define NUM_PPM 16
#define NUM_TRAINER 16
#define NUM_POTS 5
#define NUM_XPOTS 3
#elif defined(CPUARM)
#define MAX_MODELS 60
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
#define MAX_PHASES 9
#define MAX_FLIGHT_MODES 9
#define MAX_MIXERS 64
#define MAX_EXPOS 32
#define NUM_CSW 32 // number of custom switches
#define NUM_CFN 64 // number of functions assigned to switches
#define NUM_PPM 16
#define NUM_LOGICAL_SWITCH 32 // number of custom switches
#define NUM_CFN 64 // number of functions assigned to switches
#define NUM_TRAINER 16
#define NUM_POTS 3
#define NUM_XPOTS 0
#elif defined(CPUM2560) || defined(CPUM2561)
#define MAX_MODELS 30
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
#define MAX_PHASES 6
#define MAX_FLIGHT_MODES 6
#define MAX_MIXERS 32
#define MAX_EXPOS 16
#define NUM_CSW 15 // number of custom switches
#define NUM_LOGICAL_SWITCH 15 // number of custom switches
#define NUM_CFN 24 // number of functions assigned to switches
#define NUM_PPM 8
#define NUM_TRAINER 8
#define NUM_POTS 3
#define NUM_XPOTS 0
#elif defined(CPUM128)
#define MAX_MODELS 30
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
#define MAX_PHASES 5
#define MAX_FLIGHT_MODES 5
#define MAX_MIXERS 32
#define MAX_EXPOS 14
#define NUM_CSW 15 // number of custom switches
#define NUM_LOGICAL_SWITCH 15 // number of custom switches
#define NUM_CFN 24 // number of functions assigned to switches
#define NUM_PPM 8
#define NUM_TRAINER 8
#define NUM_POTS 3
#define NUM_XPOTS 0
#else
#define MAX_MODELS 16
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
#define MAX_PHASES 5
#define MAX_FLIGHT_MODES 5
#define MAX_MIXERS 32
#define MAX_EXPOS 14
#define NUM_CSW 12 // number of custom switches
#define NUM_LOGICAL_SWITCH 12 // number of custom switches
#define NUM_CFN 16 // number of functions assigned to switches
#define NUM_PPM 8
#define NUM_TRAINER 8
#define NUM_POTS 3
#define NUM_XPOTS 0
#endif
@@ -277,7 +280,8 @@ enum uartModes {
#define EXTRA_GENERAL_FIELDS \
EXTRA_GENERAL_FIELDS_ARM \
uint8_t uart3Mode; \
uint8_t potsType;
uint8_t potsType; \
uint8_t backlightColor;
#elif defined(CPUARM)
#define EXTRA_GENERAL_FIELDS EXTRA_GENERAL_FIELDS_ARM
#elif defined(PXX)
@@ -337,10 +341,12 @@ enum BacklightMode {
e_backlight_mode_on
};
#if defined(FSPLASH) || defined(XSPLASH)
#if defined(FSPLASH)
#define SPLASH_MODE uint8_t splashMode:3
#elif defined(PCBTARANIS)
#define SPLASH_MODE int8_t splashMode:3
#else
#define SPLASH_MODE uint8_t splashMode:1; uint8_t spare4:2
#define SPLASH_MODE uint8_t splashMode:1; uint8_t splashSpare:2
#endif
#define XPOTS_MULTIPOS_COUNT 6
@@ -358,6 +364,18 @@ PACK(typedef struct {
int16_t spanPos;
}) CalibData;
#if defined(PCBSTD)
#define N_PCBSTD_FIELD(x)
#else
#define N_PCBSTD_FIELD(x) x;
#endif
#if defined(PCBTARANIS)
#define N_TARANIS_FIELD(x)
#else
#define N_TARANIS_FIELD(x) x;
#endif
#define ALTERNATE_VIEW 0x10
PACK(typedef struct t_EEGeneral {
uint8_t version;
@@ -390,7 +408,8 @@ PACK(typedef struct t_EEGeneral {
uint8_t templateSetup; // RETA order for receiver channels
int8_t PPM_Multiplier;
int8_t hapticLength;
uint8_t reNavigation; // not used on STOCK board
N_PCBSTD_FIELD( uint8_t reNavigation)
N_TARANIS_FIELD(uint8_t stickReverse)
int8_t beepLength:3;
uint8_t hapticStrength:3;
uint8_t gpsFormat:1;
@@ -439,36 +458,37 @@ PACK(typedef struct t_CurveRef {
#endif
#if defined(PCBTARANIS)
PACK(typedef struct t_ExpoData {
PACK(typedef struct {
uint8_t srcRaw;
uint16_t scale;
uint8_t chn;
int8_t swtch;
uint16_t phases;
int8_t weight;
int8_t carryTrim;
int8_t carryTrim:6;
uint8_t mode:2;
char name[LEN_EXPOMIX_NAME];
int8_t offset;
CurveRef curve;
uint8_t spare;
}) ExpoData;
#define MIN_EXPO_WEIGHT -100
#define EXPO_VALID(ed) ((ed)->srcRaw)
#define EXPO_MODE_ENABLE(ed, v) (true)
#define EXPO_VALID(ed) ((ed)->mode)
#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2)))
#elif defined(CPUARM)
PACK(typedef struct t_ExpoData {
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn;
PACK(typedef struct {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn:4;
uint8_t curveMode:2;
int8_t swtch;
uint16_t phases;
int8_t weight;
uint8_t curveMode;
char name[LEN_EXPOMIX_NAME];
int8_t curveParam;
}) ExpoData;
#define MIN_EXPO_WEIGHT 0
#define EXPO_VALID(ed) ((ed)->mode)
#define EXPO_MODE_ENABLE(ed, v) ((v<0 && (ed->mode&1)) || (v>=0 && (ed->mode&2)))
#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2)))
#elif defined(CPUM2560) || defined(CPUM2561)
PACK(typedef struct t_ExpoData {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
@@ -482,7 +502,7 @@ PACK(typedef struct t_ExpoData {
}) ExpoData;
#define MIN_EXPO_WEIGHT 0
#define EXPO_VALID(ed) ((ed)->mode)
#define EXPO_MODE_ENABLE(ed, v) ((v<0 && (ed->mode&1)) || (v>=0 && (ed->mode&2)))
#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2)))
#else
PACK(typedef struct t_ExpoData {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
@@ -495,19 +515,23 @@ PACK(typedef struct t_ExpoData {
}) ExpoData;
#define MIN_EXPO_WEIGHT 0
#define EXPO_VALID(ed) ((ed)->mode)
#define EXPO_MODE_ENABLE(ed, v) ((v<0 && (ed->mode&1)) || (v>=0 && (ed->mode&2)))
#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2)))
#endif
#if defined(CPUARM)
#if defined(PCBTARANIS)
#define limit_min_max_t int16_t
#define LIMIT_MAX(lim) (GV_IS_GV_VALUE(lim->max+1000, 0, 1250) ? GET_GVAR(lim->max+1000, 0, 125, s_perout_flight_phase)*10 : lim->max+1000)
#define LIMIT_MIN(lim) (GV_IS_GV_VALUE(lim->min-1000, -1250, 0) ? GET_GVAR(lim->min-1000, -125, 0, s_perout_flight_phase)*10 : lim->min-1000)
#define LIMIT_OFS(lim) (GV_IS_GV_VALUE(lim->offset, -1000, 1000) ? GET_GVAR(lim->offset, -100, 100, s_perout_flight_phase)*10 : lim->offset)
#define LIMIT_EXT_PERCENT 150
#define LIMIT_EXT_MAX (LIMIT_EXT_PERCENT*10)
#define LIMIT_MAX(lim) (GV_IS_GV_VALUE(lim->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX) ? GET_GVAR(lim->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, s_perout_flight_mode)*10 : lim->max+1000)
#define LIMIT_MIN(lim) (GV_IS_GV_VALUE(lim->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX) ? GET_GVAR(lim->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, s_perout_flight_mode)*10 : lim->min-1000)
#define LIMIT_OFS(lim) (GV_IS_GV_VALUE(lim->offset, -1000, 1000) ? GET_GVAR(lim->offset, -1000, 1000, s_perout_flight_mode)*10 : lim->offset)
#define LIMIT_MAX_RESX(lim) calc1000toRESX(LIMIT_MAX(lim))
#define LIMIT_MIN_RESX(lim) calc1000toRESX(LIMIT_MIN(lim))
#define LIMIT_OFS_RESX(lim) calc1000toRESX(LIMIT_OFS(lim))
#else
#define limit_min_max_t int8_t
#define LIMIT_EXT_PERCENT 125
#define LIMIT_EXT_MAX LIMIT_EXT_PERCENT
#define LIMIT_MAX(lim) (lim->max+100)
#define LIMIT_MIN(lim) (lim->min-100)
#define LIMIT_OFS(lim) (lim->offset)
@@ -540,30 +564,26 @@ PACK(typedef struct t_LimitData {
#define MLTPX_REP 2
#if defined(CPUARM)
// highest bit used for small values in mix 128 --> 8 bit is enough
#define GV1_SMALL 128
// highest bit used for large values in mix 4096 --> 12 bits is used (type for weight and offset has even 16 bits)
#define GV1_LARGE 4096
// the define GV1_LARGE marks the highest bit value used for this variables
// because this would give too big numbers for ARM, we limit it further for offset and weight
// must be smaller than GV1_LARGE - RESERVE_RANGE_FOR_GVARS -1
#define GV1_SMALL 128
#define GV1_LARGE 4096
#define GV_RANGE_WEIGHT 500
#define GV_RANGE_OFFSET 500
#define DELAY_STEP 10
#define SLOW_STEP 10
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
#define DELAY_STEP 10
#define SLOW_STEP 10
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
#if defined(PCBTARANIS)
PACK(typedef struct t_MixData {
PACK(typedef struct {
uint8_t destCh;
uint16_t phases;
uint8_t mltpx; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t carryTrim:1;
uint8_t spare1:5;
int16_t weight;
int8_t swtch;
CurveRef curve;
uint8_t mixWarn:4; // mixer warning
uint8_t srcVariant:4;
uint8_t mixWarn:4; // mixer warning
uint8_t spare2:4;
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp;
@@ -571,11 +591,12 @@ PACK(typedef struct t_MixData {
uint8_t srcRaw;
int16_t offset;
char name[LEN_EXPOMIX_NAME];
uint8_t spare;
uint8_t spare3;
}) MixData;
#else
PACK(typedef struct t_MixData {
uint8_t destCh;
PACK(typedef struct {
uint8_t destCh:4;
uint8_t mixWarn:4; // mixer warning
uint16_t phases;
uint8_t curveMode:1;
uint8_t noExpo:1;
@@ -585,8 +606,6 @@ PACK(typedef struct t_MixData {
int16_t weight;
int8_t swtch;
int8_t curveParam;
uint8_t mixWarn:4; // mixer warning
uint8_t srcVariant:4;
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp;
@@ -673,7 +692,7 @@ PACK(typedef struct t_MixData {
PACK( union u_gvarint_t {
struct {
int8_t lo;
uint8_t hi;
uint8_t hi;
} bytes_t;
int16_t word;
@@ -740,7 +759,7 @@ enum LogicalSwitchesFunctions {
#define MAX_LS_DELAY 250 /*25s*/
#define MAX_LS_ANDSW SWSRC_LAST
typedef int16_t ls_telemetry_value_t;
PACK(typedef struct t_LogicalSwitchData { // Custom Switches data
PACK(typedef struct t_LogicalSwitchData { // Logical Switches data
int8_t v1;
int16_t v2;
int16_t v3;
@@ -752,7 +771,7 @@ PACK(typedef struct t_LogicalSwitchData { // Custom Switches data
#else
typedef uint8_t ls_telemetry_value_t;
#define MAX_LS_ANDSW 15
PACK(typedef struct t_LogicalSwitchData { // Custom Switches data
PACK(typedef struct t_LogicalSwitchData { // Logical Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func:4;
@@ -820,10 +839,16 @@ enum Functions {
#define IS_ADJUST_GV_FUNC(func) (0)
#endif
#if defined(VOICE)
#define HAS_REPEAT_PARAM(func) (func == FUNC_PLAY_SOUND || (func >= FUNC_PLAY_TRACK && func <= FUNC_PLAY_VALUE))
#if defined(HAPTIC)
#define IS_HAPTIC_FUNC(func) (func == FUNC_HAPTIC)
#else
#define HAS_REPEAT_PARAM(func) (func == FUNC_PLAY_SOUND)
#define IS_HAPTIC_FUNC(func) (0)
#endif
#if defined(VOICE)
#define HAS_REPEAT_PARAM(func) (func == FUNC_PLAY_SOUND || (func >= FUNC_PLAY_TRACK && func <= FUNC_PLAY_VALUE) || IS_HAPTIC_FUNC(func))
#else
#define HAS_REPEAT_PARAM(func) (func == FUNC_PLAY_SOUND || IS_HAPTIC_FUNC(func))
#endif
enum ResetFunctionParam {
@@ -860,21 +885,21 @@ PACK(typedef struct t_CustomFnData { // Function Switches data
int8_t swtch;
uint8_t func;
PACK(union {
struct {
PACK(struct {
char name[LEN_CFN_NAME];
} play;
}) play;
struct {
PACK(struct {
int16_t val;
uint8_t mode;
uint8_t param;
int16_t spare2;
} all;
}) all;
struct {
PACK(struct {
int32_t val1;
int16_t val2;
} clear;
}) clear;
});
uint8_t active;
}) CustomFnData;
@@ -887,30 +912,30 @@ PACK(typedef struct t_CustomFnData { // Function Switches data
#define CFN_TIMER_INDEX(p) ((p)->all.param)
#define CFN_PLAY_REPEAT(p) ((p)->active)
#define CFN_PLAY_REPEAT_MUL 1
#define CFN_PLAY_REPEAT_NOSTART 0x3F
#define CFN_PLAY_REPEAT_NOSTART 0xFF
#define CFN_GVAR_MODE(p) ((p)->all.mode)
#define CFN_PARAM(p) ((p)->all.val)
#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)
#define CFN_GVAR_CST_MAX GVAR_LIMIT
#else
PACK(typedef struct t_CustomFnData {
PACK(union {
struct {
int8_t swtch:6;
uint16_t func:4;
uint8_t mode:2;
uint8_t param:3;
uint8_t active:1;
} gvar;
PACK(struct {
int16_t swtch:6;
uint16_t func:4;
uint16_t mode:2;
uint16_t param:3;
uint16_t active:1;
}) gvar;
struct {
int8_t swtch:6;
uint16_t func:4;
uint8_t param:4;
uint8_t spare:1;
uint8_t active:1;
} all;
PACK(struct {
int16_t swtch:6;
uint16_t func:4;
uint16_t param:4;
uint16_t spare:1;
uint16_t active:1;
}) all;
});
uint8_t value;
}) CustomFnData;
#define CFN_SWITCH(p) ((p)->all.swtch)
@@ -924,6 +949,7 @@ PACK(typedef struct t_CustomFnData {
#define CFN_GVAR_MODE(p) ((p)->gvar.mode)
#define CFN_PARAM(p) ((p)->value)
#define CFN_RESET(p) ((p)->all.active = 0, CFN_PARAM(p) = 0)
#define CFN_GVAR_CST_MAX 125
#endif
enum TelemetryUnit {
@@ -976,6 +1002,14 @@ PACK(typedef struct t_FrSkyChannelData {
enum TelemetrySource {
TELEM_NONE,
TELEM_TX_VOLTAGE,
#if defined(CPUARM)
TELEM_TX_TIME,
TELEM_RESERVE1,
TELEM_RESERVE2,
TELEM_RESERVE3,
TELEM_RESERVE4,
TELEM_RESERVE5,
#endif
TELEM_TM1,
TELEM_TM2,
#if defined(CPUARM)
@@ -1010,15 +1044,15 @@ enum TelemetrySource {
TELEM_ACCy,
TELEM_ACCz,
TELEM_HDG,
TELEM_VSPD,
TELEM_ASPD,
TELEM_VSPEED,
TELEM_ASPEED,
TELEM_DTE,
#if defined(CPUARM)
TELEM_RESERVE1,
TELEM_RESERVE2,
TELEM_RESERVE3,
TELEM_RESERVE4,
TELEM_RESERVE5,
TELEM_RESERVE6,
TELEM_RESERVE7,
TELEM_RESERVE8,
TELEM_RESERVE9,
TELEM_RESERVE10,
#endif
TELEM_MIN_A1,
TELEM_MIN_A2,
@@ -1033,17 +1067,18 @@ enum TelemetrySource {
TELEM_MAX_T2,
TELEM_MAX_SPEED,
TELEM_MAX_DIST,
TELEM_MAX_ASPEED,
TELEM_MIN_CELL,
TELEM_MIN_CELLS_SUM,
TELEM_MIN_VFAS,
TELEM_MAX_CURRENT,
TELEM_MAX_POWER,
#if defined(CPUARM)
TELEM_RESERVE6,
TELEM_RESERVE7,
TELEM_RESERVE8,
TELEM_RESERVE9,
TELEM_RESERVE10,
TELEM_RESERVE11,
TELEM_RESERVE12,
TELEM_RESERVE13,
TELEM_RESERVE14,
TELEM_RESERVE15,
#endif
TELEM_ACC,
TELEM_GPS_TIME,
@@ -1112,18 +1147,24 @@ enum FrskyUsrProtocols {
USR_PROTO_LAST = USR_PROTO_WS_HOW_HIGH,
};
enum FrskySource {
FRSKY_SOURCE_NONE,
FRSKY_SOURCE_A1,
FRSKY_SOURCE_A2,
FRSKY_SOURCE_FAS,
FRSKY_SOURCE_CELLS,
enum FrskyCurrentSource {
FRSKY_CURRENT_SOURCE_NONE,
FRSKY_CURRENT_SOURCE_A1,
FRSKY_CURRENT_SOURCE_A2,
FRSKY_CURRENT_SOURCE_FAS,
};
enum FrskyVoltsSource {
FRSKY_VOLTS_SOURCE_A1,
FRSKY_VOLTS_SOURCE_A2,
FRSKY_VOLTS_SOURCE_FAS,
FRSKY_VOLTS_SOURCE_CELLS,
};
#if defined(CPUARM)
#define MAX_FRSKY_SCREENS 3
PACK(typedef struct t_FrSkyData {
FrSkyChannelData channels[2];
FrSkyChannelData channels[4];
uint8_t usrProto; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh, 3=Halcyon
uint8_t voltsSource:7;
uint8_t altitudeDisplayed:1;
@@ -1141,8 +1182,8 @@ PACK(typedef struct t_FrSkyData {
uint16_t storedMah:15;
int8_t fasOffset;
}) FrSkyData;
#define MIN_BLADES -1 // 1 blade
#define MAX_BLADES 3 // 5 blades
#define MIN_BLADES -1 // 1 blade
#define MAX_BLADES 126 // 128 blades
#else
#define MAX_FRSKY_SCREENS 2
PACK(typedef struct t_FrSkyData {
@@ -1175,6 +1216,7 @@ PACK(typedef struct t_MavlinkData {
#endif
enum SwashType {
SWASH_TYPE_NONE,
SWASH_TYPE_120,
SWASH_TYPE_120X,
SWASH_TYPE_140,
@@ -1212,7 +1254,7 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
#define NUM_ROTARY_ENCODERS_EXTRA 2
#define NUM_ROTARY_ENCODERS (2+NUM_ROTARY_ENCODERS_EXTRA)
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[2];
#define ROTARY_ENCODER_ARRAY_EXTRA int16_t rotaryEncodersExtra[MAX_PHASES][NUM_ROTARY_ENCODERS_EXTRA];
#define ROTARY_ENCODER_ARRAY_EXTRA int16_t rotaryEncodersExtra[MAX_FLIGHT_MODES][NUM_ROTARY_ENCODERS_EXTRA];
#elif defined(CPUM2560) && ROTARY_ENCODERS <= 2
#define NUM_ROTARY_ENCODERS_EXTRA 0
#define NUM_ROTARY_ENCODERS 2
@@ -1337,8 +1379,8 @@ enum SwitchSources {
SWSRC_REb,
#endif
SWSRC_FIRST_CSW,
SWSRC_SW1 = SWSRC_FIRST_CSW,
SWSRC_FIRST_LOGICAL_SWITCH,
SWSRC_SW1 = SWSRC_FIRST_LOGICAL_SWITCH,
SWSRC_SW2,
SWSRC_SW3,
SWSRC_SW4,
@@ -1350,13 +1392,24 @@ enum SwitchSources {
SWSRC_SWA,
SWSRC_SWB,
SWSRC_SWC,
SWSRC_LAST_CSW = SWSRC_SW1+NUM_CSW-1,
SWSRC_LAST_LOGICAL_SWITCH = SWSRC_FIRST_LOGICAL_SWITCH+NUM_LOGICAL_SWITCH-1,
SWSRC_ON,
#if defined(CPUARM)
SWSRC_FIRST_FLIGHT_MODE,
SWSRC_LAST_FLIGHT_MODE = SWSRC_FIRST_FLIGHT_MODE+MAX_FLIGHT_MODES-1,
#endif
SWSRC_COUNT,
SWSRC_OFF = -SWSRC_ON,
SWSRC_FIRST = SWSRC_OFF,
SWSRC_LAST = SWSRC_ON
SWSRC_LAST = SWSRC_COUNT-1,
SWSRC_FIRST = -SWSRC_LAST,
SWSRC_LAST_SHORT_LIST = SWSRC_LAST_LOGICAL_SWITCH,
SWSRC_FIRST_SHORT_LIST = -SWSRC_LAST_SHORT_LIST,
};
enum MixSources {
@@ -1443,16 +1496,16 @@ enum MixSources {
MIXSRC_GEA,
MIXSRC_TRN,
#endif
MIXSRC_FIRST_CSW,
MIXSRC_SW1 = MIXSRC_FIRST_CSW,
MIXSRC_FIRST_LOGICAL_SWITCH,
MIXSRC_SW1 = MIXSRC_FIRST_LOGICAL_SWITCH,
MIXSRC_SW9 = MIXSRC_SW1 + 8,
MIXSRC_SWA,
MIXSRC_SWB,
MIXSRC_SWC,
MIXSRC_LAST_CSW = MIXSRC_FIRST_CSW+NUM_CSW-1,
MIXSRC_LAST_LOGICAL_SWITCH = MIXSRC_FIRST_LOGICAL_SWITCH+NUM_LOGICAL_SWITCH-1,
MIXSRC_FIRST_PPM,
MIXSRC_LAST_PPM = MIXSRC_FIRST_PPM+NUM_PPM-1,
MIXSRC_FIRST_TRAINER,
MIXSRC_LAST_TRAINER = MIXSRC_FIRST_TRAINER+NUM_TRAINER-1,
MIXSRC_FIRST_CH,
MIXSRC_CH1 = MIXSRC_FIRST_CH,
@@ -1574,7 +1627,8 @@ enum FailsafeModes {
FAILSAFE_HOLD,
FAILSAFE_CUSTOM,
FAILSAFE_NOPULSES,
FAILSAFE_LAST = FAILSAFE_NOPULSES
FAILSAFE_RECEIVER,
FAILSAFE_LAST = FAILSAFE_RECEIVER
};
#if defined(FRSKY) || !defined(PCBSTD)
@@ -1605,6 +1659,22 @@ PACK(typedef struct {
#define AVR_FIELD(x) x;
#endif
enum ThrottleSources {
THROTTLE_SOURCE_THR,
#if defined(PCBTARANIS)
THROTTLE_SOURCE_S1,
THROTTLE_SOURCE_S2,
THROTTLE_SOURCE_S3,
THROTTLE_SOURCE_LS,
THROTTLE_SOURCE_RS,
#else
THROTTLE_SOURCE_P1,
THROTTLE_SOURCE_P2,
THROTTLE_SOURCE_P3,
#endif
THROTTLE_SOURCE_CH1,
};
PACK(typedef struct t_ModelData {
ModelHeader header;
TimerData timers[MAX_TIMERS];
@@ -1628,10 +1698,10 @@ PACK(typedef struct t_ModelData {
CURVDATA curves[MAX_CURVES];
int8_t points[NUM_POINTS];
LogicalSwitchData customSw[NUM_CSW];
LogicalSwitchData customSw[NUM_LOGICAL_SWITCH];
CustomFnData funcSw[NUM_CFN];
SwashRingData swashR;
PhaseData phaseData[MAX_PHASES];
PhaseData phaseData[MAX_FLIGHT_MODES];
AVR_FIELD(int8_t ppmFrameLength) // 0=22.5ms (10ms-30ms) 0.5ms increments
uint8_t thrTraceSrc;
+424 -217
View File
File diff suppressed because it is too large Load Diff
+40 -217
View File
@@ -72,6 +72,12 @@
#define IF_CPUARM(x)
#endif
#if defined(VARIO) && defined(CPUARM)
#define IF_VARIO_CPUARM(x) x,
#else
#define IF_VARIO_CPUARM(x)
#endif
#if defined(LUA)
#define IF_LUA(x) x,
#else
@@ -204,6 +210,12 @@
#define IF_GVARS(x)
#endif
#if defined(PCBTARANIS) && defined(REVPLUS)
#define IF_REVPLUS(x) x,
#else
#define IF_REVPLUS(x)
#endif
#if ROTARY_ENCODERS > 0
#define ROTARY_ENCODER_NAVIGATION
#endif
@@ -234,13 +246,15 @@
#if !defined(NOINLINE)
#define NOINLINE
#endif
#define CONVERT_PTR(x) ((uint32_t)(uint64_t)(x))
#define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x))
#define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x))
char *convertSimuPath(const char *path);
#else
#define FORCEINLINE inline __attribute__ ((always_inline))
#define NOINLINE __attribute__ ((noinline))
#define SIMU_SLEEP(x)
#define CONVERT_PTR(x) ((uint32_t)(x))
#define CONVERT_PTR_UINT(x) ((uint32_t)(x))
#define CONVERT_UINT_PTR(x) ((uint32_t *)(x))
#define convertSimuPath(x) (x)
#endif
@@ -297,83 +311,6 @@ extern void boardInit();
#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)
#define NUM_SWITCHES 8
@@ -587,35 +524,6 @@ extern uint8_t stickMode;
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 {
CURVE_NONE,
CURVE_X_GT0,
@@ -629,78 +537,18 @@ enum BaseCurves {
#define THRCHK_DEADBAND 16
#if defined(FSPLASH) || defined(XSPLASH)
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03)))
#if defined(PCBTARANIS)
#define SPLASH_NEEDED() (g_eeGeneral.splashMode != 3)
#else
#define SPLASH_TIMEOUT (4*100) // 4 seconds
#define SPLASH_NEEDED() (!IS_DSM2_PROTOCOL(g_model.protocol) && !g_eeGeneral.splashMode)
#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)
#if defined(FSPLASH)
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03)))
#elif defined(PCBTARANIS)
#define SPLASH_TIMEOUT (g_eeGeneral.splashMode==-4 ? 1500 : (g_eeGeneral.splashMode<=0 ? (400-g_eeGeneral.splashMode*200) : (400-g_eeGeneral.splashMode*100)))
#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
#define SPLASH_TIMEOUT (4*100) // 4 seconds
#endif
#if defined(PCBTARANIS)
@@ -734,6 +582,7 @@ struct t_inactivity
uint16_t counter;
uint8_t sum;
};
extern struct t_inactivity inactivity;
#if defined(PXX)
@@ -748,31 +597,14 @@ extern uint8_t pxxFlag[NUM_MODULES];
#define ZCHAR_MAX (LEN_STD_CHARS + LEN_SPECIAL_CHARS)
char idx2char(int8_t idx);
#if defined(CPUARM)
#if defined(CPUARM) || defined(SIMU)
int8_t char2idx(char c);
void str2zchar(char *dest, const char *src, int size);
void zchar2str(char *dest, const char *src, int size);
#endif
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);
#else
uint8_t getEvent();
#endif
uint8_t keyDown();
enum PowerState {
e_power_on,
e_power_trainer,
e_power_usb,
e_power_off
};
#include "keys.h"
#include "pwr.h"
bool switchState(EnumKeys enuk);
uint8_t trimDown(uint8_t idx);
@@ -821,7 +653,7 @@ enum StartupWarningStates {
#define FORCE_INDIRECT(ptr) __asm__ __volatile__ ("" : "=e" (ptr) : "0" (ptr))
#endif
extern uint8_t s_perout_flight_phase;
extern uint8_t s_perout_flight_mode;
#if defined(CPUARM)
#define bitfield_channels_t uint32_t
@@ -907,12 +739,13 @@ void setTrimValue(uint8_t phase, uint8_t idx, int trim);
#if defined(CPUARM)
#define GV_GET_GV1_VALUE(max) ( (max<=GV_RANGESMALL && min>=GV_RANGESMALL_NEG) ? GV1_SMALL : GV1_LARGE )
#define GV_INDEX_CALCULATION(x,max) ( (max<=GV_RANGESMALL && min>=GV_RANGESMALL_NEG) ? (uint8_t) x-GV1_SMALL : ((x&(GV1_LARGE*2-1))-GV1_LARGE) )
#define GV_IS_GV_VALUE(x,min,max) ( (max>GV1_SMALL || min<-GV1_SMALL) ? (x>GV_RANGELARGE || x<GV_RANGELARGE_NEG) : (x>max) || (x<min) )
#else
#define GV_GET_GV1_VALUE(max) ( (max<=GV_RANGESMALL) ? GV1_SMALL : GV1_LARGE )
#define GV_INDEX_CALCULATION(x,max) ( (max<=GV1_SMALL) ? (uint8_t) x-GV1_SMALL : ((x&(GV1_LARGE*2-1))-GV1_LARGE) )
#define GV_IS_GV_VALUE(x,min,max) ( (x>max) || (x<min) )
#endif
#define GV_IS_GV_VALUE(x,min,max) ( (x>max) || (x<min) )
#define GV_INDEX_CALC_DELTA(x,delta) ((x&(delta*2-1)) - delta)
#define GV_CALC_VALUE_IDX_POS(idx,delta) (-delta+idx)
@@ -964,7 +797,7 @@ extern uint8_t trimsCheckTimer;
extern volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used;
extern volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value;
extern int16_t csLastValue[NUM_CSW];
extern int16_t csLastValue[NUM_LOGICAL_SWITCH];
#define CS_LAST_VALUE_INIT -32768
#define TMR_OFF 0
@@ -1077,21 +910,6 @@ enum Analogs {
#define BUZZER_ON PORTE |= (1 << OUT_E_BUZZER)
#define BUZZER_OFF PORTE &= ~(1 << OUT_E_BUZZER)
#if defined(HAPTIC)
#if defined(PCBSKY9X)
#define HAPTIC_OFF hapticOff()
#elif defined(PCBGRUVIN9X)
#define HAPTIC_ON PORTD &= ~(1 << OUT_D_HAPTIC)
#define HAPTIC_OFF PORTD |= (1 << OUT_D_HAPTIC)
#else
#define HAPTIC_ON PORTG |= (1 << OUT_G_HAPTIC)
#define HAPTIC_OFF PORTG &= ~(1 << OUT_G_HAPTIC)
#endif
#else
#define HAPTIC_ON
#define HAPTIC_OFF
#endif
#define BITMASK(bit) (1<<(bit))
/// liefert Dimension eines Arrays
@@ -1111,7 +929,7 @@ template<class t> void swap(t & a, t & b) { t tmp = b; b = a; a = tmp; }
uint16_t isqrt32(uint32_t n);
#endif
#if defined(CPUARM)
#if defined(CPUARM) && !defined(BOOT)
#if !defined(SIMU)
extern "C" {
#include <CoOS.h>
@@ -1201,7 +1019,8 @@ extern uint8_t g_beepCnt;
extern uint8_t g_beepVal[5];
extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1
extern int16_t g_ppmIns[NUM_PPM];
extern uint8_t ppmInValid;
extern int16_t g_ppmIns[NUM_TRAINER];
extern int32_t chans[NUM_CHNOUT];
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain
extern int16_t channelOutputs[NUM_CHNOUT];
@@ -1514,6 +1333,7 @@ enum AUDIO_SOUNDS {
#endif
#include "translations.h"
#include "fonts.h"
#if defined(HAPTIC)
#include "haptic.h"
@@ -1632,7 +1452,7 @@ extern union ReusableBuffer reusableBuffer;
void checkFlashOnBeep();
#if defined(FRSKY) || defined(CPUARM)
FORCEINLINE void convertUnit(getvalue_t & val, uint8_t & unit);
void convertUnit(getvalue_t & val, uint8_t & unit); // TODO check FORCEINLINE on stock
void putsTelemetryValue(xcoord_t x, uint8_t y, lcdint_t val, uint8_t unit, uint8_t att);
#else
#define convertUnit(...)
@@ -1703,6 +1523,9 @@ getvalue_t convertCswTelemValue(LogicalSwitchData * cs);
lcdint_t applyChannelRatio(uint8_t channel, lcdint_t val);
#endif
getvalue_t div10_and_round(getvalue_t value);
#if defined(FRSKY)
NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm);
+1 -1
View File
@@ -45,7 +45,7 @@
void setupPulsesPPM(unsigned int port) // Don't enable interrupts through here
{
int16_t PPM_range = g_model.extendedLimits ? 640 * 2 : 512 * 2; //range of 0.7..1.7msec
int16_t PPM_range = g_model.extendedLimits ? (512*LIMIT_EXT_PERCENT/100) * 2 : 512 * 2; //range of 0.7..1.7msec
// Total frame length = 22.5msec
// each pulse is 0.7..1.7ms long with a 0.3ms stop tail
+8 -7
View File
@@ -211,13 +211,14 @@ void setupPulsesPXX(unsigned int port)
}
else {
flag1 = (g_model.moduleData[port].rfProtocol << 6) | pxxFlag[port];
if (failsafeCounter[port]-- == 0) {
failsafeCounter[port] = 1000;
flag1 |= PXX_SEND_FAILSAFE;
}
if (failsafeCounter[port] == 0 && g_model.moduleData[port].channelsCount > 0) {
flag1 |= PXX_SEND_FAILSAFE;
if (g_model.moduleData[port].failsafeMode != FAILSAFE_RECEIVER) {
if (failsafeCounter[port]-- == 0) {
failsafeCounter[port] = 1000;
flag1 |= PXX_SEND_FAILSAFE;
}
if (failsafeCounter[port] == 0 && g_model.moduleData[port].channelsCount > 0) {
flag1 |= PXX_SEND_FAILSAFE;
}
}
}
+47
View File
@@ -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
+6
View File
@@ -47,6 +47,8 @@
#define SYSTEM_SUBDIR "SYSTEM" // no trailing slash = important
#define BITMAPS_PATH ROOT_PATH "BMP"
#define SCRIPTS_PATH ROOT_PATH "SCRIPTS"
#define FIRMWARES_PATH ROOT_PATH "FIRMWARES"
#define EEPROMS_PATH ROOT_PATH "EEPROMS"
#define MODELS_EXT ".bin"
#define LOGS_EXT ".csv"
@@ -54,6 +56,8 @@
#define BITMAPS_EXT ".bmp"
#define SCRIPTS_EXT ".lua"
#define TEXT_EXT ".txt"
#define FIRMWARE_EXT ".bin"
#define EEPROM_EXT ".bin"
extern FATFS g_FATFS_Obj;
@@ -62,6 +66,7 @@ extern const pm_char * openLogs();
extern void closeLogs();
extern void writeLogs();
#if !defined(BOOT)
inline const pm_char *SDCARD_ERROR(FRESULT result)
{
if (result == FR_NOT_READY)
@@ -69,6 +74,7 @@ inline const pm_char *SDCARD_ERROR(FRESULT result)
else
return STR_SDCARD_ERROR;
}
#endif
#if defined(PCBTARANIS)
#define O9X_FOURCC 0x3378396F // o9x for Taranis
+23 -10
View File
@@ -60,6 +60,7 @@ GPIO_TypeDef gpiod;
GPIO_TypeDef gpioe;
TIM_TypeDef tim1;
TIM_TypeDef tim3;
TIM_TypeDef tim4;
TIM_TypeDef tim8;
TIM_TypeDef tim10;
RCC_TypeDef rcc;
@@ -101,37 +102,37 @@ sem_t *eeprom_write_sem;
#if defined(PCBTARANIS)
#define SWITCH_CASE(swtch, pin, mask) \
case swtch: \
if (state) pin &= ~(mask); else pin |= (mask); \
if ((int)state > 0) pin &= ~(mask); else pin |= (mask); \
break;
#else
#define SWITCH_CASE(swtch, pin, mask) \
case swtch: \
if (state) pin |= (mask); else pin &= ~(mask); \
if ((int)state > 0) pin |= (mask); else pin &= ~(mask); \
break;
#endif
#define SWITCH_3_CASE(swtch, pin1, pin2, mask1, mask2) \
case swtch: \
if (state < 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if (state > 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
if ((int)state < 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if ((int)state > 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
break;
#define KEY_CASE(key, pin, mask) \
case key: \
if (state) pin &= ~mask; else pin |= mask;\
if ((int)state > 0) pin &= ~mask; else pin |= mask;\
break;
#define TRIM_CASE KEY_CASE
#else
#define SWITCH_CASE(swtch, pin, mask) \
case swtch: \
if (state) pin &= ~(mask); else pin |= (mask); \
if ((int)state > 0) pin &= ~(mask); else pin |= (mask); \
break;
#define SWITCH_3_CASE(swtch, pin1, pin2, mask1, mask2) \
case swtch: \
if (state >= 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if (state <= 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
if ((int)state >= 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if ((int)state <= 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
break;
#define KEY_CASE(key, pin, mask) \
case key: \
if (state) pin |= (mask); else pin &= ~(mask);\
if ((int)state > 0) pin |= (mask); else pin &= ~(mask);\
break;
#define TRIM_CASE KEY_CASE
#endif
@@ -350,6 +351,8 @@ void StartMainThread(bool tests)
pthread_mutex_init(&audioMutex, NULL);
#endif
g_tmr10ms = 0;
main_thread_running = (tests ? 1 : 2);
pthread_create(&main_thread_pid, NULL, &main_thread, NULL);
}
@@ -464,10 +467,11 @@ FATFS g_FATFS_Obj;
char *convertSimuPath(const char *path)
{
static char result[1024];
if (path[0] == '/')
if (path[0] == '/' && strcmp(simuSdDirectory, "/") != 0)
sprintf(result, "%s%s", simuSdDirectory, path);
else
strcpy(result, path);
return result;
}
@@ -637,7 +641,11 @@ void lcdRefresh()
}
#if defined(PCBTARANIS)
void pwrInit() { }
uint32_t pwrCheck() { return true; }
void pwrOff() { }
void usbStart() { }
int usbPlugged() { return false; }
void USART_DeInit(USART_TypeDef* ) { }
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; }
@@ -666,4 +674,9 @@ void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState New
void RCC_LSEConfig(uint8_t RCC_LSE) { }
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) { return RESET; }
ErrorStatus RTC_WaitForSynchro(void) { return SUCCESS; }
void unlockFlash() { }
void lockFlash() { }
void writeFlash(uint32_t *address, uint32_t *buffer) { SIMU_SLEEP(100); }
uint32_t isBootloaderStart(const void *block) { return 1; }
#endif
+2
View File
@@ -116,6 +116,7 @@ extern GPIO_TypeDef gpioe;
#define GPIOE (&gpioe)
extern TIM_TypeDef tim1;
extern TIM_TypeDef tim3;
extern TIM_TypeDef tim4;
extern TIM_TypeDef tim8;
extern TIM_TypeDef tim10;
#undef TIM1
@@ -124,6 +125,7 @@ extern TIM_TypeDef tim10;
#undef TIM10
#define TIM1 (&tim1)
#define TIM3 (&tim3)
#define TIM4 (&tim4)
#define TIM8 (&tim8)
#define TIM10 (&tim10)
extern RCC_TypeDef rcc;
+2 -2
View File
@@ -179,7 +179,7 @@ long Open9xSim::onKeypress(FXObject*,FXSelector,void*v)
return 0;
}
long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
long Open9xSim::onTimeout(FXObject*, FXSelector, void*)
{
if(hasFocus()) {
static int keys1[]={
@@ -284,7 +284,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
per10ms();
refreshDiplay();
getApp()->addTimeout(this,2,5);
getApp()->addTimeout(this, 2, 10);
return 0;
}
+4 -2
View File
@@ -41,7 +41,9 @@
#define DEFNUMSTR(s) STR2(s)
#if defined(PCBSTD)
const pm_char vers_stamp[] PROGMEM = "VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " DEFNUMSTR(EEPROM_VER) "-" DEFNUMSTR(EEPROM_VARIANT);
#define EEPROM_STR DEFNUMSTR(EEPROM_VER) "-" DEFNUMSTR(EEPROM_VARIANT)
#else
const pm_char vers_stamp[] PROGMEM = "VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " DEFNUMSTR(EEPROM_VER);
#define EEPROM_STR DEFNUMSTR(EEPROM_VER);
#endif
const pm_char vers_stamp[] PROGMEM = "VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " EEPROM_STR;
+56
View File
@@ -0,0 +1,56 @@
#include <stdlib.h>
char * strAppend(char * dest, const char * source)
{
while ((*dest++ = *source++))
;
return dest - 1;
}
#if defined(RTCLOCK)
#include "rtc.h"
char * strAppendDate(char * str, bool time)
{
str[0] = '-';
struct gtm utm;
gettime(&utm);
div_t qr = div(utm.tm_year+1900, 10);
str[4] = '0' + qr.rem;
qr = div(qr.quot, 10);
str[3] = '0' + qr.rem;
qr = div(qr.quot, 10);
str[2] = '0' + qr.rem;
str[1] = '0' + qr.quot;
str[5] = '-';
qr = div(utm.tm_mon+1, 10);
str[7] = '0' + qr.rem;
str[6] = '0' + qr.quot;
str[8] = '-';
qr = div(utm.tm_mday, 10);
str[10] = '0' + qr.rem;
str[9] = '0' + qr.quot;
if (time) {
str[11] = '-';
div_t qr = div(utm.tm_hour, 10);
str[13] = '0' + qr.rem;
str[12] = '0' + qr.quot;
str[14] = '-';
qr = div(utm.tm_min, 10);
str[16] = '0' + qr.rem;
str[15] = '0' + qr.quot;
str[17] = '-';
qr = div(utm.tm_sec, 10);
str[19] = '0' + qr.rem;
str[18] = '0' + qr.quot;
str[20] = '\0';
return &str[20];
}
else {
str[11] = '\0';
return &str[11];
}
}
#endif
@@ -186,6 +186,8 @@ void pwrOff();
// Haptic driver
#define hapticOff() // TODO hapticOn() cleaner ...
#define HAPTIC_ON() PORTD &= ~(1 << OUT_D_HAPTIC)
#define HAPTIC_OFF() PORTD |= (1 << OUT_D_HAPTIC)
// Rotary encoder driver
#if ROTARY_ENCODERS <= 2
+4 -1
View File
@@ -47,7 +47,10 @@ extern bool isPlaying();
#define PUSH_NUMBER_PROMPT(p) pushPrompt(PROMPT_I18N_BASE+(p))
#define PUSH_SYSTEM_PROMPT(p) pushPrompt(PROMPT_SYSTEM_BASE+(p))
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a))
#define PLAY_DURATION(d) playDuration((d))
#define PLAY_DURATION(d, att) playDuration((d))
#define PLAY_DURATION_ATT
#define PLAY_TIME
#define IS_PLAY_TIME() (0)
#define IS_PLAYING(id) isPlaying()
#define PLAY_VALUE(v, id) playValue((v))
@@ -189,5 +189,7 @@ void pwrOff();
// Haptic driver
#define hapticOff() // TODO hapticOn() cleaner ...
#define HAPTIC_ON() PORTD &= ~(1 << OUT_D_HAPTIC)
#define HAPTIC_OFF() PORTD |= (1 << OUT_D_HAPTIC)
#endif
+3 -3
View File
@@ -38,7 +38,7 @@
volatile uint16_t Analog_values[NUMBER_ANALOG];
#if defined(TARANIS_STICKS)
#if defined(FRSKY_STICKS)
const char ana_direction[NUMBER_ANALOG] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0};
#endif
@@ -118,12 +118,12 @@ void adcRead()
}
// adc direction correct
#if defined(TARANIS_STICKS)
#if defined(FRSKY_STICKS)
uint32_t i ;
for (i=0; i<NUMBER_ANALOG; i++) {
if (ana_direction[i]) {
Analog_values[i] = 4096-Analog_values[i];
}
}
#endif
#endif
}
+1 -1
View File
@@ -111,7 +111,7 @@ extern "C" void DAC_IRQHandler()
{
AudioBuffer *nextBuffer = audioQueue.getNextFilledBuffer();
if (nextBuffer) {
DACC->DACC_TNPR = CONVERT_PTR(nextBuffer->data);
DACC->DACC_TNPR = CONVERT_PTR_UINT(nextBuffer->data);
DACC->DACC_TNCR = nextBuffer->size/2;
}
else {
+6 -7
View File
@@ -314,15 +314,14 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
ppmInState = 1; // triggered
}
else {
if (ppmInState && ppmInState<=16)
{
if (val>800 && val<2200) // if valid pulse-width range
{
g_ppmIns[ppmInState++ - 1] =
(int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
if (ppmInState>0 && ppmInState<=16) {
if (val>800 && val<2200) { // if valid pulse-width range
ppmInValid = 100;
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
}
else
else {
ppmInState = 0; // not triggered
}
}
}
+10 -1
View File
@@ -43,6 +43,10 @@
extern uint16_t ResetReason;
#define BOOTLOADER_SIZE 0x8000
#define FIRMWARE_SIZE (256*1024)
#define FIRMWARE_ADDRESS 0x00400000
#if defined(REVA)
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
#define GPIO_BUTTON_EXIT PIOA->PIO_PDSR
@@ -153,6 +157,10 @@ extern uint16_t sessionTimer;
void setSticksGain(uint8_t gains);
// Write Flash driver
#define FLASH_PAGESIZE 256
void writeFlash(uint32_t * address, uint32_t * buffer);
// Keys driver
extern uint32_t readKeys();
extern uint32_t readTrims();
@@ -230,8 +238,9 @@ extern int8_t Coproc_temp;
extern int8_t Coproc_maxtemp;
// Haptic driver
void hapticOff(void) ;
void hapticOff(void);
void hapticOn(uint32_t pwmPercent);
#define HAPTIC_OFF() hapticOff()
// BlueTooth driver
#if defined(BLUETOOTH)
+73
View File
@@ -0,0 +1,73 @@
#include "../../opentx.h"
uint32_t (*IAP_Function)(uint32_t, uint32_t);
void writeFlash(uint32_t *address, uint32_t *buffer) // size is 256 bytes
{
uint32_t FlashSectorNum;
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);
FlashSectorNum = (uint32_t) address;
FlashSectorNum >>= 8;// page size is 256 bytes
FlashSectorNum &= 2047;// max page number
/* Send data to the sector here */
for (int i=0; i<FLASH_PAGESIZE/4; i++) {
*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();
}
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();
}
}
uint32_t isFirmwareStart(const void * buffer)
{
const uint32_t * block = (const uint32_t *)buffer;
if ((block[0] & 0xFFFE3000) != 0x20000000 ) {
return 0;
}
if ((block[1] & 0xFFF80000) != 0x00400000) {
return 0;
}
if ((block[2] & 0xFFF80000) != 0x00400000) {
return 0;
}
return 1;
}
+2 -2
View File
@@ -167,7 +167,7 @@ extern "C" void PWM_IRQHandler(void)
else {
// Kick off serial output here
sscptr = SSC;
sscptr->SSC_TPR = CONVERT_PTR(pxxStream[0]);
sscptr->SSC_TPR = CONVERT_PTR_UINT(pxxStream[0]);
sscptr->SSC_TCR = (uint8_t *)pxxStreamPtr[0] - (uint8_t *)pxxStream[0];
sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers
}
@@ -191,7 +191,7 @@ extern "C" void PWM_IRQHandler(void)
else {
// Kick off serial output here
sscptr = SSC;
sscptr->SSC_TPR = CONVERT_PTR(dsm2Stream);
sscptr->SSC_TPR = CONVERT_PTR_UINT(dsm2Stream);
sscptr->SSC_TCR = (uint8_t *)dsm2StreamPtr - (uint8_t *)dsm2Stream;
sscptr->SSC_PTCR = SSC_PTCR_TXTEN; // Start transfers
}
+9 -6
View File
@@ -71,9 +71,15 @@ SECTIONS
*/
.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))
*(.text)
@@ -129,11 +135,8 @@ SECTIONS
. = ALIGN(4); /* Align the end of the section */
} > 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.
@@ -54,7 +54,7 @@ static SBCInquiryData inquiryData = {
SBC_PERIPHERAL_DEVICE_CONNECTED,// Peripheral device is connected
0x00, // Reserved bits
0x01, // Media is removable
SBC_SPC_VERSION_4, // SPC-4 supported
0x02, // SBC_SPC_VERSION_4, // SPC-4 supported
0x2, // Response data format, must be 0x2
0, // Hierarchical addressing not supported
0, // ACA not supported
@@ -94,6 +94,8 @@
#define SBC_VERIFY_10 0x2F
/// Request a list of the possible capacities that can be formatted on medium
#define SBC_READ_FORMAT_CAPACITIES 0x23
#define SBC_START_STOP 0x19
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
@@ -620,6 +622,21 @@ typedef struct {
} __attribute__ ((packed)) SBCReadWriteErrorRecovery; // GCC
//------------------------------------------------------------------------------
/// \brief start/stop command
/// \see
//------------------------------------------------------------------------------
typedef struct {
unsigned char bModeDataLength; //!< Length of mode data to follow
unsigned char bImmediate:1, //!<
bReserved1:7; //!< Reserved bits
unsigned char pReserved[2]; //!< Reserved bytes
unsigned char startStop:1, //!< DPO/FUA bits supported ?
eject:1, //!< Reserved bits
bReserved2:6; //!< Is medium write-protected ?
} __attribute__ ((packed)) SBCStartStop; // GCC
//------------------------------------------------------------------------------
/// \brief Generic structure for holding information about SBC commands
/// \see SBCInquiry
@@ -642,6 +659,7 @@ typedef union {
SBCWrite10 write10; //!< WRITE (10) command
SBCMediumRemoval mediumRemoval; //!< PREVENT/ALLOW MEDIUM REMOVAL command
SBCModeSense6 modeSense6; //!< MODE SENSE (6) command
SBCStartStop startStopCmd; //!< START-STOP command
} SBCCommand;
@@ -1430,7 +1430,7 @@ unsigned char SBC_GetCommandInformation(void *command,
//------------------------------------
case SBC_PREVENT_ALLOW_MEDIUM_REMOVAL:
case 0x1B:
case SBC_START_STOP:
//------------------------------------
(*type) = MSDD_NO_TRANSFER;
break;
@@ -1590,7 +1590,6 @@ unsigned char SBC_ProcessCommand(MSDLun *lun,
//------------------------------------
case SBC_PREVENT_ALLOW_MEDIUM_REMOVAL:
case 0x1B:
//------------------------------------
TRACE_INFO_WP("PrevAllowRem ");
@@ -1600,6 +1599,19 @@ unsigned char SBC_ProcessCommand(MSDLun *lun,
result = MSDD_STATUS_SUCCESS;
break;
case SBC_START_STOP:
TRACE_INFO_WP("StartStop ");
result = command->startStopCmd.startStop ;
if (result == 0) {
lun->status = LUN_EJECTED ;
}
else {
lun->status = LUN_CHANGED ;
}
result = MSDD_STATUS_SUCCESS;
break;
#if 0
//------------------------------------
case SBC_READ_FORMAT_CAPACITIES:
+4
View File
@@ -230,6 +230,10 @@ extern uint8_t RotEncoder ;
void rotencPoll();
#endif
// Haptic
#define HAPTIC_ON() PORTG |= (1 << OUT_G_HAPTIC)
#define HAPTIC_OFF() PORTG &= ~(1 << OUT_G_HAPTIC)
// USB fake driver
#define usbPlugged() false
+4 -1
View File
@@ -134,6 +134,9 @@ inline bool isPlaying()
#define PUSH_NUMBER_PROMPT(p) pushNumberPrompt((p))
#define PUSH_SYSTEM_PROMPT(p) pushNumberPrompt(PROMPT_SYSTEM_BASE-PROMPT_I18N_BASE+(p))
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a))
#define PLAY_DURATION(d) playDuration((d))
#define PLAY_DURATION(d, att) playDuration((d))
#define PLAY_DURATION_ATT
#define PLAY_TIME
#define IS_PLAY_TIME() (0)
#define IS_PLAYING(id) (0) /* isPlaying() */
#define PLAY_VALUE(v, id) playValue((v))
@@ -232,7 +232,8 @@ void SystemInit(void)
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
extern uint32_t g_pfnVectors ;
SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */
#endif
}
@@ -113,8 +113,8 @@
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f2xx_spi.h"
#include "stm32f2xx_rcc.h"
#include "../inc/stm32f2xx_spi.h"
#include "../inc/stm32f2xx_rcc.h"
/** @addtogroup STM32F2xx_StdPeriph_Driver
* @{
@@ -97,6 +97,7 @@ static int8_t SCSI_ReadFormatCapacity(uint8_t lun, uint8_t *params);
static int8_t SCSI_ReadCapacity10(uint8_t lun, uint8_t *params);
static int8_t SCSI_RequestSense (uint8_t lun, uint8_t *params);
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params);
static int8_t SCSI_AllowRemoval(uint8_t lun, uint8_t *params);
static int8_t SCSI_ModeSense6 (uint8_t lun, uint8_t *params);
static int8_t SCSI_ModeSense10 (uint8_t lun, uint8_t *params);
static int8_t SCSI_Write10(uint8_t lun , uint8_t *params);
@@ -146,7 +147,7 @@ int8_t SCSI_ProcessCmd(USB_OTG_CORE_HANDLE *pdev,
return SCSI_StartStopUnit(lun, params);
case SCSI_ALLOW_MEDIUM_REMOVAL:
return SCSI_StartStopUnit(lun, params);
return SCSI_AllowRemoval( lun, params);
case SCSI_MODE_SENSE6:
return SCSI_ModeSense6 (lun, params);
@@ -432,7 +433,28 @@ void SCSI_SenseCode(uint8_t lun, uint8_t sKey, uint8_t ASC)
* @param params: Command parameters
* @retval status
*/
extern uint8_t lunReady[] ;
static int8_t SCSI_StartStopUnit(uint8_t lun, uint8_t *params)
{
MSC_BOT_DataLen = 0;
if (lun < 2) {
if (params[4] & 1) {
// lun to be active
lunReady[lun] = 1 ;
}
else {
// lun to be ejected
lunReady[lun] = 0 ;
}
}
return 0;
}
static int8_t SCSI_AllowRemoval(uint8_t lun, uint8_t *params)
{
MSC_BOT_DataLen = 0;
return 0;
@@ -153,20 +153,25 @@ void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
/* Upon Init call usr callback */
pdev->dev.usr_cb->Init();
/* Force Device Mode*/
USB_OTG_SetCurrentMode(pdev, DEVICE_MODE);
/* Enable Interrupts */
USB_OTG_BSP_EnableInterrupt(pdev);
}
/**
* @brief USBD_DeInit
* Re-Initialize th device library
* Deinitialize USB device library
* @param pdev: device instance
* @retval status: status
*/
USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev)
{
/* Software Init */
/*Disable Interrupts*/
USB_OTG_BSP_DisableInterrupt(pdev);
USB_OTG_DisableGlobalInt(pdev);
USB_OTG_BSP_Deinit(pdev);
return USBD_OK;
}
@@ -78,9 +78,11 @@
void BSP_Init(void);
void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev);
void USB_OTG_BSP_Deinit(USB_OTG_CORE_HANDLE *pdev);
void USB_OTG_BSP_uDelay (const uint32_t usec);
void USB_OTG_BSP_mDelay (const uint32_t msec);
void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev);
void USB_OTG_BSP_DisableInterrupt (USB_OTG_CORE_HANDLE *pdev);
#ifdef USE_HOST_MODE
void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev);
void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state);
@@ -195,6 +195,12 @@ uint32_t USBD_OTG_EP1IN_ISR_Handler (USB_OTG_CORE_HANDLE *pdev)
{
DCD_WriteEmptyTxFifo(pdev , 1);
CLEAR_IN_EP_INTR(1, emptyintr);
/*
Notice: this probabbly needs the same fix as DCD_HandleInEP_ISR(), but
leaving this out, we don't use this part of code
fifoemptymsk = 0x1 << 1;
USB_OTG_MODIFY_REG32(&pdev->regs.DREGS->DIEPEMPMSK, fifoemptymsk, 0);
*/
}
return 1;
}
@@ -470,6 +476,36 @@ static uint32_t DCD_HandleInEP_ISR(USB_OTG_CORE_HANDLE *pdev)
}
if (diepint.b.emptyintr)
{
/*===============ADDED SECTION ==============================*/
/*
This only applies to INTERRUPT transfer mode.
diepint.b.emptyintr interrupt can't be reset by writing 1 to
DIEPINT register. According to reference manual, this bit
is read-only.
The CLEAR_IN_EP_INTR(epnum, emptyintr) does not work!
The only way to stop this interrupt is to disable it using
mask register DIEPEMPMSK.
Original code gets here, is unsuccessful at interrupt flag reset
and when interrupt handler returns, another one is fired again,
robbing CPU time, which is then spent only in interrupt handlers
(this one and all other that have higher priority)
This only happens in HID mode (when interrupt in endpoint is
used) and when host is not actively polling device (us) for
update. This is situation on Linux when no program is using
joystick. The kernel/joystick driver stops polling device.
*/
if ( pdev->dev.in_ep[epnum].type == USB_OTG_EP_INT ) {
fifoemptymsk = 0x1 << epnum;
USB_OTG_MODIFY_REG32(&pdev->regs.DREGS->DIEPEMPMSK, fifoemptymsk, 0);
}
/*===============END OF ADDED SECTION ==============================*/
DCD_WriteEmptyTxFifo(pdev , epnum);
+9 -7
View File
@@ -59,10 +59,11 @@
#define SAMPTIME 2 // sample time = 15 cycles
volatile uint16_t Analog_values[NUMBER_ANALOG];
#if defined(REV4a)
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,1,0,1,0, 0};
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,0,-1,1, 1};
#elif !defined(REV3)
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,0,0,1,0, 0};
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,0,-1,1, 1};
#endif
void adcInit()
@@ -98,8 +99,8 @@ void adcInit()
ADC->CCR = 0 ; //ADC_CCR_ADCPRE_0 ; // Clock div 2
DMA2_Stream0->CR = DMA_SxCR_PL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC ;
DMA2_Stream0->PAR = CONVERT_PTR(&ADC1->DR);
DMA2_Stream0->M0AR = CONVERT_PTR(Analog_values);
DMA2_Stream0->PAR = CONVERT_PTR_UINT(&ADC1->DR);
DMA2_Stream0->M0AR = CONVERT_PTR_UINT(Analog_values);
DMA2_Stream0->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
}
@@ -110,7 +111,7 @@ void adcRead()
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
ADC1->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ) ;
DMA2->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 |DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0 ; // Write ones to clear bits
DMA2_Stream0->M0AR = CONVERT_PTR(Analog_values);
DMA2_Stream0->M0AR = CONVERT_PTR_UINT(Analog_values);
DMA2_Stream0->NDTR = NUMBER_ANALOG ;
DMA2_Stream0->CR |= DMA_SxCR_EN ; // Enable DMA
ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART ;
@@ -124,9 +125,10 @@ void adcRead()
#if !defined(REV3)
// adc direction correct
for (i=0; i<NUMBER_ANALOG; i++) {
if (ana_direction[i]) {
if (ana_direction[i] == -1)
Analog_values[i] = 4096-Analog_values[i];
}
else if (ana_direction[i] == 0)
Analog_values[i] = 0;
}
#endif
}
@@ -10,8 +10,7 @@
******************************************************************************
*/
#include "../opentx.h"
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h"
#include "board_taranis.h"
/**
**********send command to lcd**************
+19 -11
View File
@@ -1,6 +1,6 @@
/**
******************************************************************************
* @file Project/spi/spi.h
* @file Project/spi/spi.h
* @author FrSky Application Team
* @Hardware version V0.2
* @date 11-July-2012
@@ -11,27 +11,35 @@
#ifndef _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"
#define __no_operation __NOP
#define LCD_NCS_HIGH() GPIO_LCD->BSRRL = PIN_LCD_NCS
#define LCD_NCS_LOW() GPIO_LCD->BSRRH = PIN_LCD_NCS
#define LCD_NCS_HIGH() GPIO_LCD_NCS->BSRRL = PIN_LCD_NCS
#define LCD_NCS_LOW() GPIO_LCD_NCS->BSRRH = PIN_LCD_NCS
#define LCD_A0_HIGH() GPIO_LCD->BSRRL = PIN_LCD_A0
#define LCD_A0_LOW() GPIO_LCD->BSRRH = PIN_LCD_A0
#define LCD_A0_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_A0
#define LCD_A0_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_A0
#define LCD_RST_HIGH() GPIO_LCD->BSRRL = PIN_LCD_RST
#define LCD_RST_LOW() GPIO_LCD->BSRRH = PIN_LCD_RST
#define LCD_RST_HIGH() GPIO_LCD_RST->BSRRL = PIN_LCD_RST
#define LCD_RST_LOW() GPIO_LCD_RST->BSRRH = PIN_LCD_RST
#define LCD_CLK_HIGH() GPIO_LCD->BSRRL = PIN_LCD_CLK
#define LCD_CLK_LOW() GPIO_LCD->BSRRH = PIN_LCD_CLK
#define LCD_CLK_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_CLK
#define LCD_CLK_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_CLK
#define LCD_MOSI_HIGH() GPIO_LCD->BSRRL = PIN_LCD_MOSI
#define LCD_MOSI_LOW() GPIO_LCD->BSRRH = PIN_LCD_MOSI
#define LCD_MOSI_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_MOSI
#define LCD_MOSI_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_MOSI
void AspiCmd(u8 Command_Byte);
void AspiData(u8 Para_data);
#ifdef __cplusplus
}
#endif
#endif
+21 -7
View File
@@ -36,7 +36,7 @@
#include "../../opentx.h"
bool dacIdle = true;
int dacIdle = 1;
void setSampleRate(uint32_t frequency)
{
@@ -78,8 +78,8 @@ void dacInit()
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_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 |
DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_CIRC ;
DMA1_Stream5->PAR = CONVERT_PTR(&DAC->DHR12R1);
// DMA1_Stream5->M0AR = CONVERT_PTR(Sine_values);
DMA1_Stream5->PAR = CONVERT_PTR_UINT(&DAC->DHR12R1);
// DMA1_Stream5->M0AR = CONVERT_PTR_UINT(Sine_values);
DMA1_Stream5->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
// DMA1_Stream5->NDTR = 100 ;
@@ -96,10 +96,10 @@ void dacInit()
bool dacQueue(AudioBuffer *buffer)
{
if (dacIdle) {
dacIdle = false;
dacIdle = 0;
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_Stream5->M0AR = CONVERT_PTR(buffer->data);
DMA1_Stream5->M0AR = CONVERT_PTR_UINT(buffer->data);
DMA1_Stream5->NDTR = buffer->size;
DMA1_Stream5->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel and interrupt
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
@@ -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
void audioInit()
{
@@ -142,14 +156,14 @@ extern "C" void DMA1_Stream5_IRQHandler()
AudioBuffer *nextBuffer = audioQueue.getNextFilledBuffer();
if (nextBuffer) {
DMA1_Stream5->M0AR = CONVERT_PTR(nextBuffer->data);
DMA1_Stream5->M0AR = CONVERT_PTR_UINT(nextBuffer->data);
DMA1_Stream5->NDTR = nextBuffer->size;
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_EN | DMA_SxCR_TCIE ; // Enable DMA channel
DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag
}
else {
dacIdle = true;
dacIdle = 1;
}
}
#endif
+5 -16
View File
@@ -37,25 +37,14 @@
#ifndef audio_driver_h
#define audio_driver_h
extern void audioInit( void ) ;
extern void audioEnd( void ) ;
void audioInit( void ) ;
void audioEnd( void ) ;
void dacStart();
void dacStop();
extern void setSampleRate(uint32_t frequency);
extern bool 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 ;
}
extern int dacIdle;
#define VOLUME_LEVEL_MAX 23
#define VOLUME_LEVEL_DEF 12
+20 -42
View File
@@ -44,22 +44,6 @@ extern "C" {
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)
void configure_pins( uint32_t pins, uint16_t config )
{
@@ -106,32 +90,6 @@ void configure_pins( uint32_t pins, uint16_t config )
}
#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)
{
IWDG->KR = 0x5555 ; // Unlock registers
@@ -172,6 +130,10 @@ void interrupt5ms()
AUDIO_HEARTBEAT();
#if defined(HAPTIC)
HAPTIC_HEARTBEAT();
#endif
if ( ++pre_scale >= 2 ) {
pre_scale = 0 ;
per10ms();
@@ -197,6 +159,10 @@ void boardInit()
eepromInit();
sportInit();
usbInit();
#if defined(HAPTIC)
hapticInit();
#endif
#if defined(DEBUG)
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
@@ -205,4 +171,16 @@ void boardInit()
}
#endif
#if defined(REVPLUS)
void turnBacklightOn(uint8_t level, uint8_t color)
{
TIM4->CCR4 = (100-level)*color;
TIM4->CCR2 = (100-level)*(100-color);
}
void turnBacklightOff(void)
{
TIM4->CCR4 = 0;
TIM4->CCR2 = 0;
}
#endif
+111 -38
View File
@@ -37,6 +37,12 @@
#ifndef board_taranis_h
#define board_taranis_h
#include "stddef.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_gpio.h"
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h"
@@ -45,26 +51,56 @@
#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/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/Core/inc/usbd_usr.h"
#include "usbd_desc.h"
#include "usb_conf.h"
#include "usbd_conf.h"
}
#if !defined(SIMU)
#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/hid/inc/usbd_hid_core.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 "usb_conf.h"
#include "usbd_conf.h"
#endif
#include "hal.h"
#include "aspi.h"
#include "i2c.h"
#include "audio_driver.h"
#define PERI1_FREQUENCY 30000000
#define PERI2_FREQUENCY 60000000
#define TIMER_MULT_APB1 2
#define TIMER_MULT_APB2 2
#ifdef __cplusplus
}
#endif
#if !defined(BOOT)
#include "audio_driver.h"
#endif
#define FLASHSIZE 0x80000
#define BOOTLOADER_SIZE 0x8000
#define FIRMWARE_ADDRESS 0x08000000
#define PERI1_FREQUENCY 30000000
#define PERI2_FREQUENCY 60000000
#define TIMER_MULT_APB1 2
#define TIMER_MULT_APB2 2
#define JACK_PPM_OUT()
#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 );
#define strcpy_P strcpy
@@ -75,7 +111,7 @@ extern uint16_t sessionTimer;
#define SLAVE_MODE() (g_model.trainerMode == 1)
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET)
void delaysInit();
void delaysInit(void);
#define DEBUG_BAUDRATE 115200
#define SPORT_BAUDRATE 57600
@@ -97,14 +133,22 @@ void delay_01us(uint16_t nb);
#define SD_GET_SIZE_MB() (0)
#define SD_GET_BLOCKNR() (0)
#define SD_GET_SPEED() (0)
void sdInit();
void sdDone();
void sdPoll10ms();
void sdInit(void);
void sdDone(void);
void sdPoll10ms(void);
#define sdMountPoll()
uint32_t sdMounted();
uint32_t sdMounted(void);
#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_Pin)
#endif
// Flash Write driver
#define FLASH_PAGESIZE 256
void unlockFlash(void);
void lockFlash(void);
void writeFlash(uint32_t * address, uint32_t * buffer);
uint32_t isFirmwareStart(const void * buffer);
uint32_t isBootloaderStart(const void * buffer);
// Pulses driver
void init_no_pulses(uint32_t port);
void disable_no_pulses(uint32_t port);
@@ -116,15 +160,15 @@ void init_dsm2( uint32_t module_index );
void disable_dsm2( uint32_t module_index );
// Trainer driver
void init_trainer_ppm();
void stop_trainer_ppm();
void init_trainer_capture();
void stop_trainer_capture();
void init_trainer_ppm(void);
void stop_trainer_ppm(void);
void init_trainer_capture(void);
void stop_trainer_capture(void);
// Keys driver
void keysInit();
uint32_t readKeys();
uint32_t readTrims();
void keysInit(void);
uint32_t readKeys(void);
uint32_t readTrims(void);
#define TRIMS_PRESSED() (readTrims())
#define KEYS_PRESSED() (~readKeys())
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & ((2<<KEY_PLUS) + (2<<KEY_MINUS))) == ((2<<KEY_PLUS) + (2<<KEY_MINUS)))
@@ -141,8 +185,8 @@ void watchdogInit(unsigned int duration);
#endif
// ADC driver
void adcInit();
void adcRead();
void adcInit(void);
void adcRead(void);
extern volatile uint16_t Analog_values[];
#if defined(REV3)
#define BATT_SCALE 120
@@ -150,28 +194,46 @@ extern volatile uint16_t Analog_values[];
#define BATT_SCALE 150
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Power driver
void pwrInit();
uint32_t pwrCheck();
void pwrOff();
void pwrInit(void);
uint32_t pwrCheck(void);
void pwrOff(void);
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
#define INTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_INT_RF_PWR)
#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR)
#define EXTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_EXT_RF_PWR)
#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_EXT_RF_PWR)
#define INTERNAL_RF_ON() GPIO_SetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR)
#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR)
#define EXTERNAL_RF_ON() GPIO_SetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
// Backlight driver
#define setBacklight(xx) TIM10->CCR1 = 100-xx
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
#if defined(REVPLUS)
void turnBacklightOn(uint8_t level, uint8_t color);
void turnBacklightOff(void);
#define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor)
#define __BACKLIGHT_ON turnBacklightOn(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
#define __BACKLIGHT_OFF turnBacklightOff()
#define IS_BACKLIGHT_ON() (TIM4->CCR4 != 0) || (TIM4->CCR2 != 0)
#else
#define setBacklight(xx) TIM10->CCR1 = 100-xx
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
#define __BACKLIGHT_OFF TIM10->CCR1 = 0
#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0)
#endif
// USB driver
#define BOOTLOADER_REQUEST() (0)
#define usbBootloader()
int usbPlugged(void);
void usbInit(void);
void usbStart(void);
bool usbPlugged(void);
void usbStop(void);
#ifdef __cplusplus
}
#endif
// EEPROM driver
#if !defined(SIMU)
@@ -186,6 +248,17 @@ void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t si
// Debug driver
void debugPutc(const char c);
// Haptic driver
void hapticInit(void);
void hapticOff(void);
#define HAPTIC_OFF() hapticOff()
#if defined(REVPLUS)
void hapticOn(uint32_t pwmPercent);
#else
void hapticOn();
#define HAPTIC_ON() hapticOn()
#endif
extern uint8_t currentTrainerMode;
#endif
@@ -34,7 +34,7 @@
*
*/
#include "../../opentx.h"
#include "board_taranis.h"
void delaysInit(void)
{
+53 -62
View File
@@ -35,9 +35,10 @@
*/
#include <string.h>
#include "../FatFs/diskio.h"
#include "../FatFs/ff.h"
#include "../CoOS/kernel/CoOS.h"
#include "board_taranis.h"
#include "../../FatFs/diskio.h"
#include "../../FatFs/ff.h"
#include "../../CoOS/kernel/CoOS.h"
#include "hal.h"
/* Definitions for MMC/SDC command */
@@ -93,6 +94,7 @@ uint32_t transSpeed; */
/*-----------------------------------------------------------------------*/
/* Lock / unlock functions */
/*-----------------------------------------------------------------------*/
#if !defined(BOOT)
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
{
*mutex = CoCreateMutex();
@@ -114,6 +116,7 @@ int ff_del_syncobj (_SYNC_t mutex)
{
return 1;
}
#endif
static const DWORD socket_state_mask_cp = (1 << 0);
static const DWORD socket_state_mask_wp = (1 << 1);
@@ -124,7 +127,6 @@ DSTATUS Stat = STA_NOINIT; /* Disk status */
static volatile
DWORD Timer1, Timer2; /* 100Hz decrement timers */
static
BYTE CardType; /* Card type flags */
enum speed_setting { INTERFACE_SLOW, INTERFACE_FAST };
@@ -178,12 +180,10 @@ static void card_power(BYTE on)
on=on;
}
#if (STM32_SD_DISK_IOCTRL == 1)
static int chk_power(void)
{
return 1; /* fake powered */
}
#endif
/*-----------------------------------------------------------------------*/
/* Transmit/Receive a byte to MMC via SPI (Platform dependent) */
@@ -433,30 +433,29 @@ void power_on (void)
static
void power_off (void)
{
GPIO_InitTypeDef GPIO_InitStructure;
if (!(Stat & STA_NOINIT)) {
SELECT();
wait_ready();
release_spi();
}
if (!(Stat & STA_NOINIT)) {
SELECT();
wait_ready();
release_spi();
}
SPI_I2S_DeInit(SPI_SD);
SPI_Cmd(SPI_SD, DISABLE);
RCC_APBPeriphClockCmd_SPI_SD(RCC_APBPeriph_SPI_SD, DISABLE);
//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_Mode = GPIO_Mode_IN;
SPI_I2S_DeInit(SPI_SD);
SPI_Cmd(SPI_SD, DISABLE);
RCC_APBPeriphClockCmd_SPI_SD(RCC_APBPeriph_SPI_SD, DISABLE);
//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_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
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 */
/*-----------------------------------------------------------------------*/
#if _FS_READONLY == 0
static
BOOL xmit_datablock (
const BYTE *buff, /* 512 byte data block to be transmitted */
@@ -537,8 +535,6 @@ BOOL xmit_datablock (
return TRUE;
}
#endif /* _READONLY */
/*-----------------------------------------------------------------------*/
@@ -655,7 +651,6 @@ DSTATUS disk_initialize (
/*-----------------------------------------------------------------------*/
/* Get Disk Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_status (
BYTE drv /* Physical drive number (0) */
)
@@ -665,7 +660,6 @@ DSTATUS disk_status (
}
/*-----------------------------------------------------------------------*/
/* 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 (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
do {
if (!rcvr_datablock(buff, 512)) {
break;
if (count == 1) { /* Single block read */
if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */
if (rcvr_datablock(buff, 512)) {
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();
@@ -700,29 +703,9 @@ DRESULT disk_read (
if (drv || !count) return RES_PARERR;
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 */
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;
return RES_OK;
}
@@ -731,8 +714,6 @@ DRESULT disk_read (
/* Write Sector(s) */
/*-----------------------------------------------------------------------*/
#if _FS_READONLY == 0
// TODO quick & dirty
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;
}
#if _FS_READONLY == 0
DRESULT disk_write (
BYTE drv, /* Physical drive number (0) */
const BYTE *buff, /* Pointer to the data to be written */
@@ -793,7 +776,6 @@ DRESULT disk_write (
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
#if (STM32_SD_DISK_IOCTRL == 1)
DRESULT disk_ioctl (
BYTE drv, /* Physical drive number (0) */
BYTE ctrl, /* Control code */
@@ -919,7 +901,6 @@ DRESULT disk_ioctl (
return res;
}
#endif /* _USE_IOCTL != 0 */
/*-----------------------------------------------------------------------*/
@@ -966,7 +947,16 @@ FATFS g_FATFS_Obj;
FIL g_telemetryFile = {0};
#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) {
referenceSystemAudioFiles();
@@ -989,6 +979,7 @@ void sdDone()
f_mount(0, 0); // unmount SD
}
}
#endif
uint32_t sdMounted()
{
+133
View File
@@ -0,0 +1,133 @@
#include "../../opentx.h"
#include "stm32f2xx_flash.h"
//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 lockFlash()
{
while (!FLASH->SR & FLASH_SR_BSY);
FLASH->CR |= FLASH_CR_LOCK;
}
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;
}
void writeFlash(uint32_t *address, uint32_t *buffer) // page size is 256 bytes
{
if ((uint32_t) address == 0x08000000) {
eraseSector(0);
}
else if ((uint32_t) address == 0x08004000) {
eraseSector(1);
}
else if ((uint32_t) address == 0x08008000) {
eraseSector(2);
}
else if ((uint32_t) address == 0x0800C000) {
eraseSector(3);
}
else if ((uint32_t) address == 0x08010000) {
eraseSector(4);
}
else if ((uint32_t) address == 0x08020000) {
eraseSector(5);
}
else if ((uint32_t) address == 0x08040000) {
eraseSector(6);
}
else if ((uint32_t) address == 0x08060000) {
eraseSector(7);
}
for (uint32_t i=0; i<FLASH_PAGESIZE/4; i++) {
/* 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;
}
/* Increment FLASH destination address */
address += 1;
buffer += 1;
}
}
uint32_t isFirmwareStart(const void * buffer)
{
const uint32_t * block = (const uint32_t *)buffer;
if ((block[0] & 0xFFFC0000) != 0x20000000) {
return 0;
}
if ((block[1] & 0xFFF00000) != 0x08000000) {
return 0;
}
if ((block[2] & 0xFFF00000) != 0x08000000) {
return 0;
}
return 1;
}
uint32_t isBootloaderStart(const void * buffer)
{
const uint32_t * block = (const uint32_t *)buffer;
for (int i=0; i<256; i++) {
if (block[i] == 0x544F4F42/*BOOT*/) {
return 1;
}
}
return 0;
}
+101 -43
View File
@@ -14,10 +14,10 @@
#define GPIO_BUTTON_MENU GPIOD->IDR
#define GPIO_BUTTON_EXIT GPIOD->IDR
#define GPIO_BUTTON_PAGE GPIOD->IDR
#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10
#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10
#define PIN_BUTTON_MINUS GPIO_Pin_11 //SW1 PE.12
#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11
#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07
#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11
#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07
#define PIN_BUTTON_PAGE GPIO_Pin_3 //SW6 PD.02
#define PIN_BUTTON_EXIT GPIO_Pin_2 //SW5 PD.03
@@ -30,12 +30,12 @@
#define GPIO_TRIM_LV_UP GPIOE->IDR
#define GPIO_TRIM_RV_DN GPIOC->IDR
#define GPIO_TRIM_RH_R GPIOC->IDR
#define PIN_TRIM_RV_DN GPIO_Pin_3 //PC.03
#define PIN_TRIM_RV_UP GPIO_Pin_2 //PC.02
#define PIN_TRIM_RH_L GPIO_Pin_1 //PC.01
#define PIN_TRIM_RH_R GPIO_Pin_13 //PC.13
#define PIN_TRIM_RV_DN GPIO_Pin_3 //PC.03
#define PIN_TRIM_RV_UP GPIO_Pin_2 //PC.02
#define PIN_TRIM_RH_L GPIO_Pin_1 //PC.01
#define PIN_TRIM_RH_R GPIO_Pin_13 //PC.13
#if defined(REV3)
#define PIN_TRIM_LH_R GPIO_Pin_4 //PE.04
#define PIN_TRIM_LH_R GPIO_Pin_4 //PE.04
#define PIN_TRIM_LH_L GPIO_Pin_3 //PE.03
#else
#define PIN_TRIM_LH_L GPIO_Pin_4 //PE.04
@@ -47,7 +47,7 @@
// Switchs
#if defined(REV3)
#define GPIO_PIN_SW_F (~GPIOE->IDR)
#define PIN_SW_F GPIO_Pin_14 //PE.14
#define PIN_SW_F GPIO_Pin_14 //PE.14
#else
#define GPIO_PIN_SW_F GPIOE->IDR
#define PIN_SW_F GPIO_Pin_14 //PE.14
@@ -55,8 +55,8 @@
#define GPIO_PIN_SW_E_L GPIOB->IDR
#define GPIO_PIN_SW_E_H GPIOB->IDR
#define PIN_SW_E_L GPIO_Pin_3 //PB.03
#define PIN_SW_E_H GPIO_Pin_4 //PB.04
#define PIN_SW_E_L GPIO_Pin_3 //PB.03
#define PIN_SW_E_H GPIO_Pin_4 //PB.04
#if defined(REV3)
#define GPIO_PIN_SW_B_L GPIOB->IDR
@@ -73,8 +73,8 @@
#if defined(REV3)
#define GPIO_PIN_SW_A_H (~GPIOB->IDR)
#define GPIO_PIN_SW_A_L (~GPIOE->IDR)
#define PIN_SW_A_H GPIO_Pin_7 //PB.07
#define PIN_SW_A_L GPIO_Pin_2 //PE.02
#define PIN_SW_A_H GPIO_Pin_7 //PB.07
#define PIN_SW_A_L GPIO_Pin_2 //PE.02
#else
#define GPIO_PIN_SW_A_H GPIOB->IDR
#define GPIO_PIN_SW_A_L GPIOE->IDR
@@ -86,7 +86,7 @@
#define GPIO_PIN_SW_G_H (~GPIOA->IDR)
#define GPIO_PIN_SW_G_L (~GPIOB->IDR)
#define PIN_SW_G_H GPIO_Pin_5 //PA.05
#define PIN_SW_G_L GPIO_Pin_0 //PB.00
#define PIN_SW_G_L GPIO_Pin_0 //PB.00
#else
#define GPIO_PIN_SW_G_H GPIOE->IDR
#define GPIO_PIN_SW_G_L GPIOE->IDR
@@ -98,7 +98,7 @@
#define GPIO_PIN_SW_C_H (~GPIOB->IDR)
#define GPIO_PIN_SW_C_L (~GPIOE->IDR)
#define PIN_SW_C_H GPIO_Pin_1 //PB.01
#define PIN_SW_C_L GPIO_Pin_7 //PE.07
#define PIN_SW_C_L GPIO_Pin_7 //PE.07
#else
#define GPIO_PIN_SW_C_H GPIOE->IDR
#define GPIO_PIN_SW_C_L GPIOA->IDR
@@ -109,8 +109,13 @@
#if defined(REV3)
#define GPIO_PIN_SW_D_H (~GPIOE->IDR)
#define GPIO_PIN_SW_D_L (~GPIOE->IDR)
#define PIN_SW_D_H GPIO_Pin_9 //PE.09
#define PIN_SW_D_L GPIO_Pin_8 //PE.08
#define PIN_SW_D_H GPIO_Pin_9 //PE.09
#define PIN_SW_D_L GPIO_Pin_8 //PE.08
#elif defined(REVPLUS)
#define GPIO_PIN_SW_D_H (GPIOE->IDR)
#define GPIO_PIN_SW_D_L (GPIOE->IDR)
#define PIN_SW_D_H GPIO_Pin_7 //PE.07
#define PIN_SW_D_L GPIO_Pin_13 //PE.13
#else
#define GPIO_PIN_SW_D_H GPIOE->IDR
#define GPIO_PIN_SW_D_L GPIOB->IDR
@@ -121,6 +126,9 @@
#if defined(REV3)
#define GPIO_PIN_SW_H (~GPIOE->IDR)
#define PIN_SW_H GPIO_Pin_13 //PE.13
#elif defined(REVPLUS)
#define GPIO_PIN_SW_H GPIOD->IDR
#define PIN_SW_H GPIO_Pin_14 //PD.14
#else
#define GPIO_PIN_SW_H GPIOE->IDR
#define PIN_SW_H GPIO_Pin_13 //PE.13
@@ -139,6 +147,9 @@
#else
#define PIN_FLP_J2 GPIO_Pin_0 //PB.00
#endif
#if defined(REVPLUS)
#define PIN_FLP_J3 GPIO_Pin_1 //PB.01
#endif
#define PIN_MVOLT GPIO_Pin_0 //PC.00
#if defined(REV3)
#define RCC_AHB1Periph_GPIOADC RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC
@@ -156,8 +167,15 @@
#define RCC_AHB1Periph_GPIOPWR RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD
#define GPIOPWRLED GPIOC
#define GPIOPWR GPIOD
#define PIN_INT_RF_PWR GPIO_Pin_15
#define GPIO_EXT_RF_PWR GPIOD
#define PIN_EXT_RF_PWR GPIO_Pin_8
#if defined(REVPLUS)
#define GPIO_INT_RF_PWR GPIOC
#define PIN_INT_RF_PWR GPIO_Pin_6
#else
#define GPIO_INT_RF_PWR GPIOD
#define PIN_INT_RF_PWR GPIO_Pin_15
#endif
// Trainer Port
#define GPIO_TR_INOUT GPIOC
@@ -219,20 +237,46 @@
#define PIN_FS_DM GPIO_Pin_11 //PA.11
#define PIN_FS_DP GPIO_Pin_12 //PA.12
// BackLight PB8
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB
#define GPIO_Pin_BL GPIO_Pin_8 //PB.08
#define GPIOBL GPIOB
#define GPIO_PinSource_BL GPIO_PinSource8
// BackLight
#if defined (REVPLUS)
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOD
#define GPIO_Pin_BL GPIO_Pin_15 //PD.15
#define Pin_BL_AF GPIO_AF_TIM4
#define GPIOBL GPIOD
#define GPIO_PinSource_BL GPIO_PinSource15
#define GPIO_Pin_BLW GPIO_Pin_13 //PD.13
#define Pin_BLW_AF GPIO_AF_TIM4
#define GPIO_PinSource_BLW GPIO_PinSource13
#else
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB
#define GPIO_Pin_BL GPIO_Pin_8 //PB.08
#define Pin_BL_AF GPIO_AF_TIM10
#define GPIOBL GPIOB
#define GPIO_PinSource_BL GPIO_PinSource8
#endif
// LCD GPIOD 10-14
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD
#define GPIO_LCD GPIOD
#define PIN_LCD_MOSI GPIO_Pin_10 //PD.10
#define PIN_LCD_CLK GPIO_Pin_11 //PD.11
#define PIN_LCD_NCS GPIO_Pin_14 //PD.14
#define PIN_LCD_A0 GPIO_Pin_13 //PD.13
#define PIN_LCD_RST GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize
// LCD
#if defined(REVPLUS)
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD
#define GPIO_LCD_SPI GPIOC
#define GPIO_LCD_NCS GPIOA
#define GPIO_LCD_RST GPIOD
#define PIN_LCD_MOSI GPIO_Pin_12 //PC.12
#define PIN_LCD_CLK GPIO_Pin_10 //PC.10
#define PIN_LCD_NCS GPIO_Pin_15 //PA.15
#define PIN_LCD_A0 GPIO_Pin_11 //PC.11
#define PIN_LCD_RST GPIO_Pin_12 //PD.12
#else
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD
#define GPIO_LCD_SPI GPIOD
#define GPIO_LCD_NCS GPIOD
#define GPIO_LCD_RST GPIOD
#define PIN_LCD_MOSI GPIO_Pin_10 //PD.10
#define PIN_LCD_CLK GPIO_Pin_11 //PD.11
#define PIN_LCD_NCS GPIO_Pin_14 //PD.14
#define PIN_LCD_A0 GPIO_Pin_13 //PD.13
#define PIN_LCD_RST GPIO_Pin_12 //PD.12
#endif
// Audio - I2S3
#define CODEC_I2S SPI3
@@ -296,27 +340,29 @@
#define RCC_AHB1Periph_GPIO_SD RCC_AHB1Periph_GPIOB
#define RCC_APBPeriphClockCmd_SPI_SD RCC_APB1PeriphClockCmd
#define RCC_APBPeriph_SPI_SD RCC_APB1Periph_SPI2
#define RCC_AHB1Periph_DMA_SD RCC_AHB1Periph_DMA1
#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 //10.5<20MHZ,make sure < 20MHZ
#define RCC_AHB1Periph_DMA_SD RCC_AHB1Periph_DMA1
#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 //10.5<20MHZ,make sure < 20MHZ
//disabled io_ctl and cp/wp
#define CARD_SUPPLY_SWITCHABLE 0
#define SOCKET_WP_CONNECTED 0
#define SOCKET_CP_CONNECTED 0
#define CARD_SUPPLY_SWITCHABLE 0
#define SOCKET_WP_CONNECTED 0
#define SOCKET_CP_CONNECTED 0
/* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */
#define STM32_SD_DISK_IOCTRL_FORCE 0
//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
#define DMA_Channel_SPI_SD_RX DMA1_Stream3
#define DMA_Channel_SPI_SD_TX DMA1_Stream4
#define DMA_Channel_SPI_SD_RX DMA1_Stream3
#define DMA_Channel_SPI_SD_TX DMA1_Stream4
#define DMA_FLAG_SPI_SD_TC_RX DMA_FLAG_TCIF3
#define DMA_FLAG_SPI_SD_TC_TX DMA_FLAG_TCIF4
#define DMA_Channel_SPI2_TX DMA_Channel_0
#define DMA_Channel_SPI2_RX DMA_Channel_0
#define DMA_FLAG_SPI_SD_TC_RX DMA_FLAG_TCIF3
#define DMA_FLAG_SPI_SD_TC_TX DMA_FLAG_TCIF4
#define DMA_Channel_SPI2_TX DMA_Channel_0
#define DMA_Channel_SPI2_RX DMA_Channel_0
#endif
// Audio----I2S3-----SPI3
@@ -331,4 +377,16 @@
#define I2C_EEPROM_ADDRESS 0xA2
#define I2C_CAT5137_ADDRESS 0x5C //0101110
// Haptic
#if defined(REVPLUS)
#define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOB
#define GPIO_PinSource_HAPTIC GPIO_PinSource8
#define GPIO_HAPTIC GPIOB
#define PIN_HAPTIC GPIO_Pin_8
#else
#define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOC
#define GPIO_HAPTIC GPIOC
#define PIN_HAPTIC GPIO_Pin_12
#endif
#endif
+105
View File
@@ -0,0 +1,105 @@
/*
* 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"
#if defined(REVPLUS)
void hapticOff(void)
{
TIM10->CCR1 = 0;
}
void hapticOn(uint32_t pwmPercent)
{
if (pwmPercent > 100) {
pwmPercent = 100;
}
TIM10->CCR1 = pwmPercent;
}
void hapticInit(void)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIO_HAPTIC, GPIO_PinSource_HAPTIC, GPIO_AF_TIM10);
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
TIM10->ARR = 100 ;
TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
TIM10->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 ; // PWM
TIM10->CCER = TIM_CCER_CC1E ;
TIM10->CCR1 = 0 ;
TIM10->EGR = 0 ;
TIM10->CR1 = TIM_CR1_CEN ; // Counter enable
}
#else
// No PWM before REVPLUS
void hapticInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE);
/* GPIO Configuration*/
GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure);
}
void hapticOff(void)
{
GPIO_ResetBits(GPIO_HAPTIC, PIN_HAPTIC);
}
void hapticOn()
{
GPIO_SetBits(GPIO_HAPTIC, PIN_HAPTIC);
}
#endif
+10 -9
View File
@@ -10,7 +10,7 @@
******************************************************************************
*/
#include "../opentx.h"
#include "board_taranis.h"
#define I2C_delay() delay_01us(100);
@@ -44,7 +44,7 @@ static void I2C_GPIO_Configuration(void)
SCL_H;
}
short I2C_START()
short I2C_START(void)
{
SDA_H;
I2C_delay();
@@ -59,7 +59,7 @@ short I2C_START()
return 1;
}
void I2C_STOP()
void I2C_STOP(void)
{
SCL_L;
I2C_delay();
@@ -71,7 +71,7 @@ void I2C_STOP()
I2C_delay();
}
void I2C_ACK()
void I2C_ACK(void)
{
SCL_L;
I2C_delay();
@@ -82,7 +82,8 @@ void I2C_ACK()
SCL_L;
I2C_delay();
}
void I2C_NO_ACK()
void I2C_NO_ACK(void)
{
SCL_L;
I2C_delay();
@@ -94,7 +95,7 @@ void I2C_NO_ACK()
I2C_delay();
}
short I2C_WAIT_ACK()
short I2C_WAIT_ACK(void)
{
short i=50;
SCL_L;
@@ -103,7 +104,7 @@ short I2C_WAIT_ACK()
I2C_delay();
SCL_H;
I2C_delay();
while(i) {
while (i) {
if(SDA_read) {
I2C_delay();
i--;
@@ -138,7 +139,7 @@ void I2C_SEND_DATA(char SendByte)
I2C_delay();
}
char I2C_READ()
char I2C_READ(void)
{
short i=8;
char ReceiveByte=0;
@@ -158,7 +159,7 @@ char I2C_READ()
return ReceiveByte;
}
void I2C_EE_Init()
void I2C_EE_Init(void)
{
/* GPIO Periph clock enable */
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
+9 -1
View File
@@ -33,6 +33,10 @@
#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)
#ifdef __cplusplus
extern "C" {
#endif
/* Exported functions ------------------------------------------------------- */
void I2C_EE_Init(void);
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_set_volume(register uint8_t volume);
uint8_t I2C_read_volume();
uint8_t I2C_read_volume(void);
#ifdef __cplusplus
}
#endif
#endif /* __I2C_EE_H */
+11 -18
View File
@@ -230,14 +230,17 @@ bool switchState(EnumKeys enuk)
void keysInit()
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOC GPIOD clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBUTTON, ENABLE);
/* GPIO Configuration*/
#if defined(REV3)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
| PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F | PIN_SW_C_L | PIN_SW_D_H | PIN_SW_H;
#elif defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
| PIN_SW_F | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L;
#else
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
@@ -249,29 +252,23 @@ void keysInit()
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOE, &GPIO_InitStructure);
#if defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H;
#else
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
#endif
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOC, &GPIO_InitStructure);
#if defined(REV3)
GPIO_InitStructure.GPIO_Pin = PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_G_L;
#elif defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H;
#else
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_D_L;
#endif
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOB, &GPIO_InitStructure);
#if defined(REV3)
@@ -279,10 +276,6 @@ void keysInit()
#else
GPIO_InitStructure.GPIO_Pin = PIN_SW_C_L;
#endif
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
#endif
+44 -14
View File
@@ -9,11 +9,11 @@
******************************************************************************
*/
#include "../opentx.h"
#include "../../opentx.h"
#define WriteData(x) AspiData(x)
#define WriteCommand(x) AspiCmd(x)
#define CONTRAST_OFS 5
#define CONTRAST_OFS 5
static void LCD_Init()
{
@@ -21,7 +21,11 @@ static void LCD_Init()
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
AspiCmd(0x81); //Set Vop
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(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
@@ -94,12 +98,12 @@ const uint8_t lcdPalette[4] = { 0, 0x03, 0x06, 0x0F };
#define LCD_WRITE_BIT(bit) \
if (bit) \
GPIOD->BSRRL = PIN_LCD_MOSI; \
LCD_MOSI_HIGH(); \
else \
GPIOD->BSRRH = PIN_LCD_MOSI; \
GPIOD->BSRRH = PIN_LCD_CLK; /* Clock low */ \
LCD_MOSI_LOW(); \
LCD_CLK_LOW(); \
__no_operation(); \
GPIOD->BSRRL = PIN_LCD_CLK; /* Clock high */
LCD_CLK_HIGH();
void lcdRefresh()
{
@@ -133,24 +137,45 @@ static void LCD_BL_Config()
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_BL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOBL, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, GPIO_AF_TIM10);
#if defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BLW;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOBL, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BLW_AF);
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock
TIM4->ARR = 100 ;
TIM4->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
TIM4->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM
TIM4->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 ; // PWM
TIM4->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E ;
int BacklightBrightness = 40 ;
TIM4->CCR2 = BacklightBrightness ;
TIM4->CCR4 = BacklightBrightness ;
TIM4->EGR = 0 ;
TIM4->CR1 = TIM_CR1_CEN ; // Counter enable
#else
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
TIM10->ARR = 100 ;
TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1;
TIM10->CCMR1 = 0x60 ; // PWM
TIM10->CCER = 1 ;
TIM10->CCR1 = 80;
TIM10->EGR = 0 ;
TIM10->CR1 = 1 ;
#endif
}
/** Init the anolog spi gpio
@@ -162,21 +187,26 @@ static void LCD_Hardware_Init()
GPIO_InitTypeDef GPIO_InitStructure;
/*!< Configure lcd CLK\ MOSI\ A0pin in output pushpull mode *************/
GPIO_InitStructure.GPIO_Pin =PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0;
GPIO_InitStructure.GPIO_Pin = PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_LCD, &GPIO_InitStructure);
GPIO_Init(GPIO_LCD_SPI, &GPIO_InitStructure);
LCD_NCS_HIGH();
/*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS |PIN_LCD_RST;
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIO_LCD_NCS, &GPIO_InitStructure);
GPIO_Init(GPIO_LCD, &GPIO_InitStructure);
/*!< Configure lcd RST pin in output pushpull mode ,PULLUP *************/
GPIO_InitStructure.GPIO_Pin = PIN_LCD_RST;
GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure);
}
//275us
+9 -9
View File
@@ -259,8 +259,8 @@ static void init_pa10_pxx()
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
DMA2_Stream6->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
DMA2_Stream6->PAR = CONVERT_PTR(&TIM1->DMAR);
DMA2_Stream6->M0AR = CONVERT_PTR(&pxxStream[INTERNAL_MODULE][1]);
DMA2_Stream6->PAR = CONVERT_PTR_UINT(&TIM1->DMAR);
DMA2_Stream6->M0AR = CONVERT_PTR_UINT(&pxxStream[INTERNAL_MODULE][1]);
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
// DMA2_Stream2->NDTR = 100 ;
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
@@ -344,7 +344,7 @@ extern "C" void TIM1_CC_IRQHandler()
if (s_current_protocol[INTERNAL_MODULE] == PROTO_PXX) {
DMA2_Stream6->CR &= ~DMA_SxCR_EN ; // Disable DMA
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
DMA2_Stream6->M0AR = CONVERT_PTR(&pxxStream[INTERNAL_MODULE][1]);
DMA2_Stream6->M0AR = CONVERT_PTR_UINT(&pxxStream[INTERNAL_MODULE][1]);
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
TIM1->CCR3 = pxxStream[INTERNAL_MODULE][0];
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
@@ -422,8 +422,8 @@ static void init_pa7_pxx()
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
DMA2_Stream2->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
DMA2_Stream2->PAR = CONVERT_PTR(&TIM8->DMAR);
DMA2_Stream2->M0AR = CONVERT_PTR(&pxxStream[EXTERNAL_MODULE][1]);
DMA2_Stream2->PAR = CONVERT_PTR_UINT(&TIM8->DMAR);
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&pxxStream[EXTERNAL_MODULE][1]);
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
// DMA2_Stream2->NDTR = 100 ;
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
@@ -496,8 +496,8 @@ static void init_pa7_dsm2()
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
DMA2_Stream2->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 | DMA_SxCR_MSIZE_0
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
DMA2_Stream2->PAR = CONVERT_PTR(&TIM8->DMAR);
DMA2_Stream2->M0AR = CONVERT_PTR(&dsm2Stream[1]);
DMA2_Stream2->PAR = CONVERT_PTR_UINT(&TIM8->DMAR);
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&dsm2Stream[1]);
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
// DMA2_Stream2->NDTR = 100 ;
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
@@ -586,7 +586,7 @@ extern "C" void TIM8_CC_IRQHandler()
if (s_current_protocol[EXTERNAL_MODULE] == PROTO_PXX) {
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
DMA2_Stream2->M0AR = CONVERT_PTR(&pxxStream[EXTERNAL_MODULE][1]);
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&pxxStream[EXTERNAL_MODULE][1]);
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
TIM8->CCR1 = pxxStream[EXTERNAL_MODULE][0];
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
@@ -595,7 +595,7 @@ extern "C" void TIM8_CC_IRQHandler()
else if (s_current_protocol[EXTERNAL_MODULE] >= PROTO_DSM2_LP45 && s_current_protocol[EXTERNAL_MODULE] <= PROTO_DSM2_DSMX) {
DMA2_Stream2->CR &= ~DMA_SxCR_EN ; // Disable DMA
DMA2->LIFCR = DMA_LIFCR_CTCIF2 | DMA_LIFCR_CHTIF2 | DMA_LIFCR_CTEIF2 | DMA_LIFCR_CDMEIF2 | DMA_LIFCR_CFEIF2 ; // Write ones to clear bits
DMA2_Stream2->M0AR = CONVERT_PTR(&dsm2Stream[1]);
DMA2_Stream2->M0AR = CONVERT_PTR_UINT(&dsm2Stream[1]);
DMA2_Stream2->CR |= DMA_SxCR_EN ; // Enable DMA
TIM8->CCR1 = dsm2Stream[0];
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
@@ -34,26 +34,8 @@
*
*/
#include "../../opentx.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
}
#include "board_taranis.h"
#include "../../pwr.h"
void pwrInit()
{
@@ -84,13 +66,21 @@ void pwrInit()
GPIO_Init(GPIOPWRLED, &GPIO_InitStructure);
#if !defined(REV3)
GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR | PIN_EXT_RF_PWR);
GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR | PIN_EXT_RF_PWR;
GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR);
GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOPWR, &GPIO_InitStructure);
GPIO_Init(GPIO_INT_RF_PWR, &GPIO_InitStructure);
GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR);
GPIO_InitStructure.GPIO_Pin = PIN_EXT_RF_PWR;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_EXT_RF_PWR, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_TRNDET;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
@@ -101,5 +91,25 @@ void pwrInit()
#endif
// 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
}
@@ -1,165 +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)
/* 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 */
} >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
PROVIDE ( _estack = ORIGIN(RAM) + LENGTH(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) }
}
/*
*****************************************************************************
**
** 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) }
}
+155
View File
@@ -0,0 +1,155 @@
/*
*****************************************************************************
**
** 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 */
*(.version)
. = ALIGN(4); /* Align the start of the text part */
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >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) }
}
+4 -3
View File
@@ -126,12 +126,13 @@ extern "C" void TIM3_IRQHandler()
// We process g_ppmInsright here to make servo movement as smooth as possible
// while under trainee control
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
if (val>4000 && val<19000) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
ppmInState = 1; // triggered
}
else {
if (ppmInState && (ppmInState<=16)) {
if ((val>800) && (val<2200)) {
if (ppmInState>0 && ppmInState<=16) {
if (val>800 && val<2200) {
ppmInValid = 100;
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
}
else {
+27 -1
View File
@@ -82,9 +82,15 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;
}
void USB_OTG_BSP_Deinit(USB_OTG_CORE_HANDLE *pdev)
{
//nothing to do
}
/**
* @brief USB_OTG_BSP_EnableInterrupt
* Enabele USB Global interrupt
* Enable USB Global interrupt
* @param None
* @retval None
*/
@@ -99,6 +105,26 @@ void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/**
* @brief USB_OTG_BSP_DisableInterrupt
* Disable USB Global interrupt
* @param None
* @retval None
*/
void USB_OTG_BSP_DisableInterrupt(USB_OTG_CORE_HANDLE *pdev)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure);
}
/**
* @brief USB_OTG_BSP_uDelay
* This function provides delay time in micro sec
+11 -14
View File
@@ -31,11 +31,6 @@
#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
#define HID_IN_EP 0x81
#define HID_OUT_EP 0x01
#define HID_IN_PACKET 4
#define HID_OUT_PACKET 4
/* USB Core and PHY interface configuration.
Tip: To avoid modifying these defines each time you need to change the USB
@@ -159,15 +154,17 @@
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
/* __packed keyword used to decrease the data type alignment to 1-byte */
#if defined (__CC_ARM) /* ARM Compiler */
#define __packed __packed
#elif defined (__ICCARM__) /* IAR Compiler */
#define __packed __packed
#elif defined ( __GNUC__ ) /* GNU Compiler */
#define __packed __attribute__ ((__packed__))
#elif defined (__TASKING__) /* TASKING Compiler */
#define __packed __unaligned
#endif /* __CC_ARM */
#if !defined(__packed)
#if defined (__CC_ARM) /* ARM Compiler */
#define __packed __packed
#elif defined (__ICCARM__) /* IAR Compiler */
#define __packed __packed
#elif defined ( __GNUC__ ) /* GNU Compiler */
#define __packed __attribute__ ((__packed__))
#elif defined (__TASKING__) /* TASKING Compiler */
#define __packed __unaligned
#endif /* __CC_ARM */
#endif
#endif //__USB_CONF__H__
+84
View File
@@ -0,0 +1,84 @@
/*
* 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)
{
//debounce
static uint8_t debounced_state = 0;
static uint8_t last_state = 0;
if ( GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS) ) {
if (last_state) debounced_state = 1;
last_state = 1;
}
else {
if (!last_state) debounced_state = 0;
last_state = 0;
}
return debounced_state;
}
USB_OTG_CORE_HANDLE USB_OTG_dev;
void OTG_FS_IRQHandler(void)
{
USBD_OTG_ISR_Handler (&USB_OTG_dev);
}
void usbInit(void)
{
USB_OTG_BSP_Init(&USB_OTG_dev);
}
void usbStart(void)
{
#if !defined(BOOT)
//intialize USB as HID device
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb);
#else
//intialize USB as MSC device
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
#endif //!defined(BOOT)
}
void usbStop(void)
{
USBD_DeInit(&USB_OTG_dev);
}
+6
View File
@@ -46,6 +46,12 @@
#define MSC_MEDIA_PACKET 4096
#define HID_IN_EP 0x81
#define HID_OUT_EP 0x01
#define HID_IN_PACKET 9
#define HID_OUT_PACKET 9
#endif //__USBD_CONF__H__
+17 -11
View File
@@ -31,6 +31,7 @@
#include "usbd_req.h"
#include "usbd_conf.h"
#include "usb_regs.h"
#include "board_taranis.h"
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{
@@ -54,16 +55,24 @@
* @{
*/
#define USBD_VID 0x0483
#define USBD_PID 0x5720
#define USBD_VID 0x0483
#define USBD_LANGID_STRING 0x409
#define USBD_MANUFACTURER_STRING "FrSky"
#define USBD_LANGID_STRING 0x409
#define USBD_MANUFACTURER_STRING "FrSky"
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Mass Storage"
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
#define USBD_INTERFACE_FS_STRING "MSC Interface"
#if defined(BOOT)
#define USBD_PID 0x5720
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Bootloader"
#define USBD_CONFIGURATION_FS_STRING "MSC Config"
#define USBD_INTERFACE_FS_STRING "MSC Interface"
#else
#define USBD_PID 0x5710
#define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick"
#define USBD_CONFIGURATION_FS_STRING "HID Config"
#define USBD_INTERFACE_FS_STRING "HID Interface"
#endif
USBD_DEVICE USR_desc =
{
@@ -159,9 +168,7 @@ uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length)
*/
uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length)
{
USBD_GetString ((uint8_t*)USBD_PRODUCT_FS_STRING, USBD_StrDesc, length);
return USBD_StrDesc;
}
@@ -188,7 +195,6 @@ uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length)
uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length)
{
USBD_GetString ((uint8_t*)USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length);
return USBD_StrDesc;
}
@@ -0,0 +1,479 @@
/**
******************************************************************************
* @file usbd_hid_core.c
* @author MCD Application Team
* @version V1.1.0
* @date 19-March-2012
* @brief This file provides the HID core functions.
*
* @verbatim
*
* ===================================================================
* HID Class Description
* ===================================================================
* This module manages the HID class V1.11 following the "Device Class Definition
* for Human Interface Devices (HID) Version 1.11 Jun 27, 2001".
* This driver implements the following aspects of the specification:
* - The Boot Interface Subclass
* - The Mouse protocol
* - Usage Page : Generic Desktop
* - Usage : Joystick)
* - Collection : Application
*
* @note In HS mode and when the DMA is used, all variables and data structures
* dealing with the DMA during the transaction process should be 32-bit aligned.
*
*
* @endverbatim
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usbd_hid_core.h"
#include "usbd_req.h"
#include "usbd_desc.h"
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{
*/
/** @defgroup USBD_HID
* @brief usbd core module
* @{
*/
/** @defgroup USBD_HID_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup USBD_HID_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup USBD_HID_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_HID_Private_FunctionPrototypes
* @{
*/
static uint8_t USBD_HID_Init (void *pdev,
uint8_t cfgidx);
static uint8_t USBD_HID_DeInit (void *pdev,
uint8_t cfgidx);
static uint8_t USBD_HID_Setup (void *pdev,
USB_SETUP_REQ *req);
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length);
static uint8_t USBD_HID_DataIn (void *pdev, uint8_t epnum);
/**
* @}
*/
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma data_alignment=4
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
/*
This USB HID endpoint report description defines a device with:
* 8 digital buttons
* 8 analog axes with 8bit resolution
Repot packet described as C struct is:
struct {
uint8_t buttons; //bit 0 - button 1, bit 1 - button 2, ..., mapped to channels 9-16, on if channel > 0
uint8_t X; //analog value, mapped to channel 1
uint8_t Y; //analog value, mapped to channel 2
uint8_t Z; //analog value, mapped to channel 3
uint8_t Rx; //analog value, mapped to channel 4
uint8_t Ry //analog value, mapped to channel 5
uint8_t Rz; //analog value, mapped to channel 6
uint8_t S1; //analog value, mapped to channel 7
uint8_t S2; //analog value, mapped to channel 8
}
*/
__ALIGN_BEGIN static uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Game Pad)
0xa1, 0x01, // COLLECTION (Application)
0xa1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x08, // REPORT_COUNT (8)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x32, // USAGE (Z)
0x09, 0x33, // USAGE (Rx)
0x09, 0x34, // USAGE (Ry)
0x09, 0x35, // USAGE (Rz)
0x09, 0x36, // USAGE (Slider)
0x09, 0x36, // USAGE (Slider)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};
/** @defgroup USBD_HID_Private_Variables
* @{
*/
USBD_Class_cb_TypeDef USBD_HID_cb =
{
USBD_HID_Init,
USBD_HID_DeInit,
USBD_HID_Setup,
NULL, /*EP0_TxSent*/
NULL, /*EP0_RxReady*/
USBD_HID_DataIn, /*DataIn*/
NULL, /*DataOut*/
NULL, /*SOF */
NULL,
NULL,
USBD_HID_GetCfgDesc,
#ifdef USB_OTG_HS_CORE
USBD_HID_GetCfgDesc, /* use same config as per FS */
#endif
};
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma data_alignment=4
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
__ALIGN_BEGIN static uint32_t USBD_HID_AltSet __ALIGN_END = 0;
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma data_alignment=4
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
__ALIGN_BEGIN static uint32_t USBD_HID_Protocol __ALIGN_END = 0;
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma data_alignment=4
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
__ALIGN_BEGIN static uint32_t USBD_HID_IdleState __ALIGN_END = 0;
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
#pragma data_alignment=4
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
/* USB HID device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
USB_HID_CONFIG_DESC_SIZ,
/* wTotalLength: Bytes returned */
0x00,
0x01, /*bNumInterfaces: 1 interface*/
0x01, /*bConfigurationValue: Configuration value*/
0x00, /*iConfiguration: Index of string descriptor describing
the configuration*/
0xE0, /*bmAttributes: bus powered and Support Remote Wake-up */
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
/************** Descriptor of Joystick Mouse interface ****************/
/* 09 */
0x09, /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/
0x00, /*bInterfaceNumber: Number of Interface*/
0x00, /*bAlternateSetting: Alternate setting*/
0x01, /*bNumEndpoints*/
0x03, /*bInterfaceClass: HID*/
0x00 /*0x01*/, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00 /*0x02*/, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0, /*iInterface: Index of string descriptor*/
/******************** Descriptor of Joystick Mouse HID ********************/
/* 18 */
0x09, /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
0x11, /*bcdHID: HID Class Spec release number*/
0x01,
0x00, /*bCountryCode: Hardware target country*/
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22, /*bDescriptorType*/
sizeof(HID_JOYSTICK_ReportDesc),/*wItemLength: Total length of Report descriptor*/
0x00,
/******************** Descriptor of Mouse endpoint ********************/
/* 27 */
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
HID_IN_EP, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET, /*wMaxPacketSize: 4 Byte max */
0x00,
0x0A, /*bInterval: Polling Interval (10 ms)*/
/* 34 */
} ;
static uint8_t ReportSent;
/**
* @}
*/
/** @defgroup USBD_HID_Private_Functions
* @{
*/
/**
* @brief USBD_HID_Init
* Initialize the HID interface
* @param pdev: device instance
* @param cfgidx: Configuration index
* @retval status
*/
static uint8_t USBD_HID_Init (void *pdev,
uint8_t cfgidx)
{
/* Open EP IN */
DCD_EP_Open(pdev,
HID_IN_EP,
HID_IN_PACKET,
USB_OTG_EP_INT);
/* Open EP OUT */
DCD_EP_Open(pdev,
HID_OUT_EP,
HID_OUT_PACKET,
USB_OTG_EP_INT);
ReportSent = 1;
return USBD_OK;
}
/**
* @brief USBD_HID_Init
* DeInitialize the HID layer
* @param pdev: device instance
* @param cfgidx: Configuration index
* @retval status
*/
static uint8_t USBD_HID_DeInit (void *pdev,
uint8_t cfgidx)
{
/* Close HID EPs */
DCD_EP_Close (pdev , HID_IN_EP);
DCD_EP_Close (pdev , HID_OUT_EP);
ReportSent = 1;
return USBD_OK;
}
/**
* @brief USBD_HID_Setup
* Handle the HID specific requests
* @param pdev: instance
* @param req: usb requests
* @retval status
*/
static uint8_t USBD_HID_Setup (void *pdev,
USB_SETUP_REQ *req)
{
uint16_t len = 0;
uint8_t *pbuf = NULL;
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
switch (req->bRequest)
{
case HID_REQ_SET_PROTOCOL:
USBD_HID_Protocol = (uint8_t)(req->wValue);
break;
case HID_REQ_GET_PROTOCOL:
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_HID_Protocol,
1);
break;
case HID_REQ_SET_IDLE:
USBD_HID_IdleState = (uint8_t)(req->wValue >> 8);
break;
case HID_REQ_GET_IDLE:
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_HID_IdleState,
1);
break;
default:
USBD_CtlError (pdev, req);
return USBD_FAIL;
}
break;
case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_DESCRIPTOR:
if( req->wValue >> 8 == HID_REPORT_DESC)
{
len = MIN(sizeof(HID_JOYSTICK_ReportDesc) , req->wLength);
pbuf = HID_JOYSTICK_ReportDesc; // wiiccReportDescriptor; //
}
else if( req->wValue >> 8 == HID_DESCRIPTOR_TYPE)
{
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
pbuf = USBD_HID_Desc;
#else
pbuf = USBD_HID_CfgDesc + 0x12;
#endif
len = MIN(USB_HID_DESC_SIZ , req->wLength);
}
USBD_CtlSendData (pdev,
pbuf,
len);
break;
case USB_REQ_GET_INTERFACE :
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_HID_AltSet,
1);
break;
case USB_REQ_SET_INTERFACE :
USBD_HID_AltSet = (uint8_t)(req->wValue);
break;
}
}
return USBD_OK;
}
/**
* @brief USBD_HID_SendReport
* Send HID Report
* @param pdev: device instance
* @param buff: pointer to report
* @retval status
*/
uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev,
uint8_t *report,
uint16_t len)
{
if (pdev->dev.device_status == USB_OTG_CONFIGURED )
{
if ( ReportSent )
{
ReportSent = 0;
DCD_EP_Tx (pdev, HID_IN_EP, report, len);
}
}
return USBD_OK;
}
/**
* @brief USBD_HID_GetCfgDesc
* return configuration descriptor
* @param speed : current device speed
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length)
{
*length = sizeof (USBD_HID_CfgDesc);
return USBD_HID_CfgDesc;
}
/**
* @brief USBD_HID_DataIn
* handle data IN Stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
static uint8_t USBD_HID_DataIn (void *pdev,
uint8_t epnum)
{
ReportSent = 1;
/* Ensure that the FIFO is empty before a new transfer, this condition could
be caused by a new transfer before the end of the previous transfer */
DCD_EP_Flush(pdev, HID_IN_EP);
return USBD_OK;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+211 -167
View File
@@ -26,8 +26,8 @@
*/
/* Includes ------------------------------------------------------------------*/
#include "../opentx.h"
#include "../FatFs/diskio.h"
#include "../../opentx.h"
#include "../../FatFs/diskio.h"
#include "board_taranis.h"
extern "C" {
@@ -35,8 +35,6 @@ extern "C" {
#include "usbd_msc_mem.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 BLOCKSIZE 512
@@ -141,7 +139,7 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
{
if (lun == 1) {
*block_size = BLOCKSIZE;
*block_num = EESIZE/BLOCKSIZE + 3 ;
*block_num = 3 + EESIZE/BLOCKSIZE + FLASHSIZE/BLOCKSIZE;
}
else {
if (!SD_CARD_PRESENT())
@@ -163,6 +161,19 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
return 0;
}
uint8_t lunReady[2] ;
void usbPluggedIn()
{
if (lunReady[0] == 0) {
lunReady[0] = 1;
}
if (lunReady[1] == 0) {
lunReady[1] = 1;
}
}
/**
* @brief check whether the medium is ready
* @param lun : logical unit number
@@ -171,9 +182,15 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
int8_t STORAGE_IsReady (uint8_t lun)
{
if (lun == 1) {
return 0;
if (lunReady[1] == 0) {
return -1 ;
}
return 0 ;
}
else {
if (lunReady[0] == 0) {
return -1 ;
}
return SD_CARD_PRESENT() ? 0 : -1;
}
}
@@ -205,14 +222,11 @@ int8_t STORAGE_Read (uint8_t lun,
uint16_t blk_len)
{
if (lun == 1) {
if (fat12Read(buf, blk_addr, blk_len) != 0) {
if (fat12Read(buf, blk_addr, blk_len) != 0)
return -1;
}
}
else {
if (SD_ReadSectors(buf,
blk_addr,
blk_len) != 0) {
if (SD_ReadSectors(buf, blk_addr, blk_len) != 0) {
return -1;
}
}
@@ -240,9 +254,7 @@ int8_t STORAGE_Write (uint8_t lun,
return -1;
}
else {
if (SD_WriteSectors(buf,
blk_addr,
blk_len) != 0)
if (SD_WriteSectors(buf, blk_addr, blk_len) != 0)
return -1;
}
@@ -267,132 +279,133 @@ int8_t STORAGE_GetMaxLun (void)
*/
const char g_FATboot[BLOCKSIZE] =
{
0xeb, 0x3c, 0x90, // Jump instruction.
0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name
0x00, 0x02, // Bytes per sector
0x01, // Sectors per FS cluster.
0x01, 0x00, // Reserved sector count
0x01, // Number of FATs
0x10, 0x00, // Number of root directory entries
(EESIZE/BLOCKSIZE)+3, 0x00, // Total sectors = 131
0xf8, // Media descriptor
0x01, 0x00, // Sectors per FAT table
0x20, 0x00, // Sectors per track
0x40, 0x00, // Number of heads
0x00, 0x00, 0x00, 0x00, // Number of hidden sectors
0x00, 0x00, 0x00, 0x00, // Large number of sectors.
0x00, // Physical drive number
0x00, // Reserved
0x29, // Extended boot signature
0xCE, 0xFA, 0x5C, 0xD1, // Disk ID (serial number)
0x56, 0x49, 0x52, 0x54, 0x46, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, // Volume label
0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, // FAT file system type
0x00, 0x00, // OS boot code
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
0xeb, 0x3c, 0x90, // Jump instruction.
0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name
0x00, 0x02, // Bytes per sector
0x08, // Sectors per FS cluster.
0x01, 0x00, // Reserved sector count
0x01, // Number of FATs
0x10, 0x00, // Number of root directory entries
3+(EESIZE/BLOCKSIZE), (FLASHSIZE/BLOCKSIZE)>>8, // Total sectors
0xf8, // Media descriptor
0x01, 0x00, // Sectors per FAT table
0x20, 0x00, // Sectors per track
0x40, 0x00, // Number of heads
0x00, 0x00, 0x00, 0x00, // Number of hidden sectors
0x00, 0x00, 0x00, 0x00, // Large number of sectors.
0x00, // Physical drive number
0x00, // Reserved
0x29, // Extended boot signature
0xCE, 0xFA, 0x5C, 0xD1, // Disk ID (serial number)
0x56, 0x49, 0x52, 0x54, 0x46, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, // Volume label
0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, // FAT file system type
0x00, 0x00, // OS boot code
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
};
#if defined(REV4a)
const char g_FAT[BLOCKSIZE] =
{
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B,
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60,
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B,
0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60,
0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06,
0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B,
0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60,
0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08,
0x81, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B,
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0xF0, 0xFF, 0x13, 0x40, 0x01, 0x15, 0x60,
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B,
0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60,
0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06,
0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B,
0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60,
0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08,
0x81, 0x20, 0x08, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xA0, 0x08, 0x8B,
0xC0, 0x08, 0x8D, 0xE0, 0x08, 0x8F, 0x00, 0x09, 0x91, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#else
const char g_FAT[BLOCKSIZE] =
{
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B,
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60,
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
0x41, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xF0, 0xFF, 0x0B,
0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60,
0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02,
0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B,
0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60,
0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04,
0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B,
0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60,
0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06,
0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B,
0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60,
0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08,
0x81, 0x20, 0x08, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xF0, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#endif
@@ -442,7 +455,7 @@ const FATDirEntry_t g_DIRroot[16] =
0x00000000
},
{
{ 'T', 'A', 'R', 'A', 'N', 'I', 'S', ' '},
{ 'E', 'E', 'P', 'R', 'O', 'M', ' ', ' '},
{ 'B', 'I', 'N'},
0x24, // Archive, hidden, system
0x00,
@@ -457,19 +470,19 @@ const FATDirEntry_t g_DIRroot[16] =
EESIZE
},
{
{ '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{ ' ', ' ', ' '},
0x00,
0x00,
{ 'F', 'I', 'R', 'M', 'W', 'A', 'R', 'E'},
{ 'B', 'I', 'N'},
0x24, // Archive, hidden, system
0x00,
0x3E,
0xA301,
0x3D55,
0x3D55,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x00000000
0xA302,
0x3D55,
0x0002 + (EESIZE/BLOCKSIZE)/8,
FLASHSIZE
},
{
{ '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
@@ -674,17 +687,24 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
while ( count )
{
if (sector == 0) {
memcpy( buffer, g_FATboot, BLOCKSIZE ) ;
memcpy(buffer, g_FATboot, BLOCKSIZE ) ;
}
else if (sector == 1/*Reserved sector count*/) {
// FAT table.
memcpy( buffer, g_FAT, BLOCKSIZE);
memcpy(buffer, g_FAT, BLOCKSIZE);
}
else if (sector == 2) {
memcpy( buffer, g_DIRroot, BLOCKSIZE ) ;
memcpy(buffer, g_DIRroot, BLOCKSIZE ) ;
}
else {
eeprom_read_block (buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
eeprom_read_block(buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
}
else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) {
uint32_t address;
address = sector - 3 - (EESIZE/BLOCKSIZE);
address *= BLOCKSIZE;
address += FIRMWARE_ADDRESS;
memcpy(buffer, (uint8_t *)address, BLOCKSIZE);
}
buffer += BLOCKSIZE ;
sector++ ;
@@ -692,35 +712,59 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
}
return 0 ;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
{
static int offset = 0;
static uint8_t eepromOffset = 0;
static uint8_t firmwareAllowed = 0;
TRACE("FAT12 Write(sector=%d, count=%d)", sector, count);
while (count) {
const EeFs * test = (const EeFs *)buffer;
if (offset == 0 && test->version==EEFS_VERS && test->mySize==sizeof(eeFs) && test->bs==BS) {
TRACE("EEPROM start found in sector %d", sector);
offset = sector;
if (sector < 3) {
// reserved, read-only
}
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
while (count) {
if (eepromOffset == 0 && isEepromStart(buffer)) {
TRACE("EEPROM start found in sector %d", sector);
eepromOffset = sector;
}
if (eepromOffset && sector >= eepromOffset && (sector-eepromOffset) < EESIZE/BLOCKSIZE) {
eeWriteBlockCmp((uint8_t *)buffer, (sector-eepromOffset)*BLOCKSIZE, BLOCKSIZE);
}
buffer += BLOCKSIZE;
sector++;
count--;
if (sector-eepromOffset >= EESIZE/BLOCKSIZE) {
TRACE("EEPROM end written at sector %d", sector-1);
eepromOffset = 0;
}
}
if (offset && sector >= offset && (sector-offset) < EESIZE/BLOCKSIZE) {
eeWriteBlockCmp((uint8_t *)buffer, (sector-offset)*BLOCKSIZE, BLOCKSIZE);
}
buffer += BLOCKSIZE;
sector++;
count--;
if (sector-offset >= EESIZE/BLOCKSIZE) {
TRACE("EEPROM end written at sector %d", sector-1);
offset = 0;
}
else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) {
// firmware
uint32_t address;
address = sector - 3 - (EESIZE/BLOCKSIZE);
address *= BLOCKSIZE;
address += FIRMWARE_ADDRESS;
while (count) {
for (uint32_t i=0; i<BLOCKSIZE/FLASH_PAGESIZE; i++) {
if (address >= FIRMWARE_ADDRESS+BOOTLOADER_SIZE/*protect bootloader*/ && address <= FIRMWARE_ADDRESS+FLASHSIZE-FLASH_PAGESIZE) {
if (address == FIRMWARE_ADDRESS+BOOTLOADER_SIZE) {
firmwareAllowed = isFirmwareStart(buffer);
}
if (firmwareAllowed) {
writeFlash((uint32_t *)address, (uint32_t *)buffer);
}
}
address += FLASH_PAGESIZE;
buffer += FLASH_PAGESIZE;
}
count--;
}
}
return 0 ;
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+1 -2
View File
@@ -26,7 +26,7 @@
*/
/* Includes ------------------------------------------------------------------*/
#include "../opentx.h"
#include "../../opentx.h"
extern "C" {
#include "usbd_usr.h"
@@ -119,7 +119,6 @@ void USBD_USR_DeviceConnected (void)
*/
void USBD_USR_DeviceDisconnected (void)
{
NVIC_SystemReset();
}
+2 -2
View File
@@ -192,7 +192,7 @@ void parseTelemHubByte(uint8_t byte)
case offsetof(FrskySerialData, current):
#if defined(FAS_OFFSET) || !defined(CPUM64)
if(((int16_t)frskyData.hub.current + g_model.frsky.fasOffset)>0)
if ((int16_t)frskyData.hub.current > 0 && ((int16_t)frskyData.hub.current + g_model.frsky.fasOffset) > 0)
frskyData.hub.current += g_model.frsky.fasOffset;
else
frskyData.hub.current = 0;
@@ -723,7 +723,7 @@ void telemetryInterrupt10ms()
uint16_t current = 0;
#endif
channel = g_model.frsky.currentSource - FRSKY_SOURCE_A1;
channel = g_model.frsky.currentSource - FRSKY_CURRENT_SOURCE_A1;
if (channel <= 1) {
current = applyChannelRatio(channel, frskyData.analog[channel].value) / 10;
}
+10 -2
View File
@@ -139,6 +139,7 @@ PACK(struct FrskySerialData {
int16_t maxTemperature2;
uint16_t maxGpsSpeed;
uint16_t maxGpsDistance;
uint16_t maxAirSpeed;
int16_t minCell;
int16_t minCells;
int16_t minVfas;
@@ -247,8 +248,15 @@ void resetTelemetry();
#define TELEMETRY_GPS_SPEED_UNIT (IS_IMPERIAL_ENABLE() ? SPEED_UNIT_IMP : SPEED_UNIT_METR)
#define TELEMETRY_GPS_SPEED_FORMAT "%d,"
#define TELEMETRY_GPS_SPEED_ARGS getConvertedTelemetryValue(frskyData.hub.gpsSpeed_bp, UNIT_KTS),
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, frskyData.hub.cellVolts[0]*2/100, frskyData.hub.cellVolts[0]*2%100, frskyData.hub.cellVolts[1]*2/100, frskyData.hub.cellVolts[1]*2%100, frskyData.hub.cellVolts[2]*2/100, frskyData.hub.cellVolts[2]*2%100, frskyData.hub.cellVolts[3]*2/100, frskyData.hub.cellVolts[3]*2%100, frskyData.hub.cellVolts[4]*2/100, frskyData.hub.cellVolts[4]*2%100, frskyData.hub.cellVolts[5]*2/100, frskyData.hub.cellVolts[5]*2%100,
#if defined(CPUARM)
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, frskyData.hub.cellVolts[0]*2/100, frskyData.hub.cellVolts[0]*2%100, frskyData.hub.cellVolts[1]*2/100, frskyData.hub.cellVolts[1]*2%100, frskyData.hub.cellVolts[2]*2/100, frskyData.hub.cellVolts[2]*2%100, frskyData.hub.cellVolts[3]*2/100, frskyData.hub.cellVolts[3]*2%100, frskyData.hub.cellVolts[4]*2/100, frskyData.hub.cellVolts[4]*2%100, frskyData.hub.cellVolts[5]*2/100, frskyData.hub.cellVolts[5]*2%100, frskyData.hub.cellVolts[6]*2/100, frskyData.hub.cellVolts[6]*2%100, frskyData.hub.cellVolts[7]*2/100, frskyData.hub.cellVolts[7]*2%100, frskyData.hub.cellVolts[8]*2/100, frskyData.hub.cellVolts[8]*2%100, frskyData.hub.cellVolts[9]*2/100, frskyData.hub.cellVolts[9]*2%100, frskyData.hub.cellVolts[10]*2/100, frskyData.hub.cellVolts[10]*2%100, frskyData.hub.cellVolts[11]*2/100, frskyData.hub.cellVolts[11]*2%100,
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,Cell 7,Cell 8,Cell 9,Cell 10,Cell 11,Cell 12,"
#else
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, frskyData.hub.cellVolts[0]*2/100, frskyData.hub.cellVolts[0]*2%100, frskyData.hub.cellVolts[1]*2/100, frskyData.hub.cellVolts[1]*2%100, frskyData.hub.cellVolts[2]*2/100, frskyData.hub.cellVolts[2]*2%100, frskyData.hub.cellVolts[3]*2/100, frskyData.hub.cellVolts[3]*2%100, frskyData.hub.cellVolts[4]*2/100, frskyData.hub.cellVolts[4]*2%100, frskyData.hub.cellVolts[5]*2/100, frskyData.hub.cellVolts[5]*2%100,
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,"
#endif
#define TELEMETRY_CURRENT_FORMAT "%d.%02d,"
#define TELEMETRY_CURRENT_ARGS frskyData.hub.current / 100, frskyData.hub.current % 100,
#define TELEMETRY_VFAS_FORMAT "%d.%d,"
+16 -4
View File
@@ -118,6 +118,10 @@
#define GPS_TIME_DATE_FIRST_ID 0x0850
#define GPS_TIME_DATE_LAST_ID 0x085f
// Temporary IDs, will be changed when FrSky will have defined them in the S.PORT protocol
#define AIR_SPEED_FIRST_ID 0x0a00
#define AIR_SPEED_LAST_ID 0x0a0f
// FrSky wrong IDs ?
#define BETA_VARIO_ID 0x8030
#define BETA_BARO_ALT_ID 0x8010
@@ -249,7 +253,7 @@ void processHubPacket(uint8_t id, uint16_t value)
case GPS_SPEED_BP_ID:
// Speed => Max speed
frskyData.hub.gpsSpeed_bp = (frskyData.hub.gpsSpeed_bp * 46) / 25;
frskyData.hub.gpsSpeed_bp = frskyData.hub.gpsSpeed_bp;
if (frskyData.hub.gpsSpeed_bp > frskyData.hub.maxGpsSpeed)
frskyData.hub.maxGpsSpeed = frskyData.hub.gpsSpeed_bp;
break;
@@ -397,9 +401,15 @@ void processSportPacket(uint8_t *packet)
else if (appId >= VFAS_FIRST_ID && appId <= VFAS_LAST_ID) {
frskyData.hub.vfas = SPORT_DATA_U32(packet)/10; //TODO: remove /10 and display with PREC2 when using SPORT
}
else if (appId >= AIR_SPEED_FIRST_ID && appId <= AIR_SPEED_LAST_ID) {
frskyData.hub.airSpeed = SPORT_DATA_U32(packet);
frskyData.hub.airSpeed /= 10;
if (frskyData.hub.airSpeed > frskyData.hub.maxAirSpeed)
frskyData.hub.maxAirSpeed = frskyData.hub.airSpeed;
}
else if (appId >= GPS_SPEED_FIRST_ID && appId <= GPS_SPEED_LAST_ID) {
frskyData.hub.gpsSpeed_bp = SPORT_DATA_U32(packet);
frskyData.hub.gpsSpeed_bp = (frskyData.hub.gpsSpeed_bp * 46) / 25 / 1000;
frskyData.hub.gpsSpeed_bp /= 1000;
if (frskyData.hub.gpsSpeed_bp > frskyData.hub.maxGpsSpeed)
frskyData.hub.maxGpsSpeed = frskyData.hub.gpsSpeed_bp;
}
@@ -595,7 +605,7 @@ void telemetryInterrupt10ms()
uint16_t current = 0;
#endif
channel = g_model.frsky.currentSource - FRSKY_SOURCE_A1;
channel = g_model.frsky.currentSource - FRSKY_CURRENT_SOURCE_A1;
if (channel <= 1) {
current = applyChannelRatio(channel, frskyData.analog[channel].value) / 10;
}
@@ -668,7 +678,7 @@ void telemetryWakeup()
if (alarmsCheckStep == 0) {
if ((IS_MODULE_XJT(0) || IS_MODULE_XJT(1)) && frskyData.swr.value > 0x33) {
AUDIO_SWR_RED();
s_global_warning = STR_ANTENNAPROBLEM;
POPUP_WARNING(STR_ANTENNAPROBLEM);
alarmsCheckTime = get_tmr10ms() + 300; /* next check in 3seconds */
}
}
@@ -781,6 +791,8 @@ void resetTelemetry()
frskyData.hub.gpsSpeed_bp = 100;
frskyData.hub.gpsSpeed_ap = 50;
frskyData.hub.airSpeed = 100;
frskyData.hub.cellsCount = 6;
frskyData.hub.baroAltitudeOffset = 500 * 100;

Some files were not shown because too many files have changed in this diff Show More