diff --git a/.travis.yml b/.travis.yml index 2a4d61081..f7e9021f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ install: - sudo dpkg --install gcc-avr_1%3a4.8-2.1_amd64.deb avr-libc_1%3a1.8.0-4.1_all.deb libmpfr4_3.1.2-1_amd64.deb binutils-avr_2.23.1-2.1_amd64.deb libmpc3_1.0.1-1ubuntu1_amd64.deb script: - - ./radio/util/commit-tests.sh . + - ./tools/commit-tests.sh . diff --git a/companion/src/firmwareinterface.cpp b/companion/src/firmwareinterface.cpp index 4f11fcbd4..889cd427a 100644 --- a/companion/src/firmwareinterface.cpp +++ b/companion/src/firmwareinterface.cpp @@ -130,10 +130,12 @@ QString FirmwareInterface::seekLabel(const QString & label) QString FirmwareInterface::getFlavour() const { - if (flavour == "opentx-x9dp") - return "opentx-taranis-plus"; - else if (flavour == "opentx-x9d") - return "opentx-taranis"; + if (flavour == "opentx-taranis-x9e") + return "opentx-x9e"; + else if (flavour == "opentx-x9dp" || flavour == "opentx-taranis-plus") + return "opentx-x9d+"; + else if (flavour == "opentx-taranis") + return "opentx-x9d"; else return flavour; } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 04ddf1f5b..e4bc84837 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -1147,7 +1147,7 @@ void addOpenTxTaranisOptions(OpenTxFirmware * firmware) Option usb_options[] = { { "massstorage", QObject::tr("Instead of Joystick emulation, USB connection is Mass Storage (as in the Bootloader)") }, { "cli", QObject::tr("Instead of Joystick emulation, USB connection is Command Line Interface") }, { NULL } }; firmware->addOptions(usb_options); firmware->addOption("mixersmon", QObject::tr("Adds mixers output view to the CHANNELS MONITOR screen, pressing [ENT] switches between the views")); - firmware->addOption("eu", QObject::tr("Removes D8 and LR12 FrSky protocols that are not legal for use in the EU on radios sold after Jan 1st, 2015")); + firmware->addOption("eu", QObject::tr("Removes D8 FrSky protocol support which is not legal for use in the EU on radios sold after Jan 1st, 2015")); firmware->addOption("internalppm", QObject::tr("Support for PPM internal module hack")); firmware->addOption("multimodule", QObject::tr("Support for the DIY-Multiprotocol-TX-Module")); firmware->addOption("sqt5font", QObject::tr("Use alternative SQT5 font")); @@ -1176,20 +1176,20 @@ void registerOpenTxFirmwares() Option dsm2_options[] = { { "DSM2", QObject::tr("Support for DSM2 modules"), 0 }, { "DSM2PPM", QObject::tr("Support for DSM2 modules using ppm instead of true serial"), 0 }, { NULL } }; /* Taranis Plus board */ - firmware = new OpenTxFirmware("opentx-taranisplus", QObject::tr("FrSky Taranis Plus"), BOARD_TARANIS_PLUS); + firmware = new OpenTxFirmware("opentx-x9d+", QObject::tr("FrSky Taranis Plus"), BOARD_TARANIS_PLUS); addOpenTxTaranisOptions(firmware); addOpenTxCommonOptions(firmware); firmwares.push_back(firmware); /* Taranis board */ - firmware = new OpenTxFirmware("opentx-taranis", QObject::tr("FrSky Taranis"), BOARD_TARANIS); + firmware = new OpenTxFirmware("opentx-x9d", QObject::tr("FrSky Taranis"), BOARD_TARANIS); firmware->addOption("haptic", QObject::tr("Haptic module installed")); addOpenTxTaranisOptions(firmware); addOpenTxCommonOptions(firmware); firmwares.push_back(firmware); /* Taranis X9E board */ - firmware = new OpenTxFirmware("opentx-taranisx9e", QObject::tr("FrSky Taranis X9E"), BOARD_TARANIS_X9E); + firmware = new OpenTxFirmware("opentx-x9e", QObject::tr("FrSky Taranis X9E"), BOARD_TARANIS_X9E); firmware->addOption("shutdownconfirm", QObject::tr("Confirmation before radio shutdown")); addOpenTxTaranisOptions(firmware); addOpenTxCommonOptions(firmware); @@ -1460,7 +1460,7 @@ void registerOpenTxFirmwares() addOpenTxCommonOptions(firmware); firmwares.push_back(firmware); - default_firmware_variant = GetFirmware("opentx-taranisplus-en"); + default_firmware_variant = GetFirmware("opentx-x9d+"); current_firmware_variant = default_firmware_variant; } diff --git a/companion/src/simulation/simulatorimport.h b/companion/src/simulation/simulatorimport.h index 6278ac70d..0f23bc12a 100644 --- a/companion/src/simulation/simulatorimport.h +++ b/companion/src/simulation/simulatorimport.h @@ -50,7 +50,7 @@ if (inputs.rotenc) pind |= 0x20; if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40; #endif -#if defined(PCBFLAMENCO) || (defined(PCBTARANIS) && defined(REV9E)) +#if defined(PCBFLAMENCO) || defined(PCBX9E) if (inputs.rotenc) simuSetKey(KEY_ENTER, true); #endif #endif diff --git a/companion/src/translations/companion_fr.ts b/companion/src/translations/companion_fr.ts index e0b34fa85..37b16476f 100644 --- a/companion/src/translations/companion_fr.ts +++ b/companion/src/translations/companion_fr.ts @@ -8067,8 +8067,8 @@ Mixage actif par défaut si non-renseigné. - Removes D8 and LR12 FrSky protocols that are not legal for use in the EU on radios sold after Jan 1st, 2015 - Supprime les protocoles RF D8 et LR12 qui ne sont plus utilisable légalementen Europe sur les radios vendues après le 1er janvier 2015 + Removes D8 FrSky protocol support which is not legal for use in the EU on radios sold after Jan 1st, 2015 + Supprime le protocole RF D8 qui n'est plus utilisable légalement en Europe sur les radios vendues après le 1er janvier 2015 diff --git a/radio/sdcard/taranis/CROSSFIRE/Crossfire.lua b/radio/sdcard/taranis/CROSSFIRE/Crossfire.lua index 7aef9071e..47e9644e1 100644 --- a/radio/sdcard/taranis/CROSSFIRE/Crossfire.lua +++ b/radio/sdcard/taranis/CROSSFIRE/Crossfire.lua @@ -1,25 +1,37 @@ local COLUMN_2 = 140 -local edit = false +local pages = { } local pageIndex = 1 local fieldIndex = 1 local pageOffset = 0 -local pages = { } +local edit = false +local charIndex = 1 -- Change display attribute to current field local function incrField(step) local fields = pages[pageIndex].fields local field = fields[fieldIndex] - local min, max = 0, 0 - if field.type <= 5 then - min = field.min - max = field.max - elseif field.type == 9 then - min = 0 - max = #field.values - 1 - end - if (step < 0 and field.value > min) or (step > 0 and field.value < max) then - field.value = field.value + step + if field.type == 10 then + local byte = string.byte(field.value, charIndex) + step + if byte < 32 then + byte = 32 + elseif byte > 122 then + byte = 122 + end + field.value = string.sub(field.value, 1, charIndex-1) .. string.char(byte) .. string.sub(field.value, charIndex+1) + else + local min, max = 0, 0 + if field.type <= 5 then + min = field.min + max = field.max + step = field.step * step + elseif field.type == 9 then + min = 0 + max = #field.values - 1 + end + if (step < 0 and field.value > min) or (step > 0 and field.value < max) then + field.value = field.value + step + end end end @@ -32,9 +44,11 @@ end local function selectField(step) local fields = pages[pageIndex].fields local newFieldIndex = fieldIndex + local field = fields[newFieldIndex] repeat newFieldIndex = 1 + ((newFieldIndex + step - 1 + #fields) % #fields) - until newFieldIndex == fieldIndex or (pages[pageIndex].fields[newFieldIndex].type ~= 11 and pages[pageIndex].fields[newFieldIndex].name ~= nil) + field = fields[newFieldIndex] + until newFieldIndex == fieldIndex or (field.type ~= 11 and field.type ~= 12 and field.name ~= nil) fieldIndex = newFieldIndex if fieldIndex > 7 + pageOffset then pageOffset = fieldIndex - 7 @@ -135,45 +149,140 @@ local function fieldGetString(data, offset) return result, offset end --- UINT8 -local function fieldUint8SelectionLoad(field, data, offset) - field.value = data[offset] - field.min = data[offset+1] - field.max = data[offset+2] - field.unit, offset = fieldGetString(data, offset+4) +local function fieldGetValue(data, offset, size) + local result = 0 + for i=0, size-1 do + result = bit32.lshift(result, 8) + data[offset + i] + end + return result end -local function fieldUint8SelectionSave(fieldIndex) - crossfireTelemetryPush(0x2D, { pages[pageIndex].id, 0xEA, fieldIndex, pages[pageIndex].fields[fieldIndex].value }) +local function fieldUnsignedSelectionLoad(field, data, offset, size) + field.value = fieldGetValue(data, offset, size) + field.min = fieldGetValue(data, offset+size, size) + field.max = fieldGetValue(data, offset+2*size, size) + field.unit, offset = fieldGetString(data, offset+3*size) + field.step = 1 end -local function fieldIntSelectionDisplay(field, y, attr) +local function fieldUnsignedToSigned(field, size) + local bandval = bit32.lshift(0x80, (size-1)*8) + field.value = field.value - bit32.band(field.value, bandval) * 2 + field.min = field.min - bit32.band(field.min, bandval) * 2 + field.max = field.max - bit32.band(field.max, bandval) * 2 +end + +local function fieldSignedSelectionLoad(field, data, offset, size) + fieldUnsignedSelectionLoad(field, data, offset, size) + fieldUnsignedToSigned(field, size) +end + +local function fieldIntSave(fieldIndex, value, size) + local frame = { pages[pageIndex].id, 0xEA, fieldIndex } + for i=size-1, 0, -1 do + frame[#frame + 1] = (bit32.rshift(value, 8*i) % 256) + end + crossfireTelemetryPush(0x2D, frame) +end + +local function fieldUnsignedSelectionSave(fieldIndex, size) + local value = pages[pageIndex].fields[fieldIndex].value + fieldIntSave(fieldIndex, value, size) +end + +local function fieldSignedSelectionSave(fieldIndex, size) + local value = pages[pageIndex].fields[fieldIndex].value + if value < 0 then + value = bit32.lshift(0x100, (size-1)*8) - value + end + fieldIntSave(fieldIndex, value, size) +end + +local function fieldIntDisplay(field, y, attr) lcd.drawNumber(COLUMN_2, y, field.value, LEFT + attr) lcd.drawText(lcd.getLastPos(), y, field.unit, attr) end --- UINT16 -local function fieldUint16SelectionLoad(field, data, offset) - field.value = bit32.lshift(data[offset], 8) + data[offset+1] - field.min = bit32.lshift(data[offset+2], 8) + data[offset+3] - field.max = bit32.lshift(data[offset+4], 8) + data[offset+5] - field.unit, offset = fieldGetString(data, offset+6) +-- UINT8 +local function fieldUint8Load(field, data, offset) + fieldUnsignedSelectionLoad(field, data, offset, 1) end -local function fieldUint16SelectionSave(fieldIndex) - crossfireTelemetryPush(0x2D, { pages[pageIndex].id, 0xEA, fieldIndex, bit32.rshift(pages[pageIndex].fields[fieldIndex].value, 8), pages[pageIndex].fields[fieldIndex].value % 255 }) +local function fieldUint8Save(fieldIndex) + fieldUnsignedSelectionSave(fieldIndex, 1) +end + +-- INT8 +local function fieldInt8Load(field, data, offset) + fieldSignedSelectionLoad(field, data, offset, 1) +end + +local function fieldInt8Save(fieldIndex) + fieldSignedSelectionSave(fieldIndex, 1) +end + +-- UINT16 +local function fieldUint16Load(field, data, offset) + fieldUnsignedSelectionLoad(field, data, offset, 2) +end + +local function fieldUint16Save(fieldIndex) + + fieldUnsignedSelectionSave(fieldIndex, 2) +end + +-- INT16 +local function fieldInt16Load(field, data, offset) + fieldSignedSelectionLoad(field, data, offset, 2) +end + +local function fieldInt16Save(fieldIndex) + fieldSignedSelectionSave(fieldIndex, 2) end -- UINT32 -local function fieldUint32SelectionLoad(field, data, offset) - field.value = bit32.lshift(data[offset], 24) + bit32.lshift(data[offset+1], 16) + bit32.lshift(data[offset+2], 8) + data[offset+3] - field.min = bit32.lshift(data[offset+4], 24) + bit32.lshift(data[offset+5], 16) + bit32.lshift(data[offset+6], 8) + data[offset+7] - field.max = bit32.lshift(data[offset+8], 24) + bit32.lshift(data[offset+9], 16) + bit32.lshift(data[offset+10], 8) + data[offset+11] - field.unit, offset = fieldGetString(data, offset+12) +local function fieldUint32Load(field, data, offset) + fieldUnsignedSelectionLoad(field, data, offset, 4) end -local function fieldUint32SelectionSave(fieldIndex) - crossfireTelemetryPush(0x2D, { pages[pageIndex].id, 0xEA, fieldIndex, bit32.rshift(pages[pageIndex].fields[fieldIndex].value, 24), bit32.rshift(pages[pageIndex].fields[fieldIndex].value, 16) % 255, bit32.rshift(pages[pageIndex].fields[fieldIndex].value, 8) % 255, pages[pageIndex].fields[fieldIndex].value % 255 }) +local function fieldUint32Save(fieldIndex) + fieldUnsignedSelectionSave(fieldIndex, 4) +end + +-- INT32 +local function fieldInt32Load(field, data, offset) + fieldSignedSelectionLoad(field, data, offset, 4) +end + +local function fieldInt32Save(fieldIndex) + fieldSignedSelectionSave(fieldIndex, 4) +end + +-- FLOAT +local function fieldFloatSelectionLoad(field, data, offset) + field.value = fieldGetValue(data, offset, 4) + field.min = fieldGetValue(data, offset+4, 4) + field.max = fieldGetValue(data, offset+8, 4) + fieldUnsignedToSigned(field, 4) + field.prec = data[offset+12] + if field.prec > 2 then + field.prec = 2 + end + field.step = fieldGetValue(data, offset+13, 4) + field.unit, offset = fieldGetString(data, offset+14) +end + +local function fieldFloatSelectionDisplay(field, y, attr) + local attrnum + if field.prec == 1 then + attrnum = LEFT + attr + PREC1 + elseif field.prec == 2 then + attrnum = LEFT + attr + PREC2 + else + attrnum = LEFT + attr + end + lcd.drawNumber(COLUMN_2, y, field.value, attrnum) + lcd.drawText(lcd.getLastPos(), y, field.unit, attr) end -- TEXT SELECTION @@ -193,36 +302,54 @@ local function fieldTextSelectionDisplay(field, y, attr) end -- STRING -local function fieldStringSelectionLoad(field, data, offset) +local function fieldStringLoad(field, data, offset) field.value, offset = fieldGetString(data, offset) if #data >= offset then field.maxlen = data[offset] end end -local function fieldStringSelectionSave(fieldIndex) - -- crossfireTelemetryPush(0x2D, { pages[pageIndex].id, 0xEA, fieldIndex, }) +local function fieldStringSave(fieldIndex) + local frame = { pages[pageIndex].id, 0xEA, fieldIndex } + for i=1, string.len(field.value) do + frame[#frame + 1] = string.byte(field.value, i) + end + frame[#frame + 1] = 0 + crossfireTelemetryPush(0x2D, frame) end -local function fieldStringSelectionDisplay(field, y, attr) - lcd.drawText(COLUMN_2, y, field.value, attr) +local function fieldStringDisplay(field, y, attr) + if edit == true and attr ~= 0 then + lcd.drawText(COLUMN_2, y, field.value, FIXEDWIDTH) + lcd.drawText(COLUMN_2+6*charIndex-6, y, string.sub(field.value, charIndex, charIndex), FIXEDWIDTH + attr) + else + lcd.drawText(COLUMN_2, y, field.value, FIXEDWIDTH + attr) + end +end + +local function fieldCommandLoad(field, data, offset) + -- TODO +end + +local function fieldCommandDisplay(field, y, attr) + lcd.drawText(0, y, field.name, attr) end local types_functions = { - { load=fieldUint8SelectionLoad, save=fieldUint8SelectionSave, display=fieldIntSelectionDisplay }, - { load=fieldUint8SelectionLoad, save=fieldUint8SelectionSave, display=fieldIntSelectionDisplay }, - { load=fieldUint16SelectionLoad, save=fieldUint16SelectionSave, display=fieldIntSelectionDisplay }, - { load=fieldUint16SelectionLoad, save=fieldUint16SelectionSave, display=fieldIntSelectionDisplay }, - { load=fieldUint32SelectionLoad, save=fieldUint32SelectionSave, display=fieldIntSelectionDisplay }, - { load=fieldUint32SelectionLoad, save=fieldUint32SelectionSave, display=fieldIntSelectionDisplay }, - nil, + { load=fieldUint8Load, save=fieldUint8Save, display=fieldIntDisplay }, + { load=fieldInt8Load, save=fieldInt8Save, display=fieldIntDisplay }, + { load=fieldUint16Load, save=fieldUint16Save, display=fieldIntDisplay }, + { load=fieldInt16Load, save=fieldInt16Save, display=fieldIntDisplay }, + { load=fieldUint32Load, save=fieldUint32Save, display=fieldIntDisplay }, + { load=fieldInt32Load, save=fieldInt32Save, display=fieldIntDisplay }, nil, nil, + { load=fieldFloatSelectionLoad, save=fieldInt32Save, display=fieldFloatSelectionDisplay }, { load=fieldTextSelectionLoad, save=fieldTextSelectionSave, display=fieldTextSelectionDisplay }, - { load=fieldStringSelectionLoad, save=fieldStringSelectionSave, display=fieldStringSelectionDisplay }, + { load=fieldStringLoad, save=fieldStringSave, display=fieldStringDisplay }, nil, - { load=fieldStringSelectionLoad, save=fieldStringSelectionSave, display=fieldStringSelectionDisplay }, - + { load=fieldStringLoad, save=nil, display=fieldStringDisplay }, + { load=fieldCommandLoad, save=nil, display=fieldCommandDisplay }, } local function parseParameterInfoMessage(data) @@ -295,11 +422,24 @@ end local function runDevicePage(index, event) local page = pages[index] if event == EVT_EXIT_BREAK then -- exit script - return 2 + if edit == true then + edit = false + else + return 2 + end elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field local field = page.fields[fieldIndex] if field.name ~= nil then - edit = not edit + if field.type == 10 then + if edit == false then + edit = true + charIndex = 1 + else + charIndex = charIndex + 1 + end + else + edit = not edit + end if edit == false and field.functions.save ~= nil then field.functions.save(fieldIndex) end diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index 23993cfc3..e57a45373 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -1,7 +1,7 @@ include(CMakeForceCompiler) include(Bitmaps) -set(PCB "TARANIS" CACHE STRING "Radio type") +set(PCB "X9D+" CACHE STRING "Radio type") set(TRANSLATIONS "EN" CACHE STRING "Radio language") option(HELI "Heli menu" ON) option(FLIGHT_MODES "Flight Modes" ON) @@ -53,9 +53,9 @@ set(M128_VARIANT 32768) set(FIRMWARE_DEPENDENCIES firmware_translations) set(9X_GUI_SRC - menu_model_inputs_mixes.cpp - menu_general_diagkeys.cpp - menu_general_diaganas.cpp + model_inputs_mixes.cpp + radio_diagkeys.cpp + radio_diaganas.cpp ) set(FATFS_SRC @@ -66,7 +66,7 @@ set(FATFS_SRC if(PCB STREQUAL HORUS) include(targets/horus/CMakeLists.txt) -elseif(PCB STREQUAL TARANIS) +elseif(PCB STREQUAL X9E OR PCB STREQUAL X9D+ OR PCB STREQUAL X9D OR PCB STREQUAL X7D) include(targets/taranis/CMakeLists.txt) elseif(PCB STREQUAL SKY9X OR PCB STREQUAL 9XRPRO OR PCB STREQUAL AR9X) include(targets/sky9x/CMakeLists.txt) @@ -78,11 +78,11 @@ elseif(PCB STREQUAL 9X2561) string(TOLOWER ${PCB} FLAVOUR) set(EEPROM EEPROM_RLC) add_definitions(-DEEPROM_VARIANT=${M2561_VARIANT}) - set(GUI_DIR 9x) + set(GUI_DIR 128x64) set(TARGET_DIR 9x) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) add_definitions(-DPCBSTD -DPCB${PCB} -DCPUM2561) - set(TARGET_SRC ${TARGET_SRC} board_stock.cpp) + set(TARGET_SRC ${TARGET_SRC} board.cpp) set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) if(SP22) add_definitions(-DSP22) @@ -99,6 +99,8 @@ else() message(FATAL_ERROR "Unknown PCB '${PCB}'") endif() +include_directories(gui gui/${GUI_DIR}) + if(NOT PCB STREQUAL 9XR AND NOT PCB STREQUAL 9XRPRO) option(DBLKEYS "Double Keys" ON) if(DBLKEYS) @@ -107,23 +109,25 @@ if(NOT PCB STREQUAL 9XR AND NOT PCB STREQUAL 9XRPRO) endif() if(CPU_TYPE STREQUAL STM32F4) - include(common/arm/stm32/f4/CMakeLists.txt) + include(targets/common/arm/stm32/f4/CMakeLists.txt) endif() if(CPU_TYPE STREQUAL STM32F2) - include(common/arm/stm32/f2/CMakeLists.txt) + include(targets/common/arm/stm32/f2/CMakeLists.txt) endif() if(CPU_FAMILY STREQUAL STM32) - include(common/arm/stm32/CMakeLists.txt) + include(targets/common/arm/stm32/CMakeLists.txt) endif() if(ARCH STREQUAL ARM) - include(common/arm/CMakeLists.txt) + include(targets/common/arm/CMakeLists.txt) else() - include(common/avr/CMakeLists.txt) + include(targets/common/avr/CMakeLists.txt) endif() +include_directories(targets/${TARGET_DIR} ${THIRDPARTY_DIR}) + foreach(LANGUAGE ${GUI_LANGUAGES}) string(TOUPPER ${LANGUAGE} LANGUAGE_CAPITALIZED) if(TRANSLATIONS STREQUAL ${LANGUAGE_CAPITALIZED}) @@ -158,7 +162,6 @@ set(GUI_SRC lcd.cpp splash.cpp fonts.cpp - helpers.cpp navigation.cpp popups.cpp widgets.cpp @@ -168,16 +171,16 @@ set(GUI_SRC set(GUI_SRC ${GUI_SRC} menu_model.cpp - menu_model_select.cpp - menu_model_setup.cpp - menu_model_limits.cpp - menu_model_logical_switches.cpp + model_select.cpp + model_setup.cpp + model_outputs.cpp + model_logical_switches.cpp model_special_functions.cpp - menu_model_telemetry.cpp - menu_general.cpp + model_telemetry.cpp + menu_radio.cpp radio_setup.cpp - menu_general_trainer.cpp - menu_general_version.cpp + radio_trainer.cpp + radio_version.cpp radio_calibration.cpp view_main.cpp view_statistics.cpp @@ -198,7 +201,7 @@ endif() if(TEMPLATES) add_definitions(-DTEMPLATES) set(SRC ${SRC} templates.cpp) - set(GUI_SRC ${GUI_SRC} menu_model_templates.cpp) + set(GUI_SRC ${GUI_SRC} model_templates.cpp) endif() if(NOT LUA STREQUAL NO) @@ -207,7 +210,7 @@ if(NOT LUA STREQUAL NO) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} ${LUA_EXPORT}) if(LUA STREQUAL YES) add_definitions(-DLUA_MODEL_SCRIPTS) - set(GUI_SRC ${GUI_SRC} menu_model_custom_scripts.cpp) + set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp) endif() set(SRC ${SRC} lua/interface.cpp lua/api_general.cpp lua/api_lcd.cpp lua/api_model.cpp) set(LUA_SRC lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c @@ -221,17 +224,17 @@ endif() if(HELI) add_definitions(-DHELI) - set(GUI_SRC ${GUI_SRC} menu_model_heli.cpp) + set(GUI_SRC ${GUI_SRC} model_heli.cpp) endif() if(FLIGHT_MODES) add_definitions(-DFLIGHT_MODES) - set(GUI_SRC ${GUI_SRC} menu_model_flightmodes.cpp) + set(GUI_SRC ${GUI_SRC} model_flightmodes.cpp) endif() if(CURVES) add_definitions(-DCURVES) - set(GUI_SRC ${GUI_SRC} menu_model_curves.cpp) + set(GUI_SRC ${GUI_SRC} model_curves.cpp) endif() if(GVARS) @@ -273,7 +276,7 @@ if(SDCARD) add_definitions(-DSDCARD) include_directories(${FATFS_DIR} ${FATFS_DIR}/option) set(SRC ${SRC} sdcard.cpp rtc.cpp logs.cpp) - set(GUI_SRC ${GUI_SRC} menu_general_sdmanager.cpp) + set(GUI_SRC ${GUI_SRC} radio_sdmanager.cpp) set(FIRMWARE_SRC ${FIRMWARE_SRC} ${FATFS_SRC}) endif() @@ -399,7 +402,7 @@ endif() set(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CPP_FLAGS} -g") set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -lm -T${RADIO_SRC_DIRECTORY}/${LINKER_SCRIPT} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections") - if(PCB STREQUAL TARANIS) + if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL X9E) add_subdirectory(targets/${TARGET_DIR}/bootloader) include_directories(${CMAKE_CURRENT_BINARY_DIR}/targets/${TARGET_DIR}/bootloader) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} bootloader) diff --git a/radio/src/bitmaps/9x/CMakeLists.txt b/radio/src/bitmaps/128x64/CMakeLists.txt similarity index 72% rename from radio/src/bitmaps/9x/CMakeLists.txt rename to radio/src/bitmaps/128x64/CMakeLists.txt index 6b8d854dd..2b5f7469b 100644 --- a/radio/src/bitmaps/9x/CMakeLists.txt +++ b/radio/src/bitmaps/128x64/CMakeLists.txt @@ -1,4 +1,4 @@ add_bitmaps_target(9x_xbm_1bit ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.xbm 128 1bit 4) add_bitmaps_target(9x_fonts_1bit ${RADIO_SRC_DIRECTORY}/fonts/std/*.png 128 "") -add_bitmaps_target(9x_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/9x/*.png 128 1bit) +add_bitmaps_target(9x_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/128x64/*.png 128 1bit) add_dependencies(9x_bitmaps 9x_fonts_1bit 9x_xbm_1bit) diff --git a/radio/src/bitmaps/9x/about.png b/radio/src/bitmaps/128x64/about.png similarity index 100% rename from radio/src/bitmaps/9x/about.png rename to radio/src/bitmaps/128x64/about.png diff --git a/radio/src/bitmaps/9x/asterisk.png b/radio/src/bitmaps/128x64/asterisk.png similarity index 100% rename from radio/src/bitmaps/9x/asterisk.png rename to radio/src/bitmaps/128x64/asterisk.png diff --git a/radio/src/bitmaps/9x/asterisk.xbm b/radio/src/bitmaps/128x64/asterisk.xbm similarity index 100% rename from radio/src/bitmaps/9x/asterisk.xbm rename to radio/src/bitmaps/128x64/asterisk.xbm diff --git a/radio/src/bitmaps/9x/splash.png b/radio/src/bitmaps/128x64/splash.png similarity index 100% rename from radio/src/bitmaps/9x/splash.png rename to radio/src/bitmaps/128x64/splash.png diff --git a/radio/src/bitmaps/9x/splash.xbm b/radio/src/bitmaps/128x64/splash.xbm similarity index 100% rename from radio/src/bitmaps/9x/splash.xbm rename to radio/src/bitmaps/128x64/splash.xbm diff --git a/radio/src/bitmaps/taranis/.gitignore b/radio/src/bitmaps/212x64/.gitignore similarity index 100% rename from radio/src/bitmaps/taranis/.gitignore rename to radio/src/bitmaps/212x64/.gitignore diff --git a/radio/src/bitmaps/taranis/CMakeLists.txt b/radio/src/bitmaps/212x64/CMakeLists.txt similarity index 72% rename from radio/src/bitmaps/taranis/CMakeLists.txt rename to radio/src/bitmaps/212x64/CMakeLists.txt index 3c03014b2..ade4b08dc 100644 --- a/radio/src/bitmaps/taranis/CMakeLists.txt +++ b/radio/src/bitmaps/212x64/CMakeLists.txt @@ -1,4 +1,4 @@ add_bitmaps_target(taranis_xbm ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.xbm 128 1bit 4) add_bitmaps_target(taranis_fonts ${RADIO_SRC_DIRECTORY}/fonts/std/*.png 128 "") -add_bitmaps_target(taranis_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/taranis/*.png 212 4bits) -add_dependencies(taranis_bitmaps taranis_fonts taranis_xbm) \ No newline at end of file +add_bitmaps_target(taranis_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/212x64/*.png 212 4bits) +add_dependencies(taranis_bitmaps taranis_fonts taranis_xbm) diff --git a/radio/src/bitmaps/taranis/about.png b/radio/src/bitmaps/212x64/about.png similarity index 100% rename from radio/src/bitmaps/taranis/about.png rename to radio/src/bitmaps/212x64/about.png diff --git a/radio/src/bitmaps/taranis/asterisk.png b/radio/src/bitmaps/212x64/asterisk.png similarity index 100% rename from radio/src/bitmaps/taranis/asterisk.png rename to radio/src/bitmaps/212x64/asterisk.png diff --git a/radio/src/bitmaps/taranis/icons.png b/radio/src/bitmaps/212x64/icons.png similarity index 100% rename from radio/src/bitmaps/taranis/icons.png rename to radio/src/bitmaps/212x64/icons.png diff --git a/radio/src/bitmaps/taranis/lock.png b/radio/src/bitmaps/212x64/lock.png similarity index 100% rename from radio/src/bitmaps/taranis/lock.png rename to radio/src/bitmaps/212x64/lock.png diff --git a/radio/src/bitmaps/taranis/logo.png b/radio/src/bitmaps/212x64/logo.png similarity index 100% rename from radio/src/bitmaps/taranis/logo.png rename to radio/src/bitmaps/212x64/logo.png diff --git a/radio/src/bitmaps/taranis/shutdown.png b/radio/src/bitmaps/212x64/shutdown.png similarity index 100% rename from radio/src/bitmaps/taranis/shutdown.png rename to radio/src/bitmaps/212x64/shutdown.png diff --git a/radio/src/bitmaps/taranis/sleep.png b/radio/src/bitmaps/212x64/sleep.png similarity index 100% rename from radio/src/bitmaps/taranis/sleep.png rename to radio/src/bitmaps/212x64/sleep.png diff --git a/radio/src/bitmaps/taranis/splash.png b/radio/src/bitmaps/212x64/splash.png similarity index 100% rename from radio/src/bitmaps/taranis/splash.png rename to radio/src/bitmaps/212x64/splash.png diff --git a/radio/src/bitmaps/taranis/startup.png b/radio/src/bitmaps/212x64/startup.png similarity index 100% rename from radio/src/bitmaps/taranis/startup.png rename to radio/src/bitmaps/212x64/startup.png diff --git a/radio/src/bitmaps/taranis/std/analog_inputs.png b/radio/src/bitmaps/212x64/std/analog_inputs.png similarity index 100% rename from radio/src/bitmaps/taranis/std/analog_inputs.png rename to radio/src/bitmaps/212x64/std/analog_inputs.png diff --git a/radio/src/bitmaps/taranis/std/calibration.png b/radio/src/bitmaps/212x64/std/calibration.png similarity index 100% rename from radio/src/bitmaps/taranis/std/calibration.png rename to radio/src/bitmaps/212x64/std/calibration.png diff --git a/radio/src/bitmaps/taranis/std/curves.png b/radio/src/bitmaps/212x64/std/curves.png similarity index 100% rename from radio/src/bitmaps/taranis/std/curves.png rename to radio/src/bitmaps/212x64/std/curves.png diff --git a/radio/src/bitmaps/taranis/std/files.png b/radio/src/bitmaps/212x64/std/files.png similarity index 100% rename from radio/src/bitmaps/taranis/std/files.png rename to radio/src/bitmaps/212x64/std/files.png diff --git a/radio/src/bitmaps/taranis/std/flight_modes.png b/radio/src/bitmaps/212x64/std/flight_modes.png similarity index 100% rename from radio/src/bitmaps/taranis/std/flight_modes.png rename to radio/src/bitmaps/212x64/std/flight_modes.png diff --git a/radio/src/bitmaps/taranis/std/global_functions.png b/radio/src/bitmaps/212x64/std/global_functions.png similarity index 100% rename from radio/src/bitmaps/taranis/std/global_functions.png rename to radio/src/bitmaps/212x64/std/global_functions.png diff --git a/radio/src/bitmaps/taranis/std/global_vars.png b/radio/src/bitmaps/212x64/std/global_vars.png similarity index 100% rename from radio/src/bitmaps/taranis/std/global_vars.png rename to radio/src/bitmaps/212x64/std/global_vars.png diff --git a/radio/src/bitmaps/taranis/std/hardware.png b/radio/src/bitmaps/212x64/std/hardware.png similarity index 100% rename from radio/src/bitmaps/taranis/std/hardware.png rename to radio/src/bitmaps/212x64/std/hardware.png diff --git a/radio/src/bitmaps/taranis/std/heli_setup.png b/radio/src/bitmaps/212x64/std/heli_setup.png similarity index 100% rename from radio/src/bitmaps/taranis/std/heli_setup.png rename to radio/src/bitmaps/212x64/std/heli_setup.png diff --git a/radio/src/bitmaps/taranis/std/inputs.png b/radio/src/bitmaps/212x64/std/inputs.png similarity index 100% rename from radio/src/bitmaps/taranis/std/inputs.png rename to radio/src/bitmaps/212x64/std/inputs.png diff --git a/radio/src/bitmaps/taranis/std/logical_sw.png b/radio/src/bitmaps/212x64/std/logical_sw.png similarity index 100% rename from radio/src/bitmaps/taranis/std/logical_sw.png rename to radio/src/bitmaps/212x64/std/logical_sw.png diff --git a/radio/src/bitmaps/taranis/std/lua_scripts.png b/radio/src/bitmaps/212x64/std/lua_scripts.png similarity index 100% rename from radio/src/bitmaps/taranis/std/lua_scripts.png rename to radio/src/bitmaps/212x64/std/lua_scripts.png diff --git a/radio/src/bitmaps/taranis/std/mainview_setup.png b/radio/src/bitmaps/212x64/std/mainview_setup.png similarity index 100% rename from radio/src/bitmaps/taranis/std/mainview_setup.png rename to radio/src/bitmaps/212x64/std/mainview_setup.png diff --git a/radio/src/bitmaps/taranis/std/mixer.png b/radio/src/bitmaps/212x64/std/mixer.png similarity index 100% rename from radio/src/bitmaps/taranis/std/mixer.png rename to radio/src/bitmaps/212x64/std/mixer.png diff --git a/radio/src/bitmaps/taranis/std/model_select.png b/radio/src/bitmaps/212x64/std/model_select.png similarity index 100% rename from radio/src/bitmaps/taranis/std/model_select.png rename to radio/src/bitmaps/212x64/std/model_select.png diff --git a/radio/src/bitmaps/taranis/std/model_settings.png b/radio/src/bitmaps/212x64/std/model_settings.png similarity index 100% rename from radio/src/bitmaps/taranis/std/model_settings.png rename to radio/src/bitmaps/212x64/std/model_settings.png diff --git a/radio/src/bitmaps/taranis/std/model_setup.png b/radio/src/bitmaps/212x64/std/model_setup.png similarity index 100% rename from radio/src/bitmaps/taranis/std/model_setup.png rename to radio/src/bitmaps/212x64/std/model_setup.png diff --git a/radio/src/bitmaps/taranis/std/radio_setup.png b/radio/src/bitmaps/212x64/std/radio_setup.png similarity index 100% rename from radio/src/bitmaps/taranis/std/radio_setup.png rename to radio/src/bitmaps/212x64/std/radio_setup.png diff --git a/radio/src/bitmaps/taranis/std/servos.png b/radio/src/bitmaps/212x64/std/servos.png similarity index 100% rename from radio/src/bitmaps/taranis/std/servos.png rename to radio/src/bitmaps/212x64/std/servos.png diff --git a/radio/src/bitmaps/taranis/std/special_functions.png b/radio/src/bitmaps/212x64/std/special_functions.png similarity index 100% rename from radio/src/bitmaps/taranis/std/special_functions.png rename to radio/src/bitmaps/212x64/std/special_functions.png diff --git a/radio/src/bitmaps/taranis/std/switch_test.png b/radio/src/bitmaps/212x64/std/switch_test.png similarity index 100% rename from radio/src/bitmaps/taranis/std/switch_test.png rename to radio/src/bitmaps/212x64/std/switch_test.png diff --git a/radio/src/bitmaps/taranis/std/telemetry.png b/radio/src/bitmaps/212x64/std/telemetry.png similarity index 100% rename from radio/src/bitmaps/taranis/std/telemetry.png rename to radio/src/bitmaps/212x64/std/telemetry.png diff --git a/radio/src/bitmaps/taranis/std/trainer.png b/radio/src/bitmaps/212x64/std/trainer.png similarity index 100% rename from radio/src/bitmaps/taranis/std/trainer.png rename to radio/src/bitmaps/212x64/std/trainer.png diff --git a/radio/src/bitmaps/taranis/std/version.png b/radio/src/bitmaps/212x64/std/version.png similarity index 100% rename from radio/src/bitmaps/taranis/std/version.png rename to radio/src/bitmaps/212x64/std/version.png diff --git a/radio/src/bitmaps/horus/CMakeLists.txt b/radio/src/bitmaps/480x272/CMakeLists.txt similarity index 58% rename from radio/src/bitmaps/horus/CMakeLists.txt rename to radio/src/bitmaps/480x272/CMakeLists.txt index 6ec6b1c59..a86089291 100644 --- a/radio/src/bitmaps/horus/CMakeLists.txt +++ b/radio/src/bitmaps/480x272/CMakeLists.txt @@ -1,12 +1,12 @@ -add_bitmaps_target(horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/bmp_*.png" 480 5/6/5) -add_bitmaps_target(horus_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/calibration/bmp_*.png" 480 5/6/5) -add_bitmaps_target(horus_button_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/button/alpha_*.png" 480 4/4/4/4) -add_bitmaps_target(horus_alpha_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/alpha_*.png" 480 4/4/4/4) -add_bitmaps_target(horus_alpha_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/calibration/alpha_*.png" 480 4/4/4/4) -add_bitmaps_target(horus_masks ${RADIO_SRC_DIRECTORY}/bitmaps/horus/mask_*.png 480 8bits) -add_bitmaps_target(horus_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/horus/slider/*.png" 480 8bits) -add_bitmaps_target(horus_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/horus/layouts/*.png" 480 8bits) -add_bitmaps_target(horus_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/horus/themes/*.png" 480 5/6/5) -add_bitmaps_target(horus_fonts ${RADIO_SRC_DIRECTORY}/fonts/horus/*.png 480 8bits) -add_bitmaps_target(horus_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/horus/volume/*.png 480 8bits) +add_bitmaps_target(horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bmp_*.png" 480 5/6/5) +add_bitmaps_target(horus_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/bmp_*.png" 480 5/6/5) +add_bitmaps_target(horus_button_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/button/alpha_*.png" 480 4/4/4/4) +add_bitmaps_target(horus_alpha_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/alpha_*.png" 480 4/4/4/4) +add_bitmaps_target(horus_alpha_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/alpha_*.png" 480 4/4/4/4) +add_bitmaps_target(horus_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/mask_*.png 480 8bits) +add_bitmaps_target(horus_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits) +add_bitmaps_target(horus_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits) +add_bitmaps_target(horus_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5) +add_bitmaps_target(horus_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits) +add_bitmaps_target(horus_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits) add_dependencies(horus_bitmaps horus_calibration_bitmaps horus_button_bitmaps horus_alpha_bitmaps horus_alpha_calibration_bitmaps horus_masks horus_slider_masks horus_layouts_masks horus_themes_bitmaps horus_fonts horus_volume_masks) diff --git a/radio/src/bitmaps/horus/bmp_splash.png b/radio/src/bitmaps/480x272/bmp_splash.png similarity index 100% rename from radio/src/bitmaps/horus/bmp_splash.png rename to radio/src/bitmaps/480x272/bmp_splash.png diff --git a/radio/src/bitmaps/horus/button/alpha_button_off.png b/radio/src/bitmaps/480x272/button/alpha_button_off.png similarity index 100% rename from radio/src/bitmaps/horus/button/alpha_button_off.png rename to radio/src/bitmaps/480x272/button/alpha_button_off.png diff --git a/radio/src/bitmaps/horus/button/alpha_button_on.png b/radio/src/bitmaps/480x272/button/alpha_button_on.png similarity index 100% rename from radio/src/bitmaps/horus/button/alpha_button_on.png rename to radio/src/bitmaps/480x272/button/alpha_button_on.png diff --git a/radio/src/bitmaps/horus/mask_about_headico.png b/radio/src/bitmaps/480x272/mask_about_headico.png similarity index 100% rename from radio/src/bitmaps/horus/mask_about_headico.png rename to radio/src/bitmaps/480x272/mask_about_headico.png diff --git a/radio/src/bitmaps/horus/mask_carroussel_left.png b/radio/src/bitmaps/480x272/mask_carroussel_left.png similarity index 100% rename from radio/src/bitmaps/horus/mask_carroussel_left.png rename to radio/src/bitmaps/480x272/mask_carroussel_left.png diff --git a/radio/src/bitmaps/horus/mask_carroussel_right.png b/radio/src/bitmaps/480x272/mask_carroussel_right.png similarity index 100% rename from radio/src/bitmaps/horus/mask_carroussel_right.png rename to radio/src/bitmaps/480x272/mask_carroussel_right.png diff --git a/radio/src/bitmaps/horus/mask_coord_shadow.png b/radio/src/bitmaps/480x272/mask_coord_shadow.png similarity index 100% rename from radio/src/bitmaps/horus/mask_coord_shadow.png rename to radio/src/bitmaps/480x272/mask_coord_shadow.png diff --git a/radio/src/bitmaps/horus/mask_cvpoint.png b/radio/src/bitmaps/480x272/mask_cvpoint.png similarity index 100% rename from radio/src/bitmaps/horus/mask_cvpoint.png rename to radio/src/bitmaps/480x272/mask_cvpoint.png diff --git a/radio/src/bitmaps/horus/mask_cvpoint_center.png b/radio/src/bitmaps/480x272/mask_cvpoint_center.png similarity index 100% rename from radio/src/bitmaps/horus/mask_cvpoint_center.png rename to radio/src/bitmaps/480x272/mask_cvpoint_center.png diff --git a/radio/src/bitmaps/horus/mask_dot.png b/radio/src/bitmaps/480x272/mask_dot.png similarity index 100% rename from radio/src/bitmaps/horus/mask_dot.png rename to radio/src/bitmaps/480x272/mask_dot.png diff --git a/radio/src/bitmaps/horus/mask_htrim_frame.png b/radio/src/bitmaps/480x272/mask_htrim_frame.png similarity index 100% rename from radio/src/bitmaps/horus/mask_htrim_frame.png rename to radio/src/bitmaps/480x272/mask_htrim_frame.png diff --git a/radio/src/bitmaps/horus/mask_library_active_model.png b/radio/src/bitmaps/480x272/mask_library_active_model.png similarity index 100% rename from radio/src/bitmaps/horus/mask_library_active_model.png rename to radio/src/bitmaps/480x272/mask_library_active_model.png diff --git a/radio/src/bitmaps/horus/mask_library_score_0.png b/radio/src/bitmaps/480x272/mask_library_score_0.png similarity index 100% rename from radio/src/bitmaps/horus/mask_library_score_0.png rename to radio/src/bitmaps/480x272/mask_library_score_0.png diff --git a/radio/src/bitmaps/horus/mask_library_score_1.png b/radio/src/bitmaps/480x272/mask_library_score_1.png similarity index 100% rename from radio/src/bitmaps/horus/mask_library_score_1.png rename to radio/src/bitmaps/480x272/mask_library_score_1.png diff --git a/radio/src/bitmaps/horus/mask_library_slot.png b/radio/src/bitmaps/480x272/mask_library_slot.png similarity index 100% rename from radio/src/bitmaps/horus/mask_library_slot.png rename to radio/src/bitmaps/480x272/mask_library_slot.png diff --git a/radio/src/bitmaps/horus/mask_library_star_0.png b/radio/src/bitmaps/480x272/mask_library_star_0.png similarity index 100% rename from radio/src/bitmaps/horus/mask_library_star_0.png rename to radio/src/bitmaps/480x272/mask_library_star_0.png diff --git a/radio/src/bitmaps/horus/mask_library_star_1.png b/radio/src/bitmaps/480x272/mask_library_star_1.png similarity index 100% rename from radio/src/bitmaps/horus/mask_library_star_1.png rename to radio/src/bitmaps/480x272/mask_library_star_1.png diff --git a/radio/src/bitmaps/horus/mask_mainviews_item_in.png b/radio/src/bitmaps/480x272/mask_mainviews_item_in.png similarity index 100% rename from radio/src/bitmaps/horus/mask_mainviews_item_in.png rename to radio/src/bitmaps/480x272/mask_mainviews_item_in.png diff --git a/radio/src/bitmaps/horus/mask_mainviews_item_out.png b/radio/src/bitmaps/480x272/mask_mainviews_item_out.png similarity index 100% rename from radio/src/bitmaps/horus/mask_mainviews_item_out.png rename to radio/src/bitmaps/480x272/mask_mainviews_item_out.png diff --git a/radio/src/bitmaps/horus/mask_point.png b/radio/src/bitmaps/480x272/mask_point.png similarity index 100% rename from radio/src/bitmaps/horus/mask_point.png rename to radio/src/bitmaps/480x272/mask_point.png diff --git a/radio/src/bitmaps/horus/mask_rscale.png b/radio/src/bitmaps/480x272/mask_rscale.png similarity index 100% rename from radio/src/bitmaps/horus/mask_rscale.png rename to radio/src/bitmaps/480x272/mask_rscale.png diff --git a/radio/src/bitmaps/horus/mask_shutdown_circle.png b/radio/src/bitmaps/480x272/mask_shutdown_circle.png similarity index 100% rename from radio/src/bitmaps/horus/mask_shutdown_circle.png rename to radio/src/bitmaps/480x272/mask_shutdown_circle.png diff --git a/radio/src/bitmaps/horus/mask_swipe_circle.png b/radio/src/bitmaps/480x272/mask_swipe_circle.png similarity index 100% rename from radio/src/bitmaps/horus/mask_swipe_circle.png rename to radio/src/bitmaps/480x272/mask_swipe_circle.png diff --git a/radio/src/bitmaps/horus/mask_swipe_left.png b/radio/src/bitmaps/480x272/mask_swipe_left.png similarity index 100% rename from radio/src/bitmaps/horus/mask_swipe_left.png rename to radio/src/bitmaps/480x272/mask_swipe_left.png diff --git a/radio/src/bitmaps/horus/mask_swipe_right.png b/radio/src/bitmaps/480x272/mask_swipe_right.png similarity index 100% rename from radio/src/bitmaps/horus/mask_swipe_right.png rename to radio/src/bitmaps/480x272/mask_swipe_right.png diff --git a/radio/src/bitmaps/horus/mask_timer.png b/radio/src/bitmaps/480x272/mask_timer.png similarity index 100% rename from radio/src/bitmaps/horus/mask_timer.png rename to radio/src/bitmaps/480x272/mask_timer.png diff --git a/radio/src/bitmaps/horus/mask_timer_bg.png b/radio/src/bitmaps/480x272/mask_timer_bg.png similarity index 100% rename from radio/src/bitmaps/horus/mask_timer_bg.png rename to radio/src/bitmaps/480x272/mask_timer_bg.png diff --git a/radio/src/bitmaps/horus/mask_topmenu_altitude_ico.png b/radio/src/bitmaps/480x272/mask_topmenu_altitude_ico.png similarity index 100% rename from radio/src/bitmaps/horus/mask_topmenu_altitude_ico.png rename to radio/src/bitmaps/480x272/mask_topmenu_altitude_ico.png diff --git a/radio/src/bitmaps/horus/mask_topmenu_masterpart_ico.png b/radio/src/bitmaps/480x272/mask_topmenu_masterpart_ico.png similarity index 100% rename from radio/src/bitmaps/horus/mask_topmenu_masterpart_ico.png rename to radio/src/bitmaps/480x272/mask_topmenu_masterpart_ico.png diff --git a/radio/src/bitmaps/horus/mask_topmenu_sdcard.png b/radio/src/bitmaps/480x272/mask_topmenu_sdcard.png similarity index 100% rename from radio/src/bitmaps/horus/mask_topmenu_sdcard.png rename to radio/src/bitmaps/480x272/mask_topmenu_sdcard.png diff --git a/radio/src/bitmaps/horus/mask_topmenu_slavepart_ico.png b/radio/src/bitmaps/480x272/mask_topmenu_slavepart_ico.png similarity index 100% rename from radio/src/bitmaps/horus/mask_topmenu_slavepart_ico.png rename to radio/src/bitmaps/480x272/mask_topmenu_slavepart_ico.png diff --git a/radio/src/bitmaps/horus/mask_topmenu_usb.png b/radio/src/bitmaps/480x272/mask_topmenu_usb.png similarity index 100% rename from radio/src/bitmaps/horus/mask_topmenu_usb.png rename to radio/src/bitmaps/480x272/mask_topmenu_usb.png diff --git a/radio/src/bitmaps/horus/mask_topmenu_volume_ico.png b/radio/src/bitmaps/480x272/mask_topmenu_volume_ico.png similarity index 100% rename from radio/src/bitmaps/horus/mask_topmenu_volume_ico.png rename to radio/src/bitmaps/480x272/mask_topmenu_volume_ico.png diff --git a/radio/src/bitmaps/horus/mask_trim_shadow.png b/radio/src/bitmaps/480x272/mask_trim_shadow.png similarity index 100% rename from radio/src/bitmaps/horus/mask_trim_shadow.png rename to radio/src/bitmaps/480x272/mask_trim_shadow.png diff --git a/radio/src/bitmaps/horus/mask_txbat.png b/radio/src/bitmaps/480x272/mask_txbat.png similarity index 100% rename from radio/src/bitmaps/horus/mask_txbat.png rename to radio/src/bitmaps/480x272/mask_txbat.png diff --git a/radio/src/bitmaps/horus/mask_vtrim_frame.png b/radio/src/bitmaps/480x272/mask_vtrim_frame.png similarity index 100% rename from radio/src/bitmaps/horus/mask_vtrim_frame.png rename to radio/src/bitmaps/480x272/mask_vtrim_frame.png diff --git a/radio/src/bitmaps/horus/slider/bar_left.png b/radio/src/bitmaps/480x272/slider/bar_left.png similarity index 100% rename from radio/src/bitmaps/horus/slider/bar_left.png rename to radio/src/bitmaps/480x272/slider/bar_left.png diff --git a/radio/src/bitmaps/horus/slider/bar_right.png b/radio/src/bitmaps/480x272/slider/bar_right.png similarity index 100% rename from radio/src/bitmaps/horus/slider/bar_right.png rename to radio/src/bitmaps/480x272/slider/bar_right.png diff --git a/radio/src/bitmaps/horus/slider/point_in.png b/radio/src/bitmaps/480x272/slider/point_in.png similarity index 100% rename from radio/src/bitmaps/horus/slider/point_in.png rename to radio/src/bitmaps/480x272/slider/point_in.png diff --git a/radio/src/bitmaps/horus/slider/point_mid.png b/radio/src/bitmaps/480x272/slider/point_mid.png similarity index 100% rename from radio/src/bitmaps/horus/slider/point_mid.png rename to radio/src/bitmaps/480x272/slider/point_mid.png diff --git a/radio/src/bitmaps/horus/slider/point_out.png b/radio/src/bitmaps/480x272/slider/point_out.png similarity index 100% rename from radio/src/bitmaps/horus/slider/point_out.png rename to radio/src/bitmaps/480x272/slider/point_out.png diff --git a/radio/src/bitmaps/horus/volume/mask_volume_0.png b/radio/src/bitmaps/480x272/volume/mask_volume_0.png similarity index 100% rename from radio/src/bitmaps/horus/volume/mask_volume_0.png rename to radio/src/bitmaps/480x272/volume/mask_volume_0.png diff --git a/radio/src/bitmaps/horus/volume/mask_volume_1.png b/radio/src/bitmaps/480x272/volume/mask_volume_1.png similarity index 100% rename from radio/src/bitmaps/horus/volume/mask_volume_1.png rename to radio/src/bitmaps/480x272/volume/mask_volume_1.png diff --git a/radio/src/bitmaps/horus/volume/mask_volume_2.png b/radio/src/bitmaps/480x272/volume/mask_volume_2.png similarity index 100% rename from radio/src/bitmaps/horus/volume/mask_volume_2.png rename to radio/src/bitmaps/480x272/volume/mask_volume_2.png diff --git a/radio/src/bitmaps/horus/volume/mask_volume_3.png b/radio/src/bitmaps/480x272/volume/mask_volume_3.png similarity index 100% rename from radio/src/bitmaps/horus/volume/mask_volume_3.png rename to radio/src/bitmaps/480x272/volume/mask_volume_3.png diff --git a/radio/src/bitmaps/horus/volume/mask_volume_4.png b/radio/src/bitmaps/480x272/volume/mask_volume_4.png similarity index 100% rename from radio/src/bitmaps/horus/volume/mask_volume_4.png rename to radio/src/bitmaps/480x272/volume/mask_volume_4.png diff --git a/radio/src/bitmaps/horus/volume/mask_volume_scale.png b/radio/src/bitmaps/480x272/volume/mask_volume_scale.png similarity index 100% rename from radio/src/bitmaps/horus/volume/mask_volume_scale.png rename to radio/src/bitmaps/480x272/volume/mask_volume_scale.png diff --git a/radio/src/bitmaps/CMakeLists.txt b/radio/src/bitmaps/CMakeLists.txt index 1105a3e15..e723cf313 100644 --- a/radio/src/bitmaps/CMakeLists.txt +++ b/radio/src/bitmaps/CMakeLists.txt @@ -1,3 +1,3 @@ -add_subdirectory(9x) -add_subdirectory(taranis) -add_subdirectory(horus) +add_subdirectory(128x64) +add_subdirectory(212x64) +add_subdirectory(480x272) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index 88892fc6d..38ac489fb 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -502,7 +502,7 @@ int cliDisplay(const char ** argv) name[len] = '\0'; serialPrint("[%s] = %s", name, switchState(EnumKeys(i)) ? "on" : "off"); } -#if defined(ROTARY_ENCODER_NAVIGATION) || defined(REV9E) || defined(PCBHORUS) || defined(PCBFLAMENCO) +#if defined(ROTARY_ENCODER_NAVIGATION) || defined(PCBX9E) || defined(PCBHORUS) || defined(PCBFLAMENCO) serialPrint("[Enc.] = %d", rotencValue / 2); #endif for (int i=TRM_BASE; i<=TRM_LAST; i++) { diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 7ce827a63..32a90cb1b 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -73,7 +73,7 @@ #define MAX_SCRIPTS 7 #define MAX_INPUTS 32 #define NUM_TRAINER 16 - #if defined(REV9E) + #if defined(PCBX9E) #define NUM_POTS 8 #define NUM_XPOTS 4 #else @@ -207,7 +207,7 @@ enum CurveType { #if defined(PCBFLAMENCO) #define NUM_SWITCHES 5 -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define NUM_SWITCHES 18 // yes, it's a lot! #elif defined(PCBTARANIS) || defined(PCBHORUS) #define NUM_SWITCHES 8 @@ -606,7 +606,7 @@ enum SwitchSources { SWSRC_SH1, SWSRC_SH2, SWSRC_TRAINER = SWSRC_SH2, -#if defined(REV9E) +#if defined(PCBX9E) SWSRC_SI0, SWSRC_SI1, SWSRC_SI2, @@ -773,13 +773,13 @@ enum MixSources { MIXSRC_POT1 = MIXSRC_FIRST_POT, LUA_EXPORT("s1", "Potentiometer 1") MIXSRC_POT2, LUA_EXPORT("s2", "Potentiometer 2") MIXSRC_POT3, LUA_EXPORT("s3", "Potentiometer 3") - #if defined(REV9E) + #if defined(PCBX9E) MIXSRC_POT4, LUA_EXPORT("s4", "Potentiometer 4 (X9E only)") #endif MIXSRC_FIRST_SLIDER, MIXSRC_SLIDER1 = MIXSRC_FIRST_SLIDER, LUA_EXPORT("ls", "Left slider") MIXSRC_SLIDER2, LUA_EXPORT("rs", "Right slider") - #if defined(REV9E) + #if defined(PCBX9E) MIXSRC_SLIDER3, LUA_EXPORT("lcs", "Left center slider (X9E only)") MIXSRC_SLIDER4, LUA_EXPORT("rcs", "Right center slider (X9E only)") MIXSRC_LAST_POT = MIXSRC_SLIDER4, @@ -851,7 +851,7 @@ enum MixSources { MIXSRC_SF, LUA_EXPORT("sf", "Switch F") MIXSRC_SG, LUA_EXPORT("sg", "Switch G") MIXSRC_SH, LUA_EXPORT("sh", "Switch H") -#if defined(REV9E) +#if defined(PCBX9E) MIXSRC_SI, LUA_EXPORT("si", "Switch I (X9E only)") MIXSRC_SJ, LUA_EXPORT("sj", "Switch J (X9E only)") MIXSRC_SK, LUA_EXPORT("sk", "Switch K (X9E only)") diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 585823496..74a13907b 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -46,10 +46,10 @@ #define TARANIS_FIELD(x) #endif -#if defined(PCBTARANIS) && defined(REV9E) - #define TARANIS_REV9E_FIELD(x) x; +#if defined(PCBX9E) + #define TARANIS_PCBX9E_FIELD(x) x; #else - #define TARANIS_REV9E_FIELD(x) + #define TARANIS_PCBX9E_FIELD(x) #endif #if defined(PCBHORUS) @@ -728,7 +728,7 @@ PACK(struct ModelHeader { #if defined(COLORLCD) typedef uint16_t swconfig_t; typedef uint32_t swarnstate_t; -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) typedef uint64_t swconfig_t; typedef uint64_t swarnstate_t; typedef uint32_t swarnenable_t; @@ -767,8 +767,8 @@ typedef uint8_t swarnenable_t; #endif #if defined(PCBHORUS) -#include "gui/horus/layout.h" -#include "gui/horus/topbar.h" +#include "gui/480x272/layout.h" +#include "gui/480x272/topbar.h" PACK(struct CustomScreenData { char layoutName[10]; Layout::PersistentData layoutData; @@ -842,7 +842,7 @@ PACK(struct ModelData { ARM_FIELD(NOBACKUP(TelemetrySensor telemetrySensors[MAX_SENSORS])) - TARANIS_REV9E_FIELD(uint8_t toplcdTimer) + TARANIS_PCBX9E_FIELD(uint8_t toplcdTimer) CUSTOM_SCREENS_DATA @@ -929,7 +929,7 @@ PACK(struct TrainerData { char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]; \ char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; #elif defined(PCBTARANIS) - #if defined(REV9E) + #if defined(PCBX9E) #define BLUETOOTH_FIELDS \ uint8_t bluetoothEnable; \ char bluetoothName[LEN_BLUETOOTH_NAME]; @@ -967,7 +967,7 @@ PACK(struct TrainerData { #endif #if defined(PCBHORUS) - #include "gui/horus/theme.h" + #include "gui/480x272/theme.h" #define THEME_DATA \ NOBACKUP(char themeName[8]); \ NOBACKUP(Theme::PersistentData themeData); @@ -1078,7 +1078,7 @@ static inline void check_struct() CHKSIZE(ModelHeader, 24); CHKSIZE(CurveData, 4); -#if defined(REV9E) +#if defined(PCBX9E) CHKSIZE(RadioData, 952); CHKSIZE(ModelData, 6520); #else diff --git a/radio/src/disk_cache.cpp b/radio/src/disk_cache.cpp index 4933a2d9f..df63e5d1e 100644 --- a/radio/src/disk_cache.cpp +++ b/radio/src/disk_cache.cpp @@ -24,9 +24,6 @@ #if defined(SIMU) && !defined(SIMU_DISKIO) #define __disk_read(...) (RES_OK) #define __disk_write(...) (RES_OK) -#else - extern DRESULT __disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); - extern DRESULT __disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); #endif #if 0 // set to 1 to enable traces @@ -37,13 +34,13 @@ DiskCache diskCache; -DiskCacheBlock::DiskCacheBlock() - : startSector(0), +DiskCacheBlock::DiskCacheBlock(): + startSector(0), endSector(0) { } -bool DiskCacheBlock::read(BYTE* buff, DWORD sector, UINT count) +bool DiskCacheBlock::read(BYTE * buff, DWORD sector, UINT count) { if (sector >= startSector && (sector+count) <= endSector) { TRACE_DISK_CACHE("\tcache read(%u, %u) from %p", (uint32_t)sector, (uint32_t)count, this); @@ -53,9 +50,8 @@ bool DiskCacheBlock::read(BYTE* buff, DWORD sector, UINT count) return false; } -DRESULT DiskCacheBlock::fill(BYTE drv, BYTE* buff, DWORD sector, UINT count) +DRESULT DiskCacheBlock::fill(BYTE drv, BYTE * buff, DWORD sector, UINT count) { - // TODO: check if trying to read beyond the end of disk DRESULT res = __disk_read(drv, data, sector, DISK_CACHE_BLOCK_SECTORS); if (res != RES_OK) { return res; @@ -80,15 +76,15 @@ bool DiskCacheBlock::empty() const return (endSector == 0); } -DiskCache::DiskCache() - : lastBlock(0) +DiskCache::DiskCache(): + lastBlock(0) { stats.noHits = 0; stats.noMisses = 0; blocks = new DiskCacheBlock[DISK_CACHE_BLOCKS_NUM]; } -DRESULT DiskCache::read(BYTE drv, BYTE* buff, DWORD sector, UINT count) +DRESULT DiskCache::read(BYTE drv, BYTE * buff, DWORD sector, UINT count) { // TODO: check if not caching first sectors would improve anything // if (sector < 1000) { @@ -101,8 +97,14 @@ DRESULT DiskCache::read(BYTE drv, BYTE* buff, DWORD sector, UINT count) TRACE_DISK_CACHE("\t\t big read(%u, %u)", this, (uint32_t)sector, (uint32_t)count); return __disk_read(drv, buff, sector, count); } + + // if block + cache block size is beyond the end of the disk, then read it directly without using cache + if (sector+DISK_CACHE_BLOCK_SECTORS >= sdGetNoSectors()) { + TRACE_DISK_CACHE("\t\t cache would be beyond end of disk(%u)", this, (uint32_t)sector); + return __disk_read(drv, buff, sector, count); + } - for(int n=0; n < DISK_CACHE_BLOCKS_NUM; ++n) { + for (int n=0; n= DISK_CACHE_BLOCKS_NUM) { lastBlock = 0; } + return blocks[lastBlock].fill(drv, buff, sector, count); } @@ -147,13 +150,13 @@ int DiskCache::getHitRate() const return (stats.noHits * 1000) / all; } -DRESULT disk_read (BYTE drv, BYTE *buff, DWORD sector, UINT count) +DRESULT disk_read(BYTE drv, BYTE * buff, DWORD sector, UINT count) { return diskCache.read(drv, buff, sector, count); } -DRESULT disk_write (BYTE drv, const BYTE *buff, DWORD sector, UINT count) +DRESULT disk_write(BYTE drv, const BYTE * buff, DWORD sector, UINT count) { return diskCache.write(drv, buff, sector, count); } diff --git a/radio/src/disk_cache.h b/radio/src/disk_cache.h index ac2830e52..8fb28aa14 100644 --- a/radio/src/disk_cache.h +++ b/radio/src/disk_cache.h @@ -22,9 +22,9 @@ #define _DISK_CACHE_H_ #include "diskio.h" +#include "sdio_sd.h" // tunable parameters -#define BLOCK_SIZE 512 // sector Size in Bytes #define DISK_CACHE_BLOCKS_NUM 8 // no cache blocks #define DISK_CACHE_BLOCK_SECTORS 16 // no sectors diff --git a/radio/src/fonts/horus/CMakeLists.txt b/radio/src/fonts/480x272/CMakeLists.txt similarity index 100% rename from radio/src/fonts/horus/CMakeLists.txt rename to radio/src/fonts/480x272/CMakeLists.txt diff --git a/radio/src/fonts/horus/font_dblsize.png b/radio/src/fonts/480x272/font_dblsize.png similarity index 100% rename from radio/src/fonts/horus/font_dblsize.png rename to radio/src/fonts/480x272/font_dblsize.png diff --git a/radio/src/fonts/horus/font_dblsize.specs b/radio/src/fonts/480x272/font_dblsize.specs similarity index 100% rename from radio/src/fonts/horus/font_dblsize.specs rename to radio/src/fonts/480x272/font_dblsize.specs diff --git a/radio/src/fonts/horus/font_midsize.png b/radio/src/fonts/480x272/font_midsize.png similarity index 100% rename from radio/src/fonts/horus/font_midsize.png rename to radio/src/fonts/480x272/font_midsize.png diff --git a/radio/src/fonts/horus/font_midsize.specs b/radio/src/fonts/480x272/font_midsize.specs similarity index 100% rename from radio/src/fonts/horus/font_midsize.specs rename to radio/src/fonts/480x272/font_midsize.specs diff --git a/radio/src/fonts/horus/font_smlsize.png b/radio/src/fonts/480x272/font_smlsize.png similarity index 100% rename from radio/src/fonts/horus/font_smlsize.png rename to radio/src/fonts/480x272/font_smlsize.png diff --git a/radio/src/fonts/horus/font_smlsize.specs b/radio/src/fonts/480x272/font_smlsize.specs similarity index 100% rename from radio/src/fonts/horus/font_smlsize.specs rename to radio/src/fonts/480x272/font_smlsize.specs diff --git a/radio/src/fonts/horus/font_stdsize.png b/radio/src/fonts/480x272/font_stdsize.png similarity index 100% rename from radio/src/fonts/horus/font_stdsize.png rename to radio/src/fonts/480x272/font_stdsize.png diff --git a/radio/src/fonts/horus/font_stdsize.specs b/radio/src/fonts/480x272/font_stdsize.specs similarity index 100% rename from radio/src/fonts/horus/font_stdsize.specs rename to radio/src/fonts/480x272/font_stdsize.specs diff --git a/radio/src/fonts/horus/font_stdsizebold.png b/radio/src/fonts/480x272/font_stdsizebold.png similarity index 100% rename from radio/src/fonts/horus/font_stdsizebold.png rename to radio/src/fonts/480x272/font_stdsizebold.png diff --git a/radio/src/fonts/horus/font_stdsizebold.specs b/radio/src/fonts/480x272/font_stdsizebold.specs similarity index 100% rename from radio/src/fonts/horus/font_stdsizebold.specs rename to radio/src/fonts/480x272/font_stdsizebold.specs diff --git a/radio/src/fonts/horus/font_tinsize.png b/radio/src/fonts/480x272/font_tinsize.png similarity index 100% rename from radio/src/fonts/horus/font_tinsize.png rename to radio/src/fonts/480x272/font_tinsize.png diff --git a/radio/src/fonts/horus/font_tinsize.specs b/radio/src/fonts/480x272/font_tinsize.specs similarity index 100% rename from radio/src/fonts/horus/font_tinsize.specs rename to radio/src/fonts/480x272/font_tinsize.specs diff --git a/radio/src/fonts/horus/font_xxlsize.png b/radio/src/fonts/480x272/font_xxlsize.png similarity index 100% rename from radio/src/fonts/horus/font_xxlsize.png rename to radio/src/fonts/480x272/font_xxlsize.png diff --git a/radio/src/fonts/horus/font_xxlsize.specs b/radio/src/fonts/480x272/font_xxlsize.specs similarity index 100% rename from radio/src/fonts/horus/font_xxlsize.specs rename to radio/src/fonts/480x272/font_xxlsize.specs diff --git a/radio/src/fonts/CMakeLists.txt b/radio/src/fonts/CMakeLists.txt index f238820be..4f9b537cf 100644 --- a/radio/src/fonts/CMakeLists.txt +++ b/radio/src/fonts/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(horus) \ No newline at end of file +add_subdirectory(480x272) diff --git a/radio/src/gui/9x/fonts.cpp b/radio/src/gui/128x64/fonts.cpp similarity index 96% rename from radio/src/gui/9x/fonts.cpp rename to radio/src/gui/128x64/fonts.cpp index 2fcbee63d..3fd937a1c 100644 --- a/radio/src/gui/9x/fonts.cpp +++ b/radio/src/gui/128x64/fonts.cpp @@ -18,132 +18,132 @@ * 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_SPECIFIC_FONT) -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_22x38_num[] PROGMEM = { -#include "font_22x38_num.lbm" -}; - -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 // defined(CPUARM) && !defined(BOOT) +#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_SPECIFIC_FONT) +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_22x38_num[] PROGMEM = { +#include "font_22x38_num.lbm" +}; + +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 // defined(CPUARM) && !defined(BOOT) diff --git a/radio/src/gui/9x/gui.h b/radio/src/gui/128x64/gui.h similarity index 93% rename from radio/src/gui/9x/gui.h rename to radio/src/gui/128x64/gui.h index d92323ad1..657dc48a4 100644 --- a/radio/src/gui/9x/gui.h +++ b/radio/src/gui/128x64/gui.h @@ -18,6 +18,13 @@ * GNU General Public License for more details. */ +#ifndef _GUI_H_ +#define _GUI_H_ + +#if defined(CPUARM) +#include "gui_helpers.h" +#endif + #include "lcd.h" #include "menus.h" @@ -48,3 +55,5 @@ void drawStick(coord_t centrex, int16_t xval, int16_t yval); #define SET_SCROLLBAR_X(x) #define LOAD_MODEL_BITMAP() + +#endif // _GUI_H_ \ No newline at end of file diff --git a/radio/src/gui/9x/lcd.cpp b/radio/src/gui/128x64/lcd.cpp similarity index 100% rename from radio/src/gui/9x/lcd.cpp rename to radio/src/gui/128x64/lcd.cpp diff --git a/radio/src/gui/9x/lcd.h b/radio/src/gui/128x64/lcd.h similarity index 100% rename from radio/src/gui/9x/lcd.h rename to radio/src/gui/128x64/lcd.h diff --git a/radio/src/gui/9x/menu_model.cpp b/radio/src/gui/128x64/menu_model.cpp similarity index 98% rename from radio/src/gui/9x/menu_model.cpp rename to radio/src/gui/128x64/menu_model.cpp index 4dc83e890..f47a79bd3 100644 --- a/radio/src/gui/9x/menu_model.cpp +++ b/radio/src/gui/128x64/menu_model.cpp @@ -18,10 +18,10 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" #if defined(MAVLINK) -#include "gui/9x/view_mavlink.h" +#include "view_mavlink.h" #endif uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) diff --git a/radio/src/gui/9x/menu_general.cpp b/radio/src/gui/128x64/menu_radio.cpp similarity index 99% rename from radio/src/gui/9x/menu_general.cpp rename to radio/src/gui/128x64/menu_radio.cpp index dfb6ab2d9..7e52f98d7 100644 --- a/radio/src/gui/9x/menu_general.cpp +++ b/radio/src/gui/128x64/menu_radio.cpp @@ -18,12 +18,12 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" - -#if defined(CPUARM) -void menuGeneralCustomFunctions(uint8_t event) -{ - MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); - return menuCustomFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext); -} -#endif +#include "../../opentx.h" + +#if defined(CPUARM) +void menuGeneralCustomFunctions(uint8_t event) +{ + MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); + return menuCustomFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext); +} +#endif diff --git a/radio/src/gui/9x/menus.cpp b/radio/src/gui/128x64/menus.cpp similarity index 100% rename from radio/src/gui/9x/menus.cpp rename to radio/src/gui/128x64/menus.cpp diff --git a/radio/src/gui/9x/menus.h b/radio/src/gui/128x64/menus.h similarity index 99% rename from radio/src/gui/9x/menus.h rename to radio/src/gui/128x64/menus.h index e33970e29..484f3bdff 100644 --- a/radio/src/gui/9x/menus.h +++ b/radio/src/gui/128x64/menus.h @@ -521,8 +521,6 @@ void displayWarning(uint8_t event); #define LABEL(...) (uint8_t)-1 -#define KEY_ENTER KEY_MENU - #define CURSOR_MOVED_LEFT(event) (IS_ROTARY_LEFT(event) || EVT_KEY_MASK(event) == KEY_LEFT) #define CURSOR_MOVED_RIGHT(event) (IS_ROTARY_RIGHT(event) || EVT_KEY_MASK(event) == KEY_RIGHT) diff --git a/radio/src/gui/9x/menu_model_curves.cpp b/radio/src/gui/128x64/model_curves.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_curves.cpp rename to radio/src/gui/128x64/model_curves.cpp diff --git a/radio/src/gui/9x/menu_model_flightmodes.cpp b/radio/src/gui/128x64/model_flightmodes.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_flightmodes.cpp rename to radio/src/gui/128x64/model_flightmodes.cpp diff --git a/radio/src/gui/9x/menu_model_heli.cpp b/radio/src/gui/128x64/model_heli.cpp similarity index 98% rename from radio/src/gui/9x/menu_model_heli.cpp rename to radio/src/gui/128x64/model_heli.cpp index 6d6fbfa01..2494cd9db 100644 --- a/radio/src/gui/9x/menu_model_heli.cpp +++ b/radio/src/gui/128x64/model_heli.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" enum menuModelHeliItems { ITEM_HELI_SWASHTYPE, diff --git a/radio/src/gui/9x/menu_model_inputs_mixes.cpp b/radio/src/gui/128x64/model_inputs_mixes.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_inputs_mixes.cpp rename to radio/src/gui/128x64/model_inputs_mixes.cpp diff --git a/radio/src/gui/9x/menu_model_logical_switches.cpp b/radio/src/gui/128x64/model_logical_switches.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_logical_switches.cpp rename to radio/src/gui/128x64/model_logical_switches.cpp diff --git a/radio/src/gui/9x/menu_model_limits.cpp b/radio/src/gui/128x64/model_outputs.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_limits.cpp rename to radio/src/gui/128x64/model_outputs.cpp diff --git a/radio/src/gui/9x/menu_model_select.cpp b/radio/src/gui/128x64/model_select.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_select.cpp rename to radio/src/gui/128x64/model_select.cpp diff --git a/radio/src/gui/9x/menu_model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_setup.cpp rename to radio/src/gui/128x64/model_setup.cpp diff --git a/radio/src/gui/9x/model_special_functions.cpp b/radio/src/gui/128x64/model_special_functions.cpp similarity index 100% rename from radio/src/gui/9x/model_special_functions.cpp rename to radio/src/gui/128x64/model_special_functions.cpp diff --git a/radio/src/gui/9x/menu_model_telemetry.cpp b/radio/src/gui/128x64/model_telemetry.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_telemetry.cpp rename to radio/src/gui/128x64/model_telemetry.cpp diff --git a/radio/src/gui/9x/menu_model_templates.cpp b/radio/src/gui/128x64/model_templates.cpp similarity index 100% rename from radio/src/gui/9x/menu_model_templates.cpp rename to radio/src/gui/128x64/model_templates.cpp diff --git a/radio/src/gui/9x/navigation.cpp b/radio/src/gui/128x64/navigation.cpp similarity index 100% rename from radio/src/gui/9x/navigation.cpp rename to radio/src/gui/128x64/navigation.cpp diff --git a/radio/src/gui/9x/popups.cpp b/radio/src/gui/128x64/popups.cpp similarity index 100% rename from radio/src/gui/9x/popups.cpp rename to radio/src/gui/128x64/popups.cpp diff --git a/radio/src/gui/9x/radio_calibration.cpp b/radio/src/gui/128x64/radio_calibration.cpp similarity index 100% rename from radio/src/gui/9x/radio_calibration.cpp rename to radio/src/gui/128x64/radio_calibration.cpp diff --git a/radio/src/gui/9x/menu_general_diaganas.cpp b/radio/src/gui/128x64/radio_diaganas.cpp similarity index 100% rename from radio/src/gui/9x/menu_general_diaganas.cpp rename to radio/src/gui/128x64/radio_diaganas.cpp diff --git a/radio/src/gui/9x/menu_general_diagkeys.cpp b/radio/src/gui/128x64/radio_diagkeys.cpp similarity index 100% rename from radio/src/gui/9x/menu_general_diagkeys.cpp rename to radio/src/gui/128x64/radio_diagkeys.cpp diff --git a/radio/src/gui/9x/menu_general_hardware.cpp b/radio/src/gui/128x64/radio_hardware.cpp similarity index 100% rename from radio/src/gui/9x/menu_general_hardware.cpp rename to radio/src/gui/128x64/radio_hardware.cpp diff --git a/radio/src/gui/9x/menu_general_sdmanager.cpp b/radio/src/gui/128x64/radio_sdmanager.cpp similarity index 100% rename from radio/src/gui/9x/menu_general_sdmanager.cpp rename to radio/src/gui/128x64/radio_sdmanager.cpp diff --git a/radio/src/gui/9x/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp similarity index 100% rename from radio/src/gui/9x/radio_setup.cpp rename to radio/src/gui/128x64/radio_setup.cpp diff --git a/radio/src/gui/9x/menu_general_trainer.cpp b/radio/src/gui/128x64/radio_trainer.cpp similarity index 100% rename from radio/src/gui/9x/menu_general_trainer.cpp rename to radio/src/gui/128x64/radio_trainer.cpp diff --git a/radio/src/gui/9x/menu_general_version.cpp b/radio/src/gui/128x64/radio_version.cpp similarity index 100% rename from radio/src/gui/9x/menu_general_version.cpp rename to radio/src/gui/128x64/radio_version.cpp diff --git a/radio/src/gui/9x/splash.cpp b/radio/src/gui/128x64/splash.cpp similarity index 98% rename from radio/src/gui/9x/splash.cpp rename to radio/src/gui/128x64/splash.cpp index fd542d974..25123da70 100644 --- a/radio/src/gui/9x/splash.cpp +++ b/radio/src/gui/128x64/splash.cpp @@ -43,7 +43,7 @@ #if defined(SPLASH) const pm_uchar splashdata[] PROGMEM = { 'S','P','S',0, - #include "bitmaps/9x/splash.lbm" + #include "bitmaps/128x64/splash.lbm" 'S','P','E',0 }; const pm_uchar * const splash_lbm = splashdata+4; diff --git a/radio/src/gui/9x/view_about.cpp b/radio/src/gui/128x64/view_about.cpp similarity index 96% rename from radio/src/gui/9x/view_about.cpp rename to radio/src/gui/128x64/view_about.cpp index 2fb972833..73ec9abdb 100644 --- a/radio/src/gui/9x/view_about.cpp +++ b/radio/src/gui/128x64/view_about.cpp @@ -18,133 +18,133 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" - -const pm_uchar about_bmp[] PROGMEM = { -#include "../../bitmaps/9x/about.lbm" -}; - -enum AboutScreens { - ABOUT_OPENTX, - ABOUT_BERTRAND, - ABOUT_ANDRE, - ABOUT_MIKE, - ABOUT_KJELL, - ABOUT_MARTIN, - ABOUT_ROMOLO, - ABOUT_ROB, - ABOUT_HARDWARE, - ABOUT_PARENTS, - ABOUT_END, - ABOUT_COUNT, -}; - -#define ABOUT_X 2 -#define ABOUT_INDENT 4 - -void menuAboutView(uint8_t event) -{ - static uint8_t screenIndex; - static uint8_t greyIndex; - - switch(event) - { - case EVT_ENTRY: - screenIndex = 0; - greyIndex = 0; - break; - case EVT_KEY_FIRST(KEY_DOWN): - screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX; - greyIndex = 0; - break; - case EVT_KEY_FIRST(KEY_UP): - screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS; - greyIndex = 0; - break; - case EVT_KEY_FIRST(KEY_EXIT): - chainMenu(menuMainView); - break; - } - - lcdDrawText(17, 0, STR_ABOUTUS, DBLSIZE|INVERS); - lcdDrawSolidHorizontalLine(17, 16, LCD_W-17); - lcd_img(8, 0, about_bmp, 0); - LcdFlags att = 0; - - uint8_t screenDuration = 150; - - switch (screenIndex) { - case ABOUT_OPENTX: - case ABOUT_END: - lcdDrawText(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); - lcdDrawText(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); - lcdDrawText(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); - lcdDrawText(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); - lcdDrawText(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); - screenDuration = 255; - break; - - case ABOUT_BERTRAND: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); - break; - - case ABOUT_ANDRE: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); - break; - - case ABOUT_MIKE: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); - break; - - case ABOUT_KJELL: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); - break; - - case ABOUT_MARTIN: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); - break; - - case ABOUT_ROMOLO: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); - break; - - case ABOUT_ROB: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROB_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); - break; - - case ABOUT_HARDWARE: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); - break; - - case ABOUT_PARENTS: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); - screenDuration = 255; - break; - } - - if (++greyIndex == screenDuration) { - greyIndex = 0; - if (++screenIndex == ABOUT_COUNT) { - chainMenu(menuMainView); - } - } -} +#include "opentx.h" + +const pm_uchar about_bmp[] PROGMEM = { +#include "about.lbm" +}; + +enum AboutScreens { + ABOUT_OPENTX, + ABOUT_BERTRAND, + ABOUT_ANDRE, + ABOUT_MIKE, + ABOUT_KJELL, + ABOUT_MARTIN, + ABOUT_ROMOLO, + ABOUT_ROB, + ABOUT_HARDWARE, + ABOUT_PARENTS, + ABOUT_END, + ABOUT_COUNT, +}; + +#define ABOUT_X 2 +#define ABOUT_INDENT 4 + +void menuAboutView(uint8_t event) +{ + static uint8_t screenIndex; + static uint8_t greyIndex; + + switch(event) + { + case EVT_ENTRY: + screenIndex = 0; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_DOWN): + screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_UP): + screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + break; + } + + lcdDrawText(17, 0, STR_ABOUTUS, DBLSIZE|INVERS); + lcdDrawSolidHorizontalLine(17, 16, LCD_W-17); + lcd_img(8, 0, about_bmp, 0); + LcdFlags att = 0; + + uint8_t screenDuration = 150; + + switch (screenIndex) { + case ABOUT_OPENTX: + case ABOUT_END: + lcdDrawText(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); + lcdDrawText(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); + lcdDrawText(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); + lcdDrawText(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); + lcdDrawText(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); + screenDuration = 255; + break; + + case ABOUT_BERTRAND: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); + break; + + case ABOUT_ANDRE: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); + break; + + case ABOUT_MIKE: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); + break; + + case ABOUT_KJELL: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); + break; + + case ABOUT_MARTIN: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); + break; + + case ABOUT_ROMOLO: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); + break; + + case ABOUT_ROB: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROB_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); + break; + + case ABOUT_HARDWARE: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); + break; + + case ABOUT_PARENTS: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); + screenDuration = 255; + break; + } + + if (++greyIndex == screenDuration) { + greyIndex = 0; + if (++screenIndex == ABOUT_COUNT) { + chainMenu(menuMainView); + } + } +} diff --git a/radio/src/gui/9x/view_main.cpp b/radio/src/gui/128x64/view_main.cpp similarity index 100% rename from radio/src/gui/9x/view_main.cpp rename to radio/src/gui/128x64/view_main.cpp diff --git a/radio/src/gui/9x/view_mavlink.cpp b/radio/src/gui/128x64/view_mavlink.cpp similarity index 100% rename from radio/src/gui/9x/view_mavlink.cpp rename to radio/src/gui/128x64/view_mavlink.cpp diff --git a/radio/src/gui/9x/view_mavlink.h b/radio/src/gui/128x64/view_mavlink.h similarity index 97% rename from radio/src/gui/9x/view_mavlink.h rename to radio/src/gui/128x64/view_mavlink.h index 19d15bb69..f62f7f559 100644 --- a/radio/src/gui/9x/view_mavlink.h +++ b/radio/src/gui/128x64/view_mavlink.h @@ -27,7 +27,7 @@ #include "opentx.h" #include "telemetry/mavlink.h" -#include "targets/common_avr/serial_driver.h" +#include "targets/common/avr/serial_driver.h" #define APSIZE (BSS | DBLSIZE) diff --git a/radio/src/gui/9x/view_statistics.cpp b/radio/src/gui/128x64/view_statistics.cpp similarity index 97% rename from radio/src/gui/9x/view_statistics.cpp rename to radio/src/gui/128x64/view_statistics.cpp index fa6b841a3..10c3efc7e 100644 --- a/radio/src/gui/9x/view_statistics.cpp +++ b/radio/src/gui/128x64/view_statistics.cpp @@ -1,200 +1,200 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" - -void menuStatisticsView(uint8_t event) -{ - TITLE(STR_MENUSTAT); - - switch(event) - { - case EVT_KEY_FIRST(KEY_UP): - chainMenu(menuStatisticsDebug); - break; - -#if defined(CPUARM) - case EVT_KEY_LONG(KEY_MENU): - g_eeGeneral.globalTimer = 0; - storageDirty(EE_GENERAL); - sessionTimer = 0; - break; -#endif - case EVT_KEY_FIRST(KEY_EXIT): - chainMenu(menuMainView); - break; - } - - lcdDrawText( 1*FW, FH*0, STR_TOTTM1TM2THRTHP); - 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); - - 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); - - putsTimer( 12*FW+5*FWNUM+1, FH*0, sessionTimer, 0, 0); - -#if defined(THRTRACE) - const coord_t x = 5; - const coord_t y = 60; - lcdDrawSolidHorizontalLine(x-3, y, MAXTRACE+3+3); - lcdDrawSolidVerticalLine(x, y-32, 32+3); - for (coord_t i=0; i MAXTRACE ? s_traceWr - MAXTRACE : 0; - for (coord_t i=1; i<=MAXTRACE && traceRd'); - putsValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CURRENT, Current_max*10*current_scale/8192, UNIT_RAW, LEFT); - // consumption - lcd_putsLeft(MENU_DEBUG_Y_MAH, STR_CPU_MAH); - putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MAH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1); -#endif - -#if defined(PCBSKY9X) - lcd_putsLeft(MENU_DEBUG_Y_CPU_TEMP, STR_CPU_TEMP); - putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CPU_TEMP, getTemperature(), UNIT_TEMPERATURE, LEFT); - lcdDrawChar(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CPU_TEMP, '>'); - putsValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CPU_TEMP, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); -#endif - -#if defined(COPROCESSOR) - lcd_putsLeft(MENU_DEBUG_Y_COPROC, STR_COPROC_TEMP); - - if (Coproc_read==0) { - lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS); - } - else if (Coproc_read==0x81) { - lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS); - } - else if (Coproc_read<3) { - lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS); - } - else { - putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, Coproc_temp, UNIT_TEMPERATURE, LEFT); - putsValueWithUnit(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_COPROC, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT); - } -#endif - -#if defined(CPUARM) - lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); - lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); - lcdDrawText(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); -#endif - -#if defined(CPUARM) - lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); - lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+2, menusStack.available(), UNSIGN|LEFT|TINSIZE); - lcdDrawText(lcdLastPos, MENU_DEBUG_Y_RTOS, "/"); - lcdDrawNumber(lcdLastPos, MENU_DEBUG_Y_RTOS+2, mixerStack.available(), UNSIGN|LEFT|TINSIZE); - lcdDrawText(lcdLastPos, MENU_DEBUG_Y_RTOS, "/"); - lcdDrawNumber(lcdLastPos, MENU_DEBUG_Y_RTOS+2, audioStack.available(), UNSIGN|LEFT|TINSIZE); -#endif - -#if !defined(CPUARM) - lcd_putsLeft(1*FH, STR_TMR1LATMAXUS); - lcdDraw8bitsNumber(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 ); - lcd_putsLeft(2*FH, STR_TMR1LATMINUS); - lcdDraw8bitsNumber(MENU_DEBUG_COL1_OFS , 2*FH, g_tmr1Latency_min/2 ); - lcd_putsLeft(3*FH, STR_TMR1JITTERUS); - lcdDraw8bitsNumber(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 ); - lcd_putsLeft(4*FH, STR_TMIXMAXMS); - lcdDrawNumber(MENU_DEBUG_COL1_OFS, 4*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2); - lcd_putsLeft(5*FH, STR_FREESTACKMINB); - lcdDrawNumber(14*FW, 5*FH, stackAvailable(), UNSIGN) ; -#endif - - lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET); - lcdInvertLastLine(); -} +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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" + +void menuStatisticsView(uint8_t event) +{ + TITLE(STR_MENUSTAT); + + switch(event) + { + case EVT_KEY_FIRST(KEY_UP): + chainMenu(menuStatisticsDebug); + break; + +#if defined(CPUARM) + case EVT_KEY_LONG(KEY_MENU): + g_eeGeneral.globalTimer = 0; + storageDirty(EE_GENERAL); + sessionTimer = 0; + break; +#endif + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + break; + } + + lcdDrawText( 1*FW, FH*0, STR_TOTTM1TM2THRTHP); + 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); + + 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); + + putsTimer( 12*FW+5*FWNUM+1, FH*0, sessionTimer, 0, 0); + +#if defined(THRTRACE) + const coord_t x = 5; + const coord_t y = 60; + lcdDrawSolidHorizontalLine(x-3, y, MAXTRACE+3+3); + lcdDrawSolidVerticalLine(x, y-32, 32+3); + for (coord_t i=0; i MAXTRACE ? s_traceWr - MAXTRACE : 0; + for (coord_t i=1; i<=MAXTRACE && traceRd'); + putsValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CURRENT, Current_max*10*current_scale/8192, UNIT_RAW, LEFT); + // consumption + lcd_putsLeft(MENU_DEBUG_Y_MAH, STR_CPU_MAH); + putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MAH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1); +#endif + +#if defined(PCBSKY9X) + lcd_putsLeft(MENU_DEBUG_Y_CPU_TEMP, STR_CPU_TEMP); + putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CPU_TEMP, getTemperature(), UNIT_TEMPERATURE, LEFT); + lcdDrawChar(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CPU_TEMP, '>'); + putsValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CPU_TEMP, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); +#endif + +#if defined(COPROCESSOR) + lcd_putsLeft(MENU_DEBUG_Y_COPROC, STR_COPROC_TEMP); + + if (Coproc_read==0) { + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS); + } + else if (Coproc_read==0x81) { + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS); + } + else if (Coproc_read<3) { + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS); + } + else { + putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, Coproc_temp, UNIT_TEMPERATURE, LEFT); + putsValueWithUnit(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_COPROC, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT); + } +#endif + +#if defined(CPUARM) + lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); + lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); + lcdDrawText(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); +#endif + +#if defined(CPUARM) + lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); + lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+2, menusStack.available(), UNSIGN|LEFT|TINSIZE); + lcdDrawText(lcdLastPos, MENU_DEBUG_Y_RTOS, "/"); + lcdDrawNumber(lcdLastPos, MENU_DEBUG_Y_RTOS+2, mixerStack.available(), UNSIGN|LEFT|TINSIZE); + lcdDrawText(lcdLastPos, MENU_DEBUG_Y_RTOS, "/"); + lcdDrawNumber(lcdLastPos, MENU_DEBUG_Y_RTOS+2, audioStack.available(), UNSIGN|LEFT|TINSIZE); +#endif + +#if !defined(CPUARM) + lcd_putsLeft(1*FH, STR_TMR1LATMAXUS); + lcdDraw8bitsNumber(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 ); + lcd_putsLeft(2*FH, STR_TMR1LATMINUS); + lcdDraw8bitsNumber(MENU_DEBUG_COL1_OFS , 2*FH, g_tmr1Latency_min/2 ); + lcd_putsLeft(3*FH, STR_TMR1JITTERUS); + lcdDraw8bitsNumber(MENU_DEBUG_COL1_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 ); + lcd_putsLeft(4*FH, STR_TMIXMAXMS); + lcdDrawNumber(MENU_DEBUG_COL1_OFS, 4*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2); + lcd_putsLeft(5*FH, STR_FREESTACKMINB); + lcdDrawNumber(14*FW, 5*FH, stackAvailable(), UNSIGN) ; +#endif + + lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET); + lcdInvertLastLine(); +} diff --git a/radio/src/gui/9x/view_telemetry.cpp b/radio/src/gui/128x64/view_telemetry.cpp similarity index 100% rename from radio/src/gui/9x/view_telemetry.cpp rename to radio/src/gui/128x64/view_telemetry.cpp diff --git a/radio/src/gui/9x/view_text.cpp b/radio/src/gui/128x64/view_text.cpp similarity index 100% rename from radio/src/gui/9x/view_text.cpp rename to radio/src/gui/128x64/view_text.cpp diff --git a/radio/src/gui/9x/widgets.cpp b/radio/src/gui/128x64/widgets.cpp similarity index 100% rename from radio/src/gui/9x/widgets.cpp rename to radio/src/gui/128x64/widgets.cpp diff --git a/radio/src/gui/taranis/bmp.cpp b/radio/src/gui/212x64/bmp.cpp similarity index 100% rename from radio/src/gui/taranis/bmp.cpp rename to radio/src/gui/212x64/bmp.cpp diff --git a/radio/src/gui/taranis/fonts.cpp b/radio/src/gui/212x64/fonts.cpp similarity index 95% rename from radio/src/gui/taranis/fonts.cpp rename to radio/src/gui/212x64/fonts.cpp index f46c820c2..94197cfcd 100644 --- a/radio/src/gui/taranis/fonts.cpp +++ b/radio/src/gui/212x64/fonts.cpp @@ -1,140 +1,140 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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 = { -#include "font_05x07.lbm" -#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 -}; - -const pm_uchar font_5x7_B[] PROGMEM = { -#include "font_05x07_B_compressed.lbm" -}; - -#if !defined(BOOT) -const pm_uchar font_10x14[] PROGMEM = { -#include "font_10x14_compressed.lbm" -#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 -}; - -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_22x38_num[] PROGMEM = { -#include "font_22x38_num.lbm" -}; - -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 // !defined(BOOT) +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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 = { +#include "font_05x07.lbm" +#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 +}; + +const pm_uchar font_5x7_B[] PROGMEM = { +#include "font_05x07_B_compressed.lbm" +}; + +#if !defined(BOOT) +const pm_uchar font_10x14[] PROGMEM = { +#include "font_10x14_compressed.lbm" +#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 +}; + +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_22x38_num[] PROGMEM = { +#include "font_22x38_num.lbm" +}; + +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 // !defined(BOOT) diff --git a/radio/src/gui/taranis/gui.h b/radio/src/gui/212x64/gui.h similarity index 97% rename from radio/src/gui/taranis/gui.h rename to radio/src/gui/212x64/gui.h index f7a540617..5f6ed2749 100644 --- a/radio/src/gui/taranis/gui.h +++ b/radio/src/gui/212x64/gui.h @@ -18,6 +18,10 @@ * GNU General Public License for more details. */ +#ifndef _GUI_H_ +#define _GUI_H_ + +#include "gui_helpers.h" #include "lcd.h" #include "menus.h" @@ -76,3 +80,4 @@ FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModes #define displayFlightModes(...) #endif +#endif // _GUI_H_ \ No newline at end of file diff --git a/radio/src/gui/taranis/lcd.cpp b/radio/src/gui/212x64/lcd.cpp similarity index 99% rename from radio/src/gui/taranis/lcd.cpp rename to radio/src/gui/212x64/lcd.cpp index a65829b99..a84e54f53 100644 --- a/radio/src/gui/taranis/lcd.cpp +++ b/radio/src/gui/212x64/lcd.cpp @@ -21,7 +21,7 @@ #include "opentx.h" #include "timers.h" -#if defined(REVPLUS) && defined(LCD_DUAL_BUFFER) +#if (defined(PCBX9E) || defined(PCBX9DP)) && defined(LCD_DUAL_BUFFER) display_t displayBuf1[DISPLAY_BUFFER_SIZE] __DMA; display_t displayBuf2[DISPLAY_BUFFER_SIZE] __DMA; display_t * displayBuf = displayBuf1; diff --git a/radio/src/gui/taranis/lcd.h b/radio/src/gui/212x64/lcd.h similarity index 97% rename from radio/src/gui/taranis/lcd.h rename to radio/src/gui/212x64/lcd.h index df60ad3a9..83639474a 100644 --- a/radio/src/gui/taranis/lcd.h +++ b/radio/src/gui/212x64/lcd.h @@ -89,7 +89,7 @@ #define display_t uint8_t #define DISPLAY_BUFFER_SIZE (LCD_W*LCD_H*4/8) -#if defined(REVPLUS) && defined(LCD_DUAL_BUFFER) +#if (defined(PCBX9E) || defined(PCBX9DP)) && defined(LCD_DUAL_BUFFER) extern display_t displayBuf1[DISPLAY_BUFFER_SIZE]; extern display_t displayBuf2[DISPLAY_BUFFER_SIZE]; extern display_t * displayBuf; @@ -97,7 +97,7 @@ extern display_t displayBuf[DISPLAY_BUFFER_SIZE]; #endif -#if defined(REVPLUS) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU) +#if (defined(PCBX9E) || defined(PCBX9DP)) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU) void lcdRefreshWait(); #else #define lcdRefreshWait() @@ -203,7 +203,7 @@ void lcdSetRefVolt(unsigned char val); void lcdClear(); void lcdSetContrast(); -#if defined(REVPLUS) && !defined(SIMU) +#if (defined(PCBX9E) || defined(PCBX9DP)) && !defined(SIMU) void lcdRefresh(bool wait=true); #else void lcdRefresh(); diff --git a/radio/src/gui/taranis/menu_model.cpp b/radio/src/gui/212x64/menu_model.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model.cpp rename to radio/src/gui/212x64/menu_model.cpp diff --git a/radio/src/gui/taranis/menu_general.cpp b/radio/src/gui/212x64/menu_radio.cpp similarity index 100% rename from radio/src/gui/taranis/menu_general.cpp rename to radio/src/gui/212x64/menu_radio.cpp diff --git a/radio/src/gui/taranis/menus.cpp b/radio/src/gui/212x64/menus.cpp similarity index 100% rename from radio/src/gui/taranis/menus.cpp rename to radio/src/gui/212x64/menus.cpp diff --git a/radio/src/gui/taranis/menus.h b/radio/src/gui/212x64/menus.h similarity index 99% rename from radio/src/gui/taranis/menus.h rename to radio/src/gui/212x64/menus.h index d3abdef94..006b11112 100644 --- a/radio/src/gui/taranis/menus.h +++ b/radio/src/gui/212x64/menus.h @@ -413,7 +413,7 @@ void menuChannelsView(uint8_t event); #define LABEL(...) (uint8_t)-1 -#if defined(REV9E) && !defined(SIMU) +#if defined(PCBX9E) && !defined(SIMU) #define KEY_UP KEY_MINUS #define KEY_DOWN KEY_PLUS #define KEY_RIGHT KEY_PLUS diff --git a/radio/src/gui/taranis/menu_model_curves.cpp b/radio/src/gui/212x64/model_curves.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_curves.cpp rename to radio/src/gui/212x64/model_curves.cpp diff --git a/radio/src/gui/taranis/menu_model_custom_scripts.cpp b/radio/src/gui/212x64/model_custom_scripts.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_custom_scripts.cpp rename to radio/src/gui/212x64/model_custom_scripts.cpp diff --git a/radio/src/gui/taranis/menu_model_display.cpp b/radio/src/gui/212x64/model_display.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_display.cpp rename to radio/src/gui/212x64/model_display.cpp diff --git a/radio/src/gui/taranis/menu_model_flightmodes.cpp b/radio/src/gui/212x64/model_flightmodes.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_flightmodes.cpp rename to radio/src/gui/212x64/model_flightmodes.cpp diff --git a/radio/src/gui/taranis/menu_model_gvars.cpp b/radio/src/gui/212x64/model_gvars.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_gvars.cpp rename to radio/src/gui/212x64/model_gvars.cpp diff --git a/radio/src/gui/taranis/menu_model_heli.cpp b/radio/src/gui/212x64/model_heli.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_heli.cpp rename to radio/src/gui/212x64/model_heli.cpp diff --git a/radio/src/gui/taranis/menu_model_inputs.cpp b/radio/src/gui/212x64/model_inputs.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_inputs.cpp rename to radio/src/gui/212x64/model_inputs.cpp diff --git a/radio/src/gui/taranis/menu_model_logical_switches.cpp b/radio/src/gui/212x64/model_logical_switches.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_logical_switches.cpp rename to radio/src/gui/212x64/model_logical_switches.cpp diff --git a/radio/src/gui/taranis/menu_model_mixes.cpp b/radio/src/gui/212x64/model_mixes.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_mixes.cpp rename to radio/src/gui/212x64/model_mixes.cpp diff --git a/radio/src/gui/taranis/menu_model_limits.cpp b/radio/src/gui/212x64/model_outputs.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_limits.cpp rename to radio/src/gui/212x64/model_outputs.cpp diff --git a/radio/src/gui/taranis/menu_model_select.cpp b/radio/src/gui/212x64/model_select.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_select.cpp rename to radio/src/gui/212x64/model_select.cpp diff --git a/radio/src/gui/taranis/menu_model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp similarity index 99% rename from radio/src/gui/taranis/menu_model_setup.cpp rename to radio/src/gui/212x64/model_setup.cpp index 733fe47b3..c062ac074 100644 --- a/radio/src/gui/taranis/menu_model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -45,7 +45,7 @@ enum menuModelSetupItems { ITEM_MODEL_TIMER3_MINUTE_BEEP, ITEM_MODEL_TIMER3_COUNTDOWN_BEEP, #endif -#if defined(REV9E) +#if defined(PCBX9E) ITEM_MODEL_TOP_LCD_TIMER, #endif ITEM_MODEL_EXTENDED_LIMITS, @@ -60,12 +60,12 @@ enum menuModelSetupItems { ITEM_MODEL_CHECKLIST_DISPLAY, ITEM_MODEL_THROTTLE_WARNING, ITEM_MODEL_SWITCHES_WARNING, -#if defined(REV9E) +#if defined(PCBX9E) ITEM_MODEL_SWITCHES_WARNING2, ITEM_MODEL_SWITCHES_WARNING3, #endif ITEM_MODEL_POTS_WARNING, -#if defined(REV9E) +#if defined(PCBX9E) ITEM_MODEL_POTS_WARNING2, #endif ITEM_MODEL_BEEP_CENTER, @@ -248,7 +248,7 @@ int getSwitchWarningsCount() #elif TIMERS == 3 #define TIMERS_ROWS TIMER_ROWS(0), TIMER_ROWS(1), TIMER_ROWS(2) #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SW_WARN_ITEMS() uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), uint8_t(getSwitchWarningsCount() > 8 ? TITLE_ROW : HIDDEN_ROW), uint8_t(getSwitchWarningsCount() > 16 ? TITLE_ROW : HIDDEN_ROW) #define POT_WARN_ITEMS() uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|NUM_POTS : 0), uint8_t(g_model.potsWarnMode ? TITLE_ROW : HIDDEN_ROW) #define TOPLCD_ROWS 0, @@ -402,7 +402,7 @@ void menuModelSetup(uint8_t event) break; #endif -#if defined(REV9E) +#if defined(PCBX9E) case ITEM_MODEL_TOP_LCD_TIMER: lcd_putsLeft(y, STR_TOPLCDTIMER); drawStringWithIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.toplcdTimer+1, attr); @@ -477,7 +477,7 @@ void menuModelSetup(uint8_t event) g_model.disableThrottleWarning = !editCheckBox(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, STR_THROTTLEWARNING, attr, event); break; -#if defined(REV9E) +#if defined(PCBX9E) case ITEM_MODEL_SWITCHES_WARNING2: case ITEM_MODEL_SWITCHES_WARNING3: case ITEM_MODEL_POTS_WARNING2: @@ -492,7 +492,7 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_SWITCHES_WARNING: { -#if defined(REV9E) +#if defined(PCBX9E) if (i>=NUM_BODY_LINES-2 && getSwitchWarningsCount() > 8*(NUM_BODY_LINES-i)) { if (CURSOR_MOVED_LEFT(event)) menuVerticalOffset--; @@ -544,7 +544,7 @@ void menuModelSetup(uint8_t event) states >>= 2; } if (attr && menuHorizontalPosition < 0) { -#if defined(REV9E) +#if defined(PCBX9E) lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, 8*(2*FW+1), 1+FH*((current+7)/8)); #else lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, current*(2*FW+1), FH+1); @@ -554,7 +554,7 @@ void menuModelSetup(uint8_t event) } case ITEM_MODEL_POTS_WARNING: -#if defined(REV9E) +#if defined(PCBX9E) if (i==NUM_BODY_LINES-1 && g_model.potsWarnMode) { if (CURSOR_MOVED_LEFT(event)) menuVerticalOffset--; @@ -597,7 +597,7 @@ void menuModelSetup(uint8_t event) if (attr && (menuHorizontalPosition==i+1)) REPEAT_LAST_CURSOR_MOVE(); } else { -#if defined(REV9E) +#if defined(PCBX9E) if (i == NUM_XPOTS) { y += FH; x = MODEL_SETUP_2ND_COLUMN; @@ -615,7 +615,7 @@ void menuModelSetup(uint8_t event) } } if (attr && menuHorizontalPosition < 0) { -#if defined(REV9E) +#if defined(PCBX9E) lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-FH-1, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH+1, 2*FH+1); #else lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH+1, FH+1); diff --git a/radio/src/gui/taranis/model_special_functions.cpp b/radio/src/gui/212x64/model_special_functions.cpp similarity index 99% rename from radio/src/gui/taranis/model_special_functions.cpp rename to radio/src/gui/212x64/model_special_functions.cpp index 7faa18381..e69c0497b 100644 --- a/radio/src/gui/taranis/model_special_functions.cpp +++ b/radio/src/gui/212x64/model_special_functions.cpp @@ -332,7 +332,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu lcdDrawTextAtIndex(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) else if (func == FUNC_BACKLIGHT) { drawSlider(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr); if (active) INCDEC_SET_FLAG(eeFlags | NO_INCDEC_MARKS); diff --git a/radio/src/gui/taranis/menu_model_telemetry.cpp b/radio/src/gui/212x64/model_telemetry.cpp similarity index 100% rename from radio/src/gui/taranis/menu_model_telemetry.cpp rename to radio/src/gui/212x64/model_telemetry.cpp diff --git a/radio/src/gui/taranis/navigation.cpp b/radio/src/gui/212x64/navigation.cpp similarity index 100% rename from radio/src/gui/taranis/navigation.cpp rename to radio/src/gui/212x64/navigation.cpp diff --git a/radio/src/gui/taranis/popups.cpp b/radio/src/gui/212x64/popups.cpp similarity index 100% rename from radio/src/gui/taranis/popups.cpp rename to radio/src/gui/212x64/popups.cpp diff --git a/radio/src/gui/taranis/radio_calibration.cpp b/radio/src/gui/212x64/radio_calibration.cpp similarity index 100% rename from radio/src/gui/taranis/radio_calibration.cpp rename to radio/src/gui/212x64/radio_calibration.cpp diff --git a/radio/src/gui/taranis/menu_general_diaganas.cpp b/radio/src/gui/212x64/radio_diaganas.cpp similarity index 100% rename from radio/src/gui/taranis/menu_general_diaganas.cpp rename to radio/src/gui/212x64/radio_diaganas.cpp diff --git a/radio/src/gui/taranis/menu_general_diagkeys.cpp b/radio/src/gui/212x64/radio_diagkeys.cpp similarity index 100% rename from radio/src/gui/taranis/menu_general_diagkeys.cpp rename to radio/src/gui/212x64/radio_diagkeys.cpp diff --git a/radio/src/gui/taranis/menu_general_hardware.cpp b/radio/src/gui/212x64/radio_hardware.cpp similarity index 92% rename from radio/src/gui/taranis/menu_general_hardware.cpp rename to radio/src/gui/212x64/radio_hardware.cpp index ec3431073..bac548ce8 100644 --- a/radio/src/gui/taranis/menu_general_hardware.cpp +++ b/radio/src/gui/212x64/radio_hardware.cpp @@ -29,12 +29,12 @@ enum menuGeneralHwItems { ITEM_SETUP_HW_LABEL_POTS, ITEM_SETUP_HW_POT1, ITEM_SETUP_HW_POT2, - CASE_REVPLUS(ITEM_SETUP_HW_POT3) - CASE_REV9E(ITEM_SETUP_HW_POT4) + CASE_PCBX9E_PCBX9DP(ITEM_SETUP_HW_POT3) + CASE_PCBX9E(ITEM_SETUP_HW_POT4) ITEM_SETUP_HW_LS, ITEM_SETUP_HW_RS, - CASE_REV9E(ITEM_SETUP_HW_LS2) - CASE_REV9E(ITEM_SETUP_HW_RS2) + CASE_PCBX9E(ITEM_SETUP_HW_LS2) + CASE_PCBX9E(ITEM_SETUP_HW_RS2) ITEM_SETUP_HW_LABEL_SWITCHES, ITEM_SETUP_HW_SA, ITEM_SETUP_HW_SB, @@ -44,17 +44,17 @@ enum menuGeneralHwItems { ITEM_SETUP_HW_SF, ITEM_SETUP_HW_SG, ITEM_SETUP_HW_SH, - CASE_REV9E(ITEM_SETUP_HW_SI) - CASE_REV9E(ITEM_SETUP_HW_SJ) - CASE_REV9E(ITEM_SETUP_HW_SK) - CASE_REV9E(ITEM_SETUP_HW_SL) - CASE_REV9E(ITEM_SETUP_HW_SM) - CASE_REV9E(ITEM_SETUP_HW_SN) - CASE_REV9E(ITEM_SETUP_HW_SO) - CASE_REV9E(ITEM_SETUP_HW_SP) - CASE_REV9E(ITEM_SETUP_HW_SQ) - CASE_REV9E(ITEM_SETUP_HW_SR) - CASE_REV9E(ITEM_SETUP_HW_BLUETOOTH) + CASE_PCBX9E(ITEM_SETUP_HW_SI) + CASE_PCBX9E(ITEM_SETUP_HW_SJ) + CASE_PCBX9E(ITEM_SETUP_HW_SK) + CASE_PCBX9E(ITEM_SETUP_HW_SL) + CASE_PCBX9E(ITEM_SETUP_HW_SM) + CASE_PCBX9E(ITEM_SETUP_HW_SN) + CASE_PCBX9E(ITEM_SETUP_HW_SO) + CASE_PCBX9E(ITEM_SETUP_HW_SP) + CASE_PCBX9E(ITEM_SETUP_HW_SQ) + CASE_PCBX9E(ITEM_SETUP_HW_SR) + CASE_PCBX9E(ITEM_SETUP_HW_BLUETOOTH) ITEM_SETUP_HW_UART3_MODE, ITEM_SETUP_HW_JITTER_FILTER, ITEM_SETUP_HW_MAX @@ -62,15 +62,15 @@ enum menuGeneralHwItems { #define HW_SETTINGS_COLUMN 15*FW -#if defined(REV9E) +#if defined(PCBX9E) #define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, 0, 0, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1 -#elif defined(REVPLUS) +#elif defined(PCBX9DP) #define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, 0, 0 #else #define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, 0, 0 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1 #define BLUETOOTH_ROWS 1, #else @@ -114,7 +114,7 @@ void menuGeneralHardware(uint8_t event) lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); break; } -#if defined(REV9E) +#if defined(PCBX9E) case ITEM_SETUP_HW_LS2: case ITEM_SETUP_HW_RS2: { @@ -137,10 +137,10 @@ void menuGeneralHardware(uint8_t event) break; case ITEM_SETUP_HW_POT1: case ITEM_SETUP_HW_POT2: -#if defined(REVPLUS) +#if defined(PCBX9DP) || defined(PCBX9E) case ITEM_SETUP_HW_POT3: #endif -#if defined(REV9E) +#if defined(PCBX9E) case ITEM_SETUP_HW_POT4: #endif { @@ -169,7 +169,7 @@ void menuGeneralHardware(uint8_t event) case ITEM_SETUP_HW_SF: case ITEM_SETUP_HW_SG: case ITEM_SETUP_HW_SH: -#if defined(REV9E) +#if defined(PCBX9E) case ITEM_SETUP_HW_SI: case ITEM_SETUP_HW_SJ: case ITEM_SETUP_HW_SK: @@ -196,7 +196,7 @@ void menuGeneralHardware(uint8_t event) } break; } -#if defined(REV9E) +#if defined(PCBX9E) case ITEM_SETUP_HW_BLUETOOTH: lcd_putsLeft(y, "Bluetooth"); drawCheckBox(HW_SETTINGS_COLUMN, y, g_eeGeneral.bluetoothEnable, menuHorizontalPosition == 0 ? attr : 0); diff --git a/radio/src/gui/taranis/menu_general_sdmanager.cpp b/radio/src/gui/212x64/radio_sdmanager.cpp similarity index 100% rename from radio/src/gui/taranis/menu_general_sdmanager.cpp rename to radio/src/gui/212x64/radio_sdmanager.cpp diff --git a/radio/src/gui/taranis/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp similarity index 98% rename from radio/src/gui/taranis/radio_setup.cpp rename to radio/src/gui/212x64/radio_setup.cpp index 7eb0a3658..e8951507e 100644 --- a/radio/src/gui/taranis/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -74,7 +74,7 @@ enum menuGeneralSetupItems { ITEM_SETUP_BACKLIGHT_MODE, ITEM_SETUP_BACKLIGHT_DELAY, ITEM_SETUP_BRIGHTNESS, - CASE_REVPLUS(ITEM_SETUP_BACKLIGHT_COLOR) + CASE_PCBX9E_PCBX9DP(ITEM_SETUP_BACKLIGHT_COLOR) ITEM_SETUP_FLASH_BEEP, CASE_SPLASH_PARAM(ITEM_SETUP_DISABLE_SPLASH) CASE_GPS(ITEM_SETUP_LABEL_GPS) @@ -115,7 +115,7 @@ void menuGeneralSetup(uint8_t event) } #endif - MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 0, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); + MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 0, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_PCBX9E_PCBX9DP(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); if (event == EVT_ENTRY) { reusableBuffer.generalSettings.stickMode = g_eeGeneral.stickMode; @@ -378,7 +378,7 @@ void menuGeneralSetup(uint8_t event) } break; -#if defined(REVPLUS) +#if defined(PCBX9DP) || defined(PCBX9E) case ITEM_SETUP_BACKLIGHT_COLOR: lcd_putsLeft(y, STR_BLCOLOR); drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr); diff --git a/radio/src/gui/taranis/menu_general_trainer.cpp b/radio/src/gui/212x64/radio_trainer.cpp similarity index 100% rename from radio/src/gui/taranis/menu_general_trainer.cpp rename to radio/src/gui/212x64/radio_trainer.cpp diff --git a/radio/src/gui/taranis/menu_general_version.cpp b/radio/src/gui/212x64/radio_version.cpp similarity index 100% rename from radio/src/gui/taranis/menu_general_version.cpp rename to radio/src/gui/212x64/radio_version.cpp diff --git a/radio/src/gui/taranis/splash.cpp b/radio/src/gui/212x64/splash.cpp similarity index 96% rename from radio/src/gui/taranis/splash.cpp rename to radio/src/gui/212x64/splash.cpp index 0a5ce7990..00d9cf7e9 100644 --- a/radio/src/gui/taranis/splash.cpp +++ b/radio/src/gui/212x64/splash.cpp @@ -23,7 +23,7 @@ #if defined(SPLASH) const pm_uchar splashdata[] PROGMEM = { 'S','P','S',0, - #include "bitmaps/taranis/splash.lbm" + #include "bitmaps/212x64/splash.lbm" 'S','P','E',0 }; const pm_uchar * const splash_lbm = splashdata+4; diff --git a/radio/src/gui/taranis/view_about.cpp b/radio/src/gui/212x64/view_about.cpp similarity index 96% rename from radio/src/gui/taranis/view_about.cpp rename to radio/src/gui/212x64/view_about.cpp index e2224ff94..cc71062d4 100644 --- a/radio/src/gui/taranis/view_about.cpp +++ b/radio/src/gui/212x64/view_about.cpp @@ -1,151 +1,151 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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 about_bmp[] PROGMEM = { -#include "../../bitmaps/taranis/about.lbm" -}; - -enum AboutScreens { - ABOUT_OPENTX, - ABOUT_BERTRAND, - ABOUT_ANDRE, - ABOUT_MIKE, - ABOUT_KJELL, - ABOUT_MARTIN, - ABOUT_ROMOLO, - ABOUT_ROB, - ABOUT_HARDWARE, - ABOUT_PARENTS, - ABOUT_END, - ABOUT_COUNT, -}; - -#define ABOUT_X 62 -#define ABOUT_INDENT 6 - -void menuAboutView(uint8_t event) -{ - static uint8_t screenIndex; - static uint8_t greyIndex; - - switch(event) - { - case EVT_ENTRY: - screenIndex = 0; - greyIndex = 0; - break; - case EVT_KEY_FIRST(KEY_DOWN): - screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX; - greyIndex = 0; - break; - case EVT_KEY_FIRST(KEY_UP): - screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS; - greyIndex = 0; - break; - case EVT_KEY_FIRST(KEY_EXIT): - chainMenu(menuMainView); - break; - } - - lcdDrawBitmap(0, 0, about_bmp); - lcdDrawText(64, 0, STR_ABOUTUS, DBLSIZE); - lcdDrawSolidHorizontalLine(ABOUT_X, 18, 120); - lcdDrawSolidHorizontalLine(ABOUT_X, 19, 130, GREY_DEFAULT); - LcdFlags att = GREY(max(0, 15-greyIndex/2)); - - uint8_t screenDuration = 150; - - switch (screenIndex) { - case ABOUT_OPENTX: - case ABOUT_END: - lcdDrawText(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); - lcdDrawText(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); - lcdDrawText(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); - lcdDrawText(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); - lcdDrawText(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); - screenDuration = 255; - break; - - case ABOUT_BERTRAND: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); - break; - - case ABOUT_ANDRE: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); - break; - - case ABOUT_MIKE: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); - break; - - case ABOUT_KJELL: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); - break; - - case ABOUT_MARTIN: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); - break; - - case ABOUT_ROMOLO: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); - break; - - case ABOUT_ROB: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROB_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); - break; - - case ABOUT_HARDWARE: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); - break; - - case ABOUT_PARENTS: - lcdDrawText(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); - lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); - screenDuration = 255; - break; - } - - if (++greyIndex == screenDuration) { - greyIndex = 0; - if (++screenIndex == ABOUT_COUNT) { - chainMenu(menuMainView); - } - } -} +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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 about_bmp[] PROGMEM = { +#include "about.lbm" +}; + +enum AboutScreens { + ABOUT_OPENTX, + ABOUT_BERTRAND, + ABOUT_ANDRE, + ABOUT_MIKE, + ABOUT_KJELL, + ABOUT_MARTIN, + ABOUT_ROMOLO, + ABOUT_ROB, + ABOUT_HARDWARE, + ABOUT_PARENTS, + ABOUT_END, + ABOUT_COUNT, +}; + +#define ABOUT_X 62 +#define ABOUT_INDENT 6 + +void menuAboutView(uint8_t event) +{ + static uint8_t screenIndex; + static uint8_t greyIndex; + + switch(event) + { + case EVT_ENTRY: + screenIndex = 0; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_DOWN): + screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_UP): + screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + break; + } + + lcdDrawBitmap(0, 0, about_bmp); + lcdDrawText(64, 0, STR_ABOUTUS, DBLSIZE); + lcdDrawSolidHorizontalLine(ABOUT_X, 18, 120); + lcdDrawSolidHorizontalLine(ABOUT_X, 19, 130, GREY_DEFAULT); + LcdFlags att = GREY(max(0, 15-greyIndex/2)); + + uint8_t screenDuration = 150; + + switch (screenIndex) { + case ABOUT_OPENTX: + case ABOUT_END: + lcdDrawText(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); + lcdDrawText(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); + lcdDrawText(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); + lcdDrawText(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); + lcdDrawText(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); + screenDuration = 255; + break; + + case ABOUT_BERTRAND: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); + break; + + case ABOUT_ANDRE: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); + break; + + case ABOUT_MIKE: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); + break; + + case ABOUT_KJELL: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); + break; + + case ABOUT_MARTIN: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); + break; + + case ABOUT_ROMOLO: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); + break; + + case ABOUT_ROB: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROB_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); + break; + + case ABOUT_HARDWARE: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); + break; + + case ABOUT_PARENTS: + lcdDrawText(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); + screenDuration = 255; + break; + } + + if (++greyIndex == screenDuration) { + greyIndex = 0; + if (++screenIndex == ABOUT_COUNT) { + chainMenu(menuMainView); + } + } +} diff --git a/radio/src/gui/taranis/view_channels.cpp b/radio/src/gui/212x64/view_channels.cpp similarity index 96% rename from radio/src/gui/taranis/view_channels.cpp rename to radio/src/gui/212x64/view_channels.cpp index 777de1448..ef88610b3 100644 --- a/radio/src/gui/taranis/view_channels.cpp +++ b/radio/src/gui/212x64/view_channels.cpp @@ -1,116 +1,116 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" - -void menuChannelsView(uint8_t event) -{ - static bool longNames = false; - bool newLongNames = false; - static bool secondPage = false; -#ifdef MIXERS_MONITOR - static bool mixersView = false; -#endif - uint8_t ch; - - switch(event) - { - case EVT_KEY_BREAK(KEY_EXIT): - popMenu(); - break; - case EVT_KEY_FIRST(KEY_RIGHT): - case EVT_KEY_FIRST(KEY_LEFT): - secondPage = !secondPage; - break; -#ifdef MIXERS_MONITOR - case EVT_KEY_FIRST(KEY_ENTER): - mixersView = !mixersView; - break; -#endif - } - - if (secondPage) - ch = 16; - else - ch = 0; - -#ifdef MIXERS_MONITOR - if (mixersView) - lcd_putsCenter(0*FH, MIXERS_MONITOR); - else -#endif - lcd_putsCenter(0*FH, CHANNELS_MONITOR); - - lcdInvertLine(0); - - // Column separator - lcdDrawSolidVerticalLine(LCD_W/2, FH, LCD_H-FH); - - for (uint8_t col=0; col<2; col++) { - - uint8_t x = col*LCD_W/2+1; - - // Channels - for (uint8_t line=0; line<8; line++) { - uint8_t y = 9+line*7; -#ifdef MIXERS_MONITOR - int32_t val = (mixersView) ? ex_chans[ch] : channelOutputs[ch]; -#else - int32_t val = channelOutputs[ch]; -#endif - uint8_t ofs = (col ? 0 : 1); - - // Channel name if present, number if not - uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); - if (lenLabel > 4) { - newLongNames = longNames = true; - } - - if (lenLabel > 0) - lcdDrawSizedText(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE); - else - putsChn(x+1-ofs, y, ch+1, SMLSIZE); - - // Value -#if defined(PPM_UNIT_US) - uint8_t wbar = (longNames ? 54 : 64); - lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE|RIGHT); -#elif defined(PPM_UNIT_PERCENT_PREC1) - uint8_t wbar = (longNames ? 48 : 58); - lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE|RIGHT); -#else - uint8_t wbar = (longNames ? 54 : 64); - lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE|RIGHT); -#endif - - // Gauge -#ifdef MIXERS_MONITOR - uint16_t lim = mixersView ? 512*2*2 : (g_model.extendedLimits ? 640*2 : 512*2); -#else - uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; -#endif - drawGauge(x+LCD_W/2-3-wbar-ofs, y, wbar, 6, val, lim); - - ch++; - } - } - - longNames = newLongNames; -} +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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" + +void menuChannelsView(uint8_t event) +{ + static bool longNames = false; + bool newLongNames = false; + static bool secondPage = false; +#ifdef MIXERS_MONITOR + static bool mixersView = false; +#endif + uint8_t ch; + + switch(event) + { + case EVT_KEY_BREAK(KEY_EXIT): + popMenu(); + break; + case EVT_KEY_FIRST(KEY_RIGHT): + case EVT_KEY_FIRST(KEY_LEFT): + secondPage = !secondPage; + break; +#ifdef MIXERS_MONITOR + case EVT_KEY_FIRST(KEY_ENTER): + mixersView = !mixersView; + break; +#endif + } + + if (secondPage) + ch = 16; + else + ch = 0; + +#ifdef MIXERS_MONITOR + if (mixersView) + lcd_putsCenter(0*FH, MIXERS_MONITOR); + else +#endif + lcd_putsCenter(0*FH, CHANNELS_MONITOR); + + lcdInvertLine(0); + + // Column separator + lcdDrawSolidVerticalLine(LCD_W/2, FH, LCD_H-FH); + + for (uint8_t col=0; col<2; col++) { + + uint8_t x = col*LCD_W/2+1; + + // Channels + for (uint8_t line=0; line<8; line++) { + uint8_t y = 9+line*7; +#ifdef MIXERS_MONITOR + int32_t val = (mixersView) ? ex_chans[ch] : channelOutputs[ch]; +#else + int32_t val = channelOutputs[ch]; +#endif + uint8_t ofs = (col ? 0 : 1); + + // Channel name if present, number if not + uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); + if (lenLabel > 4) { + newLongNames = longNames = true; + } + + if (lenLabel > 0) + lcdDrawSizedText(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE); + else + putsChn(x+1-ofs, y, ch+1, SMLSIZE); + + // Value +#if defined(PPM_UNIT_US) + uint8_t wbar = (longNames ? 54 : 64); + lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE|RIGHT); +#elif defined(PPM_UNIT_PERCENT_PREC1) + uint8_t wbar = (longNames ? 48 : 58); + lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE|RIGHT); +#else + uint8_t wbar = (longNames ? 54 : 64); + lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE|RIGHT); +#endif + + // Gauge +#ifdef MIXERS_MONITOR + uint16_t lim = mixersView ? 512*2*2 : (g_model.extendedLimits ? 640*2 : 512*2); +#else + uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; +#endif + drawGauge(x+LCD_W/2-3-wbar-ofs, y, wbar, 6, val, lim); + + ch++; + } + } + + longNames = newLongNames; +} diff --git a/radio/src/gui/taranis/view_main.cpp b/radio/src/gui/212x64/view_main.cpp similarity index 95% rename from radio/src/gui/taranis/view_main.cpp rename to radio/src/gui/212x64/view_main.cpp index cf0cbcf34..0c9c7e103 100644 --- a/radio/src/gui/taranis/view_main.cpp +++ b/radio/src/gui/212x64/view_main.cpp @@ -1,591 +1,591 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" - -#define BIGSIZE MIDSIZE -#define LBOX_CENTERX (BOX_WIDTH/2 + 16) -#define RBOX_CENTERX (LCD_W-LBOX_CENTERX-1) -#define MODELNAME_X (15) -#define MODELNAME_Y (11) -#define VBATT_X (MODELNAME_X+26) -#define VBATT_Y (FH+3) -#define VBATTUNIT_X (VBATT_X-2) -#define VBATTUNIT_Y VBATT_Y -#define BITMAP_X ((LCD_W-64)/2) -#define BITMAP_Y (LCD_H/2) -#define PHASE_X BITMAP_X -#define PHASE_Y (3*FH) -#define PHASE_FLAGS (0) -#define TIMERS_X 145 -#define TIMERS_Y 20 -#define TIMERS_H 25 -#define TIMERS_R 193 -#define REBOOT_X (LCD_W-FW) -#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 TRIM_LH_X (32+9) -#define TRIM_LV_X 10 -#define TRIM_RV_X (LCD_W-11) -#define TRIM_RH_X (LCD_W-32-9) - -#define TRIM_LEN 27 -#define MARKER_WIDTH 5 - -const pm_uchar logo_taranis[] PROGMEM = { -#include "../../bitmaps/taranis/logo.lbm" -}; - -const pm_uchar icons[] PROGMEM = { -#include "../../bitmaps/taranis/icons.lbm" -}; - -#define ICON_RSSI 0, 9 -#define ICON_SPEAKER0 9, 8 -#define ICON_SPEAKER1 17, 8 -#define ICON_SPEAKER2 25, 8 -#define ICON_SPEAKER3 33, 8 -#define ICON_SD 41, 11 -#define ICON_LOGS 51, 11 -#define ICON_TRAINER 61, 11 -#define ICON_TRAINEE 71, 11 -#define ICON_USB 81, 11 -#define ICON_REBOOT 91, 11 -#define ICON_ALTITUDE 102, 9 - -void doMainScreenGraphics() -{ - int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)]; - if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK) - calibStickVert = -calibStickVert; - drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert); - - calibStickVert = calibratedStick[CONVERT_MODE(2)]; - if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK) - calibStickVert = -calibStickVert; - drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert); -} - -void displayTrims(uint8_t phase) -{ - for (unsigned int i=0; i TRIM_MAX) { - exttrim = true; - } - if (val < -(TRIM_LEN+1)*4) { - val = -(TRIM_LEN+1); - } - else if (val > (TRIM_LEN+1)*4) { - val = TRIM_LEN+1; - } - else { - val /= 4; - } - - if (vert[i]) { - ym = 31; - lcdDrawSolidVerticalLine(xm, ym-TRIM_LEN, TRIM_LEN*2); - if (i!=2 || !g_model.thrTrim) { - lcdDrawSolidVerticalLine(xm-1, ym-1, 3); - lcdDrawSolidVerticalLine(xm+1, ym-1, 3); - } - ym -= val; - lcdDrawFilledRect(xm-3, ym-3, 7, 7, SOLID, att|ERASE); - if (trim >= 0) { - lcdDrawSolidHorizontalLine(xm-1, ym-1, 3); - } - if (trim <= 0) { - lcdDrawSolidHorizontalLine(xm-1, ym+1, 3); - } - if (exttrim) { - lcdDrawSolidHorizontalLine(xm-1, ym, 3); - } - if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { - if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? 22 : 54, xm-2, -abs(trim), RIGHT|TINSIZE|VERTICAL); - } - } - } - else { - ym = 60; - lcdDrawSolidHorizontalLine(xm-TRIM_LEN, ym, TRIM_LEN*2); - lcdDrawSolidHorizontalLine(xm-1, ym-1, 3); - lcdDrawSolidHorizontalLine(xm-1, ym+1, 3); - xm += val; - lcdDrawFilledRect(xm-3, ym-3, 7, 7, SOLID, att|ERASE); - if (trim >= 0) { - lcdDrawSolidVerticalLine(xm+1, ym-1, 3); - } - if (trim <= 0) { - lcdDrawSolidVerticalLine(xm-1, ym-1, 3); - } - if (exttrim) { - lcdDrawSolidVerticalLine(xm, ym-1, 3); - } - if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { - if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? -11 : 20), ym-2, -abs(trim), RIGHT|TINSIZE); - } - } - } - lcdDrawSquare(xm-3, ym-3, 7, att); - } -} - -void drawSliders() -{ - for (uint8_t i=NUM_STICKS; i=SLIDER1 ? LCD_H/2+1 : 1); -#endif - lcdDrawSolidVerticalLine(x, y, LCD_H/2-2); - lcdDrawSolidVerticalLine(x+1, y, LCD_H/2-2); - y += LCD_H/2-4; - y -= ((calibratedStick[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop - lcdDrawSolidVerticalLine(x-1, y, 2); - lcdDrawSolidVerticalLine(x+2, y, 2); - } -} - -#define BAR_X 14 -#define BAR_Y 1 -#define BAR_W 184 -#define BAR_H 9 -#define BAR_NOTIFS_X BAR_X+133 -#define BAR_VOLUME_X BAR_X+147 -#define BAR_TIME_X BAR_X+159 - -void displayTopBarGauge(coord_t x, int count, bool blinking=false) -{ - if (!blinking || BLINK_ON_PHASE) - lcdDrawFilledRect(x+1, BAR_Y+2, 11, 5, SOLID, ERASE); - for (int i=0; i 0) { - displayTopBarGauge(batt_icon_x+5*FW, TELEMETRY_RSSI() / 10, TELEMETRY_RSSI() < getRssiAlarmValue(0)); - } -} - -void displayTimers() -{ - // Main and Second timer - for (unsigned int i=0; i<2; i++) { - if (g_model.timers[i].mode) { - TimerState & timerState = timersStates[i]; - TimerData & timerData = g_model.timers[i]; - uint8_t y = TIMERS_Y + i*TIMERS_H; - if (ZLEN(timerData.name) > 0) { - lcdDrawSizedText(TIMERS_X, y-7, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE); - } - else { - putsTimerMode(TIMERS_X, y-7, timerData.mode, SMLSIZE); - } - putsTimer(TIMERS_X, y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT); - if (timerData.persistent) { - lcdDrawChar(TIMERS_R, y+1, 'P', SMLSIZE); - } - if (timerState.val < 0) { - if (BLINK_ON_PHASE) { - lcdDrawFilledRect(TIMERS_X-7, y-8, 60, 20); - } - } - } - } -} - -void menuMainViewChannelsMonitor(uint8_t event) -{ - switch(event) { - case EVT_KEY_BREAK(KEY_PAGE): - case EVT_KEY_BREAK(KEY_EXIT): - chainMenu(menuMainView); - event = 0; - break; - } - - return menuChannelsView(event); -} - -void onMainViewMenu(const char *result) -{ - if (result == STR_RESET_TIMER1) { - timerReset(0); - } - else if (result == STR_RESET_TIMER2) { - timerReset(1); - } -#if TIMERS > 2 - else if (result == STR_RESET_TIMER3) { - timerReset(2); - } -#endif - else if (result == STR_VIEW_NOTES) { - pushModelNotes(); - } - else if (result == STR_RESET_SUBMENU) { - POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT); - POPUP_MENU_ADD_ITEM(STR_RESET_TIMER1); - POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2); - POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3); - POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY); - } - else if (result == STR_RESET_TELEMETRY) { - telemetryReset(); - } - else if (result == STR_RESET_FLIGHT) { - flightReset(); - } - else if (result == STR_STATISTICS) { - chainMenu(menuStatisticsView); - } - else if (result == STR_ABOUT_US) { - chainMenu(menuAboutView); - } -} - -void displaySwitch(coord_t x, coord_t y, int width, unsigned int index) -{ - if (SWITCH_EXISTS(index)) { - int val = getValue(MIXSRC_FIRST_SWITCH+index); - - if (val >= 0) { - lcdDrawSolidHorizontalLine(x, y, width); - lcdDrawSolidHorizontalLine(x, y+2, width); - y += 4; - if (val > 0) { - lcdDrawSolidHorizontalLine(x, y, width); - lcdDrawSolidHorizontalLine(x, y+2, width); - y += 4; - } - } - - lcdDrawChar(width==5 ? x+1 : x, y, 'A'+index, TINSIZE); - y += 6; - - if (val <= 0) { - lcdDrawSolidHorizontalLine(x, y, width); - lcdDrawSolidHorizontalLine(x, y+2, width); - if (val < 0) { - lcdDrawSolidHorizontalLine(x, y+4, width); - lcdDrawSolidHorizontalLine(x, y+6, width); - } - } - } -} - -const MenuItem MAIN_MENU[] = { - { "RADIO SETTINGS", menuGeneralSetup }, - { "MODEL SELECT", menuModelSelect }, - { "MODEL SETTINGS", menuModelSetup }, - { "CHECKLIST", menuModelNotes }, - { "SD MANAGER", menuGeneralSdManager }, - { "VERSION", menuGeneralVersion } -}; - -bool isMenuAvailable(int index) -{ - if (index == 4) { - return modelHasNotes(); - } - else { - return true; - } -} - -int getSwitchCount() -{ - int count = 0; - for (int i=0; i= VIEW_COUNT) { - g_model.view = 0; - chainMenu(menuMainViewChannelsMonitor); - } - break; - - case EVT_KEY_LONG(KEY_PAGE): - if (!IS_FAI_ENABLED()) - chainMenu(menuTelemetryFrsky); - killEvents(event); - break; - - case EVT_KEY_FIRST(KEY_EXIT): -#if defined(GVARS) - if (gvarDisplayTimer > 0) { - gvarDisplayTimer = 0; - } -#endif - break; - } - - // Flight Mode Name - int mode = mixerCurrentFlightMode; - lcdDrawSizedText(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); - - // Model Name - putsModelName(MODELNAME_X, MODELNAME_Y, g_model.header.name, g_eeGeneral.currModel, BIGSIZE); - - // Trims sliders - displayTrims(mode); - - // Top bar - displayTopBar(); - - // Sliders (Pots / Sliders) - drawSliders(); - - lcdDrawBitmap(BITMAP_X, BITMAP_Y, modelBitmap); - - // Switches - if (getSwitchCount() > 8) { - for (int i=0; i= 14) qr2.rem += 1; - const coord_t x[4] = { 50, 142 }; - const coord_t y[4] = { 25, 42, 25, 42 }; - displaySwitch(x[qr.quot]+qr2.rem*4, y[qr2.quot], 3, i); - } - else { - displaySwitch(17+qr.rem*6, 25+qr.quot*17, 5, i); - } - } - } - else { - int index = 0; - for (int i=0; i= 5 ? 3 : 0); - LogicalSwitchData * cs = lswAddress(sw); - if (cs->func == LS_FUNC_NONE) { - lcdDrawSolidHorizontalLine(x, y+6, 4); - lcdDrawSolidHorizontalLine(x, y+7, 4); - } - else if (getSwitch(SWSRC_SW1+sw)) { - lcdDrawFilledRect(x, y, 4, 8); - } - else { - lcdDrawRect(x, y, 4, 8); - } - } - } - -#if defined(GVARS) - if (gvarDisplayTimer > 0) { - gvarDisplayTimer--; - lcdDrawFilledRect(BITMAP_X, BITMAP_Y, 64, 32, SOLID, ERASE); - lcdDrawRect(BITMAP_X, BITMAP_Y, 64, 32); - drawStringWithIndex(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, gvarLastChanged+1); - lcdDrawSizedText(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[gvarLastChanged].name, LEN_GVAR_NAME, ZCHAR); - lcdDrawText(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("["), BOLD); - drawGVarValue(BITMAP_X+2*FW, BITMAP_Y+2*FH+3, gvarLastChanged, GVAR_VALUE(gvarLastChanged, getGVarFlightMode(mixerCurrentFlightMode, gvarLastChanged)), LEFT|BOLD); - lcdDrawText(lcdLastPos, BITMAP_Y+2*FH+3, PSTR("]"), BOLD); - } -#endif -} +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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" + +#define BIGSIZE MIDSIZE +#define LBOX_CENTERX (BOX_WIDTH/2 + 16) +#define RBOX_CENTERX (LCD_W-LBOX_CENTERX-1) +#define MODELNAME_X (15) +#define MODELNAME_Y (11) +#define VBATT_X (MODELNAME_X+26) +#define VBATT_Y (FH+3) +#define VBATTUNIT_X (VBATT_X-2) +#define VBATTUNIT_Y VBATT_Y +#define BITMAP_X ((LCD_W-64)/2) +#define BITMAP_Y (LCD_H/2) +#define PHASE_X BITMAP_X +#define PHASE_Y (3*FH) +#define PHASE_FLAGS (0) +#define TIMERS_X 145 +#define TIMERS_Y 20 +#define TIMERS_H 25 +#define TIMERS_R 193 +#define REBOOT_X (LCD_W-FW) +#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 TRIM_LH_X (32+9) +#define TRIM_LV_X 10 +#define TRIM_RV_X (LCD_W-11) +#define TRIM_RH_X (LCD_W-32-9) + +#define TRIM_LEN 27 +#define MARKER_WIDTH 5 + +const pm_uchar logo_taranis[] PROGMEM = { +#include "logo.lbm" +}; + +const pm_uchar icons[] PROGMEM = { +#include "icons.lbm" +}; + +#define ICON_RSSI 0, 9 +#define ICON_SPEAKER0 9, 8 +#define ICON_SPEAKER1 17, 8 +#define ICON_SPEAKER2 25, 8 +#define ICON_SPEAKER3 33, 8 +#define ICON_SD 41, 11 +#define ICON_LOGS 51, 11 +#define ICON_TRAINER 61, 11 +#define ICON_TRAINEE 71, 11 +#define ICON_USB 81, 11 +#define ICON_REBOOT 91, 11 +#define ICON_ALTITUDE 102, 9 + +void doMainScreenGraphics() +{ + int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)]; + if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK) + calibStickVert = -calibStickVert; + drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert); + + calibStickVert = calibratedStick[CONVERT_MODE(2)]; + if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK) + calibStickVert = -calibStickVert; + drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert); +} + +void displayTrims(uint8_t phase) +{ + for (unsigned int i=0; i TRIM_MAX) { + exttrim = true; + } + if (val < -(TRIM_LEN+1)*4) { + val = -(TRIM_LEN+1); + } + else if (val > (TRIM_LEN+1)*4) { + val = TRIM_LEN+1; + } + else { + val /= 4; + } + + if (vert[i]) { + ym = 31; + lcdDrawSolidVerticalLine(xm, ym-TRIM_LEN, TRIM_LEN*2); + if (i!=2 || !g_model.thrTrim) { + lcdDrawSolidVerticalLine(xm-1, ym-1, 3); + lcdDrawSolidVerticalLine(xm+1, ym-1, 3); + } + ym -= val; + lcdDrawFilledRect(xm-3, ym-3, 7, 7, SOLID, att|ERASE); + if (trim >= 0) { + lcdDrawSolidHorizontalLine(xm-1, ym-1, 3); + } + if (trim <= 0) { + lcdDrawSolidHorizontalLine(xm-1, ym+1, 3); + } + if (exttrim) { + lcdDrawSolidHorizontalLine(xm-1, ym, 3); + } + if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { + if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? 22 : 54, xm-2, -abs(trim), RIGHT|TINSIZE|VERTICAL); + } + } + } + else { + ym = 60; + lcdDrawSolidHorizontalLine(xm-TRIM_LEN, ym, TRIM_LEN*2); + lcdDrawSolidHorizontalLine(xm-1, ym-1, 3); + lcdDrawSolidHorizontalLine(xm-1, ym+1, 3); + xm += val; + lcdDrawFilledRect(xm-3, ym-3, 7, 7, SOLID, att|ERASE); + if (trim >= 0) { + lcdDrawSolidVerticalLine(xm+1, ym-1, 3); + } + if (trim <= 0) { + lcdDrawSolidVerticalLine(xm-1, ym-1, 3); + } + if (exttrim) { + lcdDrawSolidVerticalLine(xm, ym-1, 3); + } + if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { + if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? -11 : 20), ym-2, -abs(trim), RIGHT|TINSIZE); + } + } + } + lcdDrawSquare(xm-3, ym-3, 7, att); + } +} + +void drawSliders() +{ + for (uint8_t i=NUM_STICKS; i=SLIDER1 ? LCD_H/2+1 : 1); +#endif + lcdDrawSolidVerticalLine(x, y, LCD_H/2-2); + lcdDrawSolidVerticalLine(x+1, y, LCD_H/2-2); + y += LCD_H/2-4; + y -= ((calibratedStick[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop + lcdDrawSolidVerticalLine(x-1, y, 2); + lcdDrawSolidVerticalLine(x+2, y, 2); + } +} + +#define BAR_X 14 +#define BAR_Y 1 +#define BAR_W 184 +#define BAR_H 9 +#define BAR_NOTIFS_X BAR_X+133 +#define BAR_VOLUME_X BAR_X+147 +#define BAR_TIME_X BAR_X+159 + +void displayTopBarGauge(coord_t x, int count, bool blinking=false) +{ + if (!blinking || BLINK_ON_PHASE) + lcdDrawFilledRect(x+1, BAR_Y+2, 11, 5, SOLID, ERASE); + for (int i=0; i 0) { + displayTopBarGauge(batt_icon_x+5*FW, TELEMETRY_RSSI() / 10, TELEMETRY_RSSI() < getRssiAlarmValue(0)); + } +} + +void displayTimers() +{ + // Main and Second timer + for (unsigned int i=0; i<2; i++) { + if (g_model.timers[i].mode) { + TimerState & timerState = timersStates[i]; + TimerData & timerData = g_model.timers[i]; + uint8_t y = TIMERS_Y + i*TIMERS_H; + if (ZLEN(timerData.name) > 0) { + lcdDrawSizedText(TIMERS_X, y-7, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE); + } + else { + putsTimerMode(TIMERS_X, y-7, timerData.mode, SMLSIZE); + } + putsTimer(TIMERS_X, y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT); + if (timerData.persistent) { + lcdDrawChar(TIMERS_R, y+1, 'P', SMLSIZE); + } + if (timerState.val < 0) { + if (BLINK_ON_PHASE) { + lcdDrawFilledRect(TIMERS_X-7, y-8, 60, 20); + } + } + } + } +} + +void menuMainViewChannelsMonitor(uint8_t event) +{ + switch(event) { + case EVT_KEY_BREAK(KEY_PAGE): + case EVT_KEY_BREAK(KEY_EXIT): + chainMenu(menuMainView); + event = 0; + break; + } + + return menuChannelsView(event); +} + +void onMainViewMenu(const char *result) +{ + if (result == STR_RESET_TIMER1) { + timerReset(0); + } + else if (result == STR_RESET_TIMER2) { + timerReset(1); + } +#if TIMERS > 2 + else if (result == STR_RESET_TIMER3) { + timerReset(2); + } +#endif + else if (result == STR_VIEW_NOTES) { + pushModelNotes(); + } + else if (result == STR_RESET_SUBMENU) { + POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT); + POPUP_MENU_ADD_ITEM(STR_RESET_TIMER1); + POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2); + POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3); + POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY); + } + else if (result == STR_RESET_TELEMETRY) { + telemetryReset(); + } + else if (result == STR_RESET_FLIGHT) { + flightReset(); + } + else if (result == STR_STATISTICS) { + chainMenu(menuStatisticsView); + } + else if (result == STR_ABOUT_US) { + chainMenu(menuAboutView); + } +} + +void displaySwitch(coord_t x, coord_t y, int width, unsigned int index) +{ + if (SWITCH_EXISTS(index)) { + int val = getValue(MIXSRC_FIRST_SWITCH+index); + + if (val >= 0) { + lcdDrawSolidHorizontalLine(x, y, width); + lcdDrawSolidHorizontalLine(x, y+2, width); + y += 4; + if (val > 0) { + lcdDrawSolidHorizontalLine(x, y, width); + lcdDrawSolidHorizontalLine(x, y+2, width); + y += 4; + } + } + + lcdDrawChar(width==5 ? x+1 : x, y, 'A'+index, TINSIZE); + y += 6; + + if (val <= 0) { + lcdDrawSolidHorizontalLine(x, y, width); + lcdDrawSolidHorizontalLine(x, y+2, width); + if (val < 0) { + lcdDrawSolidHorizontalLine(x, y+4, width); + lcdDrawSolidHorizontalLine(x, y+6, width); + } + } + } +} + +const MenuItem MAIN_MENU[] = { + { "RADIO SETTINGS", menuGeneralSetup }, + { "MODEL SELECT", menuModelSelect }, + { "MODEL SETTINGS", menuModelSetup }, + { "CHECKLIST", menuModelNotes }, + { "SD MANAGER", menuGeneralSdManager }, + { "VERSION", menuGeneralVersion } +}; + +bool isMenuAvailable(int index) +{ + if (index == 4) { + return modelHasNotes(); + } + else { + return true; + } +} + +int getSwitchCount() +{ + int count = 0; + for (int i=0; i= VIEW_COUNT) { + g_model.view = 0; + chainMenu(menuMainViewChannelsMonitor); + } + break; + + case EVT_KEY_LONG(KEY_PAGE): + if (!IS_FAI_ENABLED()) + chainMenu(menuTelemetryFrsky); + killEvents(event); + break; + + case EVT_KEY_FIRST(KEY_EXIT): +#if defined(GVARS) + if (gvarDisplayTimer > 0) { + gvarDisplayTimer = 0; + } +#endif + break; + } + + // Flight Mode Name + int mode = mixerCurrentFlightMode; + lcdDrawSizedText(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); + + // Model Name + putsModelName(MODELNAME_X, MODELNAME_Y, g_model.header.name, g_eeGeneral.currModel, BIGSIZE); + + // Trims sliders + displayTrims(mode); + + // Top bar + displayTopBar(); + + // Sliders (Pots / Sliders) + drawSliders(); + + lcdDrawBitmap(BITMAP_X, BITMAP_Y, modelBitmap); + + // Switches + if (getSwitchCount() > 8) { + for (int i=0; i= 14) qr2.rem += 1; + const coord_t x[4] = { 50, 142 }; + const coord_t y[4] = { 25, 42, 25, 42 }; + displaySwitch(x[qr.quot]+qr2.rem*4, y[qr2.quot], 3, i); + } + else { + displaySwitch(17+qr.rem*6, 25+qr.quot*17, 5, i); + } + } + } + else { + int index = 0; + for (int i=0; i= 5 ? 3 : 0); + LogicalSwitchData * cs = lswAddress(sw); + if (cs->func == LS_FUNC_NONE) { + lcdDrawSolidHorizontalLine(x, y+6, 4); + lcdDrawSolidHorizontalLine(x, y+7, 4); + } + else if (getSwitch(SWSRC_SW1+sw)) { + lcdDrawFilledRect(x, y, 4, 8); + } + else { + lcdDrawRect(x, y, 4, 8); + } + } + } + +#if defined(GVARS) + if (gvarDisplayTimer > 0) { + gvarDisplayTimer--; + lcdDrawFilledRect(BITMAP_X, BITMAP_Y, 64, 32, SOLID, ERASE); + lcdDrawRect(BITMAP_X, BITMAP_Y, 64, 32); + drawStringWithIndex(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, gvarLastChanged+1); + lcdDrawSizedText(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[gvarLastChanged].name, LEN_GVAR_NAME, ZCHAR); + lcdDrawText(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("["), BOLD); + drawGVarValue(BITMAP_X+2*FW, BITMAP_Y+2*FH+3, gvarLastChanged, GVAR_VALUE(gvarLastChanged, getGVarFlightMode(mixerCurrentFlightMode, gvarLastChanged)), LEFT|BOLD); + lcdDrawText(lcdLastPos, BITMAP_Y+2*FH+3, PSTR("]"), BOLD); + } +#endif +} diff --git a/radio/src/gui/taranis/view_statistics.cpp b/radio/src/gui/212x64/view_statistics.cpp similarity index 96% rename from radio/src/gui/taranis/view_statistics.cpp rename to radio/src/gui/212x64/view_statistics.cpp index ee48641ec..b20ecd31d 100644 --- a/radio/src/gui/taranis/view_statistics.cpp +++ b/radio/src/gui/212x64/view_statistics.cpp @@ -1,244 +1,244 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" - -#define STATS_1ST_COLUMN FW/2 -#define STATS_2ND_COLUMN 12*FW+FW/2 -#define STATS_3RD_COLUMN 24*FW+FW/2 -#define STATS_LABEL_WIDTH 4*FW - -void menuStatisticsView(uint8_t event) -{ - TITLE(STR_MENUSTAT); - - switch(event) - { - case EVT_KEY_FIRST(KEY_UP): - chainMenu(menuStatisticsDebug); - break; - - case EVT_KEY_LONG(KEY_MENU): - g_eeGeneral.globalTimer = 0; - storageDirty(EE_GENERAL); - sessionTimer = 0; - break; - - case EVT_KEY_FIRST(KEY_EXIT): - chainMenu(menuMainView); - break; - } - - // Session and Total timers - lcdDrawText(STATS_1ST_COLUMN, FH*1+1, "SES", BOLD); - putsTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*1+1, sessionTimer, 0, 0); - lcdDrawText(STATS_1ST_COLUMN, FH*2+1, "TOT", BOLD); - putsTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*2+1, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0); - - // Throttle special timers - lcdDrawText(STATS_2ND_COLUMN, FH*0+1, "THR", BOLD); - putsTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*0+1, s_timeCumThr, 0, 0); - lcdDrawText(STATS_2ND_COLUMN, FH*1+1, "TH%", BOLD); - putsTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*1+1, s_timeCum16ThrP/16, 0, 0); - - // Timers - for (int i=0; i 3600) - putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0); - else - putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, 0, 0); - } - -#if defined(THRTRACE) - const coord_t x = 5; - const coord_t y = 60; - lcdDrawSolidHorizontalLine(x-3, y, MAXTRACE+3+3); - lcdDrawSolidVerticalLine(x, y-32, 32+3); - for (coord_t i=0; i MAXTRACE ? s_traceWr - MAXTRACE : 0; - for (coord_t i=1; i<=MAXTRACE && traceRdtime % SECS_PER_DAY; - putsTimer(4*FW, y, tme, TIMEHOUR|LEFT, TIMEHOUR|LEFT); - //event - lcdDrawNumber(14*FW, y, te->event, LEADING0|LEFT, 3); - //data - lcdDrawSizedText (20*FW, y, "0x", 2); - lcdDrawHexNumber(22*FW-2, y, (uint16_t)(te->data >> 16)); - lcdDrawHexNumber(25*FW, y, (uint16_t)(te->data & 0xFFFF)); - } - - } - - -} -#endif //#if defined(DEBUG_TRACE_BUFFER) +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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" + +#define STATS_1ST_COLUMN FW/2 +#define STATS_2ND_COLUMN 12*FW+FW/2 +#define STATS_3RD_COLUMN 24*FW+FW/2 +#define STATS_LABEL_WIDTH 4*FW + +void menuStatisticsView(uint8_t event) +{ + TITLE(STR_MENUSTAT); + + switch(event) + { + case EVT_KEY_FIRST(KEY_UP): + chainMenu(menuStatisticsDebug); + break; + + case EVT_KEY_LONG(KEY_MENU): + g_eeGeneral.globalTimer = 0; + storageDirty(EE_GENERAL); + sessionTimer = 0; + break; + + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + break; + } + + // Session and Total timers + lcdDrawText(STATS_1ST_COLUMN, FH*1+1, "SES", BOLD); + putsTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*1+1, sessionTimer, 0, 0); + lcdDrawText(STATS_1ST_COLUMN, FH*2+1, "TOT", BOLD); + putsTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*2+1, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0); + + // Throttle special timers + lcdDrawText(STATS_2ND_COLUMN, FH*0+1, "THR", BOLD); + putsTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*0+1, s_timeCumThr, 0, 0); + lcdDrawText(STATS_2ND_COLUMN, FH*1+1, "TH%", BOLD); + putsTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*1+1, s_timeCum16ThrP/16, 0, 0); + + // Timers + for (int i=0; i 3600) + putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0); + else + putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, 0, 0); + } + +#if defined(THRTRACE) + const coord_t x = 5; + const coord_t y = 60; + lcdDrawSolidHorizontalLine(x-3, y, MAXTRACE+3+3); + lcdDrawSolidVerticalLine(x, y-32, 32+3); + for (coord_t i=0; i MAXTRACE ? s_traceWr - MAXTRACE : 0; + for (coord_t i=1; i<=MAXTRACE && traceRdtime % SECS_PER_DAY; + putsTimer(4*FW, y, tme, TIMEHOUR|LEFT, TIMEHOUR|LEFT); + //event + lcdDrawNumber(14*FW, y, te->event, LEADING0|LEFT, 3); + //data + lcdDrawSizedText (20*FW, y, "0x", 2); + lcdDrawHexNumber(22*FW-2, y, (uint16_t)(te->data >> 16)); + lcdDrawHexNumber(25*FW, y, (uint16_t)(te->data & 0xFFFF)); + } + + } + + +} +#endif //#if defined(DEBUG_TRACE_BUFFER) diff --git a/radio/src/gui/taranis/view_telemetry.cpp b/radio/src/gui/212x64/view_telemetry.cpp similarity index 100% rename from radio/src/gui/taranis/view_telemetry.cpp rename to radio/src/gui/212x64/view_telemetry.cpp diff --git a/radio/src/gui/taranis/view_text.cpp b/radio/src/gui/212x64/view_text.cpp similarity index 100% rename from radio/src/gui/taranis/view_text.cpp rename to radio/src/gui/212x64/view_text.cpp diff --git a/radio/src/gui/taranis/widgets.cpp b/radio/src/gui/212x64/widgets.cpp similarity index 98% rename from radio/src/gui/taranis/widgets.cpp rename to radio/src/gui/212x64/widgets.cpp index 348b321a7..37e2ec0cc 100644 --- a/radio/src/gui/taranis/widgets.cpp +++ b/radio/src/gui/212x64/widgets.cpp @@ -21,7 +21,7 @@ #include "opentx.h" const pm_uchar bmp_sleep[] PROGMEM = { - #include "../../bitmaps/taranis/sleep.lbm" + #include "../../bitmaps/212x64/sleep.lbm" }; #define SLEEP_BITMAP_WIDTH 60 @@ -35,7 +35,7 @@ void drawSleepBitmap() #if defined(PWR_BUTTON_DELAY) const pm_uchar bmp_shutdown[] PROGMEM = { - #include "../../bitmaps/taranis/shutdown.lbm" + #include "../../bitmaps/212x64/shutdown.lbm" }; #define SHUTDOWN_BITMAP_WIDTH 60 diff --git a/radio/src/gui/horus/bitmapbuffer.cpp b/radio/src/gui/480x272/bitmapbuffer.cpp similarity index 100% rename from radio/src/gui/horus/bitmapbuffer.cpp rename to radio/src/gui/480x272/bitmapbuffer.cpp diff --git a/radio/src/gui/horus/bitmapbuffer.h b/radio/src/gui/480x272/bitmapbuffer.h similarity index 100% rename from radio/src/gui/horus/bitmapbuffer.h rename to radio/src/gui/480x272/bitmapbuffer.h diff --git a/radio/src/gui/horus/bitmaps.cpp b/radio/src/gui/480x272/bitmaps.cpp similarity index 100% rename from radio/src/gui/horus/bitmaps.cpp rename to radio/src/gui/480x272/bitmaps.cpp diff --git a/radio/src/gui/horus/bitmaps.h b/radio/src/gui/480x272/bitmaps.h similarity index 100% rename from radio/src/gui/horus/bitmaps.h rename to radio/src/gui/480x272/bitmaps.h diff --git a/radio/src/gui/horus/colors.h b/radio/src/gui/480x272/colors.h similarity index 100% rename from radio/src/gui/horus/colors.h rename to radio/src/gui/480x272/colors.h diff --git a/radio/src/gui/horus/curves.cpp b/radio/src/gui/480x272/curves.cpp similarity index 100% rename from radio/src/gui/horus/curves.cpp rename to radio/src/gui/480x272/curves.cpp diff --git a/radio/src/gui/horus/fonts.cpp b/radio/src/gui/480x272/fonts.cpp similarity index 100% rename from radio/src/gui/horus/fonts.cpp rename to radio/src/gui/480x272/fonts.cpp diff --git a/radio/src/gui/horus/gui.h b/radio/src/gui/480x272/gui.h similarity index 97% rename from radio/src/gui/horus/gui.h rename to radio/src/gui/480x272/gui.h index 15a49646f..326c5a892 100644 --- a/radio/src/gui/horus/gui.h +++ b/radio/src/gui/480x272/gui.h @@ -18,6 +18,10 @@ * GNU General Public License for more details. */ +#ifndef _GUI_H_ +#define _GUI_H_ + +#include "gui_helpers.h" #include "lcd.h" #include "menus.h" #include "widgets.h" @@ -86,3 +90,5 @@ void drawCurvePoint(int x, int y, LcdFlags color); extern Layout * customScreens[MAX_CUSTOM_SCREENS]; extern Topbar * topbar; + +#endif // _GUI_H_ diff --git a/radio/src/gui/horus/layout.cpp b/radio/src/gui/480x272/layout.cpp similarity index 100% rename from radio/src/gui/horus/layout.cpp rename to radio/src/gui/480x272/layout.cpp diff --git a/radio/src/gui/horus/layout.h b/radio/src/gui/480x272/layout.h similarity index 100% rename from radio/src/gui/horus/layout.h rename to radio/src/gui/480x272/layout.h diff --git a/radio/src/gui/horus/layouts/layout1x1.cpp b/radio/src/gui/480x272/layouts/layout1x1.cpp similarity index 100% rename from radio/src/gui/horus/layouts/layout1x1.cpp rename to radio/src/gui/480x272/layouts/layout1x1.cpp diff --git a/radio/src/gui/horus/layouts/layout2+1.cpp b/radio/src/gui/480x272/layouts/layout2+1.cpp similarity index 100% rename from radio/src/gui/horus/layouts/layout2+1.cpp rename to radio/src/gui/480x272/layouts/layout2+1.cpp diff --git a/radio/src/gui/horus/layouts/layout2x1.cpp b/radio/src/gui/480x272/layouts/layout2x1.cpp similarity index 100% rename from radio/src/gui/horus/layouts/layout2x1.cpp rename to radio/src/gui/480x272/layouts/layout2x1.cpp diff --git a/radio/src/gui/horus/layouts/layout2x2.cpp b/radio/src/gui/480x272/layouts/layout2x2.cpp similarity index 100% rename from radio/src/gui/horus/layouts/layout2x2.cpp rename to radio/src/gui/480x272/layouts/layout2x2.cpp diff --git a/radio/src/gui/horus/layouts/layout2x4.cpp b/radio/src/gui/480x272/layouts/layout2x4.cpp similarity index 100% rename from radio/src/gui/horus/layouts/layout2x4.cpp rename to radio/src/gui/480x272/layouts/layout2x4.cpp diff --git a/radio/src/gui/horus/layouts/mask_layout1x1.png b/radio/src/gui/480x272/layouts/mask_layout1x1.png similarity index 100% rename from radio/src/gui/horus/layouts/mask_layout1x1.png rename to radio/src/gui/480x272/layouts/mask_layout1x1.png diff --git a/radio/src/gui/horus/layouts/mask_layout2+1.png b/radio/src/gui/480x272/layouts/mask_layout2+1.png similarity index 100% rename from radio/src/gui/horus/layouts/mask_layout2+1.png rename to radio/src/gui/480x272/layouts/mask_layout2+1.png diff --git a/radio/src/gui/horus/layouts/mask_layout2x1.png b/radio/src/gui/480x272/layouts/mask_layout2x1.png similarity index 100% rename from radio/src/gui/horus/layouts/mask_layout2x1.png rename to radio/src/gui/480x272/layouts/mask_layout2x1.png diff --git a/radio/src/gui/horus/layouts/mask_layout2x2.png b/radio/src/gui/480x272/layouts/mask_layout2x2.png similarity index 100% rename from radio/src/gui/horus/layouts/mask_layout2x2.png rename to radio/src/gui/480x272/layouts/mask_layout2x2.png diff --git a/radio/src/gui/horus/layouts/mask_layout2x4.png b/radio/src/gui/480x272/layouts/mask_layout2x4.png similarity index 100% rename from radio/src/gui/horus/layouts/mask_layout2x4.png rename to radio/src/gui/480x272/layouts/mask_layout2x4.png diff --git a/radio/src/gui/horus/lcd.cpp b/radio/src/gui/480x272/lcd.cpp similarity index 100% rename from radio/src/gui/horus/lcd.cpp rename to radio/src/gui/480x272/lcd.cpp diff --git a/radio/src/gui/horus/lcd.h b/radio/src/gui/480x272/lcd.h similarity index 100% rename from radio/src/gui/horus/lcd.h rename to radio/src/gui/480x272/lcd.h diff --git a/radio/src/gui/horus/menu_model.cpp b/radio/src/gui/480x272/menu_model.cpp similarity index 100% rename from radio/src/gui/horus/menu_model.cpp rename to radio/src/gui/480x272/menu_model.cpp diff --git a/radio/src/gui/horus/menu_general.cpp b/radio/src/gui/480x272/menu_radio.cpp similarity index 100% rename from radio/src/gui/horus/menu_general.cpp rename to radio/src/gui/480x272/menu_radio.cpp diff --git a/radio/src/gui/horus/menus.cpp b/radio/src/gui/480x272/menus.cpp similarity index 100% rename from radio/src/gui/horus/menus.cpp rename to radio/src/gui/480x272/menus.cpp diff --git a/radio/src/gui/horus/menus.h b/radio/src/gui/480x272/menus.h similarity index 100% rename from radio/src/gui/horus/menus.h rename to radio/src/gui/480x272/menus.h diff --git a/radio/src/gui/horus/menu_model_curves.cpp b/radio/src/gui/480x272/model_curves.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_curves.cpp rename to radio/src/gui/480x272/model_curves.cpp diff --git a/radio/src/gui/horus/menu_model_custom_scripts.cpp b/radio/src/gui/480x272/model_custom_scripts.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_custom_scripts.cpp rename to radio/src/gui/480x272/model_custom_scripts.cpp diff --git a/radio/src/gui/horus/menu_model_flightmodes.cpp b/radio/src/gui/480x272/model_flightmodes.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_flightmodes.cpp rename to radio/src/gui/480x272/model_flightmodes.cpp diff --git a/radio/src/gui/horus/menu_model_gvars.cpp b/radio/src/gui/480x272/model_gvars.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_gvars.cpp rename to radio/src/gui/480x272/model_gvars.cpp diff --git a/radio/src/gui/horus/menu_model_heli.cpp b/radio/src/gui/480x272/model_heli.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_heli.cpp rename to radio/src/gui/480x272/model_heli.cpp diff --git a/radio/src/gui/horus/menu_model_inputs.cpp b/radio/src/gui/480x272/model_inputs.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_inputs.cpp rename to radio/src/gui/480x272/model_inputs.cpp diff --git a/radio/src/gui/horus/menu_model_logical_switches.cpp b/radio/src/gui/480x272/model_logical_switches.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_logical_switches.cpp rename to radio/src/gui/480x272/model_logical_switches.cpp diff --git a/radio/src/gui/horus/menu_model_mixes.cpp b/radio/src/gui/480x272/model_mixes.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_mixes.cpp rename to radio/src/gui/480x272/model_mixes.cpp diff --git a/radio/src/gui/horus/menu_model_limits.cpp b/radio/src/gui/480x272/model_outputs.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_limits.cpp rename to radio/src/gui/480x272/model_outputs.cpp diff --git a/radio/src/gui/horus/menu_model_select.cpp b/radio/src/gui/480x272/model_select.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_select.cpp rename to radio/src/gui/480x272/model_select.cpp diff --git a/radio/src/gui/horus/menu_model_setup.cpp b/radio/src/gui/480x272/model_setup.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_setup.cpp rename to radio/src/gui/480x272/model_setup.cpp diff --git a/radio/src/gui/horus/model_special_functions.cpp b/radio/src/gui/480x272/model_special_functions.cpp similarity index 99% rename from radio/src/gui/horus/model_special_functions.cpp rename to radio/src/gui/480x272/model_special_functions.cpp index ccd8e6f67..885d87cfd 100644 --- a/radio/src/gui/horus/model_special_functions.cpp +++ b/radio/src/gui/480x272/model_special_functions.cpp @@ -324,7 +324,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc lcdDrawTextAtIndex(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } -#if defined(REVPLUS) +#if defined(PCBX9DP) || defined(PCBX9E) else if (func == FUNC_BACKLIGHT) { drawSlider(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr); INCDEC_SET_FLAG(eeFlags | NO_INCDEC_MARKS); diff --git a/radio/src/gui/horus/menu_model_telemetry.cpp b/radio/src/gui/480x272/model_telemetry.cpp similarity index 100% rename from radio/src/gui/horus/menu_model_telemetry.cpp rename to radio/src/gui/480x272/model_telemetry.cpp diff --git a/radio/src/gui/horus/navigation.cpp b/radio/src/gui/480x272/navigation.cpp similarity index 100% rename from radio/src/gui/horus/navigation.cpp rename to radio/src/gui/480x272/navigation.cpp diff --git a/radio/src/gui/horus/popups.cpp b/radio/src/gui/480x272/popups.cpp similarity index 100% rename from radio/src/gui/horus/popups.cpp rename to radio/src/gui/480x272/popups.cpp diff --git a/radio/src/gui/horus/radio_calibration.cpp b/radio/src/gui/480x272/radio_calibration.cpp similarity index 100% rename from radio/src/gui/horus/radio_calibration.cpp rename to radio/src/gui/480x272/radio_calibration.cpp diff --git a/radio/src/gui/horus/menu_general_hardware.cpp b/radio/src/gui/480x272/radio_hardware.cpp similarity index 100% rename from radio/src/gui/horus/menu_general_hardware.cpp rename to radio/src/gui/480x272/radio_hardware.cpp diff --git a/radio/src/gui/horus/menu_general_sdmanager.cpp b/radio/src/gui/480x272/radio_sdmanager.cpp similarity index 100% rename from radio/src/gui/horus/menu_general_sdmanager.cpp rename to radio/src/gui/480x272/radio_sdmanager.cpp diff --git a/radio/src/gui/horus/radio_setup.cpp b/radio/src/gui/480x272/radio_setup.cpp similarity index 100% rename from radio/src/gui/horus/radio_setup.cpp rename to radio/src/gui/480x272/radio_setup.cpp diff --git a/radio/src/gui/horus/menu_general_trainer.cpp b/radio/src/gui/480x272/radio_trainer.cpp similarity index 100% rename from radio/src/gui/horus/menu_general_trainer.cpp rename to radio/src/gui/480x272/radio_trainer.cpp diff --git a/radio/src/gui/horus/menu_general_version.cpp b/radio/src/gui/480x272/radio_version.cpp similarity index 100% rename from radio/src/gui/horus/menu_general_version.cpp rename to radio/src/gui/480x272/radio_version.cpp diff --git a/radio/src/gui/horus/screens_setup.cpp b/radio/src/gui/480x272/screens_setup.cpp similarity index 100% rename from radio/src/gui/horus/screens_setup.cpp rename to radio/src/gui/480x272/screens_setup.cpp diff --git a/radio/src/gui/horus/splash.cpp b/radio/src/gui/480x272/splash.cpp similarity index 100% rename from radio/src/gui/horus/splash.cpp rename to radio/src/gui/480x272/splash.cpp diff --git a/radio/src/gui/horus/theme.cpp b/radio/src/gui/480x272/theme.cpp similarity index 100% rename from radio/src/gui/horus/theme.cpp rename to radio/src/gui/480x272/theme.cpp diff --git a/radio/src/gui/horus/theme.h b/radio/src/gui/480x272/theme.h similarity index 100% rename from radio/src/gui/horus/theme.h rename to radio/src/gui/480x272/theme.h diff --git a/radio/src/gui/horus/themes/darkblue.cpp b/radio/src/gui/480x272/themes/darkblue.cpp similarity index 100% rename from radio/src/gui/horus/themes/darkblue.cpp rename to radio/src/gui/480x272/themes/darkblue.cpp diff --git a/radio/src/gui/horus/themes/default.cpp b/radio/src/gui/480x272/themes/default.cpp similarity index 100% rename from radio/src/gui/horus/themes/default.cpp rename to radio/src/gui/480x272/themes/default.cpp diff --git a/radio/src/gui/horus/topbar.cpp b/radio/src/gui/480x272/topbar.cpp similarity index 100% rename from radio/src/gui/horus/topbar.cpp rename to radio/src/gui/480x272/topbar.cpp diff --git a/radio/src/gui/horus/topbar.h b/radio/src/gui/480x272/topbar.h similarity index 100% rename from radio/src/gui/horus/topbar.h rename to radio/src/gui/480x272/topbar.h diff --git a/radio/src/gui/horus/view_about.cpp b/radio/src/gui/480x272/view_about.cpp similarity index 100% rename from radio/src/gui/horus/view_about.cpp rename to radio/src/gui/480x272/view_about.cpp diff --git a/radio/src/gui/horus/view_channels.cpp b/radio/src/gui/480x272/view_channels.cpp similarity index 100% rename from radio/src/gui/horus/view_channels.cpp rename to radio/src/gui/480x272/view_channels.cpp diff --git a/radio/src/gui/horus/view_logical_switches.cpp b/radio/src/gui/480x272/view_logical_switches.cpp similarity index 100% rename from radio/src/gui/horus/view_logical_switches.cpp rename to radio/src/gui/480x272/view_logical_switches.cpp diff --git a/radio/src/gui/horus/view_main.cpp b/radio/src/gui/480x272/view_main.cpp similarity index 100% rename from radio/src/gui/horus/view_main.cpp rename to radio/src/gui/480x272/view_main.cpp diff --git a/radio/src/gui/horus/view_statistics.cpp b/radio/src/gui/480x272/view_statistics.cpp similarity index 100% rename from radio/src/gui/horus/view_statistics.cpp rename to radio/src/gui/480x272/view_statistics.cpp diff --git a/radio/src/gui/horus/view_text.cpp b/radio/src/gui/480x272/view_text.cpp similarity index 100% rename from radio/src/gui/horus/view_text.cpp rename to radio/src/gui/480x272/view_text.cpp diff --git a/radio/src/gui/horus/widget.cpp b/radio/src/gui/480x272/widget.cpp similarity index 100% rename from radio/src/gui/horus/widget.cpp rename to radio/src/gui/480x272/widget.cpp diff --git a/radio/src/gui/horus/widget.h b/radio/src/gui/480x272/widget.h similarity index 100% rename from radio/src/gui/horus/widget.h rename to radio/src/gui/480x272/widget.h diff --git a/radio/src/gui/horus/widgets.cpp b/radio/src/gui/480x272/widgets.cpp similarity index 100% rename from radio/src/gui/horus/widgets.cpp rename to radio/src/gui/480x272/widgets.cpp diff --git a/radio/src/gui/horus/widgets.h b/radio/src/gui/480x272/widgets.h similarity index 100% rename from radio/src/gui/horus/widgets.h rename to radio/src/gui/480x272/widgets.h diff --git a/radio/src/gui/horus/widgets/gauge.cpp b/radio/src/gui/480x272/widgets/gauge.cpp similarity index 100% rename from radio/src/gui/horus/widgets/gauge.cpp rename to radio/src/gui/480x272/widgets/gauge.cpp diff --git a/radio/src/gui/horus/widgets/modelbmp.cpp b/radio/src/gui/480x272/widgets/modelbmp.cpp similarity index 100% rename from radio/src/gui/horus/widgets/modelbmp.cpp rename to radio/src/gui/480x272/widgets/modelbmp.cpp diff --git a/radio/src/gui/horus/widgets/outputs.cpp b/radio/src/gui/480x272/widgets/outputs.cpp similarity index 100% rename from radio/src/gui/horus/widgets/outputs.cpp rename to radio/src/gui/480x272/widgets/outputs.cpp diff --git a/radio/src/gui/horus/widgets/text.cpp b/radio/src/gui/480x272/widgets/text.cpp similarity index 100% rename from radio/src/gui/horus/widgets/text.cpp rename to radio/src/gui/480x272/widgets/text.cpp diff --git a/radio/src/gui/horus/widgets/timer.cpp b/radio/src/gui/480x272/widgets/timer.cpp similarity index 100% rename from radio/src/gui/horus/widgets/timer.cpp rename to radio/src/gui/480x272/widgets/timer.cpp diff --git a/radio/src/gui/horus/widgets/value.cpp b/radio/src/gui/480x272/widgets/value.cpp similarity index 100% rename from radio/src/gui/horus/widgets/value.cpp rename to radio/src/gui/480x272/widgets/value.cpp diff --git a/radio/src/gui/horus/widgets_container.h b/radio/src/gui/480x272/widgets_container.h similarity index 100% rename from radio/src/gui/horus/widgets_container.h rename to radio/src/gui/480x272/widgets_container.h diff --git a/radio/src/gui/9x/helpers.cpp b/radio/src/gui/9x/helpers.cpp deleted file mode 100644 index 51d7f7d72..000000000 --- a/radio/src/gui/9x/helpers.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" - -uint8_t switchToMix(uint8_t source) -{ - if (source <= 3) - return MIXSRC_3POS; - else - return MIXSRC_FIRST_SWITCH - 3 + source; -} diff --git a/radio/src/gui/gui.h b/radio/src/gui/gui.h deleted file mode 100644 index 1f5c531cb..000000000 --- a/radio/src/gui/gui.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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 _GUI_H_ -#define _GUI_H_ - -#if defined(CPUARM) -#include "gui_helpers.h" -#endif - -#if defined(PCBHORUS) - #include "horus/gui.h" -#elif defined(PCBFLAMENCO) - #include "flamenco/gui.h" -#elif defined(PCBTARANIS) - #include "taranis/gui.h" -#else - #include "9x/gui.h" -#endif - -#if defined(SIMU) -extern bool simuLcdRefresh; -extern display_t simuLcdBuf[DISPLAY_BUFFER_SIZE]; -#endif - -#endif // _GUI_H_ diff --git a/radio/src/gui/gui_helpers.cpp b/radio/src/gui/gui_helpers.cpp index e5b7eb13b..53e963965 100644 --- a/radio/src/gui/gui_helpers.cpp +++ b/radio/src/gui/gui_helpers.cpp @@ -20,8 +20,23 @@ #include "opentx.h" -#if defined(CPUARM) +#if defined(PCBTARANIS) || defined(PCBHORUS) +uint8_t switchToMix(uint8_t source) +{ + div_t qr = div(source-1, 3); + return qr.quot+MIXSRC_FIRST_SWITCH; +} +#else +uint8_t switchToMix(uint8_t source) +{ + if (source <= 3) + return MIXSRC_3POS; + else + return MIXSRC_FIRST_SWITCH - 3 + source; +} +#endif +#if defined(CPUARM) int circularIncDec(int current, int inc, int min, int max, IsValueAvailable isValueAvailable) { do { @@ -533,5 +548,4 @@ int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable) } return retval; } - #endif diff --git a/radio/src/gui/horus/helpers.cpp b/radio/src/gui/horus/helpers.cpp deleted file mode 100644 index 470c34c7b..000000000 --- a/radio/src/gui/horus/helpers.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" - -uint8_t switchToMix(uint8_t source) -{ - div_t qr = div(source-1, 3); - return qr.quot+MIXSRC_FIRST_SWITCH; -} diff --git a/radio/src/haptic.cpp b/radio/src/haptic.cpp index 7b611767d..4866f1887 100644 --- a/radio/src/haptic.cpp +++ b/radio/src/haptic.cpp @@ -38,7 +38,7 @@ void hapticQueue::heartbeat() #else if (buzzTimeLeft > 0) { buzzTimeLeft--; // time gets counted down -#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS)) || defined(PCBFLAMENCO) || defined(PCBHORUS) +#if defined(PCBSKY9X) || defined(PCBX9DP) || defined(PCBX9E) || defined(PCBFLAMENCO) || defined(PCBHORUS) // TODO define HAPTIC_PWM option hapticOn(HAPTIC_STRENGTH() * 20); #else diff --git a/radio/src/keys.h b/radio/src/keys.h index 30f5233f9..6273b30a3 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -50,6 +50,7 @@ enum EnumKeys { KEY_MINUS, #else KEY_MENU, + KEY_ENTER=KEY_MENU, KEY_EXIT, KEY_DOWN, KEY_UP, @@ -129,7 +130,7 @@ enum EnumKeys { SW_SH0, SW_SH1, SW_SH2, -#if defined(REV9E) +#if defined(PCBX9E) SW_SI0, SW_SI1, SW_SI2, diff --git a/radio/src/loadboot.cpp b/radio/src/loadboot.cpp index cfc5b1448..92cf8e62c 100644 --- a/radio/src/loadboot.cpp +++ b/radio/src/loadboot.cpp @@ -23,7 +23,7 @@ #if defined(PCBSKY9X) #include "AT91SAM3S4.h" #else - #include "targets/taranis/board_taranis.h" + #include "targets/taranis/board.h" #endif #if defined(PCBTARANIS) @@ -60,7 +60,7 @@ const uint8_t BootCode[] = { __attribute__ ((section(".bootrodata"), used)) void _bootStart() { -#if defined(REV9E) +#if defined(PCBX9E) RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOGEN | RCC_AHB1ENR_GPIODEN; #else RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIODEN; @@ -86,7 +86,7 @@ void _bootStart() // TRIMS_GPIO_PIN_RHL is on PC1 on all versions // turn on pull-ups on trim keys GPIOC->PUPDR = 0x00000004; -#if defined(REV9E) +#if defined(PCBX9E) GPIOG->PUPDR = 0x00000001; #else GPIOE->PUPDR = 0x00000040; diff --git a/radio/src/lua/CMakeLists.txt b/radio/src/lua/CMakeLists.txt index d12cfcc0c..5ffe1222e 100644 --- a/radio/src/lua/CMakeLists.txt +++ b/radio/src/lua/CMakeLists.txt @@ -11,6 +11,6 @@ macro(add_lua_export_target target) add_custom_target(lua_export_${target} DEPENDS lua_exports_${target}.inc) endmacro(add_lua_export_target) -add_lua_export_target(taranis -DCPUARM -DPCBTARANIS -DLUA -DVIRTUALINPUTS) -add_lua_export_target(taranis_x9e -DCPUARM -DPCBTARANIS -DREVPLUS -DREV9E -DLUA -DVIRTUALINPUTS) -add_lua_export_target(horus -DCPUARM -DPCBHORUS -DLUA -DVIRTUALINPUTS -I${RADIO_SRC_DIRECTORY}/gui/horus) +add_lua_export_target(taranis -DCPUARM -DPCBTARANIS -DLUA -DVIRTUALINPUTS) +add_lua_export_target(taranis_x9e -DCPUARM -DPCBTARANIS -DPCBX9E -DLUA -DVIRTUALINPUTS) +add_lua_export_target(horus -DCPUARM -DPCBHORUS -DLUA -DVIRTUALINPUTS -I${RADIO_SRC_DIRECTORY}/gui/480x272) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 10d0abefb..0c1930909 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -28,7 +28,7 @@ #include "lua/lua_exports_horus.inc" // this line must be after lua headers #elif defined(PCBFLAMENCO) #include "lua/lua_exports_flamenco.inc" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #include "lua/lua_exports_taranis_x9e.inc" #elif defined(PCBTARANIS) #include "lua/lua_exports_taranis.inc" diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index 954f62d22..4d945935d 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -48,7 +48,7 @@ void handleUsbConnection() */ #if defined(USB_MASS_STORAGE) - opentxClose(); + opentxClose(false); usbPluggedIn(); #endif } @@ -456,7 +456,7 @@ void perMain() } #endif -#if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) +#if defined(PCBX9E) && !defined(SIMU) toplcdRefreshStart(); setTopFirstTimer(getValue(MIXSRC_FIRST_TIMER+g_model.toplcdTimer)); setTopSecondTimer(g_eeGeneral.globalTimer + sessionTimer); @@ -466,7 +466,7 @@ void perMain() toplcdRefreshEnd(); #endif -#if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) +#if defined(PCBX9E) && !defined(SIMU) bluetoothWakeup(); #endif diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 2734a204b..d6aca8c80 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -580,7 +580,7 @@ enum ThrottleSources { THROTTLE_SOURCE_SD, THROTTLE_SOURCE_LS, THROTTLE_SOURCE_RS, -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) THROTTLE_SOURCE_F1 = THROTTLE_SOURCE_FIRST_POT, THROTTLE_SOURCE_F2, THROTTLE_SOURCE_F3, diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 6474a6fc9..e5660658d 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -175,8 +175,9 @@ void per10ms() #endif #if defined(FRSKY) || defined(JETI) - if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol[0])) + if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol[0])) { telemetryInterrupt10ms(); + } #endif // These moved here from evalFlightModeMixes() to improve beep trigger reliability. @@ -265,7 +266,7 @@ void generalDefault() g_eeGeneral.switchConfig = 0x00007bff; // 6x3POS, 1x2POS, 1xTOGGLE #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) // NI-MH 9.6V g_eeGeneral.vBatWarn = 87; g_eeGeneral.vBatMin = -5; @@ -312,7 +313,7 @@ void generalDefault() } #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) const int8_t defaultName[] = { 20, -1, -18, -1, -14, -9, -19 }; memcpy(g_eeGeneral.bluetoothName, defaultName, sizeof(defaultName)); #endif @@ -1950,33 +1951,31 @@ void opentxStart() } #if defined(CPUARM) || defined(CPUM2560) -void opentxClose() +void opentxClose(uint8_t shutdown) { TRACE("opentxClose()"); + if (shutdown) { #if defined(CPUARM) - watchdogSetTimeout(2000/*20s*/); + watchdogSetTimeout(2000/*20s*/); #endif - pausePulses(); // stop mixer task to disable trims processing while in shutdown - - AUDIO_BYE(); - + pausePulses(); // stop mixer task to disable trims processing while in shutdown + AUDIO_BYE(); #if defined(FRSKY) - // TODO needed? telemetryEnd(); + // TODO needed? telemetryEnd(); #endif - #if defined(LUA) - luaClose(); + luaClose(); #endif - +#if defined(HAPTIC) + hapticOff(); +#endif + } + #if defined(SDCARD) closeLogs(); #endif -#if defined(HAPTIC) - hapticOff(); -#endif - saveTimers(); #if defined(CPUARM) @@ -2022,7 +2021,6 @@ void opentxClose() while (IS_PLAYING(ID_PLAY_BYE)) { CoTickDelay(10); } - CoTickDelay(50); #endif @@ -2592,7 +2590,7 @@ void opentxInit(OPENTX_INIT_ARGS) startPulses(); - wdt_enable(WDT_500MS); + wdt_enable(WDTO_500MS); } #if defined(SIMU) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 27081b5d2..857ac0b2a 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -181,16 +181,16 @@ #define CASE_GVARS(x) #endif -#if defined(PCBTARANIS) && defined(REVPLUS) - #define CASE_REVPLUS(x) x, +#if defined(PCBX9DP) || defined(PCBX9E) + #define CASE_PCBX9E_PCBX9DP(x) x, #else - #define CASE_REVPLUS(x) + #define CASE_PCBX9E_PCBX9DP(x) #endif -#if defined(PCBTARANIS) && defined(REV9E) - #define CASE_REV9E(x) x, +#if defined(PCBX9E) + #define CASE_PCBX9E(x) x, #else - #define CASE_REV9E(x) + #define CASE_PCBX9E(x) #endif #if defined(PCBSKY9X) && !defined(AR9X) && !defined(REVA) @@ -237,21 +237,7 @@ #define RESXul 1024ul #define RESXl 1024l -#if defined(PCBHORUS) - #include "targets/horus/board_horus.h" -#elif defined(PCBFLAMENCO) - #include "targets/flamenco/board_flamenco.h" -#elif defined(PCBTARANIS) - #include "targets/taranis/board_taranis.h" -#elif defined(PCBSKY9X) - #include "targets/sky9x/board_sky9x.h" -#elif defined(PCBGRUVIN9X) - #include "targets/gruvin9x/board_gruvin9x.h" -#elif defined(PCBMEGA2560) - #include "targets/mega2560/board_mega2560.h" -#else - #include "targets/9x/board_stock.h" -#endif +#include "board.h" #if defined(DISK_CACHE) #include "disk_cache.h" @@ -322,12 +308,12 @@ void memswap(void * a, void * b, uint8_t size); #define IS_POT_AVAILABLE(x) (true) #define IS_POT_MULTIPOS(x) (false) #define IS_POT_WITHOUT_DETENT(x) (false) -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define IS_SLIDER_AVAILABLE(x) ((x)==SLIDER1 || (x)==SLIDER2 || (g_eeGeneral.slidersConfig & (0x01 << ((x)-SLIDER3)))) #define IS_POT_AVAILABLE(x) ((x)=SLIDER1 && IS_SLIDER_AVAILABLE(x))) #define IS_POT_MULTIPOS(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsConfig>>(2*((x)-POT1)))&0x03)==POT_MULTIPOS_SWITCH) #define IS_POT_WITHOUT_DETENT(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsConfig>>(2*((x)-POT1)))&0x03)==POT_WITHOUT_DETENT) -#elif defined(PCBTARANIS) && defined(REVPLUS) +#elif defined(PCBX9DP) #define IS_POT_AVAILABLE(x) ((x)!=POT3 || (g_eeGeneral.potsConfig & (0x03 << (2*((x)-POT1))))!=POT_NONE) #define IS_POT_MULTIPOS(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsConfig>>(2*((x)-POT1)))&0x03)==POT_MULTIPOS_SWITCH) #define IS_POT_WITHOUT_DETENT(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsConfig>>(2*((x)-POT1)))&0x03)==POT_WITHOUT_DETENT) @@ -344,7 +330,7 @@ void memswap(void * a, void * b, uint8_t size); #define IS_POT(x) ((x)>=POT1 && (x)<=POT_LAST) #define IS_MULTIPOS_CALIBRATED(cal) (cal->count>0 && cal->count avgJitter[NUMBER_ANALOG]; #endif #endif -#define WDT_500MS 500 - #endif // _OPENTX_H_ diff --git a/radio/src/sdcard.cpp b/radio/src/sdcard.cpp index 714275f56..bbc560816 100644 --- a/radio/src/sdcard.cpp +++ b/radio/src/sdcard.cpp @@ -326,7 +326,7 @@ uint32_t sdGetNoSectors() uint32_t sdGetSize() { - return (sdGetNoSectors() * 512) / 1000000; + return (sdGetNoSectors() * BLOCK_SIZE) / 1000000; } uint32_t sdGetFreeSectors() diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 05fbb4f2a..8a4fc7cc7 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -26,6 +26,8 @@ #include "opentx.h" #include #include +#include "targets/simu/simulcd.h" + #if defined(SIMU_AUDIO) #include #endif @@ -297,7 +299,7 @@ void Open9xSim::updateKeysAndSwitches(bool start) // SWITCH_KEY(D, 3, 3); SWITCH_KEY(E, 4, 2); SWITCH_KEY(F, 5, 3); -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) SWITCH_KEY(A, 0, 3); SWITCH_KEY(B, 1, 3); SWITCH_KEY(C, 2, 3); @@ -372,7 +374,7 @@ long Open9xSim::onTimeout(FXObject*, FXSelector, void*) } #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) SWITCH_KEY(A, 0, 3); SWITCH_KEY(B, 1, 3); SWITCH_KEY(C, 2, 3); @@ -563,7 +565,7 @@ uint16_t anaIn(uint8_t chan) #if defined(PCBHORUS) else if (chan == TX_VOLTAGE) return 1737; //~10.6V -#elif (defined(PCBTARANIS) && defined(REV9E)) +#elif defined(PCBX9E) else if (chan == TX_VOLTAGE) return 1420; //~10.6V #elif defined(PCBTARANIS) || defined(PCBFLAMENCO) diff --git a/radio/src/storage/eeprom_conversions.cpp b/radio/src/storage/eeprom_conversions.cpp index 081f5cf29..4344b4866 100644 --- a/radio/src/storage/eeprom_conversions.cpp +++ b/radio/src/storage/eeprom_conversions.cpp @@ -620,7 +620,7 @@ PACK(typedef struct { TelemetrySensor telemetrySensors[MAX_SENSORS]; - TARANIS_REV9E_FIELD(uint8_t toplcdTimer) + TARANIS_PCBX9E_FIELD(uint8_t toplcdTimer) }) ModelData_v217; int ConvertTelemetrySource_216_to_217(int source) @@ -668,7 +668,7 @@ int ConvertSwitch_217_to_218(int swtch) int ConvertSource_216_to_217(int source) { -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) // SI to SR switches added if (source >= MIXSRC_SI) source += 10; @@ -773,8 +773,8 @@ PACK(typedef struct { TARANIS_FIELD(char anaNames[NUM_STICKS + NUM_POTS][LEN_ANA_NAME]) N_TARANIS_FIELD(CustomFunctionData_v216 customFn[NUM_CFN]) - TARANIS_REV9E_FIELD(uint8_t bluetoothEnable) - TARANIS_REV9E_FIELD(char bluetoothName[LEN_BLUETOOTH_NAME]) + TARANIS_PCBX9E_FIELD(uint8_t bluetoothEnable) + TARANIS_PCBX9E_FIELD(char bluetoothName[LEN_BLUETOOTH_NAME]) }) RadioData_v216; void ConvertRadioData_216_to_217(RadioData & settings) @@ -843,7 +843,7 @@ void ConvertRadioData_217_to_218(RadioData & settings) memcpy(settings.anaNames, settings_v217->anaNames, sizeof(settings.anaNames)); #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) settings.bluetoothEnable = settings_v217->bluetoothEnable; memcpy(settings.bluetoothName, settings_v217->bluetoothName, sizeof(settings.bluetoothName)); #endif @@ -1199,7 +1199,7 @@ void ConvertModel_217_to_218(ModelData & model) if (newModel.telemetrySensors[i].unit > UNIT_WATTS) newModel.telemetrySensors[i].unit += 1; } -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) newModel.toplcdTimer = oldModel.toplcdTimer; #endif } diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 3c40ab682..84207cd53 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -155,7 +155,7 @@ void getSwitchesPosition(bool startup) #endif #if defined(PCBTARANIS) || defined(PCBHORUS) -#if defined(REV9E) +#if defined(PCBX9E) tmr10ms_t switchesMidposStart[16]; #else tmr10ms_t switchesMidposStart[6]; // TODO constant @@ -242,7 +242,7 @@ void getSwitchesPosition(bool startup) CHECK_3POS(5, SW_SG); CHECK_2POS(SW_SH); -#if defined(REV9E) +#if defined(PCBX9E) CHECK_3POS(6, SW_SI); CHECK_3POS(7, SW_SJ); CHECK_3POS(8, SW_SK); diff --git a/radio/src/targets/9x/CMakeLists.txt b/radio/src/targets/9x/CMakeLists.txt index 75afcad32..3d9d451d9 100644 --- a/radio/src/targets/9x/CMakeLists.txt +++ b/radio/src/targets/9x/CMakeLists.txt @@ -5,11 +5,11 @@ set(MCU atmega64) string(TOLOWER ${PCB} FLAVOUR) set(EEPROM_VARIANT_NEEDED ON) set(EEPROM EEPROM_RLC) -set(GUI_DIR 9x) +set(GUI_DIR 128x64) set(TARGET_DIR 9x) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) add_definitions(-DPCBSTD -DPCB${PCB} -DCPUM64) -set(TARGET_SRC ${TARGET_SRC} board_stock.cpp) +set(TARGET_SRC ${TARGET_SRC} board.cpp) set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) if(SP22) add_definitions(-DSP22) diff --git a/radio/src/targets/9x/board_stock.cpp b/radio/src/targets/9x/board.cpp similarity index 100% rename from radio/src/targets/9x/board_stock.cpp rename to radio/src/targets/9x/board.cpp diff --git a/radio/src/targets/9x/board_stock.h b/radio/src/targets/9x/board.h similarity index 96% rename from radio/src/targets/9x/board_stock.h rename to radio/src/targets/9x/board.h index ac2011783..7821e969d 100644 --- a/radio/src/targets/9x/board_stock.h +++ b/radio/src/targets/9x/board.h @@ -21,7 +21,7 @@ #ifndef _BOARD_STOCK_H_ #define _BOARD_STOCK_H_ -#include "../common_avr/board_avr.h" +#include "../common/avr/board_avr.h" // // elev thr diff --git a/radio/src/common/arm/CMakeLists.txt b/radio/src/targets/common/arm/CMakeLists.txt similarity index 97% rename from radio/src/common/arm/CMakeLists.txt rename to radio/src/targets/common/arm/CMakeLists.txt index fade603c2..6fa111337 100644 --- a/radio/src/common/arm/CMakeLists.txt +++ b/radio/src/targets/common/arm/CMakeLists.txt @@ -70,12 +70,11 @@ if(HAPTIC) endif() if(MULTIMODULE) add_definitions(-DMULTIMODULE) - set(SRC ${SRC} pulses/multi_arm.cpp) + set(SRC ${SRC} pulses/multi_arm.cpp telemetry/spektrum.cpp) endif() add_definitions(-DCPUARM) add_definitions(-DFRSKY -DFRSKY_SPORT -DFRSKY_HUB -DGPS -DPXX -DDSM2) add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE) -include_directories(targets/${TARGET_DIR} ${THIRDPARTY_DIR}) include_directories(${COOS_DIR} ${COOS_DIR}/kernel ${COOS_DIR}/portable) foreach(LANGUAGE ${TTS_LANGUAGES}) set(SRC ${SRC} translations/tts_${LANGUAGE}.cpp) diff --git a/radio/src/common/arm/stm32/CMakeLists.txt b/radio/src/targets/common/arm/stm32/CMakeLists.txt similarity index 86% rename from radio/src/common/arm/stm32/CMakeLists.txt rename to radio/src/targets/common/arm/stm32/CMakeLists.txt index 473892eb1..4068450db 100644 --- a/radio/src/common/arm/stm32/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/CMakeLists.txt @@ -4,6 +4,7 @@ set(ARCH ARM) set(STM32USB_DIR ${THIRDPARTY_DIR}/STM32_USB-Host-Device_Lib_V2.1.0/Libraries) add_definitions(-DCPUSTM32) add_definitions(-DSBUS -DCROSSFIRE) +include_directories(${RADIO_SRC_DIRECTORY}/targets/common/arm/stm32) include_directories(${STM32USB_DIR}/STM32_USB_OTG_Driver/inc) include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Core/inc) include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/inc) @@ -19,15 +20,16 @@ set(STM32USB_SRC ) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} - usb_bsp.c - usbd_desc.c - usbd_usr.cpp + ../common/arm/stm32/usb_bsp.c + ../common/arm/stm32/usbd_desc.c + ../common/arm/stm32/usbd_usr.cpp + ../common/arm/stm32/usb_driver.c ) if(USB STREQUAL SERIAL) add_definitions(-DUSB_SERIAL) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} - usbd_cdc.cpp + ../common/arm/stm32/usbd_cdc.cpp ) set(STM32USB_SRC ${STM32USB_SRC} @@ -44,19 +46,19 @@ elseif(USB STREQUAL MASSSTORAGE) ) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} - usbd_storage_msd.cpp + ../common/arm/stm32/usbd_storage_msd.cpp ) else() add_definitions(-DUSB_JOYSTICK) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} - usbd_hid_joystick.c + ../common/arm/stm32/usbd_hid_joystick.c ) endif() if(GVARS) set(GUI_SRC ${GUI_SRC} - menu_model_gvars.cpp + model_gvars.cpp ) endif() set(FIRMWARE_SRC diff --git a/radio/src/common/arm/stm32/f2/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt similarity index 91% rename from radio/src/common/arm/stm32/f2/CMakeLists.txt rename to radio/src/targets/common/arm/stm32/f2/CMakeLists.txt index b09e44256..b9409d1f3 100644 --- a/radio/src/common/arm/stm32/f2/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt @@ -18,5 +18,5 @@ set(STM32LIB_SRC STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_usart.c ) -set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} system_stm32f2xx.c) +set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} ../common/arm/stm32/f2/system_stm32f2xx.c) diff --git a/radio/src/targets/taranis/system_stm32f2xx.c b/radio/src/targets/common/arm/stm32/f2/system_stm32f2xx.c similarity index 100% rename from radio/src/targets/taranis/system_stm32f2xx.c rename to radio/src/targets/common/arm/stm32/f2/system_stm32f2xx.c diff --git a/radio/src/common/arm/stm32/f4/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt similarity index 90% rename from radio/src/common/arm/stm32/f4/CMakeLists.txt rename to radio/src/targets/common/arm/stm32/f4/CMakeLists.txt index 7bcd4b9b7..73ba54944 100644 --- a/radio/src/common/arm/stm32/f4/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt @@ -18,5 +18,5 @@ set(STM32LIB_SRC STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c ) -set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} system_stm32f4xx.c) +set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} ../common/arm/stm32/f4/system_stm32f4xx.c) diff --git a/radio/src/targets/horus/system_stm32f4xx.c b/radio/src/targets/common/arm/stm32/f4/system_stm32f4xx.c similarity index 93% rename from radio/src/targets/horus/system_stm32f4xx.c rename to radio/src/targets/common/arm/stm32/f4/system_stm32f4xx.c index 5c609ffac..05445c1a6 100644 --- a/radio/src/targets/horus/system_stm32f4xx.c +++ b/radio/src/targets/common/arm/stm32/f4/system_stm32f4xx.c @@ -1,23 +1,3 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - /** ****************************************************************************** * @file system_stm32f4xx.c @@ -28,20 +8,20 @@ * This file contains the system clock configuration for STM32F4xx devices, * and is generated by the clock configuration tool * stm32f4xx_Clock_Configuration_V1.1.0.xls - * - * 1. This file provides two functions and one global variable to be called from + * + * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * and Divider factors, AHB/APBx prescalers and Flash settings), - * depending on the configuration made in the clock xls tool. - * This function is called at startup just after reset and + * depending on the configuration made in the clock xls tool. + * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f4xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick + * by the user application to setup the SysTick * timer or configure other parameters. - * + * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. @@ -51,7 +31,7 @@ * configure the system clock before to branch to main program. * * 3. If the system clock source selected by user fails to startup, the SystemInit() - * function will do nothing and HSI still used as system clock source. User can + * function will do nothing and HSI still used as system clock source. User can * add some code to deal with this issue inside the SetSysClock() function. * * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define @@ -108,7 +88,7 @@ * SDIO and RNG clock | *----------------------------------------------------------------------------- *============================================================================= - ****************************************************************************** + ****************************************************************************** * @attention * *

© COPYRIGHT 2013 STMicroelectronics

@@ -119,15 +99,15 @@ * * 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, + * 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. * ****************************************************************************** */ - + /** @addtogroup CMSIS * @{ */ @@ -255,13 +235,15 @@ void SystemInit(void) /* Disable all interrupts */ RCC->CIR = 0x00000000; - + +#if defined(SDRAM) void SDRAM_Init(); void FMC_SDRAMWriteProtectionConfig(uint32_t SDRAM_Bank, FunctionalState NewState); SDRAM_Init(); // calls SDRAM_GPIOConfig() FMC_SDRAMWriteProtectionConfig(((uint32_t)0x00000001), DISABLE); - +#endif + #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ @@ -426,7 +408,7 @@ static void SetSysClock(void) } /* Configure Flash prefetch, Instruction cache, Data cache and wait state */ - FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS; + FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS; /* Select the main PLL as system clock source */ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); diff --git a/radio/src/targets/taranis/rtc_driver.cpp b/radio/src/targets/common/arm/stm32/rtc_driver.cpp similarity index 95% rename from radio/src/targets/taranis/rtc_driver.cpp rename to radio/src/targets/common/arm/stm32/rtc_driver.cpp index 1a1071032..2807b1add 100644 --- a/radio/src/targets/taranis/rtc_driver.cpp +++ b/radio/src/targets/common/arm/stm32/rtc_driver.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" void rtcSetTime(struct gtm * t) { diff --git a/radio/src/targets/horus/usb_bsp.c b/radio/src/targets/common/arm/stm32/usb_bsp.c similarity index 95% rename from radio/src/targets/horus/usb_bsp.c rename to radio/src/targets/common/arm/stm32/usb_bsp.c index 928a3c7b8..df4ecb757 100644 --- a/radio/src/targets/horus/usb_bsp.c +++ b/radio/src/targets/common/arm/stm32/usb_bsp.c @@ -21,7 +21,7 @@ /* Includes ------------------------------------------------------------------*/ #include "usb_bsp.h" -#include "board_horus.h" +#include "board.h" #include "usbd_conf.h" extern uint32_t SystemCoreClock; diff --git a/radio/src/targets/taranis/usb_conf.h b/radio/src/targets/common/arm/stm32/usb_conf.h similarity index 97% rename from radio/src/targets/taranis/usb_conf.h rename to radio/src/targets/common/arm/stm32/usb_conf.h index 15f7186bd..9db23007d 100644 --- a/radio/src/targets/taranis/usb_conf.h +++ b/radio/src/targets/common/arm/stm32/usb_conf.h @@ -1,28 +1,28 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef _USB_CONF_H_ -#define _USB_CONF_H_ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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. + */ -#if defined(REV9E) +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _USB_CONF_H_ +#define _USB_CONF_H_ + +#if defined(STM32F4) #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" #else #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h" @@ -162,7 +162,7 @@ #endif /* __CC_ARM */ #endif -#endif // _USB_CONF_H_ +#endif // _USB_CONF_H_ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/horus/usb_driver.c b/radio/src/targets/common/arm/stm32/usb_driver.c similarity index 98% rename from radio/src/targets/horus/usb_driver.c rename to radio/src/targets/common/arm/stm32/usb_driver.c index 3232ae6bb..fa43ce205 100644 --- a/radio/src/targets/horus/usb_driver.c +++ b/radio/src/targets/common/arm/stm32/usb_driver.c @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "board_horus.h" +#include "board.h" #include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h" #include "debug.h" diff --git a/radio/src/targets/horus/usbd_cdc.cpp b/radio/src/targets/common/arm/stm32/usbd_cdc.cpp similarity index 100% rename from radio/src/targets/horus/usbd_cdc.cpp rename to radio/src/targets/common/arm/stm32/usbd_cdc.cpp diff --git a/radio/src/targets/taranis/usbd_conf.h b/radio/src/targets/common/arm/stm32/usbd_conf.h similarity index 100% rename from radio/src/targets/taranis/usbd_conf.h rename to radio/src/targets/common/arm/stm32/usbd_conf.h diff --git a/radio/src/targets/taranis/usbd_desc.c b/radio/src/targets/common/arm/stm32/usbd_desc.c similarity index 93% rename from radio/src/targets/taranis/usbd_desc.c rename to radio/src/targets/common/arm/stm32/usbd_desc.c index 4b5e7106f..c19813488 100644 --- a/radio/src/targets/taranis/usbd_desc.c +++ b/radio/src/targets/common/arm/stm32/usbd_desc.c @@ -1,29 +1,29 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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. + */ + /* Includes ------------------------------------------------------------------*/ #include "usbd_desc.h" #include -#include "board_taranis.h" +#include "board.h" #include "usbd_conf.h" #include "usbd_core.h" #include "usbd_req.h" @@ -60,17 +60,17 @@ #if defined(USB_JOYSTICK) #define USBD_PID 0x5710 - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick" + #define USBD_PRODUCT_FS_STRING USB_NAME " Joystick" #define USBD_CONFIGURATION_FS_STRING "HID Config" #define USBD_INTERFACE_FS_STRING "HID Interface" #elif defined(USB_SERIAL) #define USBD_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Serial Port" + #define USBD_PRODUCT_FS_STRING USB_NAME " Serial Port" #define USBD_CONFIGURATION_FS_STRING "VSP Config" #define USBD_INTERFACE_FS_STRING "VSP Interface" #elif defined(USB_MASS_STORAGE) #define USBD_PID 0x5720 - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Mass Storage" + #define USBD_PRODUCT_FS_STRING USB_NAME " Mass Storage" #define USBD_CONFIGURATION_FS_STRING "MSC Config" #define USBD_INTERFACE_FS_STRING "MSC Interface" #endif diff --git a/radio/src/targets/horus/usbd_desc.h b/radio/src/targets/common/arm/stm32/usbd_desc.h similarity index 100% rename from radio/src/targets/horus/usbd_desc.h rename to radio/src/targets/common/arm/stm32/usbd_desc.h diff --git a/radio/src/targets/taranis/usbd_hid_joystick.c b/radio/src/targets/common/arm/stm32/usbd_hid_joystick.c similarity index 100% rename from radio/src/targets/taranis/usbd_hid_joystick.c rename to radio/src/targets/common/arm/stm32/usbd_hid_joystick.c diff --git a/radio/src/targets/taranis/usbd_storage_msd.cpp b/radio/src/targets/common/arm/stm32/usbd_storage_msd.cpp similarity index 83% rename from radio/src/targets/taranis/usbd_storage_msd.cpp rename to radio/src/targets/common/arm/stm32/usbd_storage_msd.cpp index c25eca72e..b2981ac2f 100644 --- a/radio/src/targets/taranis/usbd_storage_msd.cpp +++ b/radio/src/targets/common/arm/stm32/usbd_storage_msd.cpp @@ -19,9 +19,8 @@ */ /* Includes ------------------------------------------------------------------*/ -#include "../../opentx.h" -#include "../../thirdparty/FatFs/diskio.h" -#include "board_taranis.h" +#include "opentx.h" +#include "FatFs/diskio.h" #if defined(__cplusplus) && !defined(SIMU) extern "C" { @@ -30,17 +29,16 @@ extern "C" { #include "usbd_msc_mem.h" #include "usb_conf.h" -#if defined(BOOT) -#define STORAGE_LUN_NBR 2 -#else -/* SD card only when not running bootloader */ -#define STORAGE_LUN_NBR 1 +enum MassstorageLuns { + STORAGE_SDCARD_LUN, +#if defined(EEPROM) + STORAGE_EEPROM_LUN, #endif -#define BLOCKSIZE 512 + STORAGE_LUN_NBR +}; /* USB Mass storage Standard Inquiry Data */ -const unsigned char STORAGE_Inquirydata[] = {//36 - +const unsigned char STORAGE_Inquirydata[] = { //36 /* LUN 0 */ 0x00, 0x80, @@ -50,11 +48,11 @@ const unsigned char STORAGE_Inquirydata[] = {//36 0x00, 0x00, 0x00, - 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ', /* Manufacturer : 8 bytes */ - 'T', 'a', 'r', 'a', 'n', 'i', 's', ' ', /* Product : 16 Bytes */ + USB_MANUFACTURER, /* Manufacturer : 8 bytes */ + USB_PRODUCT, /* Product : 16 Bytes */ 'R', 'a', 'd', 'i', 'o', ' ', ' ', ' ', '1', '.', '0', '0', /* Version : 4 Bytes */ -#if defined(BOOT) +#if defined(EEPROM) /* LUN 1 */ 0x00, 0x80, @@ -64,16 +62,16 @@ const unsigned char STORAGE_Inquirydata[] = {//36 0x00, 0x00, 0x00, - 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ', /* Manufacturer : 8 bytes */ - 'T', 'a', 'r', 'a', 'n', 'i', 's', ' ', /* Product : 16 Bytes */ + USB_MANUFACTURER, /* Manufacturer : 8 bytes */ + USB_PRODUCT, /* Product : 16 Bytes */ 'R', 'a', 'd', 'i', 'o', ' ', ' ', ' ', '1', '.', '0' ,'0', /* Version : 4 Bytes */ #endif }; -#if defined(BOOT) -int32_t fat12Write( const uint8_t *buffer, uint16_t sector, uint16_t count ) ; -int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count ) ; +#if defined(EEPROM) +int32_t fat12Write(const uint8_t * buffer, uint16_t sector, uint16_t count); +int32_t fat12Read(uint8_t * buffer, uint16_t sector, uint16_t count ); #endif int8_t STORAGE_Init (uint8_t lun); @@ -144,30 +142,29 @@ int8_t STORAGE_Init (uint8_t lun) */ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_size) { -#if defined(BOOT) - if (lun == 1) { - *block_size = BLOCKSIZE; - *block_num = 3 + EESIZE/BLOCKSIZE + FLASHSIZE/BLOCKSIZE; +#if defined(EEPROM) + if (lun == STORAGE_EEPROM_LUN) { + *block_size = BLOCK_SIZE; + *block_num = 3 + EESIZE/BLOCK_SIZE + FLASHSIZE/BLOCK_SIZE; + return 0; } - else #endif - { - if (!SD_CARD_PRESENT()) - return -1; - *block_size = BLOCKSIZE; + if (!SD_CARD_PRESENT()) + return -1; + + *block_size = BLOCK_SIZE; - static DWORD sector_count = 0; - if (sector_count == 0) { - if (disk_ioctl(0, GET_SECTOR_COUNT, §or_count) != RES_OK) { - sector_count = 0; - return -1; - } + static DWORD sector_count = 0; + if (sector_count == 0) { + if (disk_ioctl(0, GET_SECTOR_COUNT, §or_count) != RES_OK) { + sector_count = 0; + return -1; } - - *block_num = sector_count; } + *block_num = sector_count; + return 0; } @@ -175,12 +172,13 @@ uint8_t lunReady[STORAGE_LUN_NBR]; void usbPluggedIn() { - if (lunReady[0] == 0) { - lunReady[0] = 1; + if (lunReady[STORAGE_SDCARD_LUN] == 0) { + lunReady[STORAGE_SDCARD_LUN] = 1; } -#if defined(BOOT) - if (lunReady[1] == 0) { - lunReady[1] = 1; + +#if defined(EEPROM) + if (lunReady[STORAGE_EEPROM_LUN] == 0) { + lunReady[STORAGE_EEPROM_LUN] = 1; } #endif } @@ -192,21 +190,13 @@ void usbPluggedIn() */ int8_t STORAGE_IsReady (uint8_t lun) { -#if defined(BOOT) - if (lun == 1) { - if (lunReady[1] == 0) { - return -1 ; - } - return 0 ; +#if defined(EEPROM) + if (lun == STORAGE_EEPROM_LUN) { + return (lunReady[STORAGE_EEPROM_LUN] != 0) ? 0 : -1; } - else #endif - { - if (lunReady[0] == 0) { - return -1 ; - } - return SD_CARD_PRESENT() ? 0 : -1; - } + + return (lunReady[STORAGE_SDCARD_LUN] != 0 && SD_CARD_PRESENT()) ? 0 : -1; } /** @@ -228,27 +218,19 @@ int8_t STORAGE_IsWriteProtected (uint8_t lun) * @retval Status */ -int8_t SD_ReadSectors(uint8_t *buff, uint32_t sector, uint32_t count); - int8_t STORAGE_Read (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) { -#if defined(BOOT) - if (lun == 1) { - if (fat12Read(buf, blk_addr, blk_len) != 0) - return -1; +#if defined(EEPROM) + if (lun == STORAGE_EEPROM_LUN) { + return (fat12Read(buf, blk_addr, blk_len) == 0) ? 0 : -1; } - else #endif - { - if (SD_ReadSectors(buf, blk_addr, blk_len) != 0) { - return -1; - } - } - - return 0; + + // read without cache + return (__disk_read(0, buf, blk_addr, blk_len) == RES_OK) ? 0 : -1; } /** * @brief Write data to the medium @@ -259,26 +241,19 @@ int8_t STORAGE_Read (uint8_t lun, * @retval Status */ -int8_t SD_WriteSectors(const uint8_t *buf, uint32_t sector, uint32_t count); - int8_t STORAGE_Write (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) { -#if defined(BOOT) - if (lun == 1) { - if (fat12Write(buf, blk_addr, blk_len) != 0) - return -1; +#if defined(EEPROM) + if (lun == STORAGE_EEPROM_LUN) { + return (fat12Write(buf, blk_addr, blk_len) == 0) ? 0 : -1; } - else #endif - { - if (SD_WriteSectors(buf, blk_addr, blk_len) != 0) - return -1; - } - - return (0); + + // write without cache + return (__disk_write(0, buf, blk_addr, blk_len) == RES_OK) ? 0 : -1; } /** @@ -292,12 +267,12 @@ int8_t STORAGE_GetMaxLun (void) return STORAGE_LUN_NBR - 1; } -#if defined(BOOT) +#if defined(EEPROM) //------------------------------------------------------------------------------ /** * FAT12 boot sector partition. */ -const char g_FATboot[BLOCKSIZE] = +const char g_FATboot[BLOCK_SIZE] = { 0xeb, 0x3c, 0x90, // Jump instruction. 0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name @@ -307,7 +282,7 @@ const char g_FATboot[BLOCKSIZE] = 0x01, // Number of FATs 0x10, 0x00, // Number of root directory entries - 3+(EESIZE/BLOCKSIZE), (FLASHSIZE/BLOCKSIZE)>>8, // Total sectors + 3+(EESIZE/BLOCK_SIZE), (FLASHSIZE/BLOCK_SIZE)>>8, // Total sectors 0xf8, // Media descriptor 0x01, 0x00, // Sectors per FAT table 0x20, 0x00, // Sectors per track @@ -356,7 +331,7 @@ const char g_FATboot[BLOCKSIZE] = }; #if defined(REV4a) -const char g_FAT[BLOCKSIZE] = +const char g_FAT[BLOCK_SIZE] = { 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, @@ -392,7 +367,7 @@ const char g_FAT[BLOCKSIZE] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #else -const char g_FAT[BLOCKSIZE] = +const char g_FAT[BLOCK_SIZE] = { 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, @@ -460,7 +435,7 @@ typedef struct const FATDirEntry_t g_DIRroot[16] = { { - { 'T', 'A', 'R', 'A', 'N', 'I', 'S', ' '}, + { USB_PRODUCT }, { ' ', ' ', ' '}, 0x08, // Volume 0x00, @@ -501,7 +476,7 @@ const FATDirEntry_t g_DIRroot[16] = 0x0000, 0xA302, 0x3D55, - 0x0002 + (EESIZE/BLOCKSIZE)/8, + 0x0002 + (EESIZE/BLOCK_SIZE)/8, FLASHSIZE }, { @@ -702,38 +677,37 @@ const FATDirEntry_t g_DIRroot[16] = }; // count is number of 512 byte sectors -int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count ) +int32_t fat12Read(uint8_t * buffer, uint16_t sector, uint16_t count) { - while ( count ) - { + while(count) { if (sector == 0) { - memcpy(buffer, g_FATboot, BLOCKSIZE ) ; + memcpy(buffer, g_FATboot, BLOCK_SIZE ) ; } else if (sector == 1/*Reserved sector count*/) { // FAT table. - memcpy(buffer, g_FAT, BLOCKSIZE); + memcpy(buffer, g_FAT, BLOCK_SIZE); } else if (sector == 2) { - memcpy(buffer, g_DIRroot, BLOCKSIZE ) ; + memcpy(buffer, g_DIRroot, BLOCK_SIZE ) ; } - else if (sector < 3 + (EESIZE/BLOCKSIZE)) { - eepromReadBlock(buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE); + else if (sector < 3 + (EESIZE/BLOCK_SIZE)) { + eepromReadBlock(buffer, (sector-3)*BLOCK_SIZE, BLOCK_SIZE); } - else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) { + else if (sector < 3 + (EESIZE/BLOCK_SIZE) + (FLASHSIZE/BLOCK_SIZE)) { uint32_t address; - address = sector - 3 - (EESIZE/BLOCKSIZE); - address *= BLOCKSIZE; + address = sector - 3 - (EESIZE/BLOCK_SIZE); + address *= BLOCK_SIZE; address += FIRMWARE_ADDRESS; - memcpy(buffer, (uint8_t *)address, BLOCKSIZE); + memcpy(buffer, (uint8_t *)address, BLOCK_SIZE); } - buffer += BLOCKSIZE ; + buffer += BLOCK_SIZE ; sector++ ; count-- ; } return 0 ; } -int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count) +int32_t fat12Write(const uint8_t * buffer, uint16_t sector, uint16_t count) { enum FatWriteOperation { FATWRITE_NONE, @@ -748,7 +722,7 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count) if (sector < 3) { // reserved, read-only } - else if (sector < 3 + (EESIZE/BLOCKSIZE)) { + else if (sector < 3 + (EESIZE/BLOCK_SIZE)) { // eeprom while (count) { if (operation == FATWRITE_NONE && isEepromStart(buffer)) { @@ -756,25 +730,25 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count) operation = FATWRITE_EEPROM; } if (operation == FATWRITE_EEPROM) { - eepromWriteBlock((uint8_t *)buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE); + eepromWriteBlock((uint8_t *)buffer, (sector-3)*BLOCK_SIZE, BLOCK_SIZE); } - buffer += BLOCKSIZE; + buffer += BLOCK_SIZE; sector++; count--; - if (sector-3 >= (EESIZE/BLOCKSIZE)) { + if (sector-3 >= (EESIZE/BLOCK_SIZE)) { TRACE("EEPROM end written at sector %d", sector-1); operation = FATWRITE_NONE; } } } - else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) { + else if (sector < 3 + (EESIZE/BLOCK_SIZE) + (FLASHSIZE/BLOCK_SIZE)) { // firmware uint32_t address; - address = sector - 3 - (EESIZE/BLOCKSIZE); - address *= BLOCKSIZE; + address = sector - 3 - (EESIZE/BLOCK_SIZE); + address *= BLOCK_SIZE; address += FIRMWARE_ADDRESS; while (count) { - for (uint32_t i=0; i= FIRMWARE_ADDRESS+BOOTLOADER_SIZE/*protect bootloader*/ && address <= FIRMWARE_ADDRESS+FLASHSIZE-FLASH_PAGESIZE) { if (address == FIRMWARE_ADDRESS+BOOTLOADER_SIZE && isFirmwareStart(buffer)) { TRACE("FIRMWARE start found in sector %d", sector); @@ -789,7 +763,7 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count) } sector++; count--; - if (sector-3-(EESIZE/BLOCKSIZE) >= (FLASHSIZE/BLOCKSIZE)) { + if (sector-3-(EESIZE/BLOCK_SIZE) >= (FLASHSIZE/BLOCK_SIZE)) { TRACE("FIRMWARE end written at sector %d", sector-1); operation = FATWRITE_NONE; } diff --git a/radio/src/targets/taranis/usbd_usr.cpp b/radio/src/targets/common/arm/stm32/usbd_usr.cpp similarity index 89% rename from radio/src/targets/taranis/usbd_usr.cpp rename to radio/src/targets/common/arm/stm32/usbd_usr.cpp index f130b5545..e6f317d3b 100644 --- a/radio/src/targets/taranis/usbd_usr.cpp +++ b/radio/src/targets/common/arm/stm32/usbd_usr.cpp @@ -1,25 +1,25 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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. + */ + /* Includes ------------------------------------------------------------------*/ -#include "../../opentx.h" +#include "opentx.h" extern "C" { #include "usbd_usr.h" @@ -112,7 +112,8 @@ void USBD_USR_DeviceConnected (void) */ void USBD_USR_DeviceDisconnected (void) { -#if !defined(BOOT) && defined(USB_MASS_STORAGE) +#if !defined(BOOT) && defined(USB_MASS_STORAGE) && defined(EEPROM) + // TODO is it really needed if we didn't write the EEPROM? NVIC_SystemReset(); #endif } diff --git a/radio/src/common/avr/CMakeLists.txt b/radio/src/targets/common/avr/CMakeLists.txt similarity index 94% rename from radio/src/common/avr/CMakeLists.txt rename to radio/src/targets/common/avr/CMakeLists.txt index fbc9c73b8..6512fac5f 100644 --- a/radio/src/common/avr/CMakeLists.txt +++ b/radio/src/targets/common/avr/CMakeLists.txt @@ -11,7 +11,7 @@ set(DSM2 "NO" CACHE STRING "LCD type (NO/PPM/SERIAL)") set(LUA NO) set(PULSES_SRC pulses_avr.cpp) set(SRC ${SRC} main_avr.cpp) -set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common_avr/adc_driver.cpp) +set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common/avr/adc_driver.cpp) add_definitions(-DLCD_${LCD}) if(DSM2) add_definitions(-DDSM2 -DDSM2_${DSM2}) @@ -67,8 +67,8 @@ elseif(EXT STREQUAL JETI) set(SRC ${SRC} telemetry/jeti.cpp) elseif(EXT STREQUAL MAVLINK) add_definitions(-DMAVLINK) - include_directories(${THIRDPARTY_DIR} gui/${GUI_DIR} targets/common_avr) - set(SRC ${SRC} telemetry/mavlink.cpp targets/common_avr/serial_driver.cpp) + include_directories(${THIRDPARTY_DIR} gui/${GUI_DIR} targets/common/avr) + set(SRC ${SRC} telemetry/mavlink.cpp targets/common/avr/serial_driver.cpp) set(GUI_SRC ${GUI_SRC} view_mavlink.cpp) math(EXPR EEPROM_VARIANT ${EEPROM_VARIANT}+${MAVLINK_VARIANT}) elseif(EXT STREQUAL TELEMETREZ) @@ -86,7 +86,7 @@ if(EXT STREQUAL FRSKY OR EXT STREQUAL FRSKY_SPORT OR EXT STREQUAL TELEMETREZ) option(VARIO "Vario support" ON) add_definitions(-DFRSKY) set(SRC ${SRC} telemetry/telemetry.cpp telemetry/telemetry_holders.cpp telemetry/frsky.cpp telemetry/frsky_d.cpp) - set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common_avr/telemetry_driver.cpp) + set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common/avr/telemetry_driver.cpp) set(GUI_SRC ${GUI_SRC} view_telemetry.cpp) if(FRSKY_HUB) add_definitions(-DFRSKY_HUB) diff --git a/radio/src/targets/common_avr/adc_driver.cpp b/radio/src/targets/common/avr/adc_driver.cpp similarity index 100% rename from radio/src/targets/common_avr/adc_driver.cpp rename to radio/src/targets/common/avr/adc_driver.cpp diff --git a/radio/src/targets/common_avr/board_avr.h b/radio/src/targets/common/avr/board_avr.h similarity index 100% rename from radio/src/targets/common_avr/board_avr.h rename to radio/src/targets/common/avr/board_avr.h diff --git a/radio/src/targets/common_avr/serial_driver.cpp b/radio/src/targets/common/avr/serial_driver.cpp similarity index 94% rename from radio/src/targets/common_avr/serial_driver.cpp rename to radio/src/targets/common/avr/serial_driver.cpp index d9625fd08..6602fd890 100644 --- a/radio/src/targets/common_avr/serial_driver.cpp +++ b/radio/src/targets/common/avr/serial_driver.cpp @@ -1,23 +1,23 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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 "serial_driver.h" #include "opentx.h" @@ -292,8 +292,12 @@ void SERIAL_Init(void) { // set 8N1 UCSR0B = 0 | (0 << RXCIE0) | (0 << TXCIE0) | (0 << UDRIE0) | (0 << RXEN0) | (0 << TXEN0) | (0 << UCSZ02); UCSR0C = 0 | (1 << UCSZ01) | (1 << UCSZ00); - while (UCSR0A & (1 << RXC0)) - UDR0; // flush receive buffer + +#if !defined(SIMU) + while (UCSR0A & (1 << RXC0)) { + UDR0; // flush receive buffer + } +#endif SERIAL_EnableTXD(); SERIAL_EnableRXD(); diff --git a/radio/src/targets/common_avr/serial_driver.h b/radio/src/targets/common/avr/serial_driver.h similarity index 100% rename from radio/src/targets/common_avr/serial_driver.h rename to radio/src/targets/common/avr/serial_driver.h diff --git a/radio/src/targets/common_avr/telemetry_driver.cpp b/radio/src/targets/common/avr/telemetry_driver.cpp similarity index 100% rename from radio/src/targets/common_avr/telemetry_driver.cpp rename to radio/src/targets/common/avr/telemetry_driver.cpp diff --git a/radio/src/targets/gruvin9x/CMakeLists.txt b/radio/src/targets/gruvin9x/CMakeLists.txt index 23d021c3b..65f7321d4 100644 --- a/radio/src/targets/gruvin9x/CMakeLists.txt +++ b/radio/src/targets/gruvin9x/CMakeLists.txt @@ -3,10 +3,10 @@ set(MCU atmega2560) string(TOLOWER ${PCB} FLAVOUR) set(EEPROM EEPROM_RLC) add_definitions(-DEEPROM_VARIANT=0) -set(GUI_DIR 9x) +set(GUI_DIR 128x64) set(TARGET_DIR gruvin9x) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) add_definitions(-DPCB${PCB} -DCPUM2560 -DROTARY_ENCODERS=2) -set(TARGET_SRC ${TARGET_SRC} board_gruvin9x.cpp) +set(TARGET_SRC ${TARGET_SRC} board.cpp) set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/9x/lcd_driver.cpp) diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.cpp b/radio/src/targets/gruvin9x/board.cpp similarity index 100% rename from radio/src/targets/gruvin9x/board_gruvin9x.cpp rename to radio/src/targets/gruvin9x/board.cpp diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.h b/radio/src/targets/gruvin9x/board.h similarity index 95% rename from radio/src/targets/gruvin9x/board_gruvin9x.h rename to radio/src/targets/gruvin9x/board.h index d4c11f4cc..597304f6b 100644 --- a/radio/src/targets/gruvin9x/board_gruvin9x.h +++ b/radio/src/targets/gruvin9x/board.h @@ -21,7 +21,7 @@ #ifndef _BOARD_GRUVIN9X_H_ #define _BOARD_GRUVIN9X_H_ -#include "../common_avr/board_avr.h" +#include "../common/avr/board_avr.h" // Board driver void boardInit(void); @@ -73,6 +73,7 @@ void boardInit(void); #define JACK_PPM_IN() PORTG &= ~(1< storage/datacopy.cpp - DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py +set(CPU_TYPE STM32F4) +set(HSE_VALUE 12000000) +set(SDCARD YES) +set(EEPROM SDCARD) +set(HAPTIC YES) +set(GUI_DIR 480x272) +set(TARGET_DIR horus) +set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld) +set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps) +set(LUA_EXPORT lua_export_horus) +set(FLAVOUR horus) +set(VIRTUAL_INPUTS YES) +set(RAMBACKUP YES) +option(DISK_CACHE "Enable SD card disk cache" YES) +add_definitions(-DPCBHORUS -DCOLORLCD -DSTM32F429_439xx -DSDRAM -DPPM_PIN_UART -DPPM_PIN_TIMER) +add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK) +add_definitions(-DLUAINPUTS -DXCURVES -DVARIO) +include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts) +file(GLOB THEMES_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.cpp) +file(GLOB LAYOUTS_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.cpp) +file(GLOB WIDGETS_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/widgets/*.cpp) +set(GUI_SRC + ${GUI_SRC} + bitmapbuffer.cpp + curves.cpp + bitmaps.cpp + radio_hardware.cpp + model_inputs.cpp + model_mixes.cpp + view_channels.cpp + view_logical_switches.cpp + view_about.cpp + view_text.cpp + screens_setup.cpp + theme.cpp + topbar.cpp + layout.cpp + widget.cpp + ${THEMES_SRC} + ${LAYOUTS_SRC} + ${WIDGETS_SRC} ) +if(DISK_CACHE) + set(SRC ${SRC} disk_cache.cpp) + add_definitions(-DDISK_CACHE) +endif() +set(TARGET_SRC + ${TARGET_SRC} + board.cpp + extmodule_driver.cpp + ../common/arm/stm32/rtc_driver.cpp + ) +set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + sdio_sd.c + lcd_driver.cpp + delays.c + pwr_driver.cpp + sdram_driver.c + led_driver.cpp + startup_stm32f40_41xxx.s + ) +set(STM32LIB_SRC + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c + ) +add_custom_target(datacopy + WORKING_DIRECTORY ${RADIO_DIRECTORY}/src + COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DVIRTUALINPUTS -DBACKUP > storage/datacopy.cpp + DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py +) diff --git a/radio/src/targets/horus/board_horus.cpp b/radio/src/targets/horus/board.cpp similarity index 100% rename from radio/src/targets/horus/board_horus.cpp rename to radio/src/targets/horus/board.cpp diff --git a/radio/src/targets/horus/board_horus.h b/radio/src/targets/horus/board.h similarity index 85% rename from radio/src/targets/horus/board_horus.h rename to radio/src/targets/horus/board.h index 812022881..0d1169afb 100644 --- a/radio/src/targets/horus/board_horus.h +++ b/radio/src/targets/horus/board.h @@ -46,13 +46,13 @@ extern "C" { #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h" #if !defined(SIMU) - #include "usbd_cdc_core.h" - #include "usbd_msc_core.h" - #include "usbd_hid_core.h" - #include "usbd_usr.h" - #include "usbd_desc.h" - #include "usb_conf.h" - #include "usbd_conf.h" +#include "usbd_cdc_core.h" +#include "usbd_msc_core.h" +#include "usbd_hid_core.h" +#include "usbd_usr.h" +#include "usbd_desc.h" +#include "usb_conf.h" +#include "usbd_conf.h" #endif #include "hal.h" @@ -100,24 +100,33 @@ void delay_ms(uint32_t ms); void getCPUUniqueID(char * s); // SD driver +#define BLOCK_SIZE 512 /* Block Size in Bytes */ #if !defined(SIMU) || defined(SIMU_DISKIO) - uint32_t sdIsHC(void); - uint32_t sdGetSpeed(void); - #define SD_IS_HC() (sdIsHC()) - #define SD_GET_SPEED() (sdGetSpeed()) - #define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors()) - #define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_PIN) - void sdInit(void); - void sdDone(void); - #define sdPoll10ms() - #define sdMountPoll() - uint32_t sdMounted(void); +uint32_t sdIsHC(void); +uint32_t sdGetSpeed(void); +#define SD_IS_HC() (sdIsHC()) +#define SD_GET_SPEED() (sdGetSpeed()) +#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors()) +#define SD_CARD_PRESENT() (~SD_PRESENT_GPIO->IDR & SD_PRESENT_GPIO_PIN) +void sdInit(void); +void sdDone(void); +#define sdPoll10ms() +#define sdMountPoll() +uint32_t sdMounted(void); #else - #define SD_IS_HC() (0) - #define SD_GET_SPEED() (0) - #define sdInit() - #define sdDone() - #define SD_CARD_PRESENT() true +#define SD_IS_HC() (0) +#define SD_GET_SPEED() (0) +#define sdInit() +#define sdDone() +#define SD_CARD_PRESENT() true +#endif +#if defined(DISK_CACHE) +#include "diskio.h" +DRESULT __disk_read(BYTE drv, BYTE * buff, DWORD sector, UINT count); +DRESULT __disk_write(BYTE drv, const BYTE * buff, DWORD sector, UINT count); +#else +#define __disk_read disk_read +#define __disk_write disk_write #endif // Flash Write driver @@ -175,6 +184,7 @@ extern uint32_t rotencSpeed; void checkRotaryEncoder(void); // WDT driver +#define WDTO_500MS 500 #define wdt_disable() void watchdogInit(unsigned int duration); #if defined(WATCHDOG_DISABLED) || defined(SIMU) @@ -255,6 +265,9 @@ int usbPlugged(void); void usbInit(void); void usbDeInit(void); void usbSerialPutc(uint8_t c); +#define USB_NAME "FrSky Horus" +#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */ +#define USB_PRODUCT 'H', 'o', 'r', 'u', 's', ' ', ' ', ' ' /* 8 Bytes */ #if defined(__cplusplus) && !defined(SIMU) } diff --git a/radio/src/targets/horus/delays.c b/radio/src/targets/horus/delays.c index 90abf3a80..895e5f6eb 100644 --- a/radio/src/targets/horus/delays.c +++ b/radio/src/targets/horus/delays.c @@ -19,7 +19,7 @@ */ #include -#include "board_horus.h" +#include "board.h" #define SYSTEM_TICKS_1US ((CFG_CPU_FREQ + 500000) / 1000000) // number of system ticks in 1us #define SYSTEM_TICKS_01US ((CFG_CPU_FREQ + 5000000) / 10000000) // number of system ticks in 0.1us (rounding needed for sys frequencies that are not multiple of 10MHz) diff --git a/radio/src/targets/horus/diskio.cpp b/radio/src/targets/horus/diskio.cpp index f0d0776d3..37d16829a 100644 --- a/radio/src/targets/horus/diskio.cpp +++ b/radio/src/targets/horus/diskio.cpp @@ -29,8 +29,6 @@ #include "opentx.h" #include "sdio_sd.h" -#define BLOCK_SIZE 512 /* Block Size in Bytes */ - /*-----------------------------------------------------------------------*/ /* Lock / unlock functions */ /*-----------------------------------------------------------------------*/ @@ -112,15 +110,10 @@ uint32_t sdReadRetries = 0; /*-----------------------------------------------------------------------*/ /* Read Sector(s) */ -#if !defined(DISK_CACHE) - #define __disk_read disk_read - #define __disk_write disk_write -#endif - -DRESULT __disk_read ( +DRESULT __disk_read( BYTE drv, /* Physical drive nmuber (0..) */ - BYTE *buff, /* Data buffer to store read data */ - DWORD sector, /* Sector address (LBA) */ + BYTE * buff, /* Data buffer to store read data */ + DWORD sector, /* Sector address (LBA) */ UINT count /* Number of sectors to read (1..255) */ ) { @@ -134,10 +127,10 @@ DRESULT __disk_read ( return RES_NOTRDY; } - if ((DWORD)buff < 0x20000000 /*|| (DWORD)buff >= 0x20030000*/ || ((DWORD)buff & 3)) { + if ((DWORD)buff < 0x20000000 || ((DWORD)buff & 3)) { TRACE("disk_read bad alignment (%p)", buff); - while(count--) { - res = disk_read(drv, (BYTE *)scratch, sector++, 1); + while (count--) { + res = __disk_read(drv, (BYTE *)scratch, sector++, 1); if (res != RES_OK) { TRACE("disk_read() status=%d", res); @@ -162,7 +155,6 @@ DRESULT __disk_read ( Status = SD_ReadMultiBlocks(buff, sector, BLOCK_SIZE, count); // 4GB Compliant } -#if defined(SD_DMA_MODE) if (Status == SD_OK) { SDTransferState State; @@ -183,7 +175,6 @@ DRESULT __disk_read ( TRACE("Status(ReadBlock)=%d", Status); res = RES_ERROR; } -#endif if (res == RES_OK) break; @@ -198,10 +189,10 @@ DRESULT __disk_read ( /* Write Sector(s) */ #if _READONLY == 0 -DRESULT __disk_write ( +DRESULT __disk_write( BYTE drv, /* Physical drive nmuber (0..) */ - const BYTE *buff, /* Data to be written */ - DWORD sector, /* Sector address (LBA) */ + const BYTE *buff, /* Data to be written */ + DWORD sector, /* Sector address (LBA) */ UINT count /* Number of sectors to write (1..255) */ ) { @@ -213,12 +204,12 @@ DRESULT __disk_write ( if (SD_Detect() != SD_PRESENT) return(RES_NOTRDY); - if ((DWORD)buff < 0x20000000 /*|| (DWORD)buff >= 0x20030000*/ || ((DWORD)buff & 3)) { + if ((DWORD)buff < 0x20000000 || ((DWORD)buff & 3)) { TRACE("disk_write bad alignment (%p)", buff); while(count--) { memcpy(scratch, buff, BLOCK_SIZE); - res = disk_write(drv, (BYTE *)scratch, sector++, 1); + res = __disk_write(drv, (BYTE *)scratch, sector++, 1); if (res != RES_OK) break; @@ -235,8 +226,7 @@ DRESULT __disk_write ( Status = SD_WriteMultiBlocks((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant } - if (Status == SD_OK) - { + if (Status == SD_OK) { SDTransferState State; Status = SD_WaitWriteOperation(); // Check if the Transfer is finished @@ -255,9 +245,6 @@ DRESULT __disk_write ( } #endif /* _READONLY */ - - - /*-----------------------------------------------------------------------*/ /* Miscellaneous Functions */ diff --git a/radio/src/targets/horus/led_driver.cpp b/radio/src/targets/horus/led_driver.cpp index e9e5ddeb0..4ae8f1ebd 100644 --- a/radio/src/targets/horus/led_driver.cpp +++ b/radio/src/targets/horus/led_driver.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "../horus/board_horus.h" +#include "board.h" void ledOn() { diff --git a/radio/src/targets/horus/pwr_driver.cpp b/radio/src/targets/horus/pwr_driver.cpp index 0f6ae3b62..ac9cf5efa 100644 --- a/radio/src/targets/horus/pwr_driver.cpp +++ b/radio/src/targets/horus/pwr_driver.cpp @@ -19,7 +19,7 @@ */ #include "pwr.h" -#include "board_horus.h" +#include "board.h" void pwrInit() { @@ -107,4 +107,4 @@ void pwrResetHandler() pwrOn(); } -} +} diff --git a/radio/src/targets/horus/sdio_sd.c b/radio/src/targets/horus/sdio_sd.c index cd19c1a10..f7fe33ba7 100644 --- a/radio/src/targets/horus/sdio_sd.c +++ b/radio/src/targets/horus/sdio_sd.c @@ -1133,9 +1133,6 @@ OPTIMIZE("O0") SD_Error SD_SelectDeselect(uint32_t addr) OPTIMIZE("O0") SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize) { SD_Error errorstatus = SD_OK; -#if defined (SD_POLLING_MODE) - uint32_t count = 0, *tempbuff = (uint32_t *)readbuff; -#endif TransferError = SD_OK; TransferEnd = 0; @@ -1143,12 +1140,10 @@ OPTIMIZE("O0") SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint1 DMAEndOfTransfer = 0; SDIO->DCTRL = 0x0; - -#if defined (SD_DMA_MODE) + SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); SDIO_DMACmd(ENABLE); SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, BlockSize); -#endif if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) BlockSize = 512; @@ -1193,58 +1188,6 @@ OPTIMIZE("O0") SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint1 return(errorstatus); } -#if defined (SD_POLLING_MODE) - /*!< In case of single block transfer, no need of stop transfer at all.*/ - /*!< Polling mode */ - while (!(SDIO->STA &(SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR))) - { - if (SDIO_GetFlagStatus(SDIO_FLAG_RXFIFOHF) != RESET) - { - for (count = 0; count < 8; count++) - { - *(tempbuff + count) = SDIO_ReadData(); - } - tempbuff += 8; - } - } - - if (SDIO_GetFlagStatus(SDIO_FLAG_DTIMEOUT) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_DTIMEOUT); - errorstatus = SD_DATA_TIMEOUT; - return(errorstatus); - } - else if (SDIO_GetFlagStatus(SDIO_FLAG_DCRCFAIL) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_DCRCFAIL); - errorstatus = SD_DATA_CRC_FAIL; - return(errorstatus); - } - else if (SDIO_GetFlagStatus(SDIO_FLAG_RXOVERR) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_RXOVERR); - errorstatus = SD_RX_OVERRUN; - return(errorstatus); - } - else if (SDIO_GetFlagStatus(SDIO_FLAG_STBITERR) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_STBITERR); - errorstatus = SD_START_BIT_ERR; - return(errorstatus); - } - count = SD_DATATIMEOUT; - while ((SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) && (count > 0)) - { - *tempbuff = SDIO_ReadData(); - tempbuff++; - count--; - } - - /*!< Clear all the static flags */ - SDIO_ClearFlag(SDIO_STATIC_FLAGS); - -#endif - return(errorstatus); } @@ -1394,22 +1337,15 @@ OPTIMIZE("O0") SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, ui { SD_Error errorstatus = SD_OK; -#if defined (SD_POLLING_MODE) - uint32_t bytestransferred = 0, count = 0, restwords = 0; - uint32_t *tempbuff = (uint32_t *)writebuff; -#endif - TransferError = SD_OK; TransferEnd = 0; StopCondition = 0; SDIO->DCTRL = 0x0; - -#if defined (SD_DMA_MODE) + SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, BlockSize); SDIO_DMACmd(ENABLE); -#endif if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) BlockSize = 512; @@ -1453,58 +1389,7 @@ OPTIMIZE("O0") SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, ui SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block; SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; SDIO_DataConfig(&SDIO_DataInitStructure); - - /*!< In case of single data block transfer no need of stop command at all */ -#if defined (SD_POLLING_MODE) - while (!(SDIO->STA & (SDIO_FLAG_DBCKEND | SDIO_FLAG_TXUNDERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_STBITERR))) - { - if (SDIO_GetFlagStatus(SDIO_FLAG_TXFIFOHE) != RESET) - { - if ((512 - bytestransferred) < 32) - { - restwords = ((512 - bytestransferred) % 4 == 0) ? ((512 - bytestransferred) / 4) : (( 512 - bytestransferred) / 4 + 1); - for (count = 0; count < restwords; count++, tempbuff++, bytestransferred += 4) - { - SDIO_WriteData(*tempbuff); - } - } - else - { - for (count = 0; count < 8; count++) - { - SDIO_WriteData(*(tempbuff + count)); - } - tempbuff += 8; - bytestransferred += 32; - } - } - } - if (SDIO_GetFlagStatus(SDIO_FLAG_DTIMEOUT) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_DTIMEOUT); - errorstatus = SD_DATA_TIMEOUT; - return(errorstatus); - } - else if (SDIO_GetFlagStatus(SDIO_FLAG_DCRCFAIL) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_DCRCFAIL); - errorstatus = SD_DATA_CRC_FAIL; - return(errorstatus); - } - else if (SDIO_GetFlagStatus(SDIO_FLAG_TXUNDERR) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_TXUNDERR); - errorstatus = SD_TX_UNDERRUN; - return(errorstatus); - } - else if (SDIO_GetFlagStatus(SDIO_FLAG_STBITERR) != RESET) - { - SDIO_ClearFlag(SDIO_FLAG_STBITERR); - errorstatus = SD_START_BIT_ERR; - return(errorstatus); - } -#endif - + return(errorstatus); } diff --git a/radio/src/targets/horus/sdio_sd.h b/radio/src/targets/horus/sdio_sd.h index 0a5507811..b075ee14f 100644 --- a/radio/src/targets/horus/sdio_sd.h +++ b/radio/src/targets/horus/sdio_sd.h @@ -1,28 +1,28 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef _SDIO_SD_H_ -#define _SDIO_SD_H_ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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 "../horus/board_horus.h" +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _SDIO_SD_H_ +#define _SDIO_SD_H_ + +#include "board.h" #ifdef __cplusplus extern "C" { @@ -309,12 +309,6 @@ typedef struct #define SD_CMD_SD_APP_CHANGE_SECURE_AREA ((uint8_t)49) /*!< For SD Card only */ #define SD_CMD_SD_APP_SECURE_WRITE_MKB ((uint8_t)48) /*!< For SD Card only */ -/* Uncomment the following line to select the SDIO Data transfer mode */ -#if !defined (SD_DMA_MODE) && !defined (SD_POLLING_MODE) -#define SD_DMA_MODE ((uint32_t)0x00000000) -/*#define SD_POLLING_MODE ((uint32_t)0x00000002)*/ -#endif - /** * @brief SD detection on its memory slot */ @@ -380,25 +374,5 @@ SD_Error SD_WaitWriteOperation(void); extern SD_CardInfo SDCardInfo; -#endif // _SDIO_SD_H_ -/** - * @} - */ +#endif // _SDIO_SD_H_ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/horus/sdram_driver.c b/radio/src/targets/horus/sdram_driver.c index 07ac07d27..0e796f390 100755 --- a/radio/src/targets/horus/sdram_driver.c +++ b/radio/src/targets/horus/sdram_driver.c @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "../horus/board_horus.h" +#include "board.h" #define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_16b diff --git a/radio/src/targets/horus/usb_conf.h b/radio/src/targets/horus/usb_conf.h deleted file mode 100644 index 4d0fd6737..000000000 --- a/radio/src/targets/horus/usb_conf.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef _USB_CONF_H_ -#define _USB_CONF_H_ - -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" - -/* USB Core and PHY interface configuration. - Tip: To avoid modifying these defines each time you need to change the USB - configuration, you can declare the needed define in your toolchain - compiler preprocessor. - */ -/****************** USB OTG FS PHY CONFIGURATION ******************************* -* The USB OTG FS Core supports one on-chip Full Speed PHY. -* -* The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor -* when FS core is used. -*******************************************************************************/ -#ifndef USE_USB_OTG_FS - #define USE_USB_OTG_FS // USB2.0 Full Speed == 12 Mbit -#endif /* USE_USB_OTG_FS */ - -#ifdef USE_USB_OTG_FS - #define USB_OTG_FS_CORE -#endif - -/******************************************************************************* -* FIFO Size Configuration in Device mode -* -* (i) Receive data FIFO size = RAM for setup packets + -* OUT endpoint control information + -* data OUT packets + miscellaneous -* Space = ONE 32-bits words -* --> RAM for setup packets = 10 spaces -* (n is the nbr of CTRL EPs the device core supports) -* --> OUT EP CTRL info = 1 space -* (one space for status information written to the FIFO along with each -* received packet) -* --> data OUT packets = (Largest Packet Size / 4) + 1 spaces -* (MINIMUM to receive packets) -* --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces -* (if high-bandwidth EP is enabled or multiple isochronous EPs) -* --> miscellaneous = 1 space per OUT EP -* (one space for transfer complete status information also pushed to the -* FIFO with each endpoint's last packet) -* -* (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for -* that particular IN EP. More space allocated in the IN EP Tx FIFO results -* in a better performance on the USB and can hide latencies on the AHB. -* -* (iii) TXn min size = 16 words. (n : Transmit FIFO index) -* (iv) When a TxFIFO is not used, the Configuration should be as follows: -* case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) -* --> Txm can use the space allocated for Txn. -* case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) -* --> Txn should be configured with the minimum space of 16 words -* (v) The FIFO is used optimally when used TxFIFOs are allocated in the top -* of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. -* (vi) In HS case12 FIFO locations should be reserved for internal DMA registers -* so total FIFO size should be 1012 Only instead of 1024 -*******************************************************************************/ - -/****************** USB OTG FS CONFIGURATION **********************************/ -#ifdef USB_OTG_FS_CORE - #define RX_FIFO_FS_SIZE 128 - #define TX0_FIFO_FS_SIZE 64 - #define TX1_FIFO_FS_SIZE 128 - #define TX2_FIFO_FS_SIZE 0 - #define TX3_FIFO_FS_SIZE 0 - -// #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT -// #define USB_OTG_FS_SOF_OUTPUT_ENABLED -#endif - -/****************** USB OTG MISC CONFIGURATION ********************************/ -#define VBUS_SENSING_ENABLED - -/****************** USB OTG MODE CONFIGURATION ********************************/ -//#define USE_HOST_MODE -#define USE_DEVICE_MODE -//#define USE_OTG_MODE - -#ifndef USB_OTG_FS_CORE - #ifndef USB_OTG_HS_CORE - #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined" - #endif -#endif - -#ifndef USE_DEVICE_MODE - #ifndef USE_HOST_MODE - #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined" - #endif -#endif - -#ifndef USE_USB_OTG_HS - #ifndef USE_USB_OTG_FS - #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined" - #endif -#else //USE_USB_OTG_HS - #ifndef USE_ULPI_PHY - #ifndef USE_EMBEDDED_PHY - #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined" - #endif - #endif -#endif - -/****************** C Compilers dependant keywords ****************************/ -/* In HS mode and when the DMA is used, all variables and data structures dealing - with the DMA during the transaction process should be 4-bytes aligned */ -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED - #if defined (__GNUC__) /* GNU Compiler */ - #define __ALIGN_END __attribute__ ((aligned (4))) - #define __ALIGN_BEGIN - #else - #define __ALIGN_END - #if defined (__CC_ARM) /* ARM Compiler */ - #define __ALIGN_BEGIN __align(4) - #elif defined (__ICCARM__) /* IAR Compiler */ - #define __ALIGN_BEGIN - #elif defined (__TASKING__) /* TASKING Compiler */ - #define __ALIGN_BEGIN __align(4) - #endif /* __CC_ARM */ - #endif /* __GNUC__ */ -#else - #define __ALIGN_BEGIN - #define __ALIGN_END -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ - -/* __packed keyword used to decrease the data type alignment to 1-byte */ -#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_ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/radio/src/targets/horus/usbd_conf.h b/radio/src/targets/horus/usbd_conf.h deleted file mode 100644 index 5dcfeeb45..000000000 --- a/radio/src/targets/horus/usbd_conf.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef _USBD_CONF_H_ -#define _USBD_CONF_H_ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_conf.h" - -#define USBD_CFG_MAX_NUM 1 -#define USBD_ITF_MAX_NUM 1 -#define USB_MAX_STR_DESC_SIZ 64 - -#define USBD_SELF_POWERED - -/* Class Layer Parameter */ - -#define MSC_IN_EP 0x81 -#define MSC_OUT_EP 0x01 -#define MSC_MAX_PACKET 64 - -#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 - -#define CDC_IN_EP 0x81 /* EP1 for data IN */ -#define CDC_OUT_EP 0x01 /* EP1 for data OUT */ -#define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ - -/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ -#define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ -#define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ - -#define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */ -#define APP_RX_DATA_SIZE 512 // USB serial port output buffer. TODO: tune this buffer size /* Total size of IN buffer: APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */ -#define APP_FOPS VCP_fops - -#endif // _USBD_CONF_H_ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/radio/src/targets/horus/usbd_desc.c b/radio/src/targets/horus/usbd_desc.c deleted file mode 100644 index 08b833c5f..000000000 --- a/radio/src/targets/horus/usbd_desc.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_desc.h" - -#include - -#include "board_horus.h" -#include "usbd_conf.h" -#include "usbd_core.h" -#include "usbd_req.h" -#include "usb_regs.h" - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY - * @{ - */ - - -/** @defgroup USBD_DESC - * @brief USBD descriptors module - * @{ - */ - -/** @defgroup USBD_DESC_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_Defines - * @{ - */ - -#define USBD_VID 0x0483 - -#define USBD_LANGID_STRING 0x409 -#define USBD_MANUFACTURER_STRING "FrSky" -#define USBD_SERIALNUMBER_FS_STRING "00000000001B" - - -#if defined(USB_JOYSTICK) - #define USBD_PID 0x5710 - #define USBD_PRODUCT_FS_STRING "FrSky Horus Joystick" - #define USBD_CONFIGURATION_FS_STRING "HID Config" - #define USBD_INTERFACE_FS_STRING "HID Interface" -#elif defined(USB_SERIAL) - #define USBD_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows - #define USBD_PRODUCT_FS_STRING "FrSky Horus Serial Port" - #define USBD_CONFIGURATION_FS_STRING "VSP Config" - #define USBD_INTERFACE_FS_STRING "VSP Interface" -#elif defined(USB_MASS_STORAGE) - #define USBD_PID 0x5720 - #define USBD_PRODUCT_FS_STRING "FrSky Horus Mass Storage" - #define USBD_CONFIGURATION_FS_STRING "MSC Config" - #define USBD_INTERFACE_FS_STRING "MSC Interface" -#endif - -const USBD_DEVICE USR_desc = -{ - USBD_USR_DeviceDescriptor, - USBD_USR_LangIDStrDescriptor, - USBD_USR_ManufacturerStrDescriptor, - USBD_USR_ProductStrDescriptor, - USBD_USR_SerialStrDescriptor, - USBD_USR_ConfigStrDescriptor, - USBD_USR_InterfaceStrDescriptor, -}; - -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN const uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = -{ - USB_SIZ_DEVICE_DESC, /*bLength */ - USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ - 0x00, /*bcdUSB */ - 0x02, - 0x00, /*bDeviceClass*/ - 0x00, /*bDeviceSubClass*/ - 0x00, /*bDeviceProtocol*/ - USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ - LOBYTE(USBD_VID), /*idVendor*/ - HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID), /*idVendor*/ - HIBYTE(USBD_PID), /*idVendor*/ - 0x00, /*bcdDevice rel. 2.00*/ - 0x02, - USBD_IDX_MFC_STR, /*Index of manufacturer string*/ - USBD_IDX_PRODUCT_STR, /*Index of product string*/ - USBD_IDX_SERIAL_STR, /*Index of serial number string*/ - USBD_CFG_MAX_NUM /*bNumConfigurations*/ -}; /* USB_DeviceDescriptor */ - -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = -{ - USB_LEN_DEV_QUALIFIER_DESC, - USB_DESC_TYPE_DEVICE_QUALIFIER, - 0x00, - 0x02, - 0x00, - 0x00, - 0x00, - 0x40, - 0x01, - 0x00, -}; - -/* USB Standard Device Descriptor */ -__ALIGN_BEGIN const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END = -{ - USB_SIZ_STRING_LANGID, - USB_DESC_TYPE_STRING, - LOBYTE(USBD_LANGID_STRING), - HIBYTE(USBD_LANGID_STRING), -}; - -/* -* @brief USBD_USR_DeviceDescriptor -* return the device descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) -{ - *length = sizeof(USBD_DeviceDesc); - memcpy(USBD_StrDesc, USBD_DeviceDesc, *length); - return USBD_StrDesc; -} - -/** -* @brief USBD_USR_LangIDStrDescriptor -* return the LangID string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) -{ - *length = sizeof(USBD_LangIDDesc); - memcpy(USBD_StrDesc, USBD_LangIDDesc, *length); - return USBD_StrDesc; -} - - -/** -* @brief USBD_USR_ProductStrDescriptor -* return the product string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -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; -} - -/** -* @brief USBD_USR_ManufacturerStrDescriptor -* return the manufacturer string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length) -{ - USBD_GetString ((uint8_t*)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); - return USBD_StrDesc; -} - -/** -* @brief USBD_USR_SerialStrDescriptor -* return the serial number string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -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; -} - -/** -* @brief USBD_USR_ConfigStrDescriptor -* return the configuration string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) -{ - USBD_GetString ((uint8_t *)USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); - return USBD_StrDesc; -} - - -/** -* @brief USBD_USR_InterfaceStrDescriptor -* return the interface string descriptor -* @param speed : current device speed -* @param length : pointer to data length variable -* @retval pointer to descriptor buffer -*/ -uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length) -{ - USBD_GetString ((uint8_t*)USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); - return USBD_StrDesc; -} - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/radio/src/targets/horus/usbd_hid_joystick.c b/radio/src/targets/horus/usbd_hid_joystick.c deleted file mode 100644 index fa2f40c77..000000000 --- a/radio/src/targets/horus/usbd_hid_joystick.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Includes ------------------------------------------------------------------*/ -#include "../horus/usbd_desc.h" -#include "usbd_hid_core.h" -#include "usbd_req.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 const 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 const 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 - * @{ - */ - -const 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 const 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; - const 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 const 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****/ diff --git a/radio/src/targets/horus/usbd_storage_msd.cpp b/radio/src/targets/horus/usbd_storage_msd.cpp deleted file mode 100644 index 14113f1ec..000000000 --- a/radio/src/targets/horus/usbd_storage_msd.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Includes ------------------------------------------------------------------*/ -#include "../../opentx.h" -#include "../../thirdparty/FatFs/diskio.h" -#include "board_horus.h" -#include "sdio_sd.h" - -#if defined(__cplusplus) && !defined(SIMU) -extern "C" { -#endif - -#include "usbd_msc_mem.h" -#include "usb_conf.h" - -/* SD card only when not running bootloader */ -#define STORAGE_LUN_NBR 1 -#define BLOCKSIZE 512 - -/* USB Mass storage Standard Inquiry Data */ -const unsigned char STORAGE_Inquirydata[] = {//36 - - /* LUN 0 */ - 0x00, - 0x80, - 0x02, - 0x02, - (USBD_STD_INQUIRY_LENGTH - 5), - 0x00, - 0x00, - 0x00, - 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ', /* Manufacturer : 8 bytes */ - 'H', 'o', 'r', 'u', 's', ' ', ' ', ' ', /* Product : 16 Bytes */ - 'R', 'a', 'd', 'i', 'o', ' ', ' ', ' ', - '1', '.', '0', '0', /* Version : 4 Bytes */ -}; - -int8_t STORAGE_Init (uint8_t lun); - -int8_t STORAGE_GetCapacity (uint8_t lun, - uint32_t *block_num, - uint32_t *block_size); - -int8_t STORAGE_IsReady (uint8_t lun); - -int8_t STORAGE_IsWriteProtected (uint8_t lun); - -int8_t STORAGE_Read (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len); - -int8_t STORAGE_Write (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len); - -int8_t STORAGE_GetMaxLun (void); - -USBD_STORAGE_cb_TypeDef USBD_MICRO_SDIO_fops = -{ - STORAGE_Init, - STORAGE_GetCapacity, - STORAGE_IsReady, - STORAGE_IsWriteProtected, - STORAGE_Read, - STORAGE_Write, - STORAGE_GetMaxLun, - (int8_t *)STORAGE_Inquirydata, -}; - -USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops = &USBD_MICRO_SDIO_fops; - -__IO uint32_t count = 0; - -#if defined(__cplusplus) && !defined(SIMU) -} -#endif - -int8_t STORAGE_Init (uint8_t lun) -{ - NVIC_InitTypeDef NVIC_InitStructure; - NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - -/* TODO if no SD ... if( SD_Init() != 0) - { - return (-1); - } -*/ - return (0); -} - -/** - * @brief return medium capacity and block size - * @param lun : logical unit number - * @param block_num : number of physical block - * @param block_size : size of a physical block - * @retval Status - */ -int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_size) -{ - if (!SD_CARD_PRESENT()) - return -1; - - *block_size = SDCardInfo.CardBlockSize; - *block_num = (SDCardInfo.CardCapacity / SDCardInfo.CardBlockSize) - 1; - - return 0; -} - -uint8_t lunReady[STORAGE_LUN_NBR] ; - -void usbPluggedIn() -{ - if (lunReady[0] == 0) { - lunReady[0] = 1; - } -} - -/** - * @brief check whether the medium is ready - * @param lun : logical unit number - * @retval Status - */ -int8_t STORAGE_IsReady (uint8_t lun) -{ - if (lunReady[0] == 0) - return -1 ; - return SD_CARD_PRESENT() ? 0 : -1; -} - -/** - * @brief check whether the medium is write-protected - * @param lun : logical unit number - * @retval Status - */ -int8_t STORAGE_IsWriteProtected (uint8_t lun) -{ - return 0; -} - -/** - * @brief Read data from the medium - * @param lun : logical unit number - * @param buf : Pointer to the buffer to save data - * @param blk_addr : address of 1st block to be read - * @param blk_len : nmber of blocks to be read - * @retval Status - */ - -int8_t STORAGE_Read (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len) -{ - - for (int retry=0; retry<3; retry++) { - if (SD_ReadMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) { - continue; - } - - SDTransferState State; - - SD_Error Status = SD_WaitReadOperation(); // Check if the Transfer is finished - - while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) - - if ((State == SD_TRANSFER_OK) && (Status == SD_OK)) { - return 0; - } - } - return -1; -} -/** - * @brief Write data to the medium - * @param lun : logical unit number - * @param buf : Pointer to the buffer to write from - * @param blk_addr : address of 1st block to be written - * @param blk_len : nmber of blocks to be read - * @retval Status - */ - -int8_t STORAGE_Write (uint8_t lun, - uint8_t *buf, - uint32_t blk_addr, - uint16_t blk_len) -{ - if (SD_WriteMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) - return -1; - - SDTransferState State; - - SD_Error Status = SD_WaitWriteOperation(); // Check if the Transfer is finished - - while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) - - if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) - return -1; - - return 0; -} - -/** - * @brief Return number of supported logical unit - * @param None - * @retval number of logical unit - */ - -int8_t STORAGE_GetMaxLun (void) -{ - return STORAGE_LUN_NBR - 1; -} diff --git a/radio/src/targets/horus/usbd_usr.cpp b/radio/src/targets/horus/usbd_usr.cpp deleted file mode 100644 index f130b5545..000000000 --- a/radio/src/targets/horus/usbd_usr.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Includes ------------------------------------------------------------------*/ -#include "../../opentx.h" - -extern "C" { -#include "usbd_usr.h" - -/* Points to the DEVICE_PROP structure of current device */ -/* The purpose of this register is to speed up the execution */ - - -const USBD_Usr_cb_TypeDef USR_cb = -{ - USBD_USR_Init, - USBD_USR_DeviceReset, - USBD_USR_DeviceConfigured, - USBD_USR_DeviceSuspended, - USBD_USR_DeviceResumed, - - USBD_USR_DeviceConnected, - USBD_USR_DeviceDisconnected, -}; -} - -/** -* @brief Whatever the user application needs to do when USB is initialised -* @param None -* @retval None -*/ -void USBD_USR_Init(void) -{ - -} - -/** -* @brief Displays the message on LCD on device reset event -* @param speed : device speed -* @retval None -*/ -void USBD_USR_DeviceReset (uint8_t speed) -{ - -} - - -/** -* @brief Displays the message on LCD on device config event -* @param None -* @retval Staus -*/ -void USBD_USR_DeviceConfigured (void) -{ - -} -/** -* @brief Displays the message on LCD on device suspend event -* @param None -* @retval None -*/ -void USBD_USR_DeviceSuspended(void) -{ - -} - - -/** -* @brief Displays the message on LCD on device resume event -* @param None -* @retval None -*/ -void USBD_USR_DeviceResumed(void) -{ - -} - -/** -* @brief USBD_USR_DeviceConnected -* Displays the message on LCD on device connection Event -* @param None -* @retval Staus -*/ -void USBD_USR_DeviceConnected (void) -{ - -} - - -/** -* @brief USBD_USR_DeviceDisonnected -* Displays the message on LCD on device disconnection Event -* @param None -* @retval Staus -*/ -void USBD_USR_DeviceDisconnected (void) -{ -#if !defined(BOOT) && defined(USB_MASS_STORAGE) - NVIC_SystemReset(); -#endif -} - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/mega2560/CMakeLists.txt b/radio/src/targets/mega2560/CMakeLists.txt index b4758e652..a2569c4da 100644 --- a/radio/src/targets/mega2560/CMakeLists.txt +++ b/radio/src/targets/mega2560/CMakeLists.txt @@ -5,11 +5,11 @@ set(MCU atmega2560) string(TOLOWER ${PCB} FLAVOUR) set(EEPROM EEPROM_RLC) add_definitions(-DEEPROM_VARIANT=0) -set(GUI_DIR 9x) +set(GUI_DIR 128x64) set(TARGET_DIR mega2560) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) add_definitions(-DPCB${PCB} -DCPUM2560 -DROTARY_ENCODERS=2) -set(TARGET_SRC ${TARGET_SRC} board_mega2560.cpp) +set(TARGET_SRC ${TARGET_SRC} board.cpp) set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/9x/lcd_driver.cpp) if(PWRMANAGE) diff --git a/radio/src/targets/mega2560/board_mega2560.cpp b/radio/src/targets/mega2560/board.cpp similarity index 100% rename from radio/src/targets/mega2560/board_mega2560.cpp rename to radio/src/targets/mega2560/board.cpp diff --git a/radio/src/targets/mega2560/board_mega2560.h b/radio/src/targets/mega2560/board.h similarity index 95% rename from radio/src/targets/mega2560/board_mega2560.h rename to radio/src/targets/mega2560/board.h index a62ff9d5f..68581c473 100644 --- a/radio/src/targets/mega2560/board_mega2560.h +++ b/radio/src/targets/mega2560/board.h @@ -21,7 +21,7 @@ #ifndef _BOARD_MEGA2560_H_ #define _BOARD_MEGA2560_H_ -#include "../common_avr/board_avr.h" +#include "../common/avr/board_avr.h" //Mods for futur use ? Beta tester love it //#define ROTENC_DIV2 // rotenc resolution/2 @@ -81,6 +81,7 @@ void boardInit(void); #define isBacklightEnable() PORTC & (1<CCR4 = (100-level)*color; diff --git a/radio/src/targets/simu/simpgmspace.h b/radio/src/targets/simu/simpgmspace.h index 6076f8f15..07ee28a8a 100644 --- a/radio/src/targets/simu/simpgmspace.h +++ b/radio/src/targets/simu/simpgmspace.h @@ -21,8 +21,6 @@ #ifndef _SIMPGMSPACE_H_ #define _SIMPGMSPACE_H_ -extern int g_snapshot_idx; - #ifndef __GNUC__ #include #define sleep(x) Sleep(x) diff --git a/radio/src/gui/taranis/helpers.cpp b/radio/src/targets/simu/simulcd.h similarity index 75% rename from radio/src/gui/taranis/helpers.cpp rename to radio/src/targets/simu/simulcd.h index f346aa56f..9d462ebc3 100644 --- a/radio/src/gui/taranis/helpers.cpp +++ b/radio/src/targets/simu/simulcd.h @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -18,10 +18,11 @@ * GNU General Public License for more details. */ -#include "opentx.h" +#ifndef _SIMULCD_H_ +#define _SIMULCD_H_ -uint8_t switchToMix(uint8_t source) -{ - div_t qr = div(source-1, 3); - return qr.quot+MIXSRC_FIRST_SWITCH; -} +extern int g_snapshot_idx; +extern bool simuLcdRefresh; +extern display_t simuLcdBuf[DISPLAY_BUFFER_SIZE]; + +#endif // _SIMULCD_H_ \ No newline at end of file diff --git a/radio/src/targets/sky9x/CMakeLists.txt b/radio/src/targets/sky9x/CMakeLists.txt index bdb7eca28..a99d8bb8c 100644 --- a/radio/src/targets/sky9x/CMakeLists.txt +++ b/radio/src/targets/sky9x/CMakeLists.txt @@ -35,13 +35,13 @@ set(MCU cortex-m3) set(SDCARD YES) set(HAPTIC YES) set(EEPROM EEPROM_RAW) -set(GUI_DIR 9x) +set(GUI_DIR 128x64) set(TARGET_DIR sky9x) set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) add_definitions(-DPCBSKY9X -DPPM_PIN_SERIAL) add_definitions(-DAUDIO -DVOICE -DRTCLOCK -DVARIO) add_definitions(-DEEPROM_VARIANT=0) -set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC} menu_general_hardware.cpp view_telemetry.cpp view_text.cpp view_about.cpp) +set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC} radio_hardware.cpp view_telemetry.cpp view_text.cpp view_about.cpp) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} core_cm3.c board_lowlevel.c crt.c vectors_sam3s.c) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp pwr_driver.cpp usb/device/core/USBD_UDP.c usb/device/core/USBDDriver.c @@ -53,7 +53,7 @@ set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp pwr_driver.cpp ) set(TARGET_SRC ${TARGET_SRC} - board_sky9x.cpp + board.cpp telemetry_driver.cpp serial2_driver.cpp adc_driver.cpp diff --git a/radio/src/targets/sky9x/MEDSdcard.c b/radio/src/targets/sky9x/MEDSdcard.c index bbbfd8c4a..77c7a414d 100644 --- a/radio/src/targets/sky9x/MEDSdcard.c +++ b/radio/src/targets/sky9x/MEDSdcard.c @@ -25,7 +25,7 @@ #include #include "debug.h" #include "diskio.h" -#include "board.h" +#include "board_lowlevel.h" #include "Media.h" //------------------------------------------------------------------------------ @@ -34,7 +34,6 @@ /// Number of SD Slots #define NUM_SD_SLOTS 1 -#define SD_BLOCK_SIZE 512 //------------------------------------------------------------------------------ /// Checks if the device is write protected. @@ -224,7 +223,7 @@ unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID) media->handler = 0; media->flush = 0; - media->blockSize = SD_BLOCK_SIZE; + media->blockSize = BLOCK_SIZE; media->baseAddress = 0; media->size = SD_GET_BLOCKNR(); diff --git a/radio/src/targets/sky9x/board_sky9x.cpp b/radio/src/targets/sky9x/board.cpp similarity index 100% rename from radio/src/targets/sky9x/board_sky9x.cpp rename to radio/src/targets/sky9x/board.cpp diff --git a/radio/src/targets/sky9x/board.h b/radio/src/targets/sky9x/board.h index 3f7f5be8d..15cb6d620 100644 --- a/radio/src/targets/sky9x/board.h +++ b/radio/src/targets/sky9x/board.h @@ -1,637 +1,313 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -// TODO merge this file with board_sky9x.h +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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 _BOARD_H_ -#define _BOARD_H_ +#ifndef _BOARD_SKY9X_H_ +#define _BOARD_SKY9X_H_ -#include +#include +#include "board_lowlevel.h" +#include "audio_driver.h" -#include "chip.h" +extern uint16_t ResetReason; +#define BOOTLOADER_SIZE 0x8000 +#define FIRMWARE_SIZE (256*1024) +#define FIRMWARE_ADDRESS 0x00400000 + +// Board driver +void boardInit(void); +#define boardOff() pwrOff() + +// Keys #if defined(REVA) -#include "AT91SAM3S2.h" + #define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR + #define KEYS_GPIO_REG_EXIT PIOA->PIO_PDSR + #define KEYS_GPIO_REG_UP PIOC->PIO_PDSR + #define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR + #define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR + #define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR + #define KEYS_GPIO_PIN_MENU 0x00000040 + #define KEYS_GPIO_PIN_EXIT 0x80000000 + #define KEYS_GPIO_PIN_UP 0x00000004 + #define KEYS_GPIO_PIN_DOWN 0x00000008 + #define KEYS_GPIO_PIN_RIGHT 0x00000010 + #define KEYS_GPIO_PIN_LEFT 0x00000020 #else -#include "AT91SAM3S4.h" + #define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR + #define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR + #define KEYS_GPIO_REG_UP PIOC->PIO_PDSR + #define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR + #define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR + #define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR + #define KEYS_GPIO_PIN_MENU 0x00000020 + #define KEYS_GPIO_PIN_EXIT 0x01000000 + #define KEYS_GPIO_PIN_UP 0x00000002 + #define KEYS_GPIO_PIN_DOWN 0x00000020 + #define KEYS_GPIO_PIN_RIGHT 0x00000010 + #define KEYS_GPIO_PIN_LEFT 0x00000008 #endif -#if !defined(SIMU) -#include "core_cm3.h" -#endif - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par -/// This page lists several definition related to the board description. -/// -/// Definitions -/// - BOARD_NAME - -/// Name of the board. -#define BOARD_NAME "AT91SAM3S-EK" -/// Board definition. -#define at91sam3sek -/// Family definition (already defined). -#define at91sam3s -/// Core definition -#define cortexm3 - -// TODO remove these definitions -//#define BOARD_REV_A -#define BOARD_REV_B - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_opfreq "SAM3S-EK - Operating frequencies" -/// This page lists several definition related to the board operating frequency -/// (when using the initialization done by board_lowlevel.c). -/// -/// !Definitions -/// - BOARD_MAINOSC -/// - BOARD_MCK - -/// Frequency of the board main oscillator. -#define BOARD_MAINOSC 12000000 - -/// Master clock frequency (when using board_lowlevel.c). -// #define BOARD_MCK 64000000 - -//------------------------------------------------------------------------------ -// ADC -//------------------------------------------------------------------------------ - -/// Startup time max, return from Idle mode (in �s) -#define ADC_STARTUP_TIME_MAX 15 -/// Track and hold Acquisition Time min (in ns) -#define ADC_TRACK_HOLD_TIME_MIN 1200 - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// USB attributes configuration descriptor (bus or self powered, remote wakeup) -//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP -#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_piodef "SAM3S-EK - PIO definitions" -/// This pages lists all the pio definitions contained in board.h. The constants -/// are named using the following convention: PIN_* for a constant which defines -/// a single Pin instance (but may include several PIOs sharing the same -/// controller), and PINS_* for a list of Pin instances. -/// -/// !ADC -/// - PIN_ADC0_AD0 -/// - PIN_ADC0_AD1 -/// - PIN_ADC0_AD2 -/// - PIN_ADC0_AD3 -/// - PIN_ADC0_AD4 -/// - PIN_ADC0_AD5 -/// - PIN_ADC0_AD6 -/// - PIN_ADC0_AD7 -/// - PINS_ADC0 -/// -/// !UART -/// - PINS_UART -/// -/// !EBI -/// - PIN_EBI_DATA_BUS -/// - PIN_EBI_NCS0 -/// - PIN_EBI_NRD -/// - PIN_EBI_NWE -/// - PIN_EBI_ADDR_BUS -/// - PIN_EBI_PSRAM_NBS -/// - PIN_EBI_A1 -/// - PIN_EBI_LCD_RS -/// -/// !LEDs -/// - PIN_LED_0 -/// - PIN_LED_1 -/// - PIN_LED_2 -/// - PINS_LEDS -/// -/// !MCI -/// - PINS_MCI -/// -/// !Push buttons -/// - PIN_PUSHBUTTON_1 -/// - PIN_PUSHBUTTON_2 -/// - PINS_PUSHBUTTONS -/// - PUSHBUTTON_BP1 -/// - PUSHBUTTON_BP2 -/// -/// !PWMC -/// - PIN_PWMC_PWMH0 -/// - PIN_PWMC_PWML0 -/// - PIN_PWMC_PWMH1 -/// - PIN_PWMC_PWML1 -/// - PIN_PWMC_PWMH2 -/// - PIN_PWMC_PWML2 -/// - PIN_PWMC_PWMH3 -/// - PIN_PWMC_PWML3 -/// - PIN_PWM_LED0 -/// - PIN_PWM_LED1 -/// - PIN_PWM_LED2 -/// - CHANNEL_PWM_LED0 -/// - CHANNEL_PWM_LED1 -/// - CHANNEL_PWM_LED2 -/// -/// !SPI -/// - PIN_SPI_MISO -/// - PIN_SPI_MOSI -/// - PIN_SPI_SPCK -/// - PINS_SPI -/// - PIN_SPI_NPCS0_PA11 -/// -/// ! SSC -/// - PIN_SSC_TD -/// - PIN_SSC_TK -/// - PIN_SSC_TF -/// - PINS_SSC_CODEC -/// -/// ! PCK0 -/// - PIN_PCK0 -/// -/// !TWI -/// - PIN_TWI_TWD0 -/// - PIN_TWI_TWCK0 -/// - PINS_TWI -/// -/// !USART0 -/// - PIN_USART0_RXD -/// - PIN_USART0_TXD -/// - PIN_USART0_CTS -/// - PIN_USART0_RTS -/// - PIN_USART0_SCK -/// -/// !USB -/// - PIN_USB_PULLUP -/// - -/// ADC_AD0 pin definition. -#define PIN_ADC0_AD0 {1 << 21, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD1 pin definition. -#define PIN_ADC0_AD1 {1 << 30, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD2 pin definition. -#define PIN_ADC0_AD2 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD3 pin definition. -#define PIN_ADC0_AD3 {1 << 4, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD4 pin definition. -#define PIN_ADC0_AD4 {1 << 15, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD5 pin definition. -#define PIN_ADC0_AD5 {1 << 16, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD6 pin definition. -#define PIN_ADC0_AD6 {1 << 17, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -/// ADC_AD7 pin definition. -#define PIN_ADC0_AD7 {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} - -/// Pins ADC -#define PINS_ADC PIN_ADC0_AD0, PIN_ADC0_AD1, PIN_ADC0_AD2, PIN_ADC0_AD3, PIN_ADC0_AD4, PIN_ADC0_AD5, PIN_ADC0_AD6, PIN_ADC0_AD7 - -/** UART pins (UTXD0 and URXD0) definitions, PA9,10. */ -#define PINS_UART {0x00000600, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} - -/// EBI -#define PIN_EBI_DATA_BUS {0xFF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NRD {1 << 11, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NWE {1 << 8, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} - -#define PIN_EBI_NCS0 {1 << 20, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_PSRAM_ADDR_BUS {0x3f00fff, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_PSRAM_NBS {1 << 7, PIOB, ID_PIOB, PIO_PERIPH_B, PIO_PULLUP}, \ - {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_A1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} - -#define PIN_EBI_NCS1 {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD CS pin */ -#define PIN_EBI_LCD_RS {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD RS pin */ - -#ifdef BOARD_REV_A -/** LED #0 pin definition. */ -#define PIN_LED_0 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #1 pin definition. */ -#define PIN_LED_1 {1 << 21, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #2 pin definition. */ -#define PIN_LED_2 {1 << 22, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -#endif -#ifdef BOARD_REV_B -/** LED #0 pin definition. */ -#define PIN_LED_0 {1 << 19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #1 pin definition. */ -#define PIN_LED_1 {1 << 20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} -/** LED #2 pin definition. */ -#define PIN_LED_2 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -#endif - -/** List of all LEDs definitions. */ -#define PINS_LEDS PIN_LED_0, PIN_LED_1, PIN_LED_2 - -/** MCI pins definition. */ -#define PINS_MCI {0x3fUL << 26, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_PULLUP} -/** MCI pin Card Detect. */ -#define PIN_MCI_CD {PIO_PB7, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP} - -/** Push button #0 definition. Attributes = pull-up + debounce + interrupt on rising edge. */ -#define PIN_PUSHBUTTON_1 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE} -/** Push button #1 definition. Attributes = pull-up + debounce + interrupt on falling edge. */ -#define PIN_PUSHBUTTON_2 {1 << 12, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE} -/** List of all push button definitions. */ -#define PINS_PUSHBUTTONS PIN_PUSHBUTTON_1, PIN_PUSHBUTTON_2 - -/** Push button #1 index. */ -#define PUSHBUTTON_BP1 0 -/** Push button #2 index. */ -#define PUSHBUTTON_BP2 1 - -/// Simulated joystick LEFT index. -#define JOYSTICK_LEFT 0 -/// Simulated joystick RIGHT index. -#define JOYSTICK_RIGHT 1 - -/** PWMC PWM0 pin definition. */ -#define PIN_PWMC_PWMH0 {1 << 18, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML0 {1 << 19, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} -/** PWMC PWM1 pin definition. */ -#define PIN_PWMC_PWMH1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML1 {1 << 20, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} -/** PWMC PWM2 pin definition. */ -#define PIN_PWMC_PWMH2 {1 << 20, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML2 {1 << 16, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT} -/** PWMC PWM3 pin definition. */ -#define PIN_PWMC_PWMH3 {1 << 21, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} -#define PIN_PWMC_PWML3 {1 << 15, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT} -/** PWM pin definition for LED0 */ -#define PIN_PWM_LED0 PIN_PWMC_PWMH0, PIN_PWMC_PWML0 -/** PWM pin definition for LED1 */ -#define PIN_PWM_LED1 PIN_PWMC_PWMH2, PIN_PWMC_PWML2 -/** PWM pin definition for LED2 */ -#define PIN_PWM_LED2 PIN_PWMC_PWMH3, PIN_PWMC_PWML3 -/** PWM channel for LED0 */ -#define CHANNEL_PWM_LED0 0 -/** PWM channel for LED1 */ -#define CHANNEL_PWM_LED1 2 -/** PWM channel for LED2 */ -#define CHANNEL_PWM_LED2 3 - -/** SPI MISO pin definition. */ -#define PIN_SPI_MISO {1 << 12, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** SPI MOSI pin definition. */ -#define PIN_SPI_MOSI {1 << 13, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** SPI SPCK pin definition. */ -#define PIN_SPI_SPCK {1 << 14, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** SPI chip select pin definition. */ -#define PIN_SPI_NPCS0_PA11 {1 << 11, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -/** List of SPI pin definitions (MISO, MOSI & SPCK). */ -#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SPCK - -/// SSC pins definition. -#define PIN_SSC_TD {0x1 << 26, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_SSC_TK {0x1 << 28, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_SSC_TF {0x1 << 30, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PINS_SSC_CODEC PIN_SSC_TD, PIN_SSC_TK, PIN_SSC_TF - -/// PCK0 -#define PIN_PCK0 {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} - -/// TWI pins definition. -#define TWI_V3XX -#define PIN_TWI_TWD0 {0x1 << 9, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_TWI_TWCK0 {0x1 << 10, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PINS_TWI0 PIN_TWI_TWD0, PIN_TWI_TWCK0 -#define PIN_TWI_TWD1 {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_TWI_TWCK1 {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PINS_TWI1 PIN_TWI_TWD1, PIN_TWI_TWCK1 - -/// USART0 -#define PIN_USART0_RXD {0x1 << 19, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_TXD {0x1 << 18, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_CTS {0x1 << 8, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_RTS {0x1 << 7, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART0_SCK {0x1 << 17, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} - -/// USART1 -#define PIN_USART1_RXD {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_TXD {0x1 << 22, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_CTS {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_RTS {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} -#define PIN_USART1_EN {0x1 << 23, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} - -/// USB VBus monitoring pin definition. -#ifdef BOARD_REV_A -#define PIN_USB_VBUS {1 << 23, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -#endif -#ifdef BOARD_REV_B -#define PIN_USB_VBUS {1 << 21, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} -#endif - -#define usbPlugged() (PIOC->PIO_PDSR & PIO_PC25) - -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// \par sam3s_ek_extcomp "SAM3S-EK - External components" -/// This page lists the definitions related to external on-board components -/// located in the board.h file for the AT91SAM3S-EK. -/// -/// !AT45 Dataflash Card -/// - BOARD_AT45_A_SPI_BASE -/// - BOARD_AT45_A_SPI_ID -/// - BOARD_AT45_A_SPI_PINS -/// - BOARD_AT45_A_SPI -/// - BOARD_AT45_A_NPCS -/// - BOARD_AT45_A_NPCS_PIN -/// -/// !AT45 Dataflash (serial onboard DataFlash) -/// - BOARD_AT45_B_SPI_BASE -/// - BOARD_AT45_B_SPI_ID -/// - BOARD_AT45_B_SPI_PINS -/// - BOARD_AT45_B_SPI -/// - BOARD_AT45_B_NPCS -/// - BOARD_AT45_B_NPCS_PIN -/// -/// !AT26 Serial Flash -/// - BOARD_AT26_A_SPI_BASE -/// - BOARD_AT26_A_SPI_ID -/// - BOARD_AT26_A_SPI_PINS -/// - BOARD_AT26_A_SPI -/// - BOARD_AT26_A_NPCS -/// - BOARD_AT26_A_NPCS_PIN -/// -/// !SD Card -/// - MCI2_INTERFACE -/// - BOARD_SD_MCI_BASE -/// - BOARD_SD_MCI_ID -/// - BOARD_SD_PINS -/// - BOARD_SD_SLOT -/// -/// !PSRAM -/// - BOARD_PSRAM_PINS -/// -/// !LCD -/// - BOARD_LCD_ILI9325 -/// - BOARD_LCD_PINS -/// - BOARD_BACKLIGHT_PIN -/// - BOARD_LCD_BASE -/// - BOARD_LCD_RS -/// - BOARD_LCD_WIDTH -/// - BOARD_LCD_HEIGHT -/// -/// !TouchScreen -/// - BOARD_TSC_ADS7843 -/// - PIN_TCS_IRQ -/// - PIN_TCS_BUSY -/// - BOARD_TSC_SPI_BASE -/// - BOARD_TSC_SPI_ID -/// - BOARD_TSC_SPI_PINS -/// - BOARD_TSC_NPCS -/// - BOARD_TSC_NPCS_PIN -/// -/// Base address of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_A_SPI_BASE SPI0 -///// Identifier of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_A_SPI_ID ID_SPI0 -///// Pins of the SPI peripheral connected to the dataflash. -//#define BOARD_AT45_A_SPI_PINS PINS_SPI0 -///// Dataflahs SPI number. -//#define BOARD_AT45_A_SPI 0 -///// Chip select connected to the dataflash. -//#define BOARD_AT45_A_NPCS 3 -///// Chip select pin connected to the dataflash. -//#define BOARD_AT45_A_NPCS_PIN PIN_SPI0_NPCS3 - -/// Base address of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_B_SPI_BASE SPI1 -///// Identifier of SPI peripheral connected to the dataflash. -//#define BOARD_AT45_B_SPI_ID ID_SPI1 -///// Pins of the SPI peripheral connected to the dataflash. -//#define BOARD_AT45_B_SPI_PINS PINS_SPI1 -///// Dataflahs SPI number. -//#define BOARD_AT45_B_SPI 1 -///// Chip select connected to the dataflash. -//#define BOARD_AT45_B_NPCS 3 -///// Chip select pin connected to the dataflash. -//#define BOARD_AT45_B_NPCS_PIN PIN_SPI1_NPCS3 - -/// Base address of SPI peripheral connected to the serialflash. -//#define BOARD_AT26_A_SPI_BASE SPI0 -///// Identifier of SPI peripheral connected to the serialflash. -//#define BOARD_AT26_A_SPI_ID ID_SPI0 -///// Pins of the SPI peripheral connected to the serialflash. -//#define BOARD_AT26_A_SPI_PINS PINS_SPI0 -///// Serialflash SPI number. -//#define BOARD_AT26_A_SPI 0 -///// Chip select connected to the serialflash. -//#define BOARD_AT26_A_NPCS 3 -///// Chip select pin connected to the serialflash. -//#define BOARD_AT26_A_NPCS_PIN PIN_SPI0_NPCS3 - -/// ISO7816 -/// - PIN_SMARTCARD_CONNECT -/// - PIN_ISO7816_RSTMC -/// - PINS_ISO7816 - -/// Smartcard detection pin -//#define PIN_SMARTCARD_CONNECT {1 << 5, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} -/// PIN used for reset the smartcard -//#define PIN_ISO7816_RSTMC {1 << 7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} -/// Pins used for connect the smartcard -//#define PINS_ISO7816 PIN_USART0_TXD, PIN_USART0_SCK, PIN_ISO7816_RSTMC - -/// Dma channel number -#define BOARD_MCI_DMA_CHANNEL 0 -/// MCI0 DMA hardware handshaking ID -#define DMA_HW_SRC_REQ_ID_MCI0 AT91C_HDMA_SRC_PER_0 -#define DMA_HW_DEST_REQ_ID_MCI0 AT91C_HDMA_DST_PER_0 -/// MCI1 DMA hardware handshaking ID -#define DMA_HW_SRC_REQ_ID_MCI1 AT91C_HDMA_SRC_PER_13 -#define DMA_HW_DEST_REQ_ID_MCI1 AT91C_HDMA_DST_PER_13 -/// SD DMA hardware handshaking ID -#define BOARD_SD_DMA_HW_SRC_REQ_ID DMA_HW_SRC_REQ_ID_MCI0 -#define BOARD_SD_DMA_HW_DEST_REQ_ID DMA_HW_DEST_REQ_ID_MCI0 - - -/// HS MCI interface -#define MCI2_INTERFACE -/// Base address of the MCI peripheral connected to the SD card. -#define BOARD_SD_MCI_BASE MCI0//MCI -///// Peripheral identifier of the MCI connected to the SD card. -#define BOARD_SD_MCI_ID AT91C_ID_MCI0 ID_MCI0 //ID_MCI -///// MCI pins that shall be configured to access the SD card. -#define BOARD_SD_PINS PINS_MCI -///// MCI slot to which the SD card is connected to. -#define BOARD_SD_SLOT MCI_SD_SLOTA -///// MCI Card Detect pin. -#define BOARD_SD_PIN_CD PIN_MCI_CD - -#define SD_CARD_PRESENT() ( (PIOB->PIO_PDSR & PIO_PB7) == 0 ) - -// States for initialising card -#define SD_ST_ERR -1 -#define SD_ST_STARTUP 0 -#define SD_ST_EMPTY 1 -#define SD_ST_INIT1 2 -#define SD_ST_INIT2 3 -#define SD_ST_IDLE 4 -#define SD_ST_READY 5 -#define SD_ST_IDENT 6 -#define SD_ST_STBY 7 -#define SD_ST_TRAN 8 -#define SD_ST_DATA 9 -#define SD_ST_MOUNTED 10 - -extern uint32_t Cmd_A41_resp; -extern int32_t Card_state; -extern volatile uint32_t Card_initialized; -extern uint32_t Card_CSD[4]; -extern uint32_t transSpeed; - -#define OCR_SD_CCS (1UL << 30) - -#define SD_CSD(csd, bitfield, bits) ((csd[3-(bitfield)/32] >> ((bitfield)%32)) & ((1 << (bits)) - 1)) - -#define SD_CSD_TRAN_SPEED(pSd) SD_CSD(pSd, 96, 8) ///< Max. data transfer rate - -#define SD_CSD_C_SIZE(pSd) ((SD_CSD(pSd, 72, 2) << 10) + \ - (SD_CSD(pSd, 64, 8) << 2) + \ - SD_CSD(pSd, 62, 2)) ///< Device size - -#define SD_CSD_C_SIZE_HC(csd) ((SD_CSD(csd, 64, 6) << 16) + \ - (SD_CSD(csd, 56, 8) << 8) + \ - SD_CSD(csd, 48, 8)) ///< Device size v2.0 High Capacity - -#define SD_CSD_C_SIZE_MULT(pSd) SD_CSD(pSd, 47, 3) ///< Device size multiplier - -#define SD_CSD_MULT(pSd) (1 << (SD_CSD_C_SIZE_MULT(pSd) + 2)) - -#define SD_CSD_READ_BL_LEN(pSd) SD_CSD(pSd, 80, 4) ///< Max. read data block length - -#define SD_CSD_BLKLEN(pSd) (1 << (SD_CSD_READ_BL_LEN(pSd) - 9)) - -#define SD_CSD_BLOCKNR(pSd) ((SD_CSD_C_SIZE(pSd) + 1) * SD_CSD_MULT(pSd)) * SD_CSD_BLKLEN(pSd) - -#define SD_CSD_BLOCKNR_HC(pSd) ((SD_CSD_C_SIZE_HC(pSd) + 1) * 1024) - -#if !defined(SIMU) - #define SD_IS_HC() (Cmd_A41_resp & OCR_SD_CCS) - #define SD_GET_BLOCKNR() (SD_IS_HC() ? (SD_CSD_BLOCKNR_HC(Card_CSD)) : (SD_CSD_BLOCKNR(Card_CSD))) - #define SD_GET_SPEED() (transSpeed) +#if defined(REVX) + #define TRIMS_GPIO_REG_LHL PIOB->PIO_PDSR + #define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_RVU PIOC->PIO_PDSR + #define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_LHR PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR + #define TRIMS_GPIO_REG_RVD PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR #else - #define SD_IS_HC() (0) - #define SD_GET_BLOCKNR() (0) - #define SD_GET_SPEED() (0) + #define TRIMS_GPIO_REG_LHL PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_RVU PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR + #define TRIMS_GPIO_REG_LHR PIOB->PIO_PDSR + #define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR + #define TRIMS_GPIO_REG_RVD PIOC->PIO_PDSR + #define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR #endif -//------------------------------------------------------------------------------ +#if defined(REVX) + #define TRIMS_GPIO_PIN_LHL 0x00000010 + #define TRIMS_GPIO_PIN_LVD 0x01000000 + #define TRIMS_GPIO_PIN_RVU 0x00000400 + #define TRIMS_GPIO_PIN_RHL 0x00000001 + #define TRIMS_GPIO_PIN_LHR 0x00800000 + #define TRIMS_GPIO_PIN_LVU 0x10000000 + #define TRIMS_GPIO_PIN_RVD 0x00000002 + #define TRIMS_GPIO_PIN_RHR 0x00000200 +#elif defined(REVA) + #define TRIMS_GPIO_PIN_LHL 0x00000080 + #define TRIMS_GPIO_PIN_LVD 0x08000000 + #define TRIMS_GPIO_PIN_RVU 0x40000000 + #define TRIMS_GPIO_PIN_RHL 0x20000000 + #define TRIMS_GPIO_PIN_LHR 0x00000010 + #define TRIMS_GPIO_PIN_LVU 0x10000000 + #define TRIMS_GPIO_PIN_RVD 0x00000400 + #define TRIMS_GPIO_PIN_RHR 0x00000200 +#else + #define TRIMS_GPIO_PIN_LHL 0x00800000 + #define TRIMS_GPIO_PIN_LVD 0x01000000 + #define TRIMS_GPIO_PIN_RVU 0x00000002 + #define TRIMS_GPIO_PIN_RHL 0x00000001 + #define TRIMS_GPIO_PIN_LHR 0x00000010 + #define TRIMS_GPIO_PIN_LVU 0x10000000 + #define TRIMS_GPIO_PIN_RVD 0x00000400 + #define TRIMS_GPIO_PIN_RHR 0x00000200 +#endif -//------------------------------------------------------------------------------ -/// \par sam3s_ek_mem "SAM3S-EK - Memories" -/// This page lists definitions related to internal & external on-board memories. -/// -/// !Embedded Flash -/// - BOARD_FLASH_EFC +void usbMassStorage(); -/// Internal SRAM address -#define AT91C_ISRAM AT91C_IRAM -#define AT91C_ISRAM_SIZE 0x00008000 +#define PIN_ENABLE 0x001 +#define PIN_PERIPHERAL 0x000 +#define PIN_INPUT 0x002 +#define PIN_OUTPUT 0x000 +#define PIN_PULLUP 0x004 +#define PIN_NO_PULLUP 0x000 +#define PIN_PULLDOWN 0x008 +#define PIN_NO_PULLDOWN 0x000 +#define PIN_PERI_MASK_L 0x010 +#define PIN_PERI_MASK_H 0x020 +#define PIN_PER_A 0x000 +#define PIN_PER_B 0x010 +#define PIN_PER_C 0x020 +#define PIN_PER_D 0x030 +#define PIN_PORT_MASK 0x0C0 +#define PIN_PORTA 0x000 +#define PIN_PORTB 0x040 +#define PIN_PORTC 0x080 +#define PIN_LOW 0x000 +#define PIN_HIGH 0x100 -#define AT91C_IFLASH_SIZE (0x40000) -#define AT91C_IFLASH_PAGE_SIZE (256) // Internal FLASH 0 Page Size: 256 bytes -#define AT91C_IFLASH_NB_OF_PAGES (1024) // Internal FLASH 0 Number of Pages: 512 -#define AT91C_IFLASH_LOCK_REGION_SIZE (16384) // Internal FLASH 0 Lock Region Size: 16 Kbytes -#define AT91C_IFLASH_NB_OF_LOCK_BITS (16) // Internal FLASH 0 Number of Lock Bits: 16 +// Telemetry port +#define SECOND_USART USART0 +#define SECOND_ID ID_USART0 +#define SECOND_PINS { PINS_USART0 } -//------------------------------------------------------------------------------ +void configure_pins( uint32_t pins, uint16_t config ); +uint16_t getCurrent(); +extern uint8_t temperature ; // Raw temp reading +extern uint8_t maxTemperature ; // Raw temp reading +uint8_t getTemperature(); -//------------------------------------------------------------------------------ -/// \section sam3s_ek_extcomp "SAM3S-EK - External components" -/// This page lists the definitions related to external on-board components -/// located in the board.h file for the SAM3S-EK. -/// -//------------------------------------------------------------------------------ +#define strcpy_P strcpy +#define strcat_P strcat -//------------------------------------------------------------------------------ -/// \par sam3s_ek_chipdef "SAM3S-EK - Individual chip definition" -/// This page lists the definitions related to different chip's definition -/// located in the board.h file for the SAM3S-EK. +#if !defined(REVA) +extern uint16_t Current_analogue; +extern uint16_t Current_max; +extern uint32_t Current_accumulator; +extern uint32_t Current_used; +extern uint16_t sessionTimer; +void calcConsumption(); +#endif -/// DBGU -#define BOARD_DBGU_ID ID_DBGU +// Trainer driver +#define SLAVE_MODE() (pwrCheck() == e_power_trainer) +void checkTrainerSettings(); +void init_trainer_capture(); -/// Rtc -#define BOARD_RTC_ID ID_RTC +// Write Flash driver +#define FLASH_PAGESIZE 256 +void writeFlash(uint32_t * address, uint32_t * buffer); -/// Twi eeprom -#define BOARD_ID_TWI_EEPROM ID_TWI1 -#define BOARD_BASE_TWI_EEPROM TWI1 -#define BOARD_PINS_TWI_EEPROM PINS_TWI1 +// Keys driver +extern uint32_t readKeys(); +extern uint32_t readTrims(); +#define TRIMS_PRESSED() readTrims() +#define KEYS_PRESSED() readKeys() -/// USART -#define BOARD_PIN_USART_RXD PIN_USART1_RXD -#define BOARD_PIN_USART_TXD PIN_USART1_TXD -#define BOARD_PIN_USART_CTS PIN_USART1_CTS -#define BOARD_PIN_USART_RTS PIN_USART1_RTS -#define BOARD_PIN_USART_EN PIN_USART1_EN -#define BOARD_USART_BASE USART1 -#define BOARD_ID_USART ID_USART1 +// Pulses driver +void init_no_pulses(uint32_t port); +void disable_no_pulses(uint32_t port); +void init_ppm(uint32_t port); +void disable_ppm(uint32_t port); +void init_pxx(uint32_t port); +void disable_pxx(uint32_t port); +void init_dsm2(uint32_t port); +void disable_dsm2(uint32_t port); -// BlueTooth -#define BT_USART UART1 -#define BT_ID ID_UART1 +// SD driver +#if defined(SIMU) + #define sdInit() + #define sdDone() +#else + #define sdPoll10ms() + void sdMountPoll(); + extern "C" { + void init_SDcard(); + void sdInit(); + void sdDone(); + uint32_t sd_card_ready(); + uint32_t sdMounted(); + } +#endif -//------------------------------------------------------------------------------ +// WDT driver +#if defined(SIMU) + #define wdt_disable() + #define wdt_enable(x) + #define wdt_reset() +#else + #define wdt_disable() + #define wdt_enable(x) WDT->WDT_MR = 0x3FFF207F + #define wdt_reset() WDT->WDT_CR = 0xA5000001 +#endif +// Backlight driver +#define setBacklight(xx) (PWM->PWM_CH_NUM[0].PWM_CDTYUPD = xx) +#define backlightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright) +#define backlightDisable() (PWM->PWM_CH_NUM[0].PWM_CDTY = 100) +#define isBacklightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100) -#define PIN_EBI_NANDOE {1 << 9, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDWE {1 << 10, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDCLE {1 << 17, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDALE {1 << 16, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} -#define PIN_EBI_NANDIO {0x000000FF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} - -/// Nandflash chip enable pin definition. -#define BOARD_NF_CE_PIN {1 << 14, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} -/// Nandflash ready/busy pin definition. -#define BOARD_NF_RB_PIN {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP} - -/// Nandflash controller peripheral pins definition. -#define PINS_NANDFLASH PIN_EBI_NANDIO, BOARD_NF_CE_PIN, BOARD_NF_RB_PIN, PIN_EBI_NANDOE, \ - PIN_EBI_NANDWE, PIN_EBI_NANDCLE, PIN_EBI_NANDALE - -/// Address for transferring command bytes to the nandflash. -#define BOARD_NF_COMMAND_ADDR 0x60400000 -/// Address for transferring address bytes to the nandflash. -#define BOARD_NF_ADDRESS_ADDR 0x60200000 -/// Address for transferring data bytes to the nandflash. -#define BOARD_NF_DATA_ADDR 0x60000000 - -extern uint32_t Master_frequency ; - -struct t_serial_tx -{ - uint8_t *buffer ; - uint16_t size ; - volatile uint16_t ready ; +// ADC driver +enum Analogs { + STICK1, + STICK2, + STICK3, + STICK4, + POT1, + POT2, + POT3, + POT_LAST = POT3, + TX_VOLTAGE, +#if !defined(REVA) + TX_CURRENT, +#endif + NUMBER_ANALOG }; +void adcInit(); +void adcRead(void); +uint16_t getAnalogValue(uint8_t index); +uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps +void setSticksGain(uint8_t gains); -#endif // _BOARD_H_ +// Buzzer driver +void buzzerSound(uint8_t duration); +void buzzerHeartbeat(); +#define BUZZER_HEARTBEAT buzzerHeartbeat + +// i2c driver +void i2cCheck(); + +// Coproc driver +void coprocInit(); +void coprocWriteData(uint8_t *data, uint32_t size); +void coprocReadData(bool onlytemp=false); +extern int8_t volumeRequired; +extern uint8_t Coproc_read; +extern int8_t Coproc_valid; +extern int8_t Coproc_temp; +extern int8_t Coproc_maxtemp; + +// Haptic driver +void hapticOff(void); +void hapticOn(uint32_t pwmPercent); + +// BlueTooth driver +#if defined(BLUETOOTH) +void btInit(); +void btTask(void* pdata); +void btPushByte(uint8_t data); +#endif + +// Power driver +void pwrInit(); +void pwrOff(); +uint32_t pwrCheck(); +uint32_t pwroffPressed(); +#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown) + +// EEPROM driver +void eepromInit(); +uint32_t eepromReadStatus(); +extern volatile uint32_t Spi_complete; +void eepromWriteEnable(); +void eepromBlockErase(uint32_t address); +void eepromReadArray(uint32_t address, uint8_t * buffer, uint32_t size); +void eepromByteProgram(uint32_t address, uint8_t * buffer, uint32_t size); + +// Rotary Encoder driver +void rotencInit(); +void rotencEnd(); + +#if ROTARY_ENCODERS > 0 + #define REA_DOWN() (!(PIOB->PIO_PDSR & 0x40)) +#else + #define REA_DOWN() (0) +#endif + +// Debug driver +void debugPutc(const char c); + +// Telemetry driver +void telemetryPortInit(uint32_t baudrate, int mode); +uint32_t telemetryTransmitPending(); +void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size); +void rxPdcUsart( void (*pChProcess)(uint8_t x) ); + +// Second UART driver +void serial2TelemetryInit(unsigned int protocol); +bool telemetrySecondPortReceive(uint8_t & data); + +extern const uint8_t BootCode[]; + +#endif // _BOARD_SKY9X_H_ diff --git a/radio/src/targets/sky9x/board_lowlevel.c b/radio/src/targets/sky9x/board_lowlevel.c index 57dc522db..d01d18a90 100644 --- a/radio/src/targets/sky9x/board_lowlevel.c +++ b/radio/src/targets/sky9x/board_lowlevel.c @@ -1,23 +1,23 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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. + */ + /** * \file * @@ -30,7 +30,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "board.h" +#include "board_lowlevel.h" /*---------------------------------------------------------------------------- * Local definitions diff --git a/radio/src/targets/sky9x/board_lowlevel.h b/radio/src/targets/sky9x/board_lowlevel.h new file mode 100644 index 000000000..4930fba43 --- /dev/null +++ b/radio/src/targets/sky9x/board_lowlevel.h @@ -0,0 +1,639 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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. + */ + +// TODO merge this file with board_sky9x.h + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +#include + +#include "chip.h" + +#if defined(REVA) +#include "AT91SAM3S2.h" +#else +#include "AT91SAM3S4.h" +#endif + +#if !defined(SIMU) +#include "core_cm3.h" +#endif + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \par +/// This page lists several definition related to the board description. +/// +/// Definitions +/// - BOARD_NAME + +/// Name of the board. +#define BOARD_NAME "AT91SAM3S-EK" +/// Board definition. +#define at91sam3sek +/// Family definition (already defined). +#define at91sam3s +/// Core definition +#define cortexm3 + +// TODO remove these definitions +//#define BOARD_REV_A +#define BOARD_REV_B + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \par sam3s_ek_opfreq "SAM3S-EK - Operating frequencies" +/// This page lists several definition related to the board operating frequency +/// (when using the initialization done by board_lowlevel.c). +/// +/// !Definitions +/// - BOARD_MAINOSC +/// - BOARD_MCK + +/// Frequency of the board main oscillator. +#define BOARD_MAINOSC 12000000 + +/// Master clock frequency (when using board_lowlevel.c). +// #define BOARD_MCK 64000000 + +//------------------------------------------------------------------------------ +// ADC +//------------------------------------------------------------------------------ + +/// Startup time max, return from Idle mode (in �s) +#define ADC_STARTUP_TIME_MAX 15 +/// Track and hold Acquisition Time min (in ns) +#define ADC_TRACK_HOLD_TIME_MIN 1200 + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// USB attributes configuration descriptor (bus or self powered, remote wakeup) +//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP +#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \par sam3s_ek_piodef "SAM3S-EK - PIO definitions" +/// This pages lists all the pio definitions contained in board.h. The constants +/// are named using the following convention: PIN_* for a constant which defines +/// a single Pin instance (but may include several PIOs sharing the same +/// controller), and PINS_* for a list of Pin instances. +/// +/// !ADC +/// - PIN_ADC0_AD0 +/// - PIN_ADC0_AD1 +/// - PIN_ADC0_AD2 +/// - PIN_ADC0_AD3 +/// - PIN_ADC0_AD4 +/// - PIN_ADC0_AD5 +/// - PIN_ADC0_AD6 +/// - PIN_ADC0_AD7 +/// - PINS_ADC0 +/// +/// !UART +/// - PINS_UART +/// +/// !EBI +/// - PIN_EBI_DATA_BUS +/// - PIN_EBI_NCS0 +/// - PIN_EBI_NRD +/// - PIN_EBI_NWE +/// - PIN_EBI_ADDR_BUS +/// - PIN_EBI_PSRAM_NBS +/// - PIN_EBI_A1 +/// - PIN_EBI_LCD_RS +/// +/// !LEDs +/// - PIN_LED_0 +/// - PIN_LED_1 +/// - PIN_LED_2 +/// - PINS_LEDS +/// +/// !MCI +/// - PINS_MCI +/// +/// !Push buttons +/// - PIN_PUSHBUTTON_1 +/// - PIN_PUSHBUTTON_2 +/// - PINS_PUSHBUTTONS +/// - PUSHBUTTON_BP1 +/// - PUSHBUTTON_BP2 +/// +/// !PWMC +/// - PIN_PWMC_PWMH0 +/// - PIN_PWMC_PWML0 +/// - PIN_PWMC_PWMH1 +/// - PIN_PWMC_PWML1 +/// - PIN_PWMC_PWMH2 +/// - PIN_PWMC_PWML2 +/// - PIN_PWMC_PWMH3 +/// - PIN_PWMC_PWML3 +/// - PIN_PWM_LED0 +/// - PIN_PWM_LED1 +/// - PIN_PWM_LED2 +/// - CHANNEL_PWM_LED0 +/// - CHANNEL_PWM_LED1 +/// - CHANNEL_PWM_LED2 +/// +/// !SPI +/// - PIN_SPI_MISO +/// - PIN_SPI_MOSI +/// - PIN_SPI_SPCK +/// - PINS_SPI +/// - PIN_SPI_NPCS0_PA11 +/// +/// ! SSC +/// - PIN_SSC_TD +/// - PIN_SSC_TK +/// - PIN_SSC_TF +/// - PINS_SSC_CODEC +/// +/// ! PCK0 +/// - PIN_PCK0 +/// +/// !TWI +/// - PIN_TWI_TWD0 +/// - PIN_TWI_TWCK0 +/// - PINS_TWI +/// +/// !USART0 +/// - PIN_USART0_RXD +/// - PIN_USART0_TXD +/// - PIN_USART0_CTS +/// - PIN_USART0_RTS +/// - PIN_USART0_SCK +/// +/// !USB +/// - PIN_USB_PULLUP +/// + +/// ADC_AD0 pin definition. +#define PIN_ADC0_AD0 {1 << 21, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD1 pin definition. +#define PIN_ADC0_AD1 {1 << 30, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD2 pin definition. +#define PIN_ADC0_AD2 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD3 pin definition. +#define PIN_ADC0_AD3 {1 << 4, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD4 pin definition. +#define PIN_ADC0_AD4 {1 << 15, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD5 pin definition. +#define PIN_ADC0_AD5 {1 << 16, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD6 pin definition. +#define PIN_ADC0_AD6 {1 << 17, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} +/// ADC_AD7 pin definition. +#define PIN_ADC0_AD7 {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} + +/// Pins ADC +#define PINS_ADC PIN_ADC0_AD0, PIN_ADC0_AD1, PIN_ADC0_AD2, PIN_ADC0_AD3, PIN_ADC0_AD4, PIN_ADC0_AD5, PIN_ADC0_AD6, PIN_ADC0_AD7 + +/** UART pins (UTXD0 and URXD0) definitions, PA9,10. */ +#define PINS_UART {0x00000600, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} + +/// EBI +#define PIN_EBI_DATA_BUS {0xFF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_NRD {1 << 11, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_NWE {1 << 8, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} + +#define PIN_EBI_NCS0 {1 << 20, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_PSRAM_ADDR_BUS {0x3f00fff, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_PSRAM_NBS {1 << 7, PIOB, ID_PIOB, PIO_PERIPH_B, PIO_PULLUP}, \ + {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_A1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} + +#define PIN_EBI_NCS1 {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD CS pin */ +#define PIN_EBI_LCD_RS {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD RS pin */ + +#ifdef BOARD_REV_A +/** LED #0 pin definition. */ +#define PIN_LED_0 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} +/** LED #1 pin definition. */ +#define PIN_LED_1 {1 << 21, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} +/** LED #2 pin definition. */ +#define PIN_LED_2 {1 << 22, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} +#endif +#ifdef BOARD_REV_B +/** LED #0 pin definition. */ +#define PIN_LED_0 {1 << 19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} +/** LED #1 pin definition. */ +#define PIN_LED_1 {1 << 20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} +/** LED #2 pin definition. */ +#define PIN_LED_2 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} +#endif + +/** List of all LEDs definitions. */ +#define PINS_LEDS PIN_LED_0, PIN_LED_1, PIN_LED_2 + +/** MCI pins definition. */ +#define PINS_MCI {0x3fUL << 26, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_PULLUP} +/** MCI pin Card Detect. */ +#define PIN_MCI_CD {PIO_PB7, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP} + +/** Push button #0 definition. Attributes = pull-up + debounce + interrupt on rising edge. */ +#define PIN_PUSHBUTTON_1 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE} +/** Push button #1 definition. Attributes = pull-up + debounce + interrupt on falling edge. */ +#define PIN_PUSHBUTTON_2 {1 << 12, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE} +/** List of all push button definitions. */ +#define PINS_PUSHBUTTONS PIN_PUSHBUTTON_1, PIN_PUSHBUTTON_2 + +/** Push button #1 index. */ +#define PUSHBUTTON_BP1 0 +/** Push button #2 index. */ +#define PUSHBUTTON_BP2 1 + +/// Simulated joystick LEFT index. +#define JOYSTICK_LEFT 0 +/// Simulated joystick RIGHT index. +#define JOYSTICK_RIGHT 1 + +/** PWMC PWM0 pin definition. */ +#define PIN_PWMC_PWMH0 {1 << 18, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} +#define PIN_PWMC_PWML0 {1 << 19, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} +/** PWMC PWM1 pin definition. */ +#define PIN_PWMC_PWMH1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} +#define PIN_PWMC_PWML1 {1 << 20, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} +/** PWMC PWM2 pin definition. */ +#define PIN_PWMC_PWMH2 {1 << 20, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} +#define PIN_PWMC_PWML2 {1 << 16, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT} +/** PWMC PWM3 pin definition. */ +#define PIN_PWMC_PWMH3 {1 << 21, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT} +#define PIN_PWMC_PWML3 {1 << 15, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT} +/** PWM pin definition for LED0 */ +#define PIN_PWM_LED0 PIN_PWMC_PWMH0, PIN_PWMC_PWML0 +/** PWM pin definition for LED1 */ +#define PIN_PWM_LED1 PIN_PWMC_PWMH2, PIN_PWMC_PWML2 +/** PWM pin definition for LED2 */ +#define PIN_PWM_LED2 PIN_PWMC_PWMH3, PIN_PWMC_PWML3 +/** PWM channel for LED0 */ +#define CHANNEL_PWM_LED0 0 +/** PWM channel for LED1 */ +#define CHANNEL_PWM_LED1 2 +/** PWM channel for LED2 */ +#define CHANNEL_PWM_LED2 3 + +/** SPI MISO pin definition. */ +#define PIN_SPI_MISO {1 << 12, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +/** SPI MOSI pin definition. */ +#define PIN_SPI_MOSI {1 << 13, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +/** SPI SPCK pin definition. */ +#define PIN_SPI_SPCK {1 << 14, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +/** SPI chip select pin definition. */ +#define PIN_SPI_NPCS0_PA11 {1 << 11, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +/** List of SPI pin definitions (MISO, MOSI & SPCK). */ +#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SPCK + +/// SSC pins definition. +#define PIN_SSC_TD {0x1 << 26, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_SSC_TK {0x1 << 28, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_SSC_TF {0x1 << 30, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PINS_SSC_CODEC PIN_SSC_TD, PIN_SSC_TK, PIN_SSC_TF + +/// PCK0 +#define PIN_PCK0 {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT} + +/// TWI pins definition. +#define TWI_V3XX +#define PIN_TWI_TWD0 {0x1 << 9, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_TWI_TWCK0 {0x1 << 10, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PINS_TWI0 PIN_TWI_TWD0, PIN_TWI_TWCK0 +#define PIN_TWI_TWD1 {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_TWI_TWCK1 {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PINS_TWI1 PIN_TWI_TWD1, PIN_TWI_TWCK1 + +/// USART0 +#define PIN_USART0_RXD {0x1 << 19, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART0_TXD {0x1 << 18, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART0_CTS {0x1 << 8, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART0_RTS {0x1 << 7, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART0_SCK {0x1 << 17, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} + +/// USART1 +#define PIN_USART1_RXD {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART1_TXD {0x1 << 22, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART1_CTS {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART1_RTS {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} +#define PIN_USART1_EN {0x1 << 23, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} + +/// USB VBus monitoring pin definition. +#ifdef BOARD_REV_A +#define PIN_USB_VBUS {1 << 23, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} +#endif +#ifdef BOARD_REV_B +#define PIN_USB_VBUS {1 << 21, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT} +#endif + +#define usbPlugged() (PIOC->PIO_PDSR & PIO_PC25) + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \par sam3s_ek_extcomp "SAM3S-EK - External components" +/// This page lists the definitions related to external on-board components +/// located in the board.h file for the AT91SAM3S-EK. +/// +/// !AT45 Dataflash Card +/// - BOARD_AT45_A_SPI_BASE +/// - BOARD_AT45_A_SPI_ID +/// - BOARD_AT45_A_SPI_PINS +/// - BOARD_AT45_A_SPI +/// - BOARD_AT45_A_NPCS +/// - BOARD_AT45_A_NPCS_PIN +/// +/// !AT45 Dataflash (serial onboard DataFlash) +/// - BOARD_AT45_B_SPI_BASE +/// - BOARD_AT45_B_SPI_ID +/// - BOARD_AT45_B_SPI_PINS +/// - BOARD_AT45_B_SPI +/// - BOARD_AT45_B_NPCS +/// - BOARD_AT45_B_NPCS_PIN +/// +/// !AT26 Serial Flash +/// - BOARD_AT26_A_SPI_BASE +/// - BOARD_AT26_A_SPI_ID +/// - BOARD_AT26_A_SPI_PINS +/// - BOARD_AT26_A_SPI +/// - BOARD_AT26_A_NPCS +/// - BOARD_AT26_A_NPCS_PIN +/// +/// !SD Card +/// - MCI2_INTERFACE +/// - BOARD_SD_MCI_BASE +/// - BOARD_SD_MCI_ID +/// - BOARD_SD_PINS +/// - BOARD_SD_SLOT +/// +/// !PSRAM +/// - BOARD_PSRAM_PINS +/// +/// !LCD +/// - BOARD_LCD_ILI9325 +/// - BOARD_LCD_PINS +/// - BOARD_BACKLIGHT_PIN +/// - BOARD_LCD_BASE +/// - BOARD_LCD_RS +/// - BOARD_LCD_WIDTH +/// - BOARD_LCD_HEIGHT +/// +/// !TouchScreen +/// - BOARD_TSC_ADS7843 +/// - PIN_TCS_IRQ +/// - PIN_TCS_BUSY +/// - BOARD_TSC_SPI_BASE +/// - BOARD_TSC_SPI_ID +/// - BOARD_TSC_SPI_PINS +/// - BOARD_TSC_NPCS +/// - BOARD_TSC_NPCS_PIN +/// +/// Base address of SPI peripheral connected to the dataflash. +//#define BOARD_AT45_A_SPI_BASE SPI0 +///// Identifier of SPI peripheral connected to the dataflash. +//#define BOARD_AT45_A_SPI_ID ID_SPI0 +///// Pins of the SPI peripheral connected to the dataflash. +//#define BOARD_AT45_A_SPI_PINS PINS_SPI0 +///// Dataflahs SPI number. +//#define BOARD_AT45_A_SPI 0 +///// Chip select connected to the dataflash. +//#define BOARD_AT45_A_NPCS 3 +///// Chip select pin connected to the dataflash. +//#define BOARD_AT45_A_NPCS_PIN PIN_SPI0_NPCS3 + +/// Base address of SPI peripheral connected to the dataflash. +//#define BOARD_AT45_B_SPI_BASE SPI1 +///// Identifier of SPI peripheral connected to the dataflash. +//#define BOARD_AT45_B_SPI_ID ID_SPI1 +///// Pins of the SPI peripheral connected to the dataflash. +//#define BOARD_AT45_B_SPI_PINS PINS_SPI1 +///// Dataflahs SPI number. +//#define BOARD_AT45_B_SPI 1 +///// Chip select connected to the dataflash. +//#define BOARD_AT45_B_NPCS 3 +///// Chip select pin connected to the dataflash. +//#define BOARD_AT45_B_NPCS_PIN PIN_SPI1_NPCS3 + +/// Base address of SPI peripheral connected to the serialflash. +//#define BOARD_AT26_A_SPI_BASE SPI0 +///// Identifier of SPI peripheral connected to the serialflash. +//#define BOARD_AT26_A_SPI_ID ID_SPI0 +///// Pins of the SPI peripheral connected to the serialflash. +//#define BOARD_AT26_A_SPI_PINS PINS_SPI0 +///// Serialflash SPI number. +//#define BOARD_AT26_A_SPI 0 +///// Chip select connected to the serialflash. +//#define BOARD_AT26_A_NPCS 3 +///// Chip select pin connected to the serialflash. +//#define BOARD_AT26_A_NPCS_PIN PIN_SPI0_NPCS3 + +/// ISO7816 +/// - PIN_SMARTCARD_CONNECT +/// - PIN_ISO7816_RSTMC +/// - PINS_ISO7816 + +/// Smartcard detection pin +//#define PIN_SMARTCARD_CONNECT {1 << 5, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT} +/// PIN used for reset the smartcard +//#define PIN_ISO7816_RSTMC {1 << 7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT} +/// Pins used for connect the smartcard +//#define PINS_ISO7816 PIN_USART0_TXD, PIN_USART0_SCK, PIN_ISO7816_RSTMC + +/// Dma channel number +#define BOARD_MCI_DMA_CHANNEL 0 +/// MCI0 DMA hardware handshaking ID +#define DMA_HW_SRC_REQ_ID_MCI0 AT91C_HDMA_SRC_PER_0 +#define DMA_HW_DEST_REQ_ID_MCI0 AT91C_HDMA_DST_PER_0 +/// MCI1 DMA hardware handshaking ID +#define DMA_HW_SRC_REQ_ID_MCI1 AT91C_HDMA_SRC_PER_13 +#define DMA_HW_DEST_REQ_ID_MCI1 AT91C_HDMA_DST_PER_13 +/// SD DMA hardware handshaking ID +#define BOARD_SD_DMA_HW_SRC_REQ_ID DMA_HW_SRC_REQ_ID_MCI0 +#define BOARD_SD_DMA_HW_DEST_REQ_ID DMA_HW_DEST_REQ_ID_MCI0 + + +/// HS MCI interface +#define MCI2_INTERFACE +/// Base address of the MCI peripheral connected to the SD card. +#define BOARD_SD_MCI_BASE MCI0//MCI +///// Peripheral identifier of the MCI connected to the SD card. +#define BOARD_SD_MCI_ID AT91C_ID_MCI0 ID_MCI0 //ID_MCI +///// MCI pins that shall be configured to access the SD card. +#define BOARD_SD_PINS PINS_MCI +///// MCI slot to which the SD card is connected to. +#define BOARD_SD_SLOT MCI_SD_SLOTA +///// MCI Card Detect pin. +#define BOARD_SD_PIN_CD PIN_MCI_CD + +#define BLOCK_SIZE 512 +#define MSD_BUFFER_SIZE (12*BLOCK_SIZE) // Size of the MSD IO buffer in bytes (6K, more the better) +#define SD_CARD_PRESENT() ( (PIOB->PIO_PDSR & PIO_PB7) == 0 ) + +// States for initialising card +#define SD_ST_ERR -1 +#define SD_ST_STARTUP 0 +#define SD_ST_EMPTY 1 +#define SD_ST_INIT1 2 +#define SD_ST_INIT2 3 +#define SD_ST_IDLE 4 +#define SD_ST_READY 5 +#define SD_ST_IDENT 6 +#define SD_ST_STBY 7 +#define SD_ST_TRAN 8 +#define SD_ST_DATA 9 +#define SD_ST_MOUNTED 10 + +extern uint32_t Cmd_A41_resp; +extern int32_t Card_state; +extern volatile uint32_t Card_initialized; +extern uint32_t Card_CSD[4]; +extern uint32_t transSpeed; + +#define OCR_SD_CCS (1UL << 30) + +#define SD_CSD(csd, bitfield, bits) ((csd[3-(bitfield)/32] >> ((bitfield)%32)) & ((1 << (bits)) - 1)) + +#define SD_CSD_TRAN_SPEED(pSd) SD_CSD(pSd, 96, 8) ///< Max. data transfer rate + +#define SD_CSD_C_SIZE(pSd) ((SD_CSD(pSd, 72, 2) << 10) + \ + (SD_CSD(pSd, 64, 8) << 2) + \ + SD_CSD(pSd, 62, 2)) ///< Device size + +#define SD_CSD_C_SIZE_HC(csd) ((SD_CSD(csd, 64, 6) << 16) + \ + (SD_CSD(csd, 56, 8) << 8) + \ + SD_CSD(csd, 48, 8)) ///< Device size v2.0 High Capacity + +#define SD_CSD_C_SIZE_MULT(pSd) SD_CSD(pSd, 47, 3) ///< Device size multiplier + +#define SD_CSD_MULT(pSd) (1 << (SD_CSD_C_SIZE_MULT(pSd) + 2)) + +#define SD_CSD_READ_BL_LEN(pSd) SD_CSD(pSd, 80, 4) ///< Max. read data block length + +#define SD_CSD_BLKLEN(pSd) (1 << (SD_CSD_READ_BL_LEN(pSd) - 9)) + +#define SD_CSD_BLOCKNR(pSd) ((SD_CSD_C_SIZE(pSd) + 1) * SD_CSD_MULT(pSd)) * SD_CSD_BLKLEN(pSd) + +#define SD_CSD_BLOCKNR_HC(pSd) ((SD_CSD_C_SIZE_HC(pSd) + 1) * 1024) + +#if !defined(SIMU) + #define SD_IS_HC() (Cmd_A41_resp & OCR_SD_CCS) + #define SD_GET_BLOCKNR() (SD_IS_HC() ? (SD_CSD_BLOCKNR_HC(Card_CSD)) : (SD_CSD_BLOCKNR(Card_CSD))) + #define SD_GET_SPEED() (transSpeed) +#else + #define SD_IS_HC() (0) + #define SD_GET_BLOCKNR() (0) + #define SD_GET_SPEED() (0) +#endif + +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \par sam3s_ek_mem "SAM3S-EK - Memories" +/// This page lists definitions related to internal & external on-board memories. +/// +/// !Embedded Flash +/// - BOARD_FLASH_EFC + +/// Internal SRAM address +#define AT91C_ISRAM AT91C_IRAM +#define AT91C_ISRAM_SIZE 0x00008000 + +#define AT91C_IFLASH_SIZE (0x40000) +#define AT91C_IFLASH_PAGE_SIZE (256) // Internal FLASH 0 Page Size: 256 bytes +#define AT91C_IFLASH_NB_OF_PAGES (1024) // Internal FLASH 0 Number of Pages: 512 +#define AT91C_IFLASH_LOCK_REGION_SIZE (16384) // Internal FLASH 0 Lock Region Size: 16 Kbytes +#define AT91C_IFLASH_NB_OF_LOCK_BITS (16) // Internal FLASH 0 Number of Lock Bits: 16 + +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +/// \section sam3s_ek_extcomp "SAM3S-EK - External components" +/// This page lists the definitions related to external on-board components +/// located in the board.h file for the SAM3S-EK. +/// +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \par sam3s_ek_chipdef "SAM3S-EK - Individual chip definition" +/// This page lists the definitions related to different chip's definition +/// located in the board.h file for the SAM3S-EK. + +/// DBGU +#define BOARD_DBGU_ID ID_DBGU + +/// Rtc +#define BOARD_RTC_ID ID_RTC + +/// Twi eeprom +#define BOARD_ID_TWI_EEPROM ID_TWI1 +#define BOARD_BASE_TWI_EEPROM TWI1 +#define BOARD_PINS_TWI_EEPROM PINS_TWI1 + +/// USART +#define BOARD_PIN_USART_RXD PIN_USART1_RXD +#define BOARD_PIN_USART_TXD PIN_USART1_TXD +#define BOARD_PIN_USART_CTS PIN_USART1_CTS +#define BOARD_PIN_USART_RTS PIN_USART1_RTS +#define BOARD_PIN_USART_EN PIN_USART1_EN +#define BOARD_USART_BASE USART1 +#define BOARD_ID_USART ID_USART1 + +// BlueTooth +#define BT_USART UART1 +#define BT_ID ID_UART1 + +//------------------------------------------------------------------------------ + + +#define PIN_EBI_NANDOE {1 << 9, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_NANDWE {1 << 10, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_NANDCLE {1 << 17, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_NANDALE {1 << 16, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} +#define PIN_EBI_NANDIO {0x000000FF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} + +/// Nandflash chip enable pin definition. +#define BOARD_NF_CE_PIN {1 << 14, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} +/// Nandflash ready/busy pin definition. +#define BOARD_NF_RB_PIN {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP} + +/// Nandflash controller peripheral pins definition. +#define PINS_NANDFLASH PIN_EBI_NANDIO, BOARD_NF_CE_PIN, BOARD_NF_RB_PIN, PIN_EBI_NANDOE, \ + PIN_EBI_NANDWE, PIN_EBI_NANDCLE, PIN_EBI_NANDALE + +/// Address for transferring command bytes to the nandflash. +#define BOARD_NF_COMMAND_ADDR 0x60400000 +/// Address for transferring address bytes to the nandflash. +#define BOARD_NF_ADDRESS_ADDR 0x60200000 +/// Address for transferring data bytes to the nandflash. +#define BOARD_NF_DATA_ADDR 0x60000000 + +extern uint32_t Master_frequency ; + +struct t_serial_tx +{ + uint8_t *buffer ; + uint16_t size ; + volatile uint16_t ready ; +}; + +#endif // _BOARD_H_ diff --git a/radio/src/targets/sky9x/board_sky9x.h b/radio/src/targets/sky9x/board_sky9x.h deleted file mode 100644 index bac9482bc..000000000 --- a/radio/src/targets/sky9x/board_sky9x.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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 _BOARD_SKY9X_H_ -#define _BOARD_SKY9X_H_ - -#include -#include "board.h" -#include "audio_driver.h" - -extern uint16_t ResetReason; - -#define BOOTLOADER_SIZE 0x8000 -#define FIRMWARE_SIZE (256*1024) -#define FIRMWARE_ADDRESS 0x00400000 - -// Board driver -void boardInit(void); -#define boardOff() pwrOff() - -// Keys -#if defined(REVA) - #define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR - #define KEYS_GPIO_REG_EXIT PIOA->PIO_PDSR - #define KEYS_GPIO_REG_UP PIOC->PIO_PDSR - #define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR - #define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR - #define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR - #define KEYS_GPIO_PIN_MENU 0x00000040 - #define KEYS_GPIO_PIN_EXIT 0x80000000 - #define KEYS_GPIO_PIN_UP 0x00000004 - #define KEYS_GPIO_PIN_DOWN 0x00000008 - #define KEYS_GPIO_PIN_RIGHT 0x00000010 - #define KEYS_GPIO_PIN_LEFT 0x00000020 -#else - #define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR - #define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR - #define KEYS_GPIO_REG_UP PIOC->PIO_PDSR - #define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR - #define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR - #define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR - #define KEYS_GPIO_PIN_MENU 0x00000020 - #define KEYS_GPIO_PIN_EXIT 0x01000000 - #define KEYS_GPIO_PIN_UP 0x00000002 - #define KEYS_GPIO_PIN_DOWN 0x00000020 - #define KEYS_GPIO_PIN_RIGHT 0x00000010 - #define KEYS_GPIO_PIN_LEFT 0x00000008 -#endif - -#if defined(REVX) - #define TRIMS_GPIO_REG_LHL PIOB->PIO_PDSR - #define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_RVU PIOC->PIO_PDSR - #define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_LHR PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR - #define TRIMS_GPIO_REG_RVD PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR -#else - #define TRIMS_GPIO_REG_LHL PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_RVU PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR - #define TRIMS_GPIO_REG_LHR PIOB->PIO_PDSR - #define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR - #define TRIMS_GPIO_REG_RVD PIOC->PIO_PDSR - #define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR -#endif - -#if defined(REVX) - #define TRIMS_GPIO_PIN_LHL 0x00000010 - #define TRIMS_GPIO_PIN_LVD 0x01000000 - #define TRIMS_GPIO_PIN_RVU 0x00000400 - #define TRIMS_GPIO_PIN_RHL 0x00000001 - #define TRIMS_GPIO_PIN_LHR 0x00800000 - #define TRIMS_GPIO_PIN_LVU 0x10000000 - #define TRIMS_GPIO_PIN_RVD 0x00000002 - #define TRIMS_GPIO_PIN_RHR 0x00000200 -#elif defined(REVA) - #define TRIMS_GPIO_PIN_LHL 0x00000080 - #define TRIMS_GPIO_PIN_LVD 0x08000000 - #define TRIMS_GPIO_PIN_RVU 0x40000000 - #define TRIMS_GPIO_PIN_RHL 0x20000000 - #define TRIMS_GPIO_PIN_LHR 0x00000010 - #define TRIMS_GPIO_PIN_LVU 0x10000000 - #define TRIMS_GPIO_PIN_RVD 0x00000400 - #define TRIMS_GPIO_PIN_RHR 0x00000200 -#else - #define TRIMS_GPIO_PIN_LHL 0x00800000 - #define TRIMS_GPIO_PIN_LVD 0x01000000 - #define TRIMS_GPIO_PIN_RVU 0x00000002 - #define TRIMS_GPIO_PIN_RHL 0x00000001 - #define TRIMS_GPIO_PIN_LHR 0x00000010 - #define TRIMS_GPIO_PIN_LVU 0x10000000 - #define TRIMS_GPIO_PIN_RVD 0x00000400 - #define TRIMS_GPIO_PIN_RHR 0x00000200 -#endif - -void usbMassStorage(); - -#define PIN_ENABLE 0x001 -#define PIN_PERIPHERAL 0x000 -#define PIN_INPUT 0x002 -#define PIN_OUTPUT 0x000 -#define PIN_PULLUP 0x004 -#define PIN_NO_PULLUP 0x000 -#define PIN_PULLDOWN 0x008 -#define PIN_NO_PULLDOWN 0x000 -#define PIN_PERI_MASK_L 0x010 -#define PIN_PERI_MASK_H 0x020 -#define PIN_PER_A 0x000 -#define PIN_PER_B 0x010 -#define PIN_PER_C 0x020 -#define PIN_PER_D 0x030 -#define PIN_PORT_MASK 0x0C0 -#define PIN_PORTA 0x000 -#define PIN_PORTB 0x040 -#define PIN_PORTC 0x080 -#define PIN_LOW 0x000 -#define PIN_HIGH 0x100 - -// Telemetry port -#define SECOND_USART USART0 -#define SECOND_ID ID_USART0 -#define SECOND_PINS { PINS_USART0 } - -void configure_pins( uint32_t pins, uint16_t config ); -uint16_t getCurrent(); - -extern uint8_t temperature ; // Raw temp reading -extern uint8_t maxTemperature ; // Raw temp reading -uint8_t getTemperature(); - -#define strcpy_P strcpy -#define strcat_P strcat - -#if !defined(REVA) -extern uint16_t Current_analogue; -extern uint16_t Current_max; -extern uint32_t Current_accumulator; -extern uint32_t Current_used; -extern uint16_t sessionTimer; -void calcConsumption(); -#endif - -// Trainer driver -#define SLAVE_MODE() (pwrCheck() == e_power_trainer) -void checkTrainerSettings(); -void init_trainer_capture(); - -// 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(); -#define TRIMS_PRESSED() readTrims() -#define KEYS_PRESSED() readKeys() - -// Pulses driver -void init_no_pulses(uint32_t port); -void disable_no_pulses(uint32_t port); -void init_ppm(uint32_t port); -void disable_ppm(uint32_t port); -void init_pxx(uint32_t port); -void disable_pxx(uint32_t port); -void init_dsm2(uint32_t port); -void disable_dsm2(uint32_t port); - -// SD driver -#if defined(SIMU) - #define sdInit() - #define sdDone() -#else - #define sdPoll10ms() - void sdMountPoll(); - extern "C" { - void init_SDcard(); - void sdInit(); - void sdDone(); - uint32_t sd_card_ready(); - uint32_t sdMounted(); - } -#endif - -// WDT driver -#if defined(SIMU) - #define wdt_disable() - #define wdt_enable(x) - #define wdt_reset() -#else - #define wdt_disable() - #define wdt_enable(x) WDT->WDT_MR = 0x3FFF207F - #define wdt_reset() WDT->WDT_CR = 0xA5000001 -#endif - -// Backlight driver -#define setBacklight(xx) (PWM->PWM_CH_NUM[0].PWM_CDTYUPD = xx) -#define backlightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright) -#define backlightDisable() (PWM->PWM_CH_NUM[0].PWM_CDTY = 100) -#define isBacklightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100) - -// ADC driver -enum Analogs { - STICK1, - STICK2, - STICK3, - STICK4, - POT1, - POT2, - POT3, - POT_LAST = POT3, - TX_VOLTAGE, -#if !defined(REVA) - TX_CURRENT, -#endif - NUMBER_ANALOG -}; -void adcInit(); -void adcRead(void); -uint16_t getAnalogValue(uint8_t index); -uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps -void setSticksGain(uint8_t gains); - -// Buzzer driver -void buzzerSound(uint8_t duration); -void buzzerHeartbeat(); -#define BUZZER_HEARTBEAT buzzerHeartbeat - -// i2c driver -void i2cCheck(); - -// Coproc driver -void coprocInit(); -void coprocWriteData(uint8_t *data, uint32_t size); -void coprocReadData(bool onlytemp=false); -extern int8_t volumeRequired; -extern uint8_t Coproc_read; -extern int8_t Coproc_valid; -extern int8_t Coproc_temp; -extern int8_t Coproc_maxtemp; - -// Haptic driver -void hapticOff(void); -void hapticOn(uint32_t pwmPercent); - -// BlueTooth driver -#if defined(BLUETOOTH) -void btInit(); -void btTask(void* pdata); -void btPushByte(uint8_t data); -#endif - -// Power driver -void pwrInit(); -void pwrOff(); -uint32_t pwrCheck(); -uint32_t pwroffPressed(); -#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown) - -// EEPROM driver -void eepromInit(); -uint32_t eepromReadStatus(); -extern volatile uint32_t Spi_complete; -void eepromWriteEnable(); -void eepromBlockErase(uint32_t address); -void eepromReadArray(uint32_t address, uint8_t * buffer, uint32_t size); -void eepromByteProgram(uint32_t address, uint8_t * buffer, uint32_t size); - -// Rotary Encoder driver -void rotencInit(); -void rotencEnd(); - -#if ROTARY_ENCODERS > 0 - #define REA_DOWN() (!(PIOB->PIO_PDSR & 0x40)) -#else - #define REA_DOWN() (0) -#endif - -// Debug driver -void debugPutc(const char c); - -// Telemetry driver -void telemetryPortInit(uint32_t baudrate, int mode); -uint32_t telemetryTransmitPending(); -void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size); -void rxPdcUsart( void (*pChProcess)(uint8_t x) ); - -// Second UART driver -void serial2TelemetryInit(unsigned int protocol); -bool telemetrySecondPortReceive(uint8_t & data); - -extern const uint8_t BootCode[]; - -#endif // _BOARD_SKY9X_H_ diff --git a/radio/src/targets/sky9x/i2c_driver.cpp b/radio/src/targets/sky9x/i2c_driver.cpp index ae961a91f..ec89958be 100644 --- a/radio/src/targets/sky9x/i2c_driver.cpp +++ b/radio/src/targets/sky9x/i2c_driver.cpp @@ -21,7 +21,7 @@ #include "opentx.h" #include "i2c_driver.h" #include "twi.h" -#include "board.h" +#include "board_lowlevel.h" #include "stdlib.h" #define I2C_CLK_FAST 400000 diff --git a/radio/src/targets/sky9x/massstorage.cpp b/radio/src/targets/sky9x/massstorage.cpp index 756144506..8cedee5d3 100644 --- a/radio/src/targets/sky9x/massstorage.cpp +++ b/radio/src/targets/sky9x/massstorage.cpp @@ -1,24 +1,24 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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" #ifndef SIMU @@ -27,12 +27,6 @@ extern "C" { extern unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID); } -/** Size of one block in bytes. */ -#define BLOCK_SIZE 512 - -/** Size of the MSD IO buffer in bytes (6K, more the better). */ -#define MSD_BUFFER_SIZE (12*BLOCK_SIZE) - /** LUN read/write buffer. */ unsigned char msdBuffer[MSD_BUFFER_SIZE]; diff --git a/radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h b/radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h index 68e27d901..22fc1a410 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h +++ b/radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h @@ -42,7 +42,7 @@ #ifndef USBDEVICEDESCRIPTOR_H #define USBDEVICEDESCRIPTOR_H -#include "../../../board.h" +#include "board_lowlevel.h" //------------------------------------------------------------------------------ // Definitions //------------------------------------------------------------------------------ diff --git a/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c b/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c index c0a61bf3b..09a2a4709 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c +++ b/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c @@ -39,7 +39,7 @@ //------------------------------------------------------------------------------ #include -#include "../../../board.h" +#include "radio/src/targets/sky9x/board_lowlevel.h" #include "../../../usb/device/core/USBD.h" //------------------------------------------------------------------------------ diff --git a/radio/src/targets/sky9x/usb/device/core/USBDDriver.c b/radio/src/targets/sky9x/usb/device/core/USBDDriver.c index f510d700f..2d2da3017 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBDDriver.c +++ b/radio/src/targets/sky9x/usb/device/core/USBDDriver.c @@ -42,7 +42,7 @@ #include "../../../usb/common/core/USBSetAddressRequest.h" #include "../../../usb/common/core/USBSetConfigurationRequest.h" #include "../../../usb/device/core/USBD.h" -#include "../../../board.h" +#include "board_lowlevel.h" #include "../../../usb/common/core/USBConfigurationDescriptor.h" #include "../../../usb/common/core/USBDeviceDescriptor.h" #include "../../../usb/common/core/USBDeviceQualifierDescriptor.h" diff --git a/radio/src/targets/sky9x/usb/device/core/USBD_UDP.c b/radio/src/targets/sky9x/usb/device/core/USBD_UDP.c index 80794ed04..c827c977a 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBD_UDP.c +++ b/radio/src/targets/sky9x/usb/device/core/USBD_UDP.c @@ -41,7 +41,7 @@ // Headers //------------------------------------------------------------------------------ -#include "../../../board.h" +#include "board_lowlevel.h" #include "../../../usb/common/core/USBEndpointDescriptor.h" #include "../../../usb/common/core/USBGenericRequest.h" #include "../../../usb/device/core/USBD.h" diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c b/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c index 181eacfe7..11b01d368 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c +++ b/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c @@ -36,7 +36,7 @@ #include "../../../usb/common/core/USBStringDescriptor.h" #include "../../../usb/common/massstorage/MSDeviceDescriptor.h" #include "../../../usb/common/massstorage/MSInterfaceDescriptor.h" -#include "../../../board.h" +#include "board_lowlevel.h" #include "../../../usb/common/core/USBConfigurationDescriptor.h" #include "../../../usb/common/core/USBDeviceDescriptor.h" #include "../../../usb/common/core/USBEndpointDescriptor.h" diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c b/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c index 9e40abc9c..3e8b3ba9e 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c +++ b/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c @@ -33,7 +33,7 @@ #include "../../../usb/device/massstorage/MSDLun.h" - +#include "board_lowlevel.h" #include "../../../usb/device/core/USBD.h" #include "debug.h" @@ -42,7 +42,7 @@ //------------------------------------------------------------------------------ /// Default LUN block size in bytes -#define DEFAULT_LUN_BLOCK_SIZE 512 +#define DEFAULT_LUN_BLOCK_SIZE BLOCK_SIZE //------------------------------------------------------------------------------ // Internal variables diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index 31a27d399..5f57f9984 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -1,15 +1,16 @@ -option(PCBREV "PCB Revision" REVPLUS) option(SHUTDOWN_CONFIRMATION "Shutdown confirmation" OFF) option(LCD_DUAL_BUFFER "Dual LCD Buffer" OFF) option(TARANIS_INTERNAL_PPM "Taranis internal module hack to output PPM" OFF) -if(PCBREV STREQUAL REV9E) +add_definitions(-DUSB_NAME="FrSky Taranis") + +if(PCB STREQUAL X9E) option(STICKS "Sticks type" STANDARD) set(CPU_TYPE STM32F4) set(LINKER_SCRIPT targets/taranis/stm32f4_flash.ld) set(HAPTIC YES) set(LUA_EXPORT lua_export_taranis_x9e) - set(FLAVOUR taranisx9e) - add_definitions(-DSTM32F40_41xxx -DREVPLUS -DREV9E) + set(FLAVOUR x9e) + add_definitions(-DSTM32F40_41xxx -DPCBX9E) add_definitions(-DEEPROM_VARIANT=32768) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} @@ -20,38 +21,70 @@ if(PCBREV STREQUAL REV9E) if(STICKS STREQUAL HORUS) add_definitions(-DHORUS_STICKS) endif() -elseif(PCBREV STREQUAL REVPLUS) + set(GUI_DIR 212x64) + set(GUI_SRC ${GUI_SRC} bmp.cpp) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps) + set(VIRTUAL_INPUTS YES) +elseif(PCB STREQUAL X9D+) set(CPU_TYPE STM32F2) set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) set(HAPTIC YES) set(LUA_EXPORT lua_export_taranis) - set(FLAVOUR taranisplus) - add_definitions(-DREVPLUS) + set(FLAVOUR x9d+) + add_definitions(-DPCBX9DP) add_definitions(-DEEPROM_VARIANT=0) -else() + set(GUI_DIR 212x64) + set(GUI_SRC ${GUI_SRC} bmp.cpp) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps) + set(VIRTUAL_INPUTS YES) +elseif(PCB STREQUAL X9D) set(CPU_TYPE STM32F2) set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) set(HAPTIC NO) set(LUA_EXPORT lua_export_taranis) - set(FLAVOUR taranis) + set(FLAVOUR x9d) add_definitions(-DEEPROM_VARIANT=0) + set(GUI_DIR 212x64) + set(GUI_SRC ${GUI_SRC} bmp.cpp) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps) + set(VIRTUAL_INPUTS YES) +elseif(PCB STREQUAL X7D) + set(CPU_TYPE STM32F2) + set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) + set(HAPTIC NO) + set(LUA_EXPORT lua_export_taranis) + set(FLAVOUR x7d) + add_definitions(-DPCBX7D) + add_definitions(-DEEPROM_VARIANT=0) + set(GUI_DIR 128x64) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) + set(VIRTUAL_INPUTS NO) endif() + set(HSE_VALUE 12000000) set(SDCARD YES) set(EEPROM EEPROM_RLC) -set(GUI_DIR taranis) set(TARGET_DIR taranis) -set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps) -set(VIRTUAL_INPUTS YES) add_definitions(-DPCBTARANIS -DPPM_PIN_TIMER) add_definitions(-DAUDIO -DVOICE -DRTCLOCK) add_definitions(-DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DVARIO) -set(GUI_SRC ${GUI_SRC} bmp.cpp menu_model_inputs.cpp menu_model_mixes.cpp menu_model_display.cpp menu_general_diagkeys.cpp menu_general_diaganas.cpp menu_general_hardware.cpp view_channels.cpp view_telemetry.cpp view_text.cpp view_about.cpp) +set(GUI_SRC ${GUI_SRC} + model_inputs.cpp + model_mixes.cpp + model_display.cpp + radio_diagkeys.cpp + radio_diaganas.cpp + radio_hardware.cpp + view_channels.cpp + view_telemetry.cpp + view_text.cpp + view_about.cpp + ) set(TARGET_SRC ${TARGET_SRC} - board_taranis.cpp + board.cpp extmodule_driver.cpp - rtc_driver.cpp + ../common/arm/stm32/rtc_driver.cpp ) set(FIRMWARE_SRC ${FIRMWARE_SRC} @@ -62,7 +95,6 @@ set(FIRMWARE_TARGET_SRC lcd_driver.cpp delays.c i2c_driver.cpp - usb_driver.c pwr_driver.c configure_pins.cpp flash_driver.cpp diff --git a/radio/src/targets/taranis/adc_driver.cpp b/radio/src/targets/taranis/adc_driver.cpp index a5ff35924..bc6b9de31 100644 --- a/radio/src/targets/taranis/adc_driver.cpp +++ b/radio/src/targets/taranis/adc_driver.cpp @@ -29,11 +29,11 @@ #define SAMPTIME 2 // sample time = 28 cycles #define SAMPTIME_LONG 3 // sample time = 56 cycles -#if defined(REV9E) && defined(HORUS_STICKS) +#if defined(PCBX9E) && defined(HORUS_STICKS) const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,-1,1, -1,1,1,1, -1}; -#elif defined(REV9E) +#elif defined(PCBX9E) const int8_t ana_direction[NUMBER_ANALOG] = {1,1,-1,-1, -1,-1,-1,1, -1,1,1,1, -1}; -#elif defined(REVPLUS) +#elif defined(PCBX9DP) const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,-1, -1,1, 1}; #elif defined(REV4a) const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,0, -1,1, 1}; @@ -41,7 +41,7 @@ const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,0, -1,1, 1}; #endif -#if defined(REV9E) +#if defined(PCBX9E) #define NUMBER_ANALOG_ADC1 10 #define NUMBER_ANALOG_ADC3 3 // mapping from adcValues order to enum Analogs @@ -57,12 +57,12 @@ uint16_t adcValues[NUMBER_ANALOG] __DMA; void adcInit() { -#if defined(REV9E) +#if defined(PCBX9E) configure_pins(ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_SLIDER3, PIN_ANALOG | PIN_PORTA); configure_pins(ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_SLIDER4, PIN_ANALOG | PIN_PORTB); configure_pins(ADC_GPIO_PIN_POT3 | ADC_GPIO_PIN_POT4 | ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2 | ADC_GPIO_PIN_BATT, PIN_ANALOG | PIN_PORTC); configure_pins(ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2, PIN_ANALOG | PIN_PORTF); -#elif defined(REVPLUS) +#elif defined(PCBX9DP) configure_pins(ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT1, PIN_ANALOG | PIN_PORTA); configure_pins(ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT3, PIN_ANALOG | PIN_PORTB); configure_pins(ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2 | ADC_GPIO_PIN_BATT, PIN_ANALOG | PIN_PORTC); @@ -75,7 +75,7 @@ void adcInit() ADC1->CR1 = ADC_CR1_SCAN; ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; ADC1->SQR1 = (NUMBER_ANALOG_ADC1-1) << 20; // bits 23:20 = number of conversions -#if defined(REV9E) +#if defined(PCBX9E) ADC1->SQR2 = (ADC_CHANNEL_POT4<<0) + (ADC_CHANNEL_SLIDER3<<5) + (ADC_CHANNEL_SLIDER4<<10) + (ADC_CHANNEL_BATT<<15); // conversions 7 and more ADC1->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT2<<20) + (ADC_CHANNEL_POT3<<25); // conversions 1 to 6 #else @@ -93,7 +93,7 @@ void adcInit() ADC1_DMA_Stream->NDTR = NUMBER_ANALOG_ADC1; ADC1_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0; -#if defined(REV9E) +#if defined(PCBX9E) ADC3->CR1 = ADC_CR1_SCAN; ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; ADC3->SQR1 = (NUMBER_ANALOG_ADC3-1) << 20; // NUMBER_ANALOG Channels @@ -118,15 +118,15 @@ void adcSingleRead() ADC1_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA ADC1->CR2 |= (uint32_t) ADC_CR2_SWSTART; -#if defined(REV9E) +#if defined(PCBX9E) ADC3_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA ADC3->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ); ADC3_DMA->LIFCR = ADC3_DMA_FLAGS; // Write ones to clear bits ADC3_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA ADC3->CR2 |= (uint32_t)ADC_CR2_SWSTART; -#endif // defined(REV9E) +#endif -#if defined(REV9E) +#if defined(PCBX9E) for (unsigned int i=0; i<10000; i++) { if ((ADC1_DMA->HISR & ADC1_DMA_FLAG_TC) && (ADC3_DMA->LISR & ADC3_DMA_FLAG_TC)) { break; @@ -180,7 +180,7 @@ uint16_t getAnalogValue(uint8_t index) // which produces ghost readings on these inputs. return 0; } -#if defined(REV9E) +#if defined(PCBX9E) index = ana_mapping[index]; #endif if (ana_direction[index] < 0) diff --git a/radio/src/targets/taranis/aspi.c b/radio/src/targets/taranis/aspi.c index dd481612c..d379a3138 100644 --- a/radio/src/targets/taranis/aspi.c +++ b/radio/src/targets/taranis/aspi.c @@ -1,24 +1,24 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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" +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * 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.h" /** **********send command to lcd************** @@ -39,7 +39,7 @@ return readValue; }*/ -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) void AspiCmd(uint8_t Command_Byte) { LCD_A0_LOW() ; diff --git a/radio/src/targets/taranis/audio_driver.cpp b/radio/src/targets/taranis/audio_driver.cpp index 24762dd8b..e81fea863 100644 --- a/radio/src/targets/taranis/audio_driver.cpp +++ b/radio/src/targets/taranis/audio_driver.cpp @@ -122,7 +122,7 @@ extern "C" void AUDIO_TIM_IRQHandler() { DEBUG_INTERRUPT(INT_AUDIO); DAC->CR &= ~DAC_CR_DMAEN1 ; // Stop DMA requests -#if !defined(REV9E) +#if !defined(PCBX9E) DAC->CR &= ~DAC_CR_DMAUDRIE1 ; // Stop underrun interrupt #endif DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag diff --git a/radio/src/targets/taranis/board_taranis.cpp b/radio/src/targets/taranis/board.cpp similarity index 93% rename from radio/src/targets/taranis/board_taranis.cpp rename to radio/src/targets/taranis/board.cpp index e626a242e..8488b9ce8 100644 --- a/radio/src/targets/taranis/board_taranis.cpp +++ b/radio/src/targets/taranis/board.cpp @@ -98,7 +98,7 @@ void interrupt5ms() per10ms(); } -#if defined(REV9E) +#if defined(PCBX9E) checkRotaryEncoder(); #endif } @@ -112,16 +112,16 @@ extern "C" void INTERRUPT_5MS_IRQHandler() } #endif -#if defined(REV9E) +#if defined(PCBX9E) #define PWR_PRESS_DURATION_MIN 200 // 2s #define PWR_PRESS_DURATION_MAX 500 // 5s const pm_uchar bmp_startup[] PROGMEM = { - #include "../../bitmaps/taranis/startup.lbm" + #include "startup.lbm" }; const pm_uchar bmp_lock[] PROGMEM = { - #include "../../bitmaps/taranis/lock.lbm" + #include "lock.lbm" }; #endif @@ -132,8 +132,8 @@ void boardInit() RCC_APB1PeriphClockCmd(LCD_RCC_APB1Periph | AUDIO_RCC_APB1Periph | BACKLIGHT_RCC_APB1Periph | INTERRUPT_5MS_APB1Periph | TIMER_2MHz_APB1Periph | I2C_RCC_APB1Periph | SD_RCC_APB1Periph | TRAINER_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph | SERIAL_RCC_APB1Periph, ENABLE); RCC_APB2PeriphClockCmd(BACKLIGHT_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph | EXTMODULE_RCC_APB2Periph | HEARTBEAT_RCC_APB2Periph, ENABLE); -#if !defined(REV9E) - // some REV9E boards need that the pwrInit() is moved a little bit later +#if !defined(PCBX9E) + // some X9E boards need that the pwrInit() is moved a little bit later pwrInit(); #endif @@ -152,7 +152,7 @@ void boardInit() hapticInit(); #endif -#if defined(REV9E) +#if defined(PCBX9E) bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE); #endif @@ -160,7 +160,7 @@ void boardInit() 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); #endif -#if defined(REV9E) +#if defined(PCBX9E) if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) { lcdClear(); lcdDrawBitmap(76, 2, bmp_lock, 0, 60); @@ -210,11 +210,11 @@ void boardInit() void boardOff() { BACKLIGHT_OFF(); -#if defined(REV9E) +#if defined(PCBX9E) toplcdOff(); #endif -#if defined(REV9E) +#if defined(PCBX9E) while (pwrPressed()) { wdt_reset(); } diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board.h similarity index 88% rename from radio/src/targets/taranis/board_taranis.h rename to radio/src/targets/taranis/board.h index 58fb93cb9..36f8d28f8 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board.h @@ -27,7 +27,7 @@ extern "C" { #endif -#if defined(REV9E) +#if defined(PCBX9E) #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" @@ -80,7 +80,7 @@ extern "C" { #define BOOTLOADER_SIZE 0x8000 #define FIRMWARE_ADDRESS 0x08000000 -#if defined(REV9E) +#if defined(PCBX9E) #define PERI1_FREQUENCY 42000000 #define PERI2_FREQUENCY 84000000 #else @@ -130,7 +130,7 @@ extern uint16_t sessionTimer; #define SLAVE_MODE() (g_model.trainerMode == TRAINER_MODE_SLAVE) -#if defined(REV9E) +#if defined(PCBX9E) #define TRAINER_CONNECTED() (true) #else #define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_GPIO_DETECT, TRAINER_GPIO_PIN_DETECT) == Bit_RESET) @@ -157,27 +157,29 @@ void delay_ms(uint32_t ms); void getCPUUniqueID(char * s); // SD driver +#define BLOCK_SIZE 512 /* Block Size in Bytes */ #if !defined(SIMU) || defined(SIMU_DISKIO) - uint32_t sdIsHC(void); - uint32_t sdGetSpeed(void); - #define SD_IS_HC() (sdIsHC()) - #define SD_GET_SPEED() (sdGetSpeed()) - #define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors()) +uint32_t sdIsHC(void); +uint32_t sdGetSpeed(void); +#define SD_IS_HC() (sdIsHC()) +#define SD_GET_SPEED() (sdGetSpeed()) +#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors()) #else - #define SD_IS_HC() (0) - #define SD_GET_SPEED() (0) +#define SD_IS_HC() (0) +#define SD_GET_SPEED() (0) #endif - +#define __disk_read disk_read +#define __disk_write disk_write #if defined(SIMU) - #define sdInit() - #define sdDone() +#define sdInit() +#define sdDone() #else - void sdInit(void); - void sdDone(void); - void sdPoll10ms(void); - #define sdMountPoll() - uint32_t sdMounted(void); - #define SD_CARD_PRESENT() (~SD_GPIO_PRESENT->IDR & SD_GPIO_PIN_PRESENT) +void sdInit(void); +void sdDone(void); +void sdPoll10ms(void); +#define sdMountPoll() +uint32_t sdMounted(void); +#define SD_CARD_PRESENT() (~SD_GPIO_PRESENT->IDR & SD_GPIO_PIN_PRESENT) #endif // Flash Write driver @@ -224,7 +226,7 @@ uint32_t readTrims(void); #define TRIMS_PRESSED() (readTrims()) #define KEYS_PRESSED() (readKeys()) -#if defined(REV9E) +#if defined(PCBX9E) // Rotary Encoder driver extern int32_t rotencValue; void rotencInit(void); @@ -233,6 +235,7 @@ void checkRotaryEncoder(void); #endif // WDT driver +#define WDTO_500MS 500 #if defined(WATCHDOG_DISABLED) || defined(SIMU) #define wdt_enable(x) #define wdt_reset() @@ -255,7 +258,7 @@ enum Analogs { POT1, POT2, POT3, - #if defined(REV9E) + #if defined(PCBX9E) POT4, POT_LAST = POT4, #else @@ -263,7 +266,7 @@ enum Analogs { #endif SLIDER1, SLIDER2, - #if defined(REV9E) + #if defined(PCBX9E) SLIDER3, SLIDER4, #endif @@ -287,7 +290,7 @@ void pwrInit(void); uint32_t pwrCheck(void); void pwrOn(void); void pwrOff(void); -#if defined(REV9E) +#if defined(PCBX9E) uint32_t pwrPressed(void); uint32_t pwrPressedDuration(void); #define pwroffPressed() pwrPressed() @@ -298,7 +301,7 @@ uint32_t pwroffPressed(void); // Backlight driver void backlightInit(void); -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) void turnBacklightOn(uint8_t level, uint8_t color); void turnBacklightOff(void); #define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor) @@ -317,6 +320,9 @@ int usbPlugged(void); void usbInit(void); void usbDeInit(void); void usbSerialPutc(uint8_t c); +#define USB_NAME "FrSky Taranis" +#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */ +#define USB_PRODUCT 'T', 'a', 'r', 'a', 'n', 'i', 's', ' ' /* 8 Bytes */ #if defined(__cplusplus) && !defined(SIMU) } @@ -353,7 +359,7 @@ int32_t getVolume(void); // Haptic driver void hapticInit(void); void hapticOff(void); -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) void hapticOn(uint32_t pwmPercent); #else void hapticOn(void); @@ -384,7 +390,7 @@ void lcdInitFinish(void); void lcdOff(void); // Top LCD driver -#if defined(REV9E) +#if defined(PCBX9E) void toplcdInit(void); void toplcdOff(void); void toplcdRefreshStart(void); diff --git a/radio/src/targets/taranis/bootloader/CMakeLists.txt b/radio/src/targets/taranis/bootloader/CMakeLists.txt index 86af4bbcd..0b95b945d 100644 --- a/radio/src/targets/taranis/bootloader/CMakeLists.txt +++ b/radio/src/targets/taranis/bootloader/CMakeLists.txt @@ -2,10 +2,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -if(PCBREV STREQUAL REV9E) +if(PCB STREQUAL X9E) set(BOOTLOADER_SRC ${BOOTLOADER_SRC} - ../system_stm32f4xx.c + ../../common/arm/stm32/f4/system_stm32f4xx.c ../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c @@ -16,7 +16,7 @@ if(PCBREV STREQUAL REV9E) else() set(BOOTLOADER_SRC ${BOOTLOADER_SRC} - ../system_stm32f2xx.c + ../../common/arm/stm32/f2/system_stm32f2xx.c ../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c @@ -28,8 +28,8 @@ endif() set(BOOTLOADER_SRC ${BOOTLOADER_SRC} - ../../../gui/taranis/lcd.cpp - ../../../gui/taranis/fonts.cpp + ../../../gui/212x64/lcd.cpp + ../../../gui/212x64/fonts.cpp ../../../keys.cpp ../../../strhelpers.cpp ../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_core.c @@ -50,13 +50,13 @@ set(BOOTLOADER_SRC ../i2c_driver.cpp ../flash_driver.cpp ../diskio.cpp - ../usbd_usr.cpp - ../usbd_storage_msd.cpp + ../../common/arm/stm32/usbd_usr.cpp + ../../common/arm/stm32/usbd_storage_msd.cpp ../delays.c - ../usbd_desc.c + ../../common/arm/stm32/usbd_desc.c ../aspi.c - ../usb_bsp.c - ../usb_driver.c + ../../common/arm/stm32/usb_bsp.c + ../../common/arm/stm32/usb_driver.c ../pwr_driver.c init.c boot.cpp diff --git a/radio/src/targets/taranis/bootloader/boot.cpp b/radio/src/targets/taranis/bootloader/boot.cpp index aa41f6538..96ed2d3bd 100644 --- a/radio/src/targets/taranis/bootloader/boot.cpp +++ b/radio/src/targets/taranis/bootloader/boot.cpp @@ -53,8 +53,8 @@ #include #include -#include "../../../gui/taranis/lcd.h" -#include "../../taranis/board_taranis.h" +#include "../../../gui/212x64/lcd.h" +#include "board.h" #include "storage/eeprom_rlc.h" #include "pwr.h" #include "keys.h" @@ -67,7 +67,7 @@ #if defined(PCBTARANIS) #define BOOTLOADER_TITLE " Taranis BootLoader - " VERSION - #if defined(REV9E) + #if defined(PCBX9E) #define BOOT_KEY_UP KEY_MINUS #define BOOT_KEY_DOWN KEY_PLUS #else @@ -155,7 +155,7 @@ extern void init_spi(void); extern void writeBlock(void); extern void usbPluggedIn(); -#if defined(REV9E) +#if defined(PCBX9E) typedef int32_t rotenc_t; extern rotenc_t rotencValue; #endif @@ -172,7 +172,7 @@ void interrupt10ms(void) ++enuk; } -#if defined(REV9E) +#if defined(PCBX9E) checkRotaryEncoder(); static rotenc_t rePreviousValue; rotenc_t reNewValue = (rotencValue / 2); @@ -672,7 +672,7 @@ int main() } if (state != ST_FLASHING && state != ST_USB) { -#if defined(REV9E) +#if defined(PCBX9E) if (pwrPressed()) { #else if (pwrCheck() == e_power_off) { diff --git a/radio/src/targets/taranis/delays.c b/radio/src/targets/taranis/delays.c index d83d3abbb..108db6c69 100644 --- a/radio/src/targets/taranis/delays.c +++ b/radio/src/targets/taranis/delays.c @@ -19,12 +19,11 @@ */ #include -#include "board_taranis.h" -#if !defined(REV9E) +#include "board.h" +#if !defined(PCBX9E) #include "dwt.h" // the old ST library that we use does not define DWT register for STM32F2xx #endif - #define SYSTEM_TICKS_1US ((CFG_CPU_FREQ + 500000) / 1000000) // number of system ticks in 1us #define SYSTEM_TICKS_01US ((CFG_CPU_FREQ + 5000000) / 10000000) // number of system ticks in 0.1us (rounding needed for sys frequencies that are not multiple of 10MHz) diff --git a/radio/src/targets/taranis/diskio.cpp b/radio/src/targets/taranis/diskio.cpp index 53e9a5d1e..004f2d12e 100644 --- a/radio/src/targets/taranis/diskio.cpp +++ b/radio/src/targets/taranis/diskio.cpp @@ -18,9 +18,9 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" -#include "../../thirdparty/FatFs/diskio.h" -#include "../../thirdparty/FatFs/ff.h" +#include "opentx.h" +#include "FatFs/diskio.h" +#include "FatFs/ff.h" /* Definitions for MMC/SDC command */ #define CMD0 (0x40+0) /* GO_IDLE_STATE */ @@ -628,12 +628,35 @@ DSTATUS disk_status ( } +#if defined(STM32F4) && !defined(BOOT) +DWORD scratch[BLOCK_SIZE / 4] __DMA; +#endif + /*-----------------------------------------------------------------------*/ /* Read Sector(s) */ /*-----------------------------------------------------------------------*/ -int8_t SD_ReadSectors(uint8_t *buff, uint32_t sector, uint32_t count) +int8_t SD_ReadSectors(uint8_t * buff, uint32_t sector, uint32_t count) { +#if defined(STM32F4) && !defined(BOOT) + if ((DWORD)buff < 0x20000000 || ((DWORD)buff & 3)) { + TRACE("disk_read bad alignment (%p)", buff); + while (count--) { + int8_t res = SD_ReadSectors((BYTE *)scratch, sector++, 1); + + if (res != 0) { + return res; + } + + memcpy(buff, scratch, BLOCK_SIZE); + + buff += BLOCK_SIZE; + } + + return 0; + } +#endif + if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ if (count == 1) { /* Single block read */ @@ -686,8 +709,27 @@ DRESULT disk_read ( /* Write Sector(s) */ /*-----------------------------------------------------------------------*/ -int8_t SD_WriteSectors(const uint8_t *buff, uint32_t sector, uint32_t count) +int8_t SD_WriteSectors(const uint8_t * buff, uint32_t sector, uint32_t count) { +#if defined(STM32F4) && !defined(BOOT) + if ((DWORD)buff < 0x20000000 || ((DWORD)buff & 3)) { + TRACE("disk_write bad alignment (%p)", buff); + while (count--) { + memcpy(scratch, buff, BLOCK_SIZE); + + int8_t res = SD_WriteSectors((const uint8_t *)scratch, sector++, 1); + + if (res != 0) { + return res; + } + + buff += BLOCK_SIZE; + } + + return 0; + } +#endif + if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ if (count == 1) { /* Single block write */ @@ -720,8 +762,6 @@ int8_t SD_WriteSectors(const uint8_t *buff, uint32_t sector, uint32_t count) return count ? -1 : 0; } -#if _FS_READONLY == 0 - DRESULT disk_write ( BYTE drv, /* Physical drive number (0) */ const BYTE *buff, /* Pointer to the data to be written */ @@ -736,8 +776,6 @@ DRESULT disk_write ( TRACE_SD_CARD_EVENT((res != 0), sd_disk_write, (count << 24) + (sector & 0x00FFFFFF)); return (res != 0) ? RES_ERROR : RES_OK; } -#endif /* _READONLY == 0 */ - /*-----------------------------------------------------------------------*/ @@ -798,7 +836,8 @@ DRESULT disk_ioctl ( if ((csd[0] >> 6) == 1) { /* SDC version 2.00 */ csize = csd[9] + ((WORD)csd[8] << 8) + 1; *(DWORD*)buff = (DWORD)csize << 10; - } else { /* SDC version 1.XX or MMC*/ + } + else { /* SDC version 1.XX or MMC*/ n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2; csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1; *(DWORD*)buff = (DWORD)csize << (n - 9); diff --git a/radio/src/targets/taranis/flash_driver.cpp b/radio/src/targets/taranis/flash_driver.cpp index 9fa7fa0b8..a3e7416fd 100644 --- a/radio/src/targets/taranis/flash_driver.cpp +++ b/radio/src/targets/taranis/flash_driver.cpp @@ -127,7 +127,7 @@ uint32_t isFirmwareStart(const void * buffer) { const uint32_t * block = (const uint32_t *)buffer; -#if defined(REV9E) +#if defined(PCBX9E) if ((block[0] & 0xFFFC0000) != 0x10000000 && (block[0] & 0xFFFC0000) != 0x20000000) { return 0; } diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index aae3a72d1..3c15e3e31 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -28,7 +28,7 @@ #define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02 #define KEYS_GPIO_REG_PAGE GPIOD->IDR #define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03 -#if defined(REV9E) +#if defined(PCBX9E) #if defined(SIMU) #define KEYS_GPIO_REG_PLUS GPIOE->IDR #define KEYS_GPIO_PIN_PLUS GPIO_Pin_5 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys @@ -52,7 +52,7 @@ #define ENC_GPIO_PIN_B GPIO_Pin_13 // PD.13 // Trims -#if defined(REV9E) +#if defined(PCBX9E) #define TRIMS_GPIO_REG_LHL GPIOG->IDR #define TRIMS_GPIO_PIN_LHL GPIO_Pin_1 // PG.01 #define TRIMS_GPIO_REG_LHR GPIOG->IDR @@ -89,7 +89,7 @@ #endif // Switches -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_A_H GPIOD->IDR #define SWITCHES_GPIO_PIN_A_H GPIO_Pin_10 // PD.10 #define SWITCHES_GPIO_REG_A_L GPIOD->IDR @@ -101,7 +101,7 @@ #define SWITCHES_GPIO_PIN_A_L GPIO_Pin_0 // PE.00 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_B_H GPIOG->IDR #define SWITCHES_GPIO_PIN_B_H GPIO_Pin_11 // PG.11 #define SWITCHES_GPIO_REG_B_L GPIOG->IDR @@ -113,7 +113,7 @@ #define SWITCHES_GPIO_PIN_B_L GPIO_Pin_2 // PE.02 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_C_H GPIOF->IDR #define SWITCHES_GPIO_PIN_C_H GPIO_Pin_13 // PF.13 #define SWITCHES_GPIO_REG_C_L GPIOF->IDR @@ -125,12 +125,12 @@ #define SWITCHES_GPIO_PIN_C_L GPIO_Pin_5 // PA.05 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_D_H GPIOE->IDR #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_1 // PE.01 #define SWITCHES_GPIO_REG_D_L GPIOE->IDR #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_2 // PE.02 -#elif defined(REVPLUS) +#elif defined(PCBX9DP) #define SWITCHES_GPIO_REG_D_H GPIOE->IDR #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_7 // PE.07 #define SWITCHES_GPIO_REG_D_L GPIOE->IDR @@ -142,7 +142,7 @@ #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_1 // PB.01 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_E_H GPIOE->IDR #define SWITCHES_GPIO_PIN_E_H GPIO_Pin_7 // PE.07 #define SWITCHES_GPIO_REG_E_L GPIOE->IDR @@ -154,7 +154,7 @@ #define SWITCHES_GPIO_PIN_E_L GPIO_Pin_4 // PB.04 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_F GPIOE->IDR #define SWITCHES_GPIO_PIN_F GPIO_Pin_11 // PE.11 #else @@ -162,7 +162,7 @@ #define SWITCHES_GPIO_PIN_F GPIO_Pin_14 // PE.14 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_G_H GPIOF->IDR #define SWITCHES_GPIO_PIN_G_H GPIO_Pin_3 // PF.03 #define SWITCHES_GPIO_REG_G_L GPIOF->IDR @@ -174,10 +174,10 @@ #define SWITCHES_GPIO_PIN_G_L GPIO_Pin_8 // PE.08 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_H GPIOF->IDR #define SWITCHES_GPIO_PIN_H GPIO_Pin_1 // PF.01 -#elif defined(REVPLUS) +#elif defined(PCBX9DP) #define SWITCHES_GPIO_REG_H GPIOD->IDR #define SWITCHES_GPIO_PIN_H GPIO_Pin_14 // PD.14 #else @@ -185,7 +185,7 @@ #define SWITCHES_GPIO_PIN_H GPIO_Pin_13 // PE.13 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define SWITCHES_GPIO_REG_I_H GPIOF->IDR #define SWITCHES_GPIO_PIN_I_H GPIO_Pin_15 // PF.15 #define SWITCHES_GPIO_REG_I_L GPIOE->IDR @@ -228,7 +228,7 @@ #define SWITCHES_GPIO_PIN_R_L GPIO_Pin_0 // PE.00 #endif -#if defined(REV9E) +#if defined(PCBX9E) #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG) #define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_M_L) #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_N_H | SWITCHES_GPIO_PIN_N_L | SWITCHES_GPIO_PIN_R_H) @@ -237,7 +237,7 @@ #define KEYS_GPIOE_PINS (TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_LVD | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L| SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_I_L | SWITCHES_GPIO_PIN_L_H | SWITCHES_GPIO_PIN_L_L | SWITCHES_GPIO_PIN_M_H | SWITCHES_GPIO_PIN_O_L | SWITCHES_GPIO_PIN_R_L) #define KEYS_GPIOF_PINS (KEYS_GPIO_PIN_ENTER | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_C_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | SWITCHES_GPIO_PIN_I_H | SWITCHES_GPIO_PIN_O_H | SWITCHES_GPIO_PIN_P_H | SWITCHES_GPIO_PIN_P_L | SWITCHES_GPIO_PIN_Q_H | SWITCHES_GPIO_PIN_Q_L) #define KEYS_GPIOG_PINS (TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR| SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_J_H | SWITCHES_GPIO_PIN_J_L | SWITCHES_GPIO_PIN_K_H | SWITCHES_GPIO_PIN_K_L) -#elif defined(REVPLUS) +#elif defined(PCBX9DP) #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE) #define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_C_L) #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_A_H) @@ -254,7 +254,7 @@ #endif // ADC -#if defined(REV9E) +#if defined(PCBX9E) #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2) #define ADC_RCC_APB2Periph (RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC3) #else @@ -273,7 +273,7 @@ #define ADC1_DMA_Stream DMA2_Stream4 #define ADC1_DMA_FLAGS (DMA_HIFCR_CTCIF4 | DMA_HIFCR_CHTIF4 | DMA_HIFCR_CTEIF4 | DMA_HIFCR_CDMEIF4 | DMA_HIFCR_CFEIF4) #define ADC1_DMA_FLAG_TC DMA_HISR_TCIF4 -#if defined(REV9E) +#if defined(PCBX9E) #define ADC_GPIO_PIN_POT1 GPIO_Pin_8 // PF.08 #define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00 #define ADC_GPIO_PIN_POT3 GPIO_Pin_5 // PC.05 @@ -296,7 +296,7 @@ #define ADC3_DMA_Stream DMA2_Stream0 #define ADC3_DMA_FLAGS (DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0) #define ADC3_DMA_FLAG_TC DMA_LISR_TCIF0 -#elif defined(REVPLUS) +#elif defined(PCBX9DP) #define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06 #define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00 #define ADC_GPIO_PIN_POT3 GPIO_Pin_1 // PB.01 @@ -332,7 +332,7 @@ // Internal Module #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2) #define INTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1 -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) #define INTMODULE_PWR_GPIO GPIOC #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_6 // PC.06 #else @@ -453,7 +453,7 @@ #define USB_GPIO_AF GPIO_AF_OTG1_FS // BackLight -#if defined(REV9E) +#if defined(PCBX9E) #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOE #define BACKLIGHT_RCC_APB1Periph 0 #define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM9 @@ -465,7 +465,7 @@ #define BACKLIGHT_GPIO_PinSource_2 GPIO_PinSource5 #define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM9 #define BACKLIGHT_GPIO_AF_2 GPIO_AF_TIM9 -#elif defined (REVPLUS) +#elif defined (PCBX9DP) #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD #define BACKLIGHT_RCC_APB1Periph RCC_APB1Periph_TIM4 #define BACKLIGHT_RCC_APB2Periph 0 @@ -489,7 +489,7 @@ #endif // LCD -#if defined(REV9E) +#if defined(PCBX9E) #define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1) #define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3 #define LCD_GPIO_SPI GPIOC @@ -507,7 +507,7 @@ #define LCD_DMA_FLAGS (DMA_HIFCR_CTCIF7 | DMA_HIFCR_CHTIF7 | DMA_HIFCR_CTEIF7 | DMA_HIFCR_CDMEIF7 | DMA_HIFCR_CFEIF7) #define LCD_DMA_FLAG_INT DMA_HIFCR_CTCIF7 #define LCD_SPI SPI3 -#elif defined(REVPLUS) +#elif defined(PCBX9DP) #define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1) #define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3 #define LCD_GPIO_SPI GPIOC @@ -597,7 +597,7 @@ #define AUDIO_DMA DMA1 // Haptic -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) #define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOB #define HAPTIC_RCC_APB2Periph RCC_APB2Periph_TIM10 #define HAPTIC_GPIO_PinSource GPIO_PinSource8 @@ -613,7 +613,7 @@ #endif // Top LCD on X9E -#if defined(REV9E) +#if defined(PCBX9E) #define TOPLCD_RCC_AHB1Periph RCC_AHB1Periph_GPIOG #define TOPLCD_GPIO GPIOG #define TOPLCD_GPIO_PIN_DATA GPIO_Pin_5 @@ -624,7 +624,7 @@ #endif // Bluetooth on X9E -#if defined(REV9E) +#if defined(PCBX9E) #define BT_USART USART6 #define BT_GPIO_AF GPIO_AF_USART6 #define BT_USART_IRQn USART6_IRQn diff --git a/radio/src/targets/taranis/haptic_driver.cpp b/radio/src/targets/taranis/haptic_driver.cpp index 2669de23c..020c61c5e 100644 --- a/radio/src/targets/taranis/haptic_driver.cpp +++ b/radio/src/targets/taranis/haptic_driver.cpp @@ -18,9 +18,9 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) void hapticOff(void) { HAPTIC_TIMER->CCR1 = 0; @@ -58,7 +58,7 @@ void hapticInit(void) #else -// No PWM before REVPLUS +// No PWM before X9D+ void hapticInit(void) { GPIO_InitTypeDef GPIO_InitStructure; diff --git a/radio/src/targets/taranis/i2c_driver.cpp b/radio/src/targets/taranis/i2c_driver.cpp index 3bf5f48f8..344859fda 100644 --- a/radio/src/targets/taranis/i2c_driver.cpp +++ b/radio/src/targets/taranis/i2c_driver.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "board_taranis.h" +#include "board.h" void eepromPageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite); void eepromWaitEepromStandbyState(void); diff --git a/radio/src/targets/taranis/keys_driver.cpp b/radio/src/targets/taranis/keys_driver.cpp index 82951edbe..d0447d52d 100644 --- a/radio/src/targets/taranis/keys_driver.cpp +++ b/radio/src/targets/taranis/keys_driver.cpp @@ -33,7 +33,7 @@ uint32_t readKeys() if (~KEYS_GPIO_REG_EXIT & KEYS_GPIO_PIN_EXIT) result |= 1 << KEY_EXIT; -#if !defined(REV9E) || defined(SIMU) +#if !defined(PCBX9E) || defined(SIMU) if (~KEYS_GPIO_REG_PLUS & KEYS_GPIO_PIN_PLUS) result |= 1 << KEY_PLUS; if (~KEYS_GPIO_REG_MINUS & KEYS_GPIO_PIN_MINUS) @@ -81,7 +81,7 @@ uint8_t keyDown() return readKeys(); } -#if defined(REV9E) +#if defined(PCBX9E) uint32_t Rotary_position; rotenc_t rotencValue; void checkRotaryEncoder() @@ -116,7 +116,7 @@ void readKeysAndTrims() keys[enuk++].input(in & i); } -#if defined(REV9E) && !defined(SIMU) +#if defined(PCBX9E) && !defined(SIMU) #define X9E_RE_TIMEOUT 5 static rotenc_t rePreviousValue; rotenc_t reNewValue = (rotencValue / 2); @@ -157,7 +157,7 @@ void readKeysAndTrims() } } -#if defined(REV9E) +#if defined(PCBX9E) #define ADD_2POS_CASE(x) \ case SW_S ## x ## 2: \ xxx = SWITCHES_GPIO_REG_ ## x & SWITCHES_GPIO_PIN_ ## x ; \ @@ -217,7 +217,7 @@ bool switchState(EnumKeys enuk) ADD_2POS_CASE(F); ADD_3POS_CASE(G, 6); ADD_2POS_CASE(H); -#if defined(REV9E) +#if defined(PCBX9E) ADD_3POS_CASE(I, 8); ADD_3POS_CASE(J, 9); ADD_3POS_CASE(K, 10); diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 4add2ed46..5e059f208 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -18,12 +18,12 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" #define WriteData(x) AspiData(x) #define WriteCommand(x) AspiCmd(x) -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) #define CONTRAST_OFS 160 #define RESET_WAIT_DELAY_MS 300 //wait time after LCD reset before first command #define WAIT_FOR_DMA_END() { while(lcd_busy) {}; } @@ -36,7 +36,7 @@ bool lcdInitFinished = false; void lcdInitFinish(); -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) // New hardware SPI driver for LCD void initLcdSpi() @@ -155,7 +155,7 @@ void Set_Address(u8 x, u8 y) LCD_CLK_HIGH(); \ LCD_CLK_HIGH(); -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) volatile bool lcd_busy; @@ -213,7 +213,7 @@ extern "C" void LCD_DMA_Stream_IRQHandler() lcd_busy = false; } -#else // #if defined(REVPLUS) +#else // #if defined(PCBX9E) || defined(PCBX9DP) void lcdRefresh() { if (!lcdInitFinished) { @@ -252,7 +252,7 @@ void backlightInit() { GPIO_InitTypeDef GPIO_InitStructure; -#if defined(REV9E) +#if defined(PCBX9E) GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1|BACKLIGHT_GPIO_PIN_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; @@ -269,7 +269,7 @@ void backlightInit() BACKLIGHT_TIMER->CCR1 = 100 ; BACKLIGHT_TIMER->EGR = 0 ; BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN ; // Counter enable -#elif defined(REVPLUS) +#elif defined(PCBX9DP) GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1|BACKLIGHT_GPIO_PIN_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; @@ -376,7 +376,7 @@ void lcdInitFinish() { lcdInitFinished = true; -#if defined(REVPLUS) +#if defined(PCBX9E) || defined(PCBX9DP) initLcdSpi(); #endif @@ -420,7 +420,7 @@ void lcdSetRefVolt(uint8_t val) AspiCmd(val+CONTRAST_OFS); //0--255 } -#if defined(REV9E) +#if defined(PCBX9E) void turnBacklightOn(uint8_t level, uint8_t color) { BACKLIGHT_TIMER->CCR1 = ((100-level)*(20-color))/20; @@ -432,7 +432,7 @@ void turnBacklightOff(void) BACKLIGHT_TIMER->CCR1 = 0; BACKLIGHT_TIMER->CCR2 = 0; } -#elif defined(REVPLUS) +#elif defined(PCBX9DP) void turnBacklightOn(uint8_t level, uint8_t color) { BACKLIGHT_TIMER->CCR4 = ((100-level)*(20-color))/20; diff --git a/radio/src/targets/taranis/pwr_driver.c b/radio/src/targets/taranis/pwr_driver.c index 13d8400ee..b40f2a08e 100644 --- a/radio/src/targets/taranis/pwr_driver.c +++ b/radio/src/targets/taranis/pwr_driver.c @@ -19,7 +19,7 @@ */ #include "pwr.h" -#include "board_taranis.h" +#include "board.h" void pwrInit() { @@ -70,7 +70,7 @@ void pwrOff() while(1) { wdt_reset(); -#if defined(REV9E) +#if defined(PCBX9E) // 9E needs watchdog reset because CPU is still running while // the power key is held pressed by the user. // The power key should be released by now, but we must make sure @@ -90,7 +90,7 @@ void pwrOff() // this function must not return! } -#if defined(REV9E) +#if defined(PCBX9E) uint32_t pwrPressed() { return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET; @@ -102,7 +102,7 @@ uint32_t pwroffPressed() } #endif -#if !defined(REV9E) +#if !defined(PCBX9E) uint32_t pwrCheck() { if (!pwroffPressed()) diff --git a/radio/src/targets/taranis/system_stm32f4xx.c b/radio/src/targets/taranis/system_stm32f4xx.c deleted file mode 100644 index b816925b4..000000000 --- a/radio/src/targets/taranis/system_stm32f4xx.c +++ /dev/null @@ -1,473 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32f4xx_system - * @{ - */ - -/** @addtogroup STM32F4xx_System_Private_Includes - * @{ - */ - -#include "stm32f4xx.h" - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/*!< Uncomment the following line if you need to use external SRAM mounted - on STM324xG_EVAL/STM324x7I_EVAL board as data memory */ -/* #define DATA_IN_ExtSRAM */ - -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -/******************************************************************************/ - -/************************* PLL Parameters *************************************/ -/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */ -#define PLL_M 12 -#define PLL_N 336 - -/* SYSCLK = PLL_VCO / PLL_P */ -#define PLL_P 2 - -/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */ -#define PLL_Q 7 - -/******************************************************************************/ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Variables - * @{ - */ - - uint32_t SystemCoreClock = 168000000; - - __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes - * @{ - */ - -static void SetSysClock(void); -#ifdef DATA_IN_ExtSRAM - static void SystemInit_ExtMemCtl(void); -#endif /* DATA_IN_ExtSRAM */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system - * Initialize the Embedded Flash Interface, the PLL and update the - * SystemFrequency variable. - * @param None - * @retval None - */ -void SystemInit(void) -{ - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ - #endif - /* Reset the RCC clock configuration to the default reset state ------------*/ - /* Set HSION bit */ - RCC->CR |= (uint32_t)0x00000001; - - /* Reset CFGR register */ - RCC->CFGR = 0x00000000; - - /* Reset HSEON, CSSON and PLLON bits */ - RCC->CR &= (uint32_t)0xFEF6FFFF; - - /* Reset PLLCFGR register */ - RCC->PLLCFGR = 0x24003010; - - /* Reset HSEBYP bit */ - RCC->CR &= (uint32_t)0xFFFBFFFF; - - /* Disable all interrupts */ - RCC->CIR = 0x00000000; - -#ifdef DATA_IN_ExtSRAM - SystemInit_ExtMemCtl(); -#endif /* DATA_IN_ExtSRAM */ - - /* Configure the System clock source, PLL Multiplier and Divider factors, - AHB/APBx prescalers and Flash settings ----------------------------------*/ - SetSysClock(); - - /* Configure the Vector Table location add offset address ------------------*/ -#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 -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value - * 25 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ -void SystemCoreClockUpdate(void) -{ - uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; - - /* Get SYSCLK source -------------------------------------------------------*/ - tmp = RCC->CFGR & RCC_CFGR_SWS; - - switch (tmp) - { - case 0x00: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - case 0x04: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - case 0x08: /* PLL used as system clock source */ - - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N - SYSCLK = PLL_VCO / PLL_P - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; - pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; - - if (pllsource != 0) - { - /* HSE used as PLL clock source */ - pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); - } - else - { - /* HSI used as PLL clock source */ - pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); - } - - pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; - SystemCoreClock = pllvco/pllp; - break; - default: - SystemCoreClock = HSI_VALUE; - break; - } - /* Compute HCLK frequency --------------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK frequency */ - SystemCoreClock >>= tmp; -} - -/** - * @brief Configures the System clock source, PLL Multiplier and Divider factors, - * AHB/APBx prescalers and Flash settings - * @Note This function should be called only once the RCC clock configuration - * is reset to the default reset state (done in SystemInit() function). - * @param None - * @retval None - */ -static void SetSysClock(void) -{ -/******************************************************************************/ -/* PLL (clocked by HSE) used as System clock source */ -/******************************************************************************/ - __IO uint32_t StartUpCounter = 0, HSEStatus = 0; - - /* Enable HSE */ - RCC->CR |= ((uint32_t)RCC_CR_HSEON); - - /* Wait till HSE is ready and if Time out is reached exit */ - do - { - HSEStatus = RCC->CR & RCC_CR_HSERDY; - StartUpCounter++; - } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); - - if ((RCC->CR & RCC_CR_HSERDY) != RESET) - { - HSEStatus = (uint32_t)0x01; - } - else - { - HSEStatus = (uint32_t)0x00; - } - - if (HSEStatus == (uint32_t)0x01) - { - /* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */ - RCC->APB1ENR |= RCC_APB1ENR_PWREN; - PWR->CR |= PWR_CR_VOS; - - /* HCLK = SYSCLK / 1*/ - RCC->CFGR |= RCC_CFGR_HPRE_DIV1; - - /* PCLK2 = HCLK / 2*/ - RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; - - /* PCLK1 = HCLK / 4*/ - RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; - - /* Configure the main PLL */ - RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) | - (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24); - - /* Enable the main PLL */ - RCC->CR |= RCC_CR_PLLON; - - /* Wait till the main PLL is ready */ - while((RCC->CR & RCC_CR_PLLRDY) == 0) - { - } - - /* Configure Flash prefetch, Instruction cache, Data cache and wait state */ - FLASH->ACR = FLASH_ACR_PRFTEN |FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS; - - /* Select the main PLL as system clock source */ - RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); - RCC->CFGR |= RCC_CFGR_SW_PLL; - - /* Wait till the main PLL is used as system clock source */ - while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL); - { - } - } - else - { /* If HSE fails to start-up, the application will have wrong clock - configuration. User can add here some code to deal with this error */ - } - -} - -/** - * @brief Setup the external memory controller. Called in startup_stm32f4xx.s - * before jump to __main - * @param None - * @retval None - */ -#ifdef DATA_IN_ExtSRAM -/** - * @brief Setup the external memory controller. - * Called in startup_stm32f4xx.s before jump to main. - * This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I_EVAL board - * This SRAM will be used as program data memory (including heap and stack). - * @param None - * @retval None - */ -void SystemInit_ExtMemCtl(void) -{ -/*-- GPIOs Configuration -----------------------------------------------------*/ -/* - +-------------------+--------------------+------------------+------------------+ - + SRAM pins assignment + - +-------------------+--------------------+------------------+------------------+ - | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | - | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | - | PD4 <-> FSMC_NOE | PE2 <-> FSMC_A23 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | - | PD5 <-> FSMC_NWE | PE3 <-> FSMC_A19 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | - | PD8 <-> FSMC_D13 | PE4 <-> FSMC_A20 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | - | PD9 <-> FSMC_D14 | PE5 <-> FSMC_A21 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | - | PD10 <-> FSMC_D15 | PE6 <-> FSMC_A22 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | - | PD11 <-> FSMC_A16 | PE7 <-> FSMC_D4 | PF13 <-> FSMC_A7 |------------------+ - | PD12 <-> FSMC_A17 | PE8 <-> FSMC_D5 | PF14 <-> FSMC_A8 | - | PD13 <-> FSMC_A18 | PE9 <-> FSMC_D6 | PF15 <-> FSMC_A9 | - | PD14 <-> FSMC_D0 | PE10 <-> FSMC_D7 |------------------+ - | PD15 <-> FSMC_D1 | PE11 <-> FSMC_D8 | - +-------------------| PE12 <-> FSMC_D9 | - | PE13 <-> FSMC_D10 | - | PE14 <-> FSMC_D11 | - | PE15 <-> FSMC_D12 | - +--------------------+ -*/ - /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ - RCC->AHB1ENR |= 0x00000078; - - /* Connect PDx pins to FSMC Alternate function */ - GPIOD->AFR[0] = 0x00cc00cc; - GPIOD->AFR[1] = 0xcccccccc; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xaaaa0a0a; - /* Configure PDx pins speed to 100 MHz */ - GPIOD->OSPEEDR = 0xffff0f0f; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FSMC Alternate function */ - GPIOE->AFR[0] = 0xcccccccc; - GPIOE->AFR[1] = 0xcccccccc; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xaaaaaaaa; - /* Configure PEx pins speed to 100 MHz */ - GPIOE->OSPEEDR = 0xffffffff; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FSMC Alternate function */ - GPIOF->AFR[0] = 0x00cccccc; - GPIOF->AFR[1] = 0xcccc0000; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xaa000aaa; - /* Configure PFx pins speed to 100 MHz */ - GPIOF->OSPEEDR = 0xff000fff; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FSMC Alternate function */ - GPIOG->AFR[0] = 0x00cccccc; - GPIOG->AFR[1] = 0x000000c0; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0x00080aaa; - /* Configure PGx pins speed to 100 MHz */ - GPIOG->OSPEEDR = 0x000c0fff; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - -/*-- FSMC Configuration ------------------------------------------------------*/ - /* Enable the FSMC interface clock */ - RCC->AHB3ENR |= 0x00000001; - - /* Configure and enable Bank1_SRAM2 */ - FSMC_Bank1->BTCR[2] = 0x00001011; - FSMC_Bank1->BTCR[3] = 0x00000201; - FSMC_Bank1E->BWTR[2] = 0x0fffffff; -/* - Bank1_SRAM2 is configured as follow: - - p.FSMC_AddressSetupTime = 1; - p.FSMC_AddressHoldTime = 0; - p.FSMC_DataSetupTime = 2; - p.FSMC_BusTurnAroundDuration = 0; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0; - p.FSMC_AccessMode = FSMC_AccessMode_A; - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; -*/ -} -#endif /* DATA_IN_ExtSRAM */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/radio/src/targets/taranis/usb_bsp.c b/radio/src/targets/taranis/usb_bsp.c deleted file mode 100644 index fb2bbf460..000000000 --- a/radio/src/targets/taranis/usb_bsp.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Includes ------------------------------------------------------------------*/ - -#include "usb_bsp.h" - -#include "board_taranis.h" -#include "usbd_conf.h" - -extern uint32_t SystemCoreClock; - -/** -* @brief USB_OTG_BSP_Init -* Initilizes BSP configurations -* @param None -* @retval None -*/ - -void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - RCC_AHB1PeriphClockCmd(USB_RCC_AHB1Periph_GPIO, ENABLE); - - /* Configure DM and DP Pins */ - GPIO_InitStructure.GPIO_Pin = USB_GPIO_PIN_DM | USB_GPIO_PIN_DP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(USB_GPIO, &GPIO_InitStructure); - - GPIO_PinAFConfig(USB_GPIO, USB_GPIO_PinSource_DM, USB_GPIO_AF); - GPIO_PinAFConfig(USB_GPIO, USB_GPIO_PinSource_DP, USB_GPIO_AF); - - /* Configure VBUS Pin */ - GPIO_InitStructure.GPIO_Pin = USB_GPIO_PIN_VBUS; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; - GPIO_Init(USB_GPIO, &GPIO_InitStructure); - - 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 -* Enable USB Global interrupt -* @param None -* @retval None -*/ -void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) -{ - NVIC_SetPriority(OTG_FS_IRQn, 11); // Lower priority interrupt - NVIC_EnableIRQ(OTG_FS_IRQn); -} - -/** -* @brief USB_OTG_BSP_DisableInterrupt -* Disable USB Global interrupt -* @param None -* @retval None -*/ -void USB_OTG_BSP_DisableInterrupt(USB_OTG_CORE_HANDLE *pdev) -{ - NVIC_DisableIRQ(OTG_FS_IRQn); -} - - -/** -* @brief USB_OTG_BSP_uDelay -* This function provides delay time in micro sec -* @param usec : Value of delay required in micro sec -* @retval None -*/ -void USB_OTG_BSP_uDelay (const uint32_t usec) -{ - uint32_t count = 0; - const uint32_t utime = ((SystemCoreClock/1000000) * usec); - do - { - if ( ++count > utime ) - { - return ; - } - } - while (1); -} - - -/** -* @brief USB_OTG_BSP_mDelay -* This function provides delay time in milli sec -* @param msec : Value of delay required in milli sec -* @retval None -*/ -void USB_OTG_BSP_mDelay (const uint32_t msec) -{ - USB_OTG_BSP_uDelay(msec * 1000); -} - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/taranis/usb_driver.c b/radio/src/targets/taranis/usb_driver.c deleted file mode 100644 index e6dcc4ad2..000000000 --- a/radio/src/targets/taranis/usb_driver.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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 "debug.h" - -int usbPlugged(void) -{ - // debounce - static uint8_t debounced_state = 0; - static uint8_t last_state = 0; - - if (GPIO_ReadInputDataBit(USB_GPIO, USB_GPIO_PIN_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) -{ - DEBUG_INTERRUPT(INT_OTG_FS); - USBD_OTG_ISR_Handler(&USB_OTG_dev); -} - -void usbInit(void) -{ -#if defined(USB_JOYSTICK) - // initialize USB as HID device - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb); -#elif defined(USB_SERIAL) - // initialize USB as CDC device (virtual serial port) - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); -#elif defined(USB_MASS_STORAGE) - // initialize USB as MSC device - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb); -#endif -} - -void usbDeInit(void) -{ - USBD_DeInit(&USB_OTG_dev); -} diff --git a/radio/src/targets/taranis/usbd_cdc.cpp b/radio/src/targets/taranis/usbd_cdc.cpp deleted file mode 100644 index e19620577..000000000 --- a/radio/src/targets/taranis/usbd_cdc.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED -#pragma data_alignment = 4 -#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ - -#include "opentx.h" - -extern "C" { - -/* Includes ------------------------------------------------------------------*/ -#include "usb_conf.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ - - -/* These are external variables imported from CDC core to be used for IN - transfer management. */ -extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer. - These data will be sent over USB IN endpoint - in the CDC core functions. */ -extern volatile uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to - start address when writing received data - in the buffer APP_Rx_Buffer. */ -extern volatile uint32_t APP_Rx_ptr_out; - -/* Private function prototypes -----------------------------------------------*/ -static uint16_t VCP_Init (void); -static uint16_t VCP_DeInit (void); -static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len); -static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len); - -// static uint16_t VCP_COMConfig(uint8_t Conf); - -CDC_IF_Prop_TypeDef VCP_fops = -{ - VCP_Init, - VCP_DeInit, - VCP_Ctrl, - 0, - VCP_DataRx -}; - -} // extern "C" - -bool cdcConnected = false; - -/* Private functions ---------------------------------------------------------*/ -/** - * @brief VCP_Init - * Initializes the Media on the STM32 - * @param None - * @retval Result of the opeartion (USBD_OK in all cases) - */ -static uint16_t VCP_Init(void) -{ - cdcConnected = true; - return USBD_OK; -} - -/** - * @brief VCP_DeInit - * DeInitializes the Media on the STM32 - * @param None - * @retval Result of the opeartion (USBD_OK in all cases) - */ -static uint16_t VCP_DeInit(void) -{ - cdcConnected = false; - return USBD_OK; -} - - -/** - * @brief VCP_Ctrl - * Manage the CDC class requests - * @param Cmd: Command code - * @param Buf: Buffer containing command data (request parameters) - * @param Len: Number of data to be sent (in bytes) - * @retval Result of the opeartion (USBD_OK in all cases) - */ -static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) -{ - switch (Cmd) - { - case SEND_ENCAPSULATED_COMMAND: - /* Not needed for this driver */ - break; - - case GET_ENCAPSULATED_RESPONSE: - /* Not needed for this driver */ - break; - - case SET_COMM_FEATURE: - /* Not needed for this driver */ - break; - - case GET_COMM_FEATURE: - /* Not needed for this driver */ - break; - - case CLEAR_COMM_FEATURE: - /* Not needed for this driver */ - break; - - case SET_LINE_CODING: - /* Not needed for this driver */ - break; - - case GET_LINE_CODING: - /* Not needed for this driver */ - break; - - case SET_CONTROL_LINE_STATE: - /* Not needed for this driver */ - break; - - case SEND_BREAK: - /* Not needed for this driver */ - break; - - default: - break; - } - - return USBD_OK; -} - -// some debug vars -uint16_t usbWraps = 0; -uint16_t charsWritten = 0; - -void usbSerialPutc(uint8_t c) -{ - if (!cdcConnected) return; - - uint32_t txDataLen; - do { - txDataLen = APP_RX_DATA_SIZE + APP_Rx_ptr_in - APP_Rx_ptr_out; - if (txDataLen >= APP_RX_DATA_SIZE) { - txDataLen -= APP_RX_DATA_SIZE; - } - } while (txDataLen >= (APP_RX_DATA_SIZE - CDC_DATA_MAX_PACKET_SIZE)); - - APP_Rx_Buffer[APP_Rx_ptr_in] = c; - ++charsWritten; - /* To avoid buffer overflow */ - if (APP_Rx_ptr_in >= APP_RX_DATA_SIZE-1) { - APP_Rx_ptr_in = 0; - ++usbWraps; - } - else { - APP_Rx_ptr_in++; - } -} - -/** - * @brief VCP_DataRx - * Data received over USB OUT endpoint is available here - * - * @note - * This function will block any OUT packet reception on USB endpoint - * until exiting this function. If you exit this function before transfer - * is complete on CDC interface (ie. using DMA controller) it will result - * in receiving more data while previous ones are still not sent. - * - * @note - * This function is executed inside the USBD_OTG_ISR_Handler() interrupt handler! - - * @param Buf: Buffer of data to be received - * @param Len: Number of data received (in bytes) - * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL - */ -static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len) -{ - // TODO: try implementing inbound flow control: - // if the cliRxFifo does not have enough free space to receive all - // available characters, return VCP_FAIL. Maybe that will throttle down - // the sender and we will receive the same packet at a later time. - -#if defined(CLI) - //copy data to the application FIFO - for (uint32_t i = 0; i < Len; i++) - { - cliRxFifo.push(Buf[i]); - } -#endif - - return USBD_OK; -} - - - -// /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/taranis/usbd_desc.h b/radio/src/targets/taranis/usbd_desc.h deleted file mode 100644 index 171102a8e..000000000 --- a/radio/src/targets/taranis/usbd_desc.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * 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. - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ - -#ifndef _USBD_DESC_H_ -#define _USBD_DESC_H_ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_core.h" -#include "usbd_def.h" - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY - * @{ - */ - -/** @defgroup USB_DESC - * @brief general defines for the usb device library file - * @{ - */ - -/** @defgroup USB_DESC_Exported_Defines - * @{ - */ -#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 -#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 -#define USB_STRING_DESCRIPTOR_TYPE 0x03 -#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 -#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 -#define USB_SIZ_DEVICE_DESC 18 -#define USB_SIZ_STRING_LANGID 4 - -/** - * @} - */ - - -/** @defgroup USBD_DESC_Exported_TypesDefinitions - * @{ - */ -/** - * @} - */ - - - -/** @defgroup USBD_DESC_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_Variables - * @{ - */ -extern const uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; -extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]; -extern const uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC]; -extern const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; -extern const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]; -extern const USBD_DEVICE USR_desc; -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_FunctionsPrototype - * @{ - */ - - -uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length); -uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length); - -#ifdef USB_SUPPORT_USER_STRING_DESC -uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length); -#endif /* USB_SUPPORT_USER_STRING_DESC */ - -/** - * @} - */ - -#endif // _USBD_DESC_H_ - -/** - * @} - */ - -/** -* @} -*/ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/tasks_arm.cpp b/radio/src/tasks_arm.cpp index 3cf289b7a..c42275329 100644 --- a/radio/src/tasks_arm.cpp +++ b/radio/src/tasks_arm.cpp @@ -235,7 +235,7 @@ void menusTask(void * pdata) #endif } -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) toplcdOff(); #endif diff --git a/radio/src/telemetry/frsky.cpp b/radio/src/telemetry/frsky.cpp index b6f8faf9d..ebc40ac02 100644 --- a/radio/src/telemetry/frsky.cpp +++ b/radio/src/telemetry/frsky.cpp @@ -63,7 +63,7 @@ NOINLINE void processFrskyTelemetryData(uint8_t data) } #endif -#if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) +#if defined(PCBX9E) && !defined(SIMU) #define BLUETOOTH_BUFFER_LENGTH 20 static uint8_t bluetoothBuffer[BLUETOOTH_BUFFER_LENGTH]; static uint8_t bluetoothIndex = 0; diff --git a/radio/src/telemetry/frsky.h b/radio/src/telemetry/frsky.h index f82e524be..a3be50cca 100644 --- a/radio/src/telemetry/frsky.h +++ b/radio/src/telemetry/frsky.h @@ -272,7 +272,7 @@ PACK(struct FrskyTelemetryData { #endif #endif -#if defined(PCBTARANIS) && defined(REVPLUS) +#if defined(PCBX9DP) || defined(PCBX9E) #define IS_VALID_XJT_VERSION() (telemetryData.xjtVersion != 0 && telemetryData.xjtVersion != 0xff) #else #define IS_VALID_XJT_VERSION() (1) diff --git a/radio/src/telemetry/frsky_sport.cpp b/radio/src/telemetry/frsky_sport.cpp index a496b73bb..697db6843 100644 --- a/radio/src/telemetry/frsky_sport.cpp +++ b/radio/src/telemetry/frsky_sport.cpp @@ -252,7 +252,7 @@ void processSportPacket(uint8_t * packet) else telemetryData.rssi.set(data); } -#if defined(PCBTARANIS) && defined(REVPLUS) +#if defined(PCBX9DP) || defined(PCBX9E) else if (id == XJT_VERSION_ID) { telemetryData.xjtVersion = HUB_DATA_U16(packet); if (!IS_VALID_XJT_VERSION()) { diff --git a/radio/src/telemetry/mavlink.h b/radio/src/telemetry/mavlink.h index fb2281259..c580a9e60 100644 --- a/radio/src/telemetry/mavlink.h +++ b/radio/src/telemetry/mavlink.h @@ -29,7 +29,7 @@ #define MAVLINK_COMM_NUM_BUFFERS 1 #include "GCS_MAVLink/include_v1.0/mavlink_types.h" -#include "targets/common_avr/serial_driver.h" +#include "targets/common/avr/serial_driver.h" #include "opentx.h" extern int8_t mav_heartbeat; diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 59098f058..9a7e08e52 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -141,7 +141,7 @@ void telemetryWakeup() } #endif -#if defined(PCBTARANIS) && defined(REVPLUS) +#if defined(PCBX9DP) || defined(PCBX9E) #define FRSKY_BAD_ANTENNA() (IS_VALID_XJT_VERSION() && telemetryData.swr.value > 0x33) #else #define FRSKY_BAD_ANTENNA() (telemetryData.swr.value > 0x33) diff --git a/radio/src/templates.cpp b/radio/src/templates.cpp index 7fb91280c..9f2848cd5 100644 --- a/radio/src/templates.cpp +++ b/radio/src/templates.cpp @@ -40,8 +40,8 @@ #include "opentx.h" -#if defined(PCBTARANIS) - #pragma message("Templates with virtual inputs (FrSky Taranis) are not implemented!") +#if defined(VIRTUALINPUTS) + #pragma message("Templates with VIRTUALINPUTS enabled are not implemented!") #endif MixData* setDest(uint8_t dch, uint8_t src, bool clear=false) diff --git a/radio/src/tests/lcd.cpp b/radio/src/tests/lcd.cpp index 3a41496c0..9d637f62e 100644 --- a/radio/src/tests/lcd.cpp +++ b/radio/src/tests/lcd.cpp @@ -28,6 +28,7 @@ #define SWAP_DEFINED #include "opentx.h" #include "location.h" +#include "targets/simu/simulcd.h" void doPaint(QPainter & p) { diff --git a/radio/src/thirdparty/CoOS/OsConfig.h b/radio/src/thirdparty/CoOS/OsConfig.h index 2c2fb2db5..f6e66f19f 100644 --- a/radio/src/thirdparty/CoOS/OsConfig.h +++ b/radio/src/thirdparty/CoOS/OsConfig.h @@ -69,9 +69,9 @@ Idle task stack size(word). /*!< System frequency (Hz). */ -#if defined(PCBFLAMENCO) || (defined(PCBTARANIS) && defined(REV9E)) || defined(PCBHORUS) +#if defined(STM32F4) #define CFG_CPU_FREQ (168000000) -#elif defined(PCBTARANIS) +#elif defined(STM32) #define CFG_CPU_FREQ (120000000) #else #define CFG_CPU_FREQ (36000000) // TODO check if really correct for sky9x? diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c index ae2ead91c..7a9ca6492 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c @@ -78,7 +78,9 @@ uint8_t MSC_BOT_Status; #pragma data_alignment=4 #endif #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ -__ALIGN_BEGIN uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET] __ALIGN_END ; + +#include "definitions.h" +uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET] __DMA; #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED #if defined ( __ICCARM__ ) /*!< IAR Compiler */ diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c index 1a7ccf6bc..b7f1d020b 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c @@ -666,7 +666,7 @@ static int8_t SCSI_ProcessRead (uint8_t lun) { uint32_t len; - len = MIN(SCSI_blk_len , MSC_MEDIA_PACKET); + len = MIN(SCSI_blk_len , MSC_MEDIA_PACKET); if( USBD_STORAGE_fops->Read(lun , MSC_BOT_Data, diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index dcb201b92..36ce2aac3 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -405,7 +405,7 @@ const pm_char STR_SHUTDOWN[] PROGMEM = TR_SHUTDOWN; const pm_char STR_SAVEMODEL[] PROGMEM = TR_SAVEMODEL; #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) const pm_char STR_POWEROFF[] PROGMEM = TR_POWEROFF; #endif diff --git a/radio/src/translations.h b/radio/src/translations.h index 6aeaa1f2a..614c62c10 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -621,7 +621,7 @@ extern const pm_char STR_SHUTDOWN[]; extern const pm_char STR_SAVEMODEL[]; #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBX9E) extern const pm_char STR_POWEROFF[]; #endif diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 094937c62..2af246467 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -162,7 +162,7 @@ #define TR_RETA123 "SVPK12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "SVPK123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "SVPK1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "SVPK123LR" @@ -505,7 +505,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310S1\0 ""\310S2\0 ""\310S3\0 ""\310S4\0 ""\311LS\0 ""\311RS\0 ""\311LS2 ""\311RS2 " #define TR_SW_VSRCRAW "\312SA\0 ""\312SB\0 ""\312SC\0 ""\312SD\0 ""\312SE\0 ""\312SF\0 ""\312SG\0 ""\312SH\0 ""\312SI\0 ""\312SJ\0 ""\312SK\0 ""\312SL\0 ""\312SM\0 ""\312SN\0 ""\312SO\0 ""\312SP\0 ""\312SQ\0 ""\312SR\0 " #elif defined(PCBTARANIS) diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index dc81836ec..96013a5c7 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -166,7 +166,7 @@ #define TR_RETA123 "SHGQ12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "SHGQ123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "SHGQ1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "SHGQ123LR" @@ -519,7 +519,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) @@ -1273,9 +1273,9 @@ #define ZSTR_ACCX "AccX" #define ZSTR_ACCY "AccY" #define ZSTR_ACCZ "AccZ" -#define ZSTR_GYROX "GYRX" -#define ZSTR_GYROY "GYRY" -#define ZSTR_GYROZ "GYRZ" +#define ZSTR_GYROX "GYRX" +#define ZSTR_GYROY "GYRY" +#define ZSTR_GYROZ "GYRZ" #define ZSTR_CURR "Curr" #define ZSTR_CAPACITY "Capa" #define ZSTR_VFAS "VFAS" @@ -1291,30 +1291,30 @@ #define ZSTR_BATT2_VOLTAGE "RB2V" #define ZSTR_BATT1_CURRENT "RB1A" #define ZSTR_BATT2_CURRENT "RB2A" -#define ZSTR_BATT1_CONSUMPTION "RB1C" -#define ZSTR_BATT2_CONSUMPTION "RB2C" -#define ZSTR_BATT1_TEMP "RB1T" -#define ZSTR_BATT2_TEMP "RB2T" -#define ZSTR_RB_STATE "RBS" -#define ZSTR_CHANS_STATE "RBCS" -#define ZSTR_RX_RSSI1 "1RSS" -#define ZSTR_RX_RSSI2 "2RSS" -#define ZSTR_RX_QUALITY "RQly" -#define ZSTR_RX_SNR "RSNR" -#define ZSTR_ANTENNA "ANT" -#define ZSTR_RF_MODE "RFMD" -#define ZSTR_TX_POWER "TPWR" -#define ZSTR_TX_RSSI "TRSS" -#define ZSTR_TX_QUALITY "TQly" -#define ZSTR_TX_SNR "TSNR" -#define ZSTR_PITCH "Ptch" -#define ZSTR_ROLL "Roll" -#define ZSTR_YAW "Yaw" -#define ZSTR_FLIGHT_MODE "FM" -#define ZSTR_THROTTLE "Thr" -#define ZSTR_QOS_A "FdeA" -#define ZSTR_QOS_B "FdeB" -#define ZSTR_QOS_L "FdeL" -#define ZSTR_QOS_R "FdeR" -#define ZSTR_QOS_F "FLss" -#define ZSTR_QOS_H "Hold" +#define ZSTR_BATT1_CONSUMPTION "RB1C" +#define ZSTR_BATT2_CONSUMPTION "RB2C" +#define ZSTR_BATT1_TEMP "RB1T" +#define ZSTR_BATT2_TEMP "RB2T" +#define ZSTR_RB_STATE "RBS" +#define ZSTR_CHANS_STATE "RBCS" +#define ZSTR_RX_RSSI1 "1RSS" +#define ZSTR_RX_RSSI2 "2RSS" +#define ZSTR_RX_QUALITY "RQly" +#define ZSTR_RX_SNR "RSNR" +#define ZSTR_ANTENNA "ANT" +#define ZSTR_RF_MODE "RFMD" +#define ZSTR_TX_POWER "TPWR" +#define ZSTR_TX_RSSI "TRSS" +#define ZSTR_TX_QUALITY "TQly" +#define ZSTR_TX_SNR "TSNR" +#define ZSTR_PITCH "Ptch" +#define ZSTR_ROLL "Roll" +#define ZSTR_YAW "Yaw" +#define ZSTR_FLIGHT_MODE "FM" +#define ZSTR_THROTTLE "Thr" +#define ZSTR_QOS_A "FdeA" +#define ZSTR_QOS_B "FdeB" +#define ZSTR_QOS_L "FdeL" +#define ZSTR_QOS_R "FdeR" +#define ZSTR_QOS_F "FLss" +#define ZSTR_QOS_H "Hold" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 598276c69..a2a8ff520 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -166,7 +166,7 @@ #define TR_RETA123 "RETA12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "RETA123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "RETA1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "RETA123LR" @@ -519,7 +519,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 9e5a27587..921be0de1 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -162,7 +162,7 @@ #define TR_RETA123 "RETA12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "RETA123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "RETA1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "RETA123LR" @@ -497,7 +497,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 40fdc2d6e..30b07a7d7 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -162,7 +162,7 @@ #define TR_RETA123 "RETA12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "RETA123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "RETA1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "RETA123LR" @@ -497,7 +497,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index cff60d615..de40282a8 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -162,7 +162,7 @@ #define TR_RETA123 "DPGA12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "DPGA123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "DPGA1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "DPGA123LR" @@ -504,7 +504,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 995791949..f96fc00d5 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -162,7 +162,7 @@ #define TR_RETA123 "DEMA12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "DEMA123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "DEMA123SDSD" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "DEMA123SD" @@ -504,7 +504,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index c44df1598..874170079 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -163,7 +163,7 @@ #define TR_RETA123 "RETA12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "RETA123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "RETA1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "RETA123LR" @@ -505,7 +505,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index e853bd6cb..b76183a26 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -164,7 +164,7 @@ #define TR_RETA123 "KWGL12345LR" #elif defined(PCBFLAMENCO) #define TR_RETA123 "KWGL123LR" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "KWGL1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "KWGL123LR" @@ -506,7 +506,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310S1\0""\310S2\0""\310S3\0""\310S4\0""\311LS\0""\311RS\0""\311LS2""\311RS2" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 680fc29bc..95c294fe3 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -492,7 +492,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index c17499200..e72d18630 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -160,7 +160,7 @@ #if defined(PCBFLAMENCO) #define TR_RETA123 "RHGS123HV" -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_RETA123 "RHGS1234HVHV" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "RHGS123HV" @@ -511,7 +511,7 @@ #elif defined(PCBFLAMENCO) #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " -#elif defined(PCBTARANIS) && defined(REV9E) +#elif defined(PCBX9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) diff --git a/radio/util/build-firmware.py b/radio/util/build-firmware.py index a0969e4fa..60200fa9f 100755 --- a/radio/util/build-firmware.py +++ b/radio/util/build-firmware.py @@ -98,22 +98,20 @@ elif options[optcount] == "ar9x": maxsize = 65536 * 4 board = BOARD_SKY9X board_family = BOARD_FAMILY_ARM -elif options[optcount] == "taranis": - command_options["PCB"] = "TARANIS" +elif options[optcount] == "x9d": + command_options["PCB"] = "X9D" firmware_options = options_taranis maxsize = 65536 * 8 board = BOARD_TARANIS board_family = BOARD_FAMILY_ARM -elif options[optcount] == "taranisplus": - command_options["PCB"] = "TARANIS" - command_options["PCBREV"] = "REVPLUS" +elif options[optcount] == "x9d+": + command_options["PCB"] = "X9D+" firmware_options = options_taranisplus maxsize = 65536 * 8 board = BOARD_TARANIS board_family = BOARD_FAMILY_ARM -elif options[optcount] == "taranisx9e": - command_options["PCB"] = "TARANIS" - command_options["PCBREV"] = "REV9E" +elif options[optcount] == "x9e": + command_options["PCB"] = "X9E" firmware_options = options_taranisx9e maxsize = 65536 * 8 board = BOARD_TARANIS @@ -220,4 +218,4 @@ if not os.path.isfile(path): shutil.copyfile(target, path) print filename -exit(0) \ No newline at end of file +exit(0) diff --git a/radio/util/build-companion.sh b/tools/build-companion.sh similarity index 81% rename from radio/util/build-companion.sh rename to tools/build-companion.sh index a71d82051..49dd605ab 100755 --- a/radio/util/build-companion.sh +++ b/tools/build-companion.sh @@ -29,13 +29,13 @@ make -j2 libsimulator cmake ${COMMON_OPTIONS} -DPCB=9XRPRO ${SRCDIR} make -j2 libsimulator -cmake ${STM32_OPTIONS} -DPCB=TARANIS ${SRCDIR} +cmake ${STM32_OPTIONS} -DPCB=X9D ${SRCDIR} make -j2 libsimulator -cmake ${STM32_OPTIONS} -DPCB=TARANIS -DPCBREV=REVPLUS ${SRCDIR} +cmake ${STM32_OPTIONS} -DPCB=X9D+ ${SRCDIR} make -j2 libsimulator -cmake ${STM32_OPTIONS} -DPCB=TARANIS -DPCBREV=REV9E ${SRCDIR} +cmake ${STM32_OPTIONS} -DPCB=X9E ${SRCDIR} make -j2 libsimulator cmake ${STM32_OPTIONS} -DPCB=HORUS ${SRCDIR} diff --git a/radio/util/commit-tests.sh b/tools/commit-tests.sh similarity index 81% rename from radio/util/commit-tests.sh rename to tools/commit-tests.sh index 8db70d9b3..91681eb5d 100755 --- a/radio/util/commit-tests.sh +++ b/tools/commit-tests.sh @@ -4,20 +4,13 @@ set -e set -x -cd $1 -SRCDIR=$(pwd) -cd - +SCRIPT=$(readlink -f "$0") +SRCDIR=$(dirname "$SCRIPT")/.. +COMMON_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/qt55" mkdir build || true cd build -COMMON_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/qt55" - -# Companion -rm -rf * -cmake ${COMMON_OPTIONS} ${SRCDIR} -make -j2 - # OpenTX on 9X stock with FrSky telemetry rm -rf * cmake ${COMMON_OPTIONS} -DPCB=9X -DHELI=YES -DEXT=FRSKY ${SRCDIR} @@ -67,28 +60,33 @@ make -j2 gtests ; ./gtests # OpenTX on Taranis rm -rf * -cmake ${COMMON_OPTIONS} -DPCB=TARANIS -DHELI=YES -DLUA=YES -DWARNINGS_AS_ERRORS=YES ${SRCDIR} +cmake ${COMMON_OPTIONS} -DPCB=X9D -DHELI=YES -DLUA=YES -DWARNINGS_AS_ERRORS=YES ${SRCDIR} make -j2 firmware make -j2 simu make -j2 gtests ; ./gtests # OpenTX on Taranis X9E rm -rf * -cmake ${COMMON_OPTIONS} -DPCB=TARANIS -DPCBREV=REV9E -DHELI=YES -DLUA=YES -DWARNINGS_AS_ERRORS=YES ${SRCDIR} +cmake ${COMMON_OPTIONS} -DPCB=X9E -DHELI=YES -DLUA=YES -DWARNINGS_AS_ERRORS=YES --DPPM_UNIT_PERCENT_PREC1=YES ${SRCDIR} make -j2 firmware make -j2 simu make -j2 gtests ; ./gtests # OpenTX on Taranis Plus rm -rf * -cmake ${COMMON_OPTIONS} -DPCB=TARANIS -DPCBREV=REVPLUS -DHELI=YES -DLUA=YES -DWARNINGS_AS_ERRORS=YES ${SRCDIR} +cmake ${COMMON_OPTIONS} -DPCB=X9D+ -DHELI=YES -DLUA=YES -DWARNINGS_AS_ERRORS=YES -DCURVES=YES ${SRCDIR} make -j2 firmware make -j2 simu make -j2 gtests ; ./gtests # OpenTX on Horus rm -rf * -cmake ${COMMON_OPTIONS} -DPCB=HORUS -DHELI=NO -DUSB=SERIAL -DCLI=YES -DDEBUG=YES ${SRCDIR} +cmake ${COMMON_OPTIONS} -DPCB=HORUS -DHELI=NO -DUSB=SERIAL -DCLI=YES -DDEBUG=YES -DGVARS=YES ${SRCDIR} make -j2 firmware make -j2 simu # make -j2 gtests ; ./gtests + +# Companion +rm -rf * +cmake ${COMMON_OPTIONS} ${SRCDIR} +make -j2 diff --git a/tools/nightly22/build-nightly.sh b/tools/nightly22/build-nightly.sh new file mode 100755 index 000000000..336b083ee --- /dev/null +++ b/tools/nightly22/build-nightly.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -e + +branch=next +docker=nightly22 +workdir=/home/opentx/nightly22 +output=/var/www/html/2.2/nightly + + +# Incrementnightly index +index=`cat index.txt` +index=`expr $index + 1` +echo $index > index.txt +suffix="N$index" + +cd ${workdir} + +# Call sdcard generation +code/tools/nightly22/build-sdcard.sh + +# Create on-demand build environment +cp code/radio/util/Dockerfile . +docker build -t new-$docker --build-arg OPENTX_VERSION_SUFFIX=$suffix . +docker rmi $docker || true +docker tag new-$docker $docker +docker rmi new-$docker + +# Build Linux companion +docker run -dit --name companion -v /home/opentx/$docker:/opentx $docker +docker exec companion sh -c "mkdir -p build && cd build && cmake /opentx/code && cp radio/src/stamp.h /opentx/binaries/stamp-opentx.txt" + +cp binaries/stamp-opentx.txt $output/firmware +docker exec companion rm -rf build +docker exec companion /opentx/code/tools/build-companion.sh /opentx/code /opentx/binaries/ $suffix +docker stop companion +docker rm companion +cp binaries/*.deb $output/companion/linux/ + +# Clean binaries It will be hosting built on demand firmware +rm -rf binaries/* +rm -rf binaries/.lock + +# Request companion compilation on Windows +cd $output/companion/windows +wget -qO- http://winbox.open-tx.org/companion-builds/compile22.php?branch=$branch\&suffix=$suffix +wget -O companion-windows-2.2.0$suffix.exe http://winbox.open-tx.org/companion-builds/companion-windows-2.2.0$suffix.exe +chmod -Rf g+w companion-windows-2.2.0$suffix.exe + +# Update windows stamp +rm -f companion-windows.stamp +echo "#define VERSION "'"2.2.0'$suffix'"' >> companion-windows.stamp + + diff --git a/tools/nightly22/build-sdcard.sh b/tools/nightly22/build-sdcard.sh new file mode 100755 index 000000000..2a9bc0a85 --- /dev/null +++ b/tools/nightly22/build-sdcard.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -e + +branch=next +workdir=/home/opentx/nightly22 +output=/var/www/html/2.2/nightly + +cd ${workdir} + +# Copy git sdcard data +rm -Rf ${workdir}/sdcard +cp -r ${workdir}/code/radio/sdcard . + +# Get images for Horus +mkdir -p ${workdir}/sdcard/horus/IMAGES +cp /home/opentx/horus-bitmaps/* ${workdir}/sdcard/horus/IMAGES/ + +# Request sound pack generation +wget -qO- http://winbox.open-tx.org/voice-builds/compile22.php?branch=${branch} + +# Get sounds +cd sdcard +wget http://winbox.open-tx.org/voice-builds/english-irish-taranis.zip +wget http://winbox.open-tx.org/voice-builds/english-scottish-taranis.zip +wget http://winbox.open-tx.org/voice-builds/english-american-taranis.zip +wget http://winbox.open-tx.org/voice-builds/english-australian-taranis.zip +wget http://winbox.open-tx.org/voice-builds/english-english-taranis.zip +wget http://winbox.open-tx.org/voice-builds/french-taranis.zip + +# Prepare the sdcard zip files for Horus +unzip english-irish-taranis.zip -d ${workdir}/sdcard/horus +mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-irish +unzip english-scottish-taranis.zip -d ${workdir}/sdcard/horus +mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-scottish +unzip english-australian-taranis.zip -d ${workdir}/sdcard/horus +mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-australian +unzip english-american-taranis.zip -d ${workdir}/sdcard/horus +mv ${workdir}/sdcard/horus/SOUNDS/en ${workdir}/sdcard/horus/SOUNDS/en-american +unzip english-english-taranis -d ${workdir}/sdcard/horus +unzip french-taranis.zip -d ${workdir}/sdcard/horus +wget -O ${workdir}/sdcard/horus/SOUNDS/en/english.cvs http://winbox.open-tx.org/voice-builds/english-english-taranis.csv +wget -O ${workdir}/sdcard/horus/SOUNDS/fr/french.cvs http://winbox.open-tx.org/voice-builds/french-taranis.csv + +# Duplicate for Taranis and create sdcards.zip +mkdir ${workdir}/sdcard/taranis/SOUNDS +cp -r ${workdir}/sdcard/horus/SOUNDS ${workdir}/sdcard/taranis/ +rm -f ${workdir}/sdcard/*.zip +cd ${workdir}/sdcard/taranis && zip -r ${output}/sdcard/sdcard-taranis.zip * +cd ${workdir}/sdcard/horus && zip -r ${output}/sdcard/sdcard-horus.zip * +rm -Rf ${workdir}/sdcard