mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 11:29:51 +03:00
parent
ebee591990
commit
40ece81de2
79 changed files with 1947 additions and 1370 deletions
|
@ -38,7 +38,8 @@ env:
|
||||||
# - FLAVOR=X9D
|
# - FLAVOR=X9D
|
||||||
# - FLAVOR=X9D+
|
# - FLAVOR=X9D+
|
||||||
# - FLAVOR=X9E
|
# - FLAVOR=X9E
|
||||||
- FLAVOR=X12
|
- FLAVOR=HORUS
|
||||||
|
# - FLAVOR=X10
|
||||||
# - FLAVOR=X12Sr10
|
# - FLAVOR=X12Sr10
|
||||||
# - FLAVOR=X12S
|
# - FLAVOR=X12S
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ namespace Board {
|
||||||
BOARD_TARANIS_X9DP,
|
BOARD_TARANIS_X9DP,
|
||||||
BOARD_TARANIS_X9E,
|
BOARD_TARANIS_X9E,
|
||||||
BOARD_FLAMENCO,
|
BOARD_FLAMENCO,
|
||||||
BOARD_HORUS,
|
BOARD_X12S,
|
||||||
|
BOARD_X10,
|
||||||
BOARD_UNKNOWN = -1
|
BOARD_UNKNOWN = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,7 +116,9 @@ Board::SwitchInfo getSwitchInfo(Board::Type board, unsigned index);
|
||||||
#define IS_TARANIS_PLUS(board) (board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E)
|
#define IS_TARANIS_PLUS(board) (board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E)
|
||||||
#define IS_TARANIS_X9E(board) (board==Board::BOARD_TARANIS_X9E)
|
#define IS_TARANIS_X9E(board) (board==Board::BOARD_TARANIS_X9E)
|
||||||
#define IS_TARANIS(board) (IS_TARANIS_X9(board) || IS_TARANIS_X7(board))
|
#define IS_TARANIS(board) (IS_TARANIS_X9(board) || IS_TARANIS_X7(board))
|
||||||
#define IS_HORUS(board) (board==Board::BOARD_HORUS)
|
#define IS_HORUS_X12S(board) (board==Board::BOARD_X12S)
|
||||||
|
#define IS_HORUS_X10(board) (board==Board::BOARD_X10)
|
||||||
|
#define IS_HORUS(board) (IS_HORUS_X12S(board) || IS_HORUS_X10(board))
|
||||||
#define IS_HORUS_OR_TARANIS(board) (IS_HORUS(board) || IS_TARANIS(board))
|
#define IS_HORUS_OR_TARANIS(board) (IS_HORUS(board) || IS_TARANIS(board))
|
||||||
#define IS_FLAMENCO(board) (board==Board::BOARD_FLAMENCO)
|
#define IS_FLAMENCO(board) (board==Board::BOARD_FLAMENCO)
|
||||||
#define IS_STM32(board) (IS_TARANIS(board) || IS_HORUS(board) || IS_FLAMENCO(board))
|
#define IS_STM32(board) (IS_TARANIS(board) || IS_HORUS(board) || IS_FLAMENCO(board))
|
||||||
|
|
|
@ -1745,8 +1745,10 @@ QString getBoardName(Board::Type board)
|
||||||
return "9XR-PRO";
|
return "9XR-PRO";
|
||||||
case Board::BOARD_AR9X:
|
case Board::BOARD_AR9X:
|
||||||
return "AR9X";
|
return "AR9X";
|
||||||
case Board::BOARD_HORUS:
|
case Board::BOARD_X12S:
|
||||||
return "Horus";
|
return "Horus";
|
||||||
|
case Board::BOARD_X10:
|
||||||
|
return "X10";
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
@ -1772,7 +1774,8 @@ const int Firmware::getFlashSize()
|
||||||
case Board::BOARD_TARANIS_X9E:
|
case Board::BOARD_TARANIS_X9E:
|
||||||
case Board::BOARD_FLAMENCO:
|
case Board::BOARD_FLAMENCO:
|
||||||
return FSIZE_TARANIS;
|
return FSIZE_TARANIS;
|
||||||
case Board::BOARD_HORUS:
|
case Board::BOARD_X12S:
|
||||||
|
case Board::BOARD_X10:
|
||||||
return FSIZE_HORUS;
|
return FSIZE_HORUS;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -3037,7 +3037,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig
|
||||||
|
|
||||||
eepromImportDebug() << QString("OpenTxModelData::OpenTxModelData(name: %1, board: %2, ver: %3, var: %4)").arg(name).arg(board).arg(version).arg(variant);
|
eepromImportDebug() << QString("OpenTxModelData::OpenTxModelData(name: %1, board: %2, ver: %3, var: %4)").arg(name).arg(board).arg(version).arg(variant);
|
||||||
|
|
||||||
if (board == BOARD_HORUS)
|
if (IS_HORUS(board))
|
||||||
internalField.Append(new ZCharField<15>(modelData.name, "Model name"));
|
internalField.Append(new ZCharField<15>(modelData.name, "Model name"));
|
||||||
else if (HAS_LARGE_LCD(board))
|
else if (HAS_LARGE_LCD(board))
|
||||||
internalField.Append(new ZCharField<12>(modelData.name, "Model name"));
|
internalField.Append(new ZCharField<12>(modelData.name, "Model name"));
|
||||||
|
|
|
@ -86,8 +86,10 @@ const char * OpenTxEepromInterface::getName()
|
||||||
return "OpenTX for ar9x board / 9X";
|
return "OpenTX for ar9x board / 9X";
|
||||||
case BOARD_FLAMENCO:
|
case BOARD_FLAMENCO:
|
||||||
return "OpenTX for Flamenco experimental";
|
return "OpenTX for Flamenco experimental";
|
||||||
case BOARD_HORUS:
|
case BOARD_X12S:
|
||||||
return "OpenTX for FrSky Horus";
|
return "OpenTX for FrSky Horus";
|
||||||
|
case BOARD_X10:
|
||||||
|
return "OpenTX for FrSky X10";
|
||||||
default:
|
default:
|
||||||
return "OpenTX for an unknown board";
|
return "OpenTX for an unknown board";
|
||||||
}
|
}
|
||||||
|
@ -96,7 +98,8 @@ const char * OpenTxEepromInterface::getName()
|
||||||
uint32_t OpenTxEepromInterface::getFourCC()
|
uint32_t OpenTxEepromInterface::getFourCC()
|
||||||
{
|
{
|
||||||
switch (board) {
|
switch (board) {
|
||||||
case BOARD_HORUS:
|
case BOARD_X12S:
|
||||||
|
case BOARD_X10:
|
||||||
return 0x3478746F;
|
return 0x3478746F;
|
||||||
case BOARD_TARANIS_X7:
|
case BOARD_TARANIS_X7:
|
||||||
return 0x3678746F;
|
return 0x3678746F;
|
||||||
|
@ -1267,11 +1270,18 @@ void registerOpenTxFirmwares()
|
||||||
registerOpenTxFirmware(firmware);
|
registerOpenTxFirmware(firmware);
|
||||||
|
|
||||||
/* FrSky Horus board */
|
/* FrSky Horus board */
|
||||||
firmware = new OpenTxFirmware("opentx-horus", QObject::tr("FrSky Horus"), BOARD_HORUS);
|
firmware = new OpenTxFirmware("opentx-x12s", QObject::tr("FrSky Horus"), BOARD_X12S);
|
||||||
addOpenTxFrskyOptions(firmware);
|
addOpenTxFrskyOptions(firmware);
|
||||||
firmware->addOption("pcbdev", QObject::tr("Use ONLY with first DEV pcb version"));
|
firmware->addOption("pcbdev", QObject::tr("Use ONLY with first DEV pcb version"));
|
||||||
registerOpenTxFirmware(firmware);
|
registerOpenTxFirmware(firmware);
|
||||||
|
|
||||||
|
|
||||||
|
/* FrSky X10 board */
|
||||||
|
/* Disabled for now
|
||||||
|
firmware = new OpenTxFirmware("opentx-x10", QObject::tr("FrSky X10"), BOARD_X10);
|
||||||
|
addOpenTxFrskyOptions(firmware);
|
||||||
|
registerOpenTxFirmware(firmware);
|
||||||
|
*/
|
||||||
/* 9XR-Pro */
|
/* 9XR-Pro */
|
||||||
firmware = new OpenTxFirmware("opentx-9xrpro", QObject::tr("Turnigy 9XR-PRO"), BOARD_9XRPRO);
|
firmware = new OpenTxFirmware("opentx-9xrpro", QObject::tr("Turnigy 9XR-PRO"), BOARD_9XRPRO);
|
||||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||||
|
|
|
@ -681,7 +681,7 @@ void MdiChild::setCurrentFile(const QString & fileName)
|
||||||
void MdiChild::writeEeprom() // write to Tx
|
void MdiChild::writeEeprom() // write to Tx
|
||||||
{
|
{
|
||||||
Board::Type board = getCurrentBoard();
|
Board::Type board = getCurrentBoard();
|
||||||
if (board == Board::BOARD_HORUS) {
|
if (IS_HORUS(board)) {
|
||||||
QString radioPath = findMassstoragePath("RADIO", true);
|
QString radioPath = findMassstoragePath("RADIO", true);
|
||||||
qDebug() << "Searching for SD card, found" << radioPath;
|
qDebug() << "Searching for SD card, found" << radioPath;
|
||||||
if (radioPath.isEmpty()) {
|
if (radioPath.isEmpty()) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ void RadioData::convert(Board::Type before, Board::Type after)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (after == Board::BOARD_HORUS) {
|
if (IS_HORUS(after)) {
|
||||||
fixModelFilenames();
|
fixModelFilenames();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -426,15 +426,16 @@ void SimulatorDialog::setupUi()
|
||||||
setWindowTitle(windowName);
|
setWindowTitle(windowName);
|
||||||
|
|
||||||
switch(m_board) {
|
switch(m_board) {
|
||||||
case Board::BOARD_TARANIS_X7 :
|
case Board::BOARD_TARANIS_X7:
|
||||||
radioUiWidget = new SimulatedUIWidgetX7(simulator, this);
|
radioUiWidget = new SimulatedUIWidgetX7(simulator, this);
|
||||||
break;
|
break;
|
||||||
case Board::BOARD_TARANIS_X9D :
|
case Board::BOARD_TARANIS_X9D:
|
||||||
case Board::BOARD_TARANIS_X9DP :
|
case Board::BOARD_TARANIS_X9DP:
|
||||||
case Board::BOARD_TARANIS_X9E :
|
case Board::BOARD_TARANIS_X9E:
|
||||||
radioUiWidget = new SimulatedUIWidgetX9(simulator, this);
|
radioUiWidget = new SimulatedUIWidgetX9(simulator, this);
|
||||||
break;
|
break;
|
||||||
case Board::BOARD_HORUS :
|
case Board::BOARD_X12S:
|
||||||
|
case Board::BOARD_X10:
|
||||||
radioUiWidget = new SimulatedUIWidgetX12(simulator, this);
|
radioUiWidget = new SimulatedUIWidgetX12(simulator, this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -86,7 +86,7 @@ void SimulatorStartupDialog::changeEvent(QEvent *e)
|
||||||
// FIXME : need a better way to check for this
|
// FIXME : need a better way to check for this
|
||||||
bool SimulatorStartupDialog::usesCategorizedStorage(const QString & name)
|
bool SimulatorStartupDialog::usesCategorizedStorage(const QString & name)
|
||||||
{
|
{
|
||||||
return name.contains("horus", Qt::CaseInsensitive);
|
return name.contains("x12s", Qt::CaseInsensitive) || name.contains("x10", Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimulatorStartupDialog::usesCategorizedStorage()
|
bool SimulatorStartupDialog::usesCategorizedStorage()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
include(CMakeForceCompiler)
|
include(CMakeForceCompiler)
|
||||||
include(Bitmaps)
|
include(Bitmaps)
|
||||||
|
|
||||||
set(PCB_TYPES X9D X9D+ X9E X7 HORUS 9X 9XR 9X128 9XR128 SKY9X 9XRPRO AR9X 9X2561 GRUVIN9X MEGA2560)
|
set(PCB_TYPES X7 X9D X9D+ X9E X10 X12S 9X 9XR 9X128 9XR128 9X2561 GRUVIN9X MEGA2560 SKY9X 9XRPRO AR9X)
|
||||||
set(GUI_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU NL)
|
set(GUI_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU NL)
|
||||||
set(TTS_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU)
|
set(TTS_LANGUAGES CZ DE EN ES FR IT PT SK SE PL HU)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ option(DANGEROUS_MODULE_FUNCTIONS "Dangerous module functions (RangeCheck / Bind
|
||||||
option(FAI "Competition mode (no telemetry)" OFF)
|
option(FAI "Competition mode (no telemetry)" OFF)
|
||||||
option(AUTOSOURCE "Automatic source detection in menus" ON)
|
option(AUTOSOURCE "Automatic source detection in menus" ON)
|
||||||
option(AUTOSWITCH "Automatic switch detection in menus" ON)
|
option(AUTOSWITCH "Automatic switch detection in menus" ON)
|
||||||
|
option(SEMIHOSTING "Enable debugger semihosting" OFF)
|
||||||
option(JITTER_MEASURE "Enable ADC jitter measurement" OFF)
|
option(JITTER_MEASURE "Enable ADC jitter measurement" OFF)
|
||||||
option(WATCHDOG_DISABLED "Disable hardware Watchdog" OFF)
|
option(WATCHDOG_DISABLED "Disable hardware Watchdog" OFF)
|
||||||
if(SDL_FOUND)
|
if(SDL_FOUND)
|
||||||
|
@ -81,7 +82,7 @@ set(FATFS_SRC
|
||||||
${FATFS_DIR}/option/ccsbcs.c
|
${FATFS_DIR}/option/ccsbcs.c
|
||||||
)
|
)
|
||||||
|
|
||||||
if(PCB STREQUAL HORUS)
|
if(PCB STREQUAL X12S OR PCB STREQUAL X10)
|
||||||
include(targets/horus/CMakeLists.txt)
|
include(targets/horus/CMakeLists.txt)
|
||||||
elseif(PCB STREQUAL X9E OR PCB STREQUAL X9D+ OR PCB STREQUAL X9D OR PCB STREQUAL X7)
|
elseif(PCB STREQUAL X9E OR PCB STREQUAL X9D+ OR PCB STREQUAL X9D OR PCB STREQUAL X7)
|
||||||
include(targets/taranis/CMakeLists.txt)
|
include(targets/taranis/CMakeLists.txt)
|
||||||
|
@ -165,7 +166,7 @@ else()
|
||||||
add_definitions(-DEEPROM -DEEPROM_RAW)
|
add_definitions(-DEEPROM -DEEPROM_RAW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARCH STREQUAL ARM AND NOT PCB STREQUAL HORUS AND NOT PCB STREQUAL FLAMENCO)
|
if(ARCH STREQUAL ARM AND NOT PCB STREQUAL X12S AND NOT PCB STREQUAL X10 AND NOT PCB STREQUAL FLAMENCO)
|
||||||
set(SRC ${SRC} storage/eeprom_conversions.cpp)
|
set(SRC ${SRC} storage/eeprom_conversions.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -204,7 +205,7 @@ if(NOT LUA STREQUAL NO)
|
||||||
set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp)
|
set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp)
|
||||||
endif()
|
endif()
|
||||||
set(SRC ${SRC} lua/interface.cpp lua/api_general.cpp lua/api_lcd.cpp lua/api_model.cpp)
|
set(SRC ${SRC} lua/interface.cpp lua/api_general.cpp lua/api_lcd.cpp lua/api_model.cpp)
|
||||||
if(PCB STREQUAL HORUS)
|
if(PCB STREQUAL X12S OR PCB STREQUAL X10)
|
||||||
set(SRC ${SRC} lua/widgets.cpp)
|
set(SRC ${SRC} lua/widgets.cpp)
|
||||||
endif()
|
endif()
|
||||||
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
|
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
|
||||||
|
@ -433,6 +434,10 @@ if(NOT MSVC)
|
||||||
|
|
||||||
# these are in addition to CMAKE_CXX_FLAGS
|
# these are in addition to CMAKE_CXX_FLAGS
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-lm -T${RADIO_SRC_DIRECTORY}/${LINKER_SCRIPT} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections")
|
set(CMAKE_EXE_LINKER_FLAGS "-lm -T${RADIO_SRC_DIRECTORY}/${LINKER_SCRIPT} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections")
|
||||||
|
if(SEMIHOSTING)
|
||||||
|
add_definitions(-DSEMIHOSTING)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=rdimon.specs")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL X9E OR PCB STREQUAL X7)
|
if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL X9E OR PCB STREQUAL X7)
|
||||||
add_subdirectory(targets/${TARGET_DIR}/bootloader)
|
add_subdirectory(targets/${TARGET_DIR}/bootloader)
|
||||||
|
|
|
@ -74,7 +74,7 @@ template <unsigned int NUM_BITS> class BitField {
|
||||||
|
|
||||||
#if defined(SIMU) && defined(SIMU_AUDIO)
|
#if defined(SIMU) && defined(SIMU_AUDIO)
|
||||||
#define AUDIO_BUFFER_COUNT (10) // simulator needs more buffers for smooth audio
|
#define AUDIO_BUFFER_COUNT (10) // simulator needs more buffers for smooth audio
|
||||||
#elif defined(PCBHORUS)
|
#elif defined(PCBX12S)
|
||||||
#define AUDIO_BUFFER_COUNT (2) // smaller than Taranis since there is also a buffer on the ADC chip
|
#define AUDIO_BUFFER_COUNT (2) // smaller than Taranis since there is also a buffer on the ADC chip
|
||||||
#else
|
#else
|
||||||
#define AUDIO_BUFFER_COUNT (3)
|
#define AUDIO_BUFFER_COUNT (3)
|
||||||
|
@ -101,7 +101,7 @@ enum AudioBufferState
|
||||||
#define AUDIO_DATA_MIN 0
|
#define AUDIO_DATA_MIN 0
|
||||||
#define AUDIO_DATA_MAX 0xffff
|
#define AUDIO_DATA_MAX 0xffff
|
||||||
#define AUDIO_BITS_PER_SAMPLE 16
|
#define AUDIO_BITS_PER_SAMPLE 16
|
||||||
#elif defined(PCBHORUS)
|
#elif defined(PCBX12S)
|
||||||
typedef int16_t audio_data_t;
|
typedef int16_t audio_data_t;
|
||||||
#define AUDIO_DATA_SILENCE 0
|
#define AUDIO_DATA_SILENCE 0
|
||||||
#define AUDIO_DATA_MIN INT16_MIN
|
#define AUDIO_DATA_MIN INT16_MIN
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
add_bitmaps_target(horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bmp_*.png" 480 5/6/5)
|
if(PCB STREQUAL X12S)
|
||||||
add_bitmaps_target(horus_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/bmp_*.png" 480 5/6/5)
|
add_bitmaps_target(x12s_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/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(x12s_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/bmp_*.png" 480 5/6/5)
|
||||||
add_bitmaps_target(horus_alpha_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/alpha_*.png" 480 4/4/4/4)
|
add_bitmaps_target(x12s_button_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/button/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(x12s_alpha_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/alpha_*.png" 480 4/4/4/4)
|
||||||
add_bitmaps_target(horus_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/mask_*.png 480 8bits)
|
add_bitmaps_target(x12s_alpha_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/alpha_*.png" 480 4/4/4/4)
|
||||||
add_bitmaps_target(horus_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
add_bitmaps_target(x12s_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/mask_*.png 480 8bits)
|
||||||
add_bitmaps_target(horus_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
add_bitmaps_target(x12s_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
||||||
add_bitmaps_target(horus_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5)
|
add_bitmaps_target(x12s_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
||||||
add_bitmaps_target(horus_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits)
|
add_bitmaps_target(x12s_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5)
|
||||||
add_bitmaps_target(horus_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
add_bitmaps_target(x12s_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.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)
|
add_bitmaps_target(x12s_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
||||||
|
add_dependencies(x12s_bitmaps x12s_calibration_bitmaps x12s_button_bitmaps x12s_alpha_bitmaps x12s_alpha_calibration_bitmaps x12s_masks x12s_slider_masks x12s_layouts_masks x12s_themes_bitmaps x12s_fonts x12s_volume_masks)
|
||||||
|
else()
|
||||||
|
add_bitmaps_target(x10_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/bmp_*.png" 480 5/6/5-R)
|
||||||
|
add_bitmaps_target(x10_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/bmp_*.png" 480 5/6/5-R)
|
||||||
|
add_bitmaps_target(x10_button_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/button/alpha_*.png" 480 4/4/4/4-R)
|
||||||
|
add_bitmaps_target(x10_alpha_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/alpha_*.png" 480 4/4/4/4-R)
|
||||||
|
add_bitmaps_target(x10_alpha_calibration_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/calibration/alpha_*.png" 480 4/4/4/4-R)
|
||||||
|
add_bitmaps_target(x10_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/mask_*.png 480 8bits)
|
||||||
|
add_bitmaps_target(x10_slider_masks "${RADIO_SRC_DIRECTORY}/bitmaps/480x272/slider/*.png" 480 8bits)
|
||||||
|
add_bitmaps_target(x10_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.png" 480 8bits)
|
||||||
|
add_bitmaps_target(x10_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.png" 480 5/6/5-R)
|
||||||
|
add_bitmaps_target(x10_fonts ${RADIO_SRC_DIRECTORY}/fonts/480x272/*.png 480 8bits)
|
||||||
|
add_bitmaps_target(x10_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/480x272/volume/*.png 480 8bits)
|
||||||
|
add_dependencies(x10_bitmaps x10_calibration_bitmaps x10_button_bitmaps x10_alpha_bitmaps x10_alpha_calibration_bitmaps x10_masks x10_slider_masks x10_layouts_masks x10_themes_bitmaps x10_fonts x10_volume_masks)
|
||||||
|
endif()
|
||||||
|
|
|
@ -681,7 +681,7 @@ int cliDisplay(const char ** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[1], "adc")) {
|
else if (!strcmp(argv[1], "adc")) {
|
||||||
for (int i=0; i<NUMBER_ANALOG; i++) {
|
for (int i=0; i<NUM_ANALOGS; i++) {
|
||||||
serialPrint("adc[%d] = %04X", i, (int)adcValues[i]);
|
serialPrint("adc[%d] = %04X", i, (int)adcValues[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,7 +859,7 @@ int cliRepeat(const char ** argv)
|
||||||
int cliShowJitter(const char ** argv)
|
int cliShowJitter(const char ** argv)
|
||||||
{
|
{
|
||||||
serialPrint( "# anaIn rawJ avgJ");
|
serialPrint( "# anaIn rawJ avgJ");
|
||||||
for (int i=0; i<NUMBER_ANALOG; i++) {
|
for (int i=0; i<NUM_ANALOGS; i++) {
|
||||||
serialPrint("A%02d %04X %04X %3d %3d", i, getAnalogValue(i), anaIn(i), rawJitter[i].get(), avgJitter[i].get());
|
serialPrint("A%02d %04X %04X %3d %3d", i, getAnalogValue(i), anaIn(i), rawJitter[i].get(), avgJitter[i].get());
|
||||||
if (IS_POT_MULTIPOS(i)) {
|
if (IS_POT_MULTIPOS(i)) {
|
||||||
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
|
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
|
||||||
|
@ -897,7 +897,7 @@ int cliGps(const char ** argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBX9E) || defined(PCBHORUS)
|
#if defined(BLUETOOTH)
|
||||||
int cliBlueTooth(const char ** argv)
|
int cliBlueTooth(const char ** argv)
|
||||||
{
|
{
|
||||||
int baudrate = 0;
|
int baudrate = 0;
|
||||||
|
@ -964,7 +964,7 @@ const CliCommand cliCommands[] = {
|
||||||
#if defined(INTERNAL_GPS)
|
#if defined(INTERNAL_GPS)
|
||||||
{ "gps", cliGps, "<baudrate>|$<command>|trace" },
|
{ "gps", cliGps, "<baudrate>|$<command>|trace" },
|
||||||
#endif
|
#endif
|
||||||
#if defined(PCBX9E) || defined(PCBHORUS)
|
#if defined(BLUETOOTH)
|
||||||
{ "bt", cliBlueTooth, "<baudrate>|$<command>|read" },
|
{ "bt", cliBlueTooth, "<baudrate>|$<command>|read" },
|
||||||
#endif
|
#endif
|
||||||
{ NULL, NULL, NULL } /* sentinel */
|
{ NULL, NULL, NULL } /* sentinel */
|
||||||
|
|
|
@ -215,12 +215,18 @@ enum CurveType {
|
||||||
#define NUM_ROTARY_ENCODERS 0
|
#define NUM_ROTARY_ENCODERS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBX10)
|
||||||
#define NUM_AUX_TRIMS 2
|
#define NUM_AUX_TRIMS 2
|
||||||
#define NUM_MOUSE_ANALOGS 2
|
#define NUM_MOUSE_ANALOGS 2
|
||||||
|
#define NUM_DUMMY_ANAS 2
|
||||||
|
#elif defined(PCBHORUS)
|
||||||
|
#define NUM_AUX_TRIMS 2
|
||||||
|
#define NUM_MOUSE_ANALOGS 2
|
||||||
|
#define NUM_DUMMY_ANAS 0
|
||||||
#else
|
#else
|
||||||
#define NUM_AUX_TRIMS 0
|
#define NUM_AUX_TRIMS 0
|
||||||
#define NUM_MOUSE_ANALOGS 0
|
#define NUM_MOUSE_ANALOGS 0
|
||||||
|
#define NUM_DUMMY_ANAS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
|
|
|
@ -776,8 +776,10 @@ PACK(struct CustomScreenData {
|
||||||
// TODO other boards could have their custom screens here as well
|
// TODO other boards could have their custom screens here as well
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBX12S)
|
||||||
#define MODELDATA_EXTRA NOBACKUP(uint8_t spare:3); NOBACKUP(uint8_t trainerMode:3); NOBACKUP(uint8_t potsWarnMode:2); ModuleData moduleData[NUM_MODULES+1]; NOBACKUP(ScriptData scriptsData[MAX_SCRIPTS]); NOBACKUP(char inputNames[MAX_INPUTS][LEN_INPUT_NAME]); NOBACKUP(uint8_t potsWarnEnabled); NOBACKUP(int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]);
|
#define MODELDATA_EXTRA NOBACKUP(uint8_t spare:3); NOBACKUP(uint8_t trainerMode:3); NOBACKUP(uint8_t potsWarnMode:2); ModuleData moduleData[NUM_MODULES+1]; NOBACKUP(ScriptData scriptsData[MAX_SCRIPTS]); NOBACKUP(char inputNames[MAX_INPUTS][LEN_INPUT_NAME]); NOBACKUP(uint8_t potsWarnEnabled); NOBACKUP(int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]);
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define MODELDATA_EXTRA NOBACKUP(uint8_t spare:3); NOBACKUP(uint8_t trainerMode:3); NOBACKUP(uint8_t potsWarnMode:2); ModuleData moduleData[NUM_MODULES+1]; NOBACKUP(ScriptData scriptsData[MAX_SCRIPTS]); NOBACKUP(char inputNames[MAX_INPUTS][LEN_INPUT_NAME]); NOBACKUP(uint8_t potsWarnEnabled); NOBACKUP(int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]); NOBACKUP(uint8_t potsWarnSpares[NUM_DUMMY_ANAS]);
|
||||||
#elif defined(PCBFLAMENCO)
|
#elif defined(PCBFLAMENCO)
|
||||||
#define MODELDATA_EXTRA uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS];
|
#define MODELDATA_EXTRA uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS];
|
||||||
#elif defined(PCBTARANIS)
|
#elif defined(PCBTARANIS)
|
||||||
|
@ -905,7 +907,7 @@ PACK(struct TrainerData {
|
||||||
uint32_t switchConfig; \
|
uint32_t switchConfig; \
|
||||||
uint8_t potsConfig; /* two bits per pot */ \
|
uint8_t potsConfig; /* two bits per pot */ \
|
||||||
NOBACKUP(char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]); \
|
NOBACKUP(char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]); \
|
||||||
NOBACKUP(char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS][LEN_ANA_NAME]); \
|
NOBACKUP(char anaNames[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_DUMMY_ANAS][LEN_ANA_NAME]); \
|
||||||
NOBACKUP(char currModelFilename[LEN_MODEL_FILENAME+1]); \
|
NOBACKUP(char currModelFilename[LEN_MODEL_FILENAME+1]); \
|
||||||
NOBACKUP(uint8_t bluetoothEnable:1); \
|
NOBACKUP(uint8_t bluetoothEnable:1); \
|
||||||
NOBACKUP(uint8_t blOffBright:7); \
|
NOBACKUP(uint8_t blOffBright:7); \
|
||||||
|
@ -977,7 +979,7 @@ PACK(struct TrainerData {
|
||||||
PACK(struct RadioData {
|
PACK(struct RadioData {
|
||||||
NOBACKUP(uint8_t version);
|
NOBACKUP(uint8_t version);
|
||||||
NOBACKUP(uint16_t variant);
|
NOBACKUP(uint16_t variant);
|
||||||
CalibData calib[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
CalibData calib[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS+NUM_DUMMY_ANAS];
|
||||||
NOBACKUP(uint16_t chkSum);
|
NOBACKUP(uint16_t chkSum);
|
||||||
N_HORUS_FIELD(int8_t currModel);
|
N_HORUS_FIELD(int8_t currModel);
|
||||||
N_HORUS_FIELD(uint8_t contrast);
|
N_HORUS_FIELD(uint8_t contrast);
|
||||||
|
@ -1095,7 +1097,6 @@ static inline void check_struct()
|
||||||
CHKSIZE(FrSkyTelemetryData, 106);
|
CHKSIZE(FrSkyTelemetryData, 106);
|
||||||
CHKSIZE(ModelHeader, 24);
|
CHKSIZE(ModelHeader, 24);
|
||||||
CHKSIZE(CurveData, 4);
|
CHKSIZE(CurveData, 4);
|
||||||
|
|
||||||
#if defined(PCBX9E)
|
#if defined(PCBX9E)
|
||||||
CHKSIZE(RadioData, 952);
|
CHKSIZE(RadioData, 952);
|
||||||
CHKSIZE(ModelData, 6520);
|
CHKSIZE(ModelData, 6520);
|
||||||
|
|
|
@ -38,6 +38,9 @@ extern "C" {
|
||||||
typedef void (*traceCallbackFunc)(const char * text);
|
typedef void (*traceCallbackFunc)(const char * text);
|
||||||
extern traceCallbackFunc traceCallback;
|
extern traceCallbackFunc traceCallback;
|
||||||
void debugPrintf(const char * format, ...);
|
void debugPrintf(const char * format, ...);
|
||||||
|
#elif defined(SEMIHOSTING)
|
||||||
|
#include <stdio.h>
|
||||||
|
#define debugPrintf(...) printf(__VA_ARGS__)
|
||||||
#elif defined(DEBUG) && defined(CLI) && defined(USB_SERIAL)
|
#elif defined(DEBUG) && defined(CLI) && defined(USB_SERIAL)
|
||||||
#define debugPrintf(...) do { if (cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0)
|
#define debugPrintf(...) do { if (cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0)
|
||||||
#elif defined(DEBUG) && defined(CLI)
|
#elif defined(DEBUG) && defined(CLI)
|
||||||
|
|
|
@ -304,7 +304,7 @@ void menuModelExpoOne(event_t event)
|
||||||
|
|
||||||
drawFunction(expoFn);
|
drawFunction(expoFn);
|
||||||
|
|
||||||
int16_t x512 = calibratedStick[ed->chn];
|
int16_t x512 = calibratedAnalogs[ed->chn];
|
||||||
lcdDrawNumber(LCD_W-8, 6*FH, calcRESXto100(x512), 0);
|
lcdDrawNumber(LCD_W-8, 6*FH, calcRESXto100(x512), 0);
|
||||||
int16_t y512 = expoFn(x512);
|
int16_t y512 = expoFn(x512);
|
||||||
lcdDrawNumber(LCD_W-8-6*FW, 1*FH, calcRESXto100(y512), 0);
|
lcdDrawNumber(LCD_W-8-6*FW, 1*FH, calcRESXto100(y512), 0);
|
||||||
|
|
|
@ -805,26 +805,26 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
|
||||||
// check pot 1 - if changed -> scroll values
|
// check pot 1 - if changed -> scroll values
|
||||||
static int16_t p1val;
|
static int16_t p1val;
|
||||||
static int16_t p1valprev;
|
static int16_t p1valprev;
|
||||||
p1valdiff = (p1val-calibratedStick[6]) / SCROLL_POT1_TH;
|
p1valdiff = (p1val-calibratedAnalogs[CALIBRATED_POT1]) / SCROLL_POT1_TH;
|
||||||
if (p1valdiff) {
|
if (p1valdiff) {
|
||||||
p1valdiff = (p1valprev-calibratedStick[6]) / 2;
|
p1valdiff = (p1valprev-calibratedAnalogs[CALIBRATED_POT1]) / 2;
|
||||||
p1val = calibratedStick[6];
|
p1val = calibratedAnalogs[CALIBRATED_POT1];
|
||||||
}
|
}
|
||||||
p1valprev = calibratedStick[6];
|
p1valprev = calibratedAnalogs[CALIBRATED_POT1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NAVIGATION_POT2)
|
#if defined(NAVIGATION_POT2)
|
||||||
// check pot 2 - if changed -> scroll menu
|
// check pot 2 - if changed -> scroll menu
|
||||||
static int16_t p2valprev;
|
static int16_t p2valprev;
|
||||||
p2valdiff = (p2valprev-calibratedStick[4]) / SCROLL_TH;
|
p2valdiff = (p2valprev-calibratedAnalogs[CALIBRATED_POT2]) / SCROLL_TH;
|
||||||
if (p2valdiff) p2valprev = calibratedStick[4];
|
if (p2valdiff) p2valprev = calibratedAnalogs[CALIBRATED_POT2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NAVIGATION_POT3)
|
#if defined(NAVIGATION_POT3)
|
||||||
// check pot 3 if changed -> cursor down/up
|
// check pot 3 if changed -> cursor down/up
|
||||||
static int16_t p3valprev;
|
static int16_t p3valprev;
|
||||||
int8_t scrollUD = (p3valprev-calibratedStick[5]) / SCROLL_TH;
|
int8_t scrollUD = (p3valprev-calibratedAnalogs[CALIBRATED_POT3]) / SCROLL_TH;
|
||||||
if (scrollUD) p3valprev = calibratedStick[5];
|
if (scrollUD) p3valprev = calibratedAnalogs[CALIBRATED_POT3];
|
||||||
#else
|
#else
|
||||||
#define scrollUD 0
|
#define scrollUD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -50,9 +50,9 @@ void menuRadioDiagAnalogs(event_t event)
|
||||||
#endif
|
#endif
|
||||||
lcdDrawHexNumber(x+3*FW-1, y, anaIn(i));
|
lcdDrawHexNumber(x+3*FW-1, y, anaIn(i));
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256, RIGHT);
|
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||||
#else
|
#else
|
||||||
lcdDraw8bitsNumber(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
lcdDraw8bitsNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ void drawPotsBars()
|
||||||
// Optimization by Mike Blandford
|
// Optimization by Mike Blandford
|
||||||
for (uint8_t x=LCD_W/2 - (NUM_POTS+NUM_SLIDERS-1) * 5 / 2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=5, i++) {
|
for (uint8_t x=LCD_W/2 - (NUM_POTS+NUM_SLIDERS-1) * 5 / 2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=5, i++) {
|
||||||
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
||||||
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
uint8_t len = ((calibratedAnalogs[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||||
V_BAR(x, LCD_H-8, len);
|
V_BAR(x, LCD_H-8, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,15 +59,15 @@ void drawPotsBars()
|
||||||
|
|
||||||
void doMainScreenGraphics()
|
void doMainScreenGraphics()
|
||||||
{
|
{
|
||||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
|
||||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||||
calibStickVert = -calibStickVert;
|
calibStickVert = -calibStickVert;
|
||||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
drawStick(LBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
|
||||||
|
|
||||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
|
||||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||||
calibStickVert = -calibStickVert;
|
calibStickVert = -calibStickVert;
|
||||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
drawStick(RBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
|
||||||
|
|
||||||
drawPotsBars();
|
drawPotsBars();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ void drawPotsBars()
|
||||||
// Optimization by Mike Blandford
|
// Optimization by Mike Blandford
|
||||||
for (uint8_t x=LCD_W/2-(NUM_POTS+NUM_SLIDERS)/2*BAR_SPACING+BAR_SPACING/2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=BAR_SPACING, i++) {
|
for (uint8_t x=LCD_W/2-(NUM_POTS+NUM_SLIDERS)/2*BAR_SPACING+BAR_SPACING/2, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; x+=BAR_SPACING, i++) {
|
||||||
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
if (IS_POT_SLIDER_AVAILABLE(i)) {
|
||||||
uint8_t len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
uint8_t len = ((calibratedAnalogs[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||||
V_BAR(x, LCD_H-8, len);
|
V_BAR(x, LCD_H-8, len);
|
||||||
putsStickName(x-2, LCD_H-6, i, TINSIZE);
|
putsStickName(x-2, LCD_H-6, i, TINSIZE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ void menuRadioDiagAnalogs(event_t event)
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
lcdDrawNumber(x+10*FW-1, y, rawJitter[i].get(), RIGHT);
|
lcdDrawNumber(x+10*FW-1, y, rawJitter[i].get(), RIGHT);
|
||||||
lcdDrawNumber(x+13*FW-1, y, avgJitter[i].get(), RIGHT);
|
lcdDrawNumber(x+13*FW-1, y, avgJitter[i].get(), RIGHT);
|
||||||
lcdDrawNumber(x+17*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256, RIGHT);
|
lcdDrawNumber(x+17*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||||
#else
|
#else
|
||||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256, RIGHT);
|
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,15 +72,15 @@ const pm_uchar icons[] PROGMEM = {
|
||||||
|
|
||||||
void doMainScreenGraphics()
|
void doMainScreenGraphics()
|
||||||
{
|
{
|
||||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
|
||||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||||
calibStickVert = -calibStickVert;
|
calibStickVert = -calibStickVert;
|
||||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
drawStick(LBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
|
||||||
|
|
||||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
|
||||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||||
calibStickVert = -calibStickVert;
|
calibStickVert = -calibStickVert;
|
||||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
drawStick(RBOX_CENTERX, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayTrims(uint8_t phase)
|
void displayTrims(uint8_t phase)
|
||||||
|
@ -174,7 +174,7 @@ void drawSliders()
|
||||||
lcdDrawSolidVerticalLine(x, y, LCD_H/2-2);
|
lcdDrawSolidVerticalLine(x, y, LCD_H/2-2);
|
||||||
lcdDrawSolidVerticalLine(x+1, y, LCD_H/2-2);
|
lcdDrawSolidVerticalLine(x+1, y, LCD_H/2-2);
|
||||||
y += LCD_H/2-4;
|
y += LCD_H/2-4;
|
||||||
y -= ((calibratedStick[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
|
y -= ((calibratedAnalogs[i]+RESX)*(LCD_H/2-4)/(RESX*2)); // calculate once per loop
|
||||||
lcdDrawSolidVerticalLine(x-1, y, 2);
|
lcdDrawSolidVerticalLine(x-1, y, 2);
|
||||||
lcdDrawSolidVerticalLine(x+2, y, 2);
|
lcdDrawSolidVerticalLine(x+2, y, 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t p
|
||||||
if (pat == SOLID) {
|
if (pat == SOLID) {
|
||||||
while (w--) {
|
while (w--) {
|
||||||
drawAlphaPixel(p, opacity, color);
|
drawAlphaPixel(p, opacity, color);
|
||||||
p++;
|
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -61,7 +61,7 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t p
|
||||||
else {
|
else {
|
||||||
pat = pat >> 1;
|
pat = pat >> 1;
|
||||||
}
|
}
|
||||||
p++;
|
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,8 @@ void BitmapBuffer::invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFla
|
||||||
for (int j=0; j<w; j++) {
|
for (int j=0; j<w; j++) {
|
||||||
// TODO ASSERT_IN_DISPLAY(p);
|
// TODO ASSERT_IN_DISPLAY(p);
|
||||||
RGB_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
RGB_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||||
drawPixel(p++, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
drawPixel(p, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||||
|
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +257,8 @@ void BitmapBuffer::drawMask(coord_t x, coord_t y, BitmapBuffer * mask, LcdFlags
|
||||||
display_t * q = mask->getPixelPtr(offset, row);
|
display_t * q = mask->getPixelPtr(offset, row);
|
||||||
for (coord_t col=0; col<width; col++) {
|
for (coord_t col=0; col<width; col++) {
|
||||||
drawAlphaPixel(p, *((uint8_t *)q), color);
|
drawAlphaPixel(p, *((uint8_t *)q), color);
|
||||||
p++; q++;
|
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||||
|
MOVE_TO_NEXT_RIGHT_PIXEL(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,10 +491,10 @@ BitmapBuffer * BitmapBuffer::loadMask(const char * filename)
|
||||||
{
|
{
|
||||||
BitmapBuffer * bitmap = BitmapBuffer::load(filename);
|
BitmapBuffer * bitmap = BitmapBuffer::load(filename);
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
display_t * p = bitmap->getData();
|
display_t * p = bitmap->getPixelPtr(0, 0);
|
||||||
for (int i = bitmap->getWidth() * bitmap->getHeight(); i > 0; i--) {
|
for (int i = bitmap->getWidth() * bitmap->getHeight(); i > 0; i--) {
|
||||||
*((uint8_t *)p) = OPACITY_MAX - ((*p) >> 12);
|
*((uint8_t *)p) = OPACITY_MAX - ((*p) >> 12);
|
||||||
p++;
|
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
@ -624,14 +626,13 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t * dest = bmp->getData();
|
|
||||||
uint32_t rowSize;
|
uint32_t rowSize;
|
||||||
bool hasAlpha = false;
|
bool hasAlpha = false;
|
||||||
|
|
||||||
switch (depth) {
|
switch (depth) {
|
||||||
case 32:
|
case 32:
|
||||||
for (int i=h-1; i>=0; i--) {
|
for (int i=h-1; i>=0; i--) {
|
||||||
uint8_t * dst = ((uint8_t *)dest) + i*w*2;
|
display_t * dst = bmp->getPixelPtr(0, i);
|
||||||
for (unsigned int j=0; j<w; j++) {
|
for (unsigned int j=0; j<w; j++) {
|
||||||
uint32_t pixel;
|
uint32_t pixel;
|
||||||
result = f_read(&imgFile, (uint8_t *)&pixel, 4, &read);
|
result = f_read(&imgFile, (uint8_t *)&pixel, 4, &read);
|
||||||
|
@ -641,23 +642,23 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (hasAlpha) {
|
if (hasAlpha) {
|
||||||
*((uint16_t *)dst) = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((pixel & 0xff) == 0xff) {
|
if ((pixel & 0xff) == 0xff) {
|
||||||
*((uint16_t *)dst) = RGB(pixel >> 24, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
*dst = RGB(pixel >> 24, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hasAlpha = true;
|
hasAlpha = true;
|
||||||
bmp->setFormat(BMP_ARGB4444);
|
bmp->setFormat(BMP_ARGB4444);
|
||||||
for (uint16_t * p = dest + i*w; p<dest + h*w; p++) {
|
for (display_t * p = bmp->getPixelPtr(j, i); p != bmp->getPixelPtr(0, h); MOVE_TO_NEXT_RIGHT_PIXEL(p)) {
|
||||||
uint16_t tmp = *p;
|
display_t tmp = *p;
|
||||||
*p = ((tmp >> 1) & 0x0f) + (((tmp >> 7) & 0x0f) << 4) + (((tmp >> 12) & 0x0f) << 8);
|
*p = ((tmp >> 1) & 0x0f) + (((tmp >> 7) & 0x0f) << 4) + (((tmp >> 12) & 0x0f) << 8);
|
||||||
}
|
}
|
||||||
*((uint16_t *)dst) = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dst += 2;
|
MOVE_TO_NEXT_RIGHT_PIXEL(dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -674,12 +675,12 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||||
delete bmp;
|
delete bmp;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
uint8_t * dst = ((uint8_t *)dest) + i*w*2;
|
display_t * dst = bmp->getPixelPtr(0, i);
|
||||||
for (uint32_t j=0; j<w; j++) {
|
for (uint32_t j=0; j<w; j++) {
|
||||||
uint8_t index = (buf[j/2] >> ((j & 1) ? 0 : 4)) & 0x0F;
|
uint8_t index = (buf[j/2] >> ((j & 1) ? 0 : 4)) & 0x0F;
|
||||||
uint8_t val = palette[index];
|
uint8_t val = palette[index];
|
||||||
*((uint16_t *)dst) = RGB(val, val, val);
|
*dst = RGB(val, val, val);
|
||||||
dst += 2;
|
MOVE_TO_NEXT_RIGHT_PIXEL(dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -792,22 +793,22 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename)
|
||||||
#if 0
|
#if 0
|
||||||
DMABitmapConvert(bmp->data, img, w, h, n == 4 ? DMA2D_ARGB4444 : DMA2D_RGB565);
|
DMABitmapConvert(bmp->data, img, w, h, n == 4 ? DMA2D_ARGB4444 : DMA2D_RGB565);
|
||||||
#else
|
#else
|
||||||
uint16_t * dest = bmp->getData();
|
display_t * dest = bmp->getPixelPtr(0, 0);
|
||||||
const uint8_t * p = img;
|
const uint8_t * p = img;
|
||||||
if (n == 4) {
|
if (n == 4) {
|
||||||
for(int row = 0; row < h; ++row) {
|
for (int row = 0; row < h; ++row) {
|
||||||
for(int col = 0; col < w; ++col) {
|
for (int col = 0; col < w; ++col) {
|
||||||
*dest = ARGB(p[3], p[0], p[1], p[2]);
|
*dest = ARGB(p[3], p[0], p[1], p[2]);
|
||||||
++dest;
|
MOVE_TO_NEXT_RIGHT_PIXEL(dest);
|
||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(int row = 0; row < h; ++row) {
|
for (int row = 0; row < h; ++row) {
|
||||||
for(int col = 0; col < w; ++col) {
|
for (int col = 0; col < w; ++col) {
|
||||||
*dest = RGB(p[0], p[1], p[2]);
|
*dest = RGB(p[0], p[1], p[2]);
|
||||||
++dest;
|
MOVE_TO_NEXT_RIGHT_PIXEL(dest);
|
||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,15 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
#define MOVE_PIXEL_RIGHT(p, count) p -= count
|
||||||
|
#else
|
||||||
|
#define MOVE_PIXEL_RIGHT(p, count) p += count
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MOVE_TO_NEXT_RIGHT_PIXEL(p) MOVE_PIXEL_RIGHT(p, 1)
|
||||||
|
|
||||||
|
|
||||||
#define USE_STB
|
#define USE_STB
|
||||||
|
|
||||||
// TODO should go to lcd.h again
|
// TODO should go to lcd.h again
|
||||||
|
@ -70,6 +79,15 @@ class BitmapBufferBase
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const display_t * getPixelPtr(coord_t x, coord_t y) const
|
||||||
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = width - x - 1;
|
||||||
|
y = height - y - 1;
|
||||||
|
#endif
|
||||||
|
return &data[y*width + x];
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t format;
|
uint8_t format;
|
||||||
uint16_t width;
|
uint16_t width;
|
||||||
|
@ -140,8 +158,21 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const display_t * getPixelPtr(coord_t x, coord_t y) const
|
||||||
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = width - x - 1;
|
||||||
|
y = height - y - 1;
|
||||||
|
#endif
|
||||||
|
return &data[y*width + x];
|
||||||
|
}
|
||||||
|
|
||||||
inline display_t * getPixelPtr(coord_t x, coord_t y)
|
inline display_t * getPixelPtr(coord_t x, coord_t y)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = width - x - 1;
|
||||||
|
y = height - y - 1;
|
||||||
|
#endif
|
||||||
return &data[y*width + x];
|
return &data[y*width + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +211,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||||
if (!data || h==0 || w==0) return;
|
if (!data || h==0 || w==0) return;
|
||||||
if (h<0) { y+=h; h=-h; }
|
if (h<0) { y+=h; h=-h; }
|
||||||
if (w<0) { x+=w; w=-w; }
|
if (w<0) { x+=w; w=-w; }
|
||||||
DMAFillRect(data, width, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
DMAFillRect(data, width, height, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att);
|
void drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att);
|
||||||
|
@ -242,10 +273,10 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||||
h = height - y;
|
h = height - y;
|
||||||
}
|
}
|
||||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||||
DMACopyAlphaBitmap(data, this->width, x, y, bmp->getData(), srcw, srcx, srcy, w, h);
|
DMACopyAlphaBitmap(data, width, height, x, y, bmp->getData(), srcw, srch, srcx, srcy, w, h);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DMACopyBitmap(data, width, x, y, bmp->getData(), srcw, srcx, srcy, w, h);
|
DMACopyBitmap(data, width, height, x, y, bmp->getData(), srcw, srch, srcx, srcy, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -258,10 +289,11 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||||
scaledh = height - y;
|
scaledh = height - y;
|
||||||
|
|
||||||
for (int i = 0; i < scaledh; i++) {
|
for (int i = 0; i < scaledh; i++) {
|
||||||
uint16_t * p = &data[(y + i) * width + x];
|
display_t * p = getPixelPtr(x, y + i);
|
||||||
const uint16_t * qstart = &bmp->getData()[(srcy + int(i / scale)) * bmp->getWidth() + srcx];
|
const display_t * qstart = bmp->getPixelPtr(srcx, srcy + int(i / scale));
|
||||||
for (int j = 0; j < scaledw; j++) {
|
for (int j = 0; j < scaledw; j++) {
|
||||||
const uint16_t * q = qstart + int(j / scale);
|
const display_t * q = qstart;
|
||||||
|
MOVE_PIXEL_RIGHT(q, int(j / scale));
|
||||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||||
ARGB_SPLIT(*q, a, r, g, b);
|
ARGB_SPLIT(*q, a, r, g, b);
|
||||||
drawAlphaPixel(p, a, RGB_JOIN(r<<1, g<<2, b<<1));
|
drawAlphaPixel(p, a, RGB_JOIN(r<<1, g<<2, b<<1));
|
||||||
|
@ -269,7 +301,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||||
else {
|
else {
|
||||||
drawPixel(p, *q);
|
drawPixel(p, *q);
|
||||||
}
|
}
|
||||||
p++;
|
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,8 +411,13 @@ void lcdDrawBlackOverlay()
|
||||||
BitmapBuffer _lcd(BMP_RGB565, LCD_W, LCD_H, displayBuf);
|
BitmapBuffer _lcd(BMP_RGB565, LCD_W, LCD_H, displayBuf);
|
||||||
BitmapBuffer * lcd = &_lcd;
|
BitmapBuffer * lcd = &_lcd;
|
||||||
|
|
||||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i=0; i<h; i++) {
|
for (int i=0; i<h; i++) {
|
||||||
for (int j=0; j<w; j++) {
|
for (int j=0; j<w; j++) {
|
||||||
dest[(y+i)*destw+x+j] = color;
|
dest[(y+i)*destw+x+j] = color;
|
||||||
|
@ -420,15 +425,29 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
srcx = srcw - (srcx + w);
|
||||||
|
srcy = srch - (srcy + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i=0; i<h; i++) {
|
for (int i=0; i<h; i++) {
|
||||||
memcpy(dest+(y+i)*destw+x, src+(srcy+i)*srcw+srcx, 2*w);
|
memcpy(dest+(y+i)*destw+x, src+(srcy+i)*srcw+srcx, 2*w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
srcx = srcw - (srcx + w);
|
||||||
|
srcy = srch - (srcy + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (coord_t line=0; line<h; line++) {
|
for (coord_t line=0; line<h; line++) {
|
||||||
uint16_t * p = dest + (y+line)*destw + x;
|
uint16_t * p = dest + (y+line)*destw + x;
|
||||||
const uint16_t * q = src + (srcy+line)*srcw + srcx;
|
const uint16_t * q = src + (srcy+line)*srcw + srcx;
|
||||||
|
|
|
@ -363,6 +363,9 @@ bool menuModelSelect(event_t event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_PGUP):
|
case EVT_KEY_FIRST(KEY_PGUP):
|
||||||
|
#if defined(PCBX10)
|
||||||
|
case EVT_KEY_LONG(KEY_PGDN):
|
||||||
|
#endif
|
||||||
if (selectMode == MODE_SELECT_MODEL) {
|
if (selectMode == MODE_SELECT_MODEL) {
|
||||||
if (categoriesVerticalPosition == 0)
|
if (categoriesVerticalPosition == 0)
|
||||||
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
||||||
|
@ -378,9 +381,14 @@ bool menuModelSelect(event_t event)
|
||||||
modelslist.moveModel(model, previous_category, currentCategory);
|
modelslist.moveModel(model, previous_category, currentCategory);
|
||||||
setCurrentModel(currentCategory->size()-1);
|
setCurrentModel(currentCategory->size()-1);
|
||||||
}
|
}
|
||||||
|
killEvents(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
case EVT_KEY_FIRST(KEY_PGDN):
|
case EVT_KEY_FIRST(KEY_PGDN):
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
case EVT_KEY_BREAK(KEY_PGDN):
|
||||||
|
#endif
|
||||||
if (selectMode == MODE_SELECT_MODEL) {
|
if (selectMode == MODE_SELECT_MODEL) {
|
||||||
categoriesVerticalPosition += 1;
|
categoriesVerticalPosition += 1;
|
||||||
if (categoriesVerticalPosition >= modelslist.categories.size())
|
if (categoriesVerticalPosition >= modelslist.categories.size())
|
||||||
|
|
|
@ -352,14 +352,22 @@ bool check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
|
||||||
if (menuTab && !menuCalibrationState) {
|
if (menuTab && !menuCalibrationState) {
|
||||||
int cc = curr;
|
int cc = curr;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
#if defined(PCBX12S)
|
||||||
case EVT_KEY_FIRST(KEY_PGDN):
|
case EVT_KEY_FIRST(KEY_PGDN):
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
case EVT_KEY_BREAK(KEY_PGDN):
|
||||||
|
#endif
|
||||||
if (++cc == menuTabSize)
|
if (++cc == menuTabSize)
|
||||||
cc = 0;
|
cc = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_PGUP):
|
case EVT_KEY_FIRST(KEY_PGUP):
|
||||||
|
#if defined(PCBX10)
|
||||||
|
case EVT_KEY_LONG(KEY_PGDN):
|
||||||
|
#endif
|
||||||
if (cc-- == 0)
|
if (cc-- == 0)
|
||||||
cc = menuTabSize-1;
|
cc = menuTabSize-1;
|
||||||
|
killEvents(event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,15 +45,15 @@ void drawStick(coord_t x, coord_t y, const BitmapBuffer * background, int16_t xv
|
||||||
|
|
||||||
void drawSticks()
|
void drawSticks()
|
||||||
{
|
{
|
||||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
int16_t calibStickVert = calibratedAnalogs[CONVERT_MODE(1)];
|
||||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||||
calibStickVert = -calibStickVert;
|
calibStickVert = -calibStickVert;
|
||||||
drawStick(STICK_LEFT_X, STICKS_Y, calibStickBackground, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
drawStick(STICK_LEFT_X, STICKS_Y, calibStickBackground, calibratedAnalogs[CONVERT_MODE(0)], calibStickVert);
|
||||||
|
|
||||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
calibStickVert = calibratedAnalogs[CONVERT_MODE(2)];
|
||||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||||
calibStickVert = -calibStickVert;
|
calibStickVert = -calibStickVert;
|
||||||
drawStick(STICK_RIGHT_X, STICKS_Y, calibStickBackground, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
drawStick(STICK_RIGHT_X, STICKS_Y, calibStickBackground, calibratedAnalogs[CONVERT_MODE(3)], calibStickVert);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPots()
|
void drawPots()
|
||||||
|
@ -62,17 +62,19 @@ void drawPots()
|
||||||
extern void drawMainPots();
|
extern void drawMainPots();
|
||||||
drawMainPots();
|
drawMainPots();
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
// The 2 main front sliders
|
// The 2 main front sliders
|
||||||
drawVerticalSlider(125, 120, 120, calibratedStick[7], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS |
|
drawVerticalSlider(125, 120, 120, calibratedAnalogs[CALIBRATED_SLIDER_FRONT_LEFT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
OPTION_SLIDER_SQUARE_BUTTON);
|
drawVerticalSlider(LCD_W-125-12, 120, 120, calibratedAnalogs[CALIBRATED_SLIDER_FRONT_RIGHT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
drawVerticalSlider(LCD_W-125-12, 120, 120, calibratedStick[8], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS |
|
#endif
|
||||||
OPTION_SLIDER_SQUARE_BUTTON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
void drawMouse()
|
void drawMouse()
|
||||||
{
|
{
|
||||||
drawStick(STICK_LEFT_X, STICKS_Y+100, calibTrackpBackground, calibratedStick[11], calibratedStick[12]);
|
drawStick(STICK_LEFT_X, STICKS_Y+100, calibTrackpBackground, calibratedAnalogs[CALIBRATED_MOUSE1], calibratedAnalogs[CALIBRATED_MOUSE2]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool menuCommonCalib(event_t event)
|
bool menuCommonCalib(event_t event)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +215,10 @@ bool menuCommonCalib(event_t event)
|
||||||
|
|
||||||
drawSticks();
|
drawSticks();
|
||||||
drawPots();
|
drawPots();
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
drawMouse();
|
drawMouse();
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,10 @@ enum MenuRadioHardwareItems {
|
||||||
ITEM_RADIO_HARDWARE_POT3,
|
ITEM_RADIO_HARDWARE_POT3,
|
||||||
ITEM_RADIO_HARDWARE_LS,
|
ITEM_RADIO_HARDWARE_LS,
|
||||||
ITEM_RADIO_HARDWARE_RS,
|
ITEM_RADIO_HARDWARE_RS,
|
||||||
|
#if defined(PCBX12S)
|
||||||
ITEM_RADIO_HARDWARE_LS2,
|
ITEM_RADIO_HARDWARE_LS2,
|
||||||
ITEM_RADIO_HARDWARE_RS2,
|
ITEM_RADIO_HARDWARE_RS2,
|
||||||
|
#endif
|
||||||
ITEM_RADIO_HARDWARE_LABEL_SWITCHES,
|
ITEM_RADIO_HARDWARE_LABEL_SWITCHES,
|
||||||
ITEM_RADIO_HARDWARE_SA,
|
ITEM_RADIO_HARDWARE_SA,
|
||||||
ITEM_RADIO_HARDWARE_SB,
|
ITEM_RADIO_HARDWARE_SB,
|
||||||
|
@ -54,14 +56,18 @@ enum MenuRadioHardwareItems {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HW_SETTINGS_COLUMN 150
|
#define HW_SETTINGS_COLUMN 150
|
||||||
|
#if defined(PCBX10)
|
||||||
|
#define POTS_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
|
||||||
|
#else
|
||||||
#define POTS_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
|
#define POTS_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
|
||||||
|
#endif
|
||||||
#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
|
#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
|
||||||
#define BLUETOOTH_ROWS 1,
|
#define BLUETOOTH_ROWS 1,
|
||||||
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
|
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
|
||||||
|
|
||||||
bool menuRadioHardware(event_t event)
|
bool menuRadioHardware(event_t event)
|
||||||
{
|
{
|
||||||
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, BLUETOOTH_ROWS 0 });
|
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, BLUETOOTH_ROWS 0, 0, 0 });
|
||||||
|
|
||||||
uint8_t sub = menuVerticalPosition;
|
uint8_t sub = menuVerticalPosition;
|
||||||
|
|
||||||
|
@ -93,8 +99,10 @@ bool menuRadioHardware(event_t event)
|
||||||
|
|
||||||
case ITEM_RADIO_HARDWARE_LS:
|
case ITEM_RADIO_HARDWARE_LS:
|
||||||
case ITEM_RADIO_HARDWARE_RS:
|
case ITEM_RADIO_HARDWARE_RS:
|
||||||
|
#if defined(PCBX12S)
|
||||||
case ITEM_RADIO_HARDWARE_LS2:
|
case ITEM_RADIO_HARDWARE_LS2:
|
||||||
case ITEM_RADIO_HARDWARE_RS2:
|
case ITEM_RADIO_HARDWARE_RS2:
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int idx = k - ITEM_RADIO_HARDWARE_LS;
|
int idx = k - ITEM_RADIO_HARDWARE_LS;
|
||||||
uint8_t mask = (0x01 << idx);
|
uint8_t mask = (0x01 << idx);
|
||||||
|
|
|
@ -48,13 +48,21 @@ bool menuAboutView(event_t event)
|
||||||
screenIndex = 0;
|
screenIndex = 0;
|
||||||
greyIndex = 0;
|
greyIndex = 0;
|
||||||
break;
|
break;
|
||||||
|
#if defined(PCBX12S)
|
||||||
case EVT_KEY_FIRST(KEY_PGDN):
|
case EVT_KEY_FIRST(KEY_PGDN):
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
case EVT_KEY_BREAK(KEY_PGDN):
|
||||||
|
#endif
|
||||||
screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX;
|
screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX;
|
||||||
greyIndex = 0;
|
greyIndex = 0;
|
||||||
break;
|
break;
|
||||||
case EVT_KEY_FIRST(KEY_PGUP):
|
case EVT_KEY_FIRST(KEY_PGUP):
|
||||||
|
#if defined(PCBX10)
|
||||||
|
case EVT_KEY_LONG(KEY_PGDN):
|
||||||
|
#endif
|
||||||
screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS;
|
screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS;
|
||||||
greyIndex = 0;
|
greyIndex = 0;
|
||||||
|
killEvents(event);
|
||||||
break;
|
break;
|
||||||
case EVT_KEY_FIRST(KEY_EXIT):
|
case EVT_KEY_FIRST(KEY_EXIT):
|
||||||
chainMenu(menuMainView);
|
chainMenu(menuMainView);
|
||||||
|
|
|
@ -35,13 +35,13 @@ Topbar * topbar;
|
||||||
void drawMainPots()
|
void drawMainPots()
|
||||||
{
|
{
|
||||||
// The 3 pots
|
// The 3 pots
|
||||||
drawHorizontalSlider(TRIM_LH_X, POTS_LINE_Y, 160, calibratedStick[4], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
drawHorizontalSlider(TRIM_LH_X, POTS_LINE_Y, 160, calibratedAnalogs[CALIBRATED_POT1], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
drawHorizontalSlider(LCD_W/2-20, POTS_LINE_Y, XPOTS_MULTIPOS_COUNT*5, 1 + (potsPos[1] & 0x0f), 1, XPOTS_MULTIPOS_COUNT + 1, XPOTS_MULTIPOS_COUNT, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_NUMBER_BUTTON);
|
drawHorizontalSlider(LCD_W/2-20, POTS_LINE_Y, XPOTS_MULTIPOS_COUNT*5, 1 + (potsPos[1] & 0x0f), 1, XPOTS_MULTIPOS_COUNT + 1, XPOTS_MULTIPOS_COUNT, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_NUMBER_BUTTON);
|
||||||
drawHorizontalSlider(TRIM_RH_X, POTS_LINE_Y, 160, calibratedStick[6], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
drawHorizontalSlider(TRIM_RH_X, POTS_LINE_Y, 160, calibratedAnalogs[CALIBRATED_POT3], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
|
|
||||||
// The 2 rear sliders
|
// The 2 rear sliders
|
||||||
drawVerticalSlider(6, TRIM_V_Y, 160, calibratedStick[9], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
drawVerticalSlider(6, TRIM_V_Y, 160, calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
drawVerticalSlider(LCD_W-18, TRIM_V_Y, 160, calibratedStick[10], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
drawVerticalSlider(LCD_W-18, TRIM_V_Y, 160, calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTrims(uint8_t flightMode)
|
void drawTrims(uint8_t flightMode)
|
||||||
|
@ -175,12 +175,19 @@ bool menuMainView(event_t event)
|
||||||
pushMenu(menuTabScreensSetup[1]);
|
pushMenu(menuTabScreensSetup[1]);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
case EVT_KEY_FIRST(KEY_PGDN):
|
case EVT_KEY_FIRST(KEY_PGDN):
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
case EVT_KEY_BREAK(KEY_PGDN):
|
||||||
|
#endif
|
||||||
storageDirty(EE_GENERAL);
|
storageDirty(EE_GENERAL);
|
||||||
g_model.view = circularIncDec(g_model.view, +1, 0, getMainViewsCount()-1);
|
g_model.view = circularIncDec(g_model.view, +1, 0, getMainViewsCount()-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_PGUP):
|
case EVT_KEY_FIRST(KEY_PGUP):
|
||||||
|
#if defined(PCBX10)
|
||||||
|
case EVT_KEY_LONG(KEY_PGDN):
|
||||||
|
#endif
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
storageDirty(EE_GENERAL);
|
storageDirty(EE_GENERAL);
|
||||||
g_model.view = circularIncDec(g_model.view, -1, 0, getMainViewsCount()-1);
|
g_model.view = circularIncDec(g_model.view, -1, 0, getMainViewsCount()-1);
|
||||||
|
|
|
@ -150,7 +150,7 @@ bool menuStatsAnalogs(event_t event)
|
||||||
{
|
{
|
||||||
MENU("Analogs", STATS_ICONS, menuTabStats, e_StatsAnalogs, 0, { 0 });
|
MENU("Analogs", STATS_ICONS, menuTabStats, e_StatsAnalogs, 0, { 0 });
|
||||||
|
|
||||||
for (uint8_t i=0; i<NUMBER_ANALOG; i++) {
|
for (uint8_t i=0; i<NUM_ANALOGS; i++) {
|
||||||
coord_t y = MENU_CONTENT_TOP + (i/2)*FH;
|
coord_t y = MENU_CONTENT_TOP + (i/2)*FH;
|
||||||
coord_t x = MENUS_MARGIN_LEFT + (i & 1 ? LCD_W/2 : 0);
|
coord_t x = MENUS_MARGIN_LEFT + (i & 1 ? LCD_W/2 : 0);
|
||||||
lcdDrawNumber(x, y, i+1, LEADING0|LEFT, 2, NULL, ":");
|
lcdDrawNumber(x, y, i+1, LEADING0|LEFT, 2, NULL, ":");
|
||||||
|
@ -158,12 +158,12 @@ bool menuStatsAnalogs(event_t event)
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
lcdDrawNumber(x+100, y, rawJitter[i].get());
|
lcdDrawNumber(x+100, y, rawJitter[i].get());
|
||||||
lcdDrawNumber(x+140, y, avgJitter[i].get());
|
lcdDrawNumber(x+140, y, avgJitter[i].get());
|
||||||
lcdDrawNumber(x+180, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*250/256, PREC1);
|
lcdDrawNumber(x+180, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*250/256, PREC1);
|
||||||
#else
|
#else
|
||||||
if (i < NUM_STICKS+NUM_POTS+NUM_SLIDERS)
|
if (i < NUM_STICKS+NUM_POTS+NUM_SLIDERS)
|
||||||
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[CONVERT_MODE(i)]*25/256);
|
lcdDrawNumber(x+100, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256);
|
||||||
else if (i >= MOUSE1)
|
else if (i >= MOUSE1)
|
||||||
lcdDrawNumber(x+100, y, (int16_t)calibratedStick[NUM_STICKS+NUM_POTS+NUM_SLIDERS+i-MOUSE1]*25/256);
|
lcdDrawNumber(x+100, y, (int16_t)calibratedAnalogs[CALIBRATED_MOUSE1+i-MOUSE1]*25/256);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ if(ARCH STREQUAL ARM)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PCB STREQUAL FLAMENCO OR PCB STREQUAL HORUS)
|
if(PCB STREQUAL FLAMENCO OR PCB STREQUAL X12S OR PCB STREQUAL X10)
|
||||||
if(HELI)
|
if(HELI)
|
||||||
set(HELI_SRC gui/common/colorlcd/model_heli.cpp)
|
set(HELI_SRC gui/common/colorlcd/model_heli.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -147,6 +147,11 @@ bool isSourceAvailable(int source)
|
||||||
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
|
||||||
return IS_POT_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
return IS_POT_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
if ((source>=MIXSRC_S3 && source<=MIXSRC_S4) || (source>=MIXSRC_MOUSE1 && source<=MIXSRC_MOUSE2))
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) {
|
if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) {
|
||||||
return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH);
|
return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH);
|
||||||
|
|
|
@ -339,7 +339,7 @@ void logsWrite()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
f_printf(&g_oLogFile, "%d,", calibratedStick[i]);
|
f_printf(&g_oLogFile, "%d,", calibratedAnalogs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBFLAMENCO)
|
#if defined(PCBFLAMENCO)
|
||||||
|
|
|
@ -43,7 +43,8 @@ set(LUA_INCLUDES_STM32F4
|
||||||
-I${RADIO_SRC_DIRECTORY}/${STM32LIB_DIR}/CMSIS/Device/ST/STM32F4xx/Include
|
-I${RADIO_SRC_DIRECTORY}/${STM32LIB_DIR}/CMSIS/Device/ST/STM32F4xx/Include
|
||||||
)
|
)
|
||||||
|
|
||||||
add_lua_export_target(x7 ${LUA_INCLUDES_STM32F2} -DPCBTARANIS -DPCBX7)
|
add_lua_export_target(x7 ${LUA_INCLUDES_STM32F2} -DPCBTARANIS -DPCBX7)
|
||||||
add_lua_export_target(x9d ${LUA_INCLUDES_STM32F2} -DPCBTARANIS -DPCBX9D)
|
add_lua_export_target(x9d ${LUA_INCLUDES_STM32F2} -DPCBTARANIS -DPCBX9D)
|
||||||
add_lua_export_target(x9e ${LUA_INCLUDES_STM32F4} -DPCBTARANIS -DPCBX9E -DSTM32F40_41xxx)
|
add_lua_export_target(x9e ${LUA_INCLUDES_STM32F4} -DPCBTARANIS -DPCBX9E -DSTM32F40_41xxx)
|
||||||
add_lua_export_target(horus ${LUA_INCLUDES_STM32F4} -DPCBHORUS -DSTM32F40_41xxx)
|
add_lua_export_target(x10 ${LUA_INCLUDES_STM32F4} -DPCBHORUS -DPCBX10 -DSTM32F40_41xxx)
|
||||||
|
add_lua_export_target(x12s ${LUA_INCLUDES_STM32F4} -DPCBHORUS -DPCBX12S -DSTM32F40_41xxx)
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
#include "lua/lua_api.h"
|
#include "lua/lua_api.h"
|
||||||
#include "telemetry/frsky.h"
|
#include "telemetry/frsky.h"
|
||||||
|
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBX12S)
|
||||||
#include "lua/lua_exports_horus.inc" // this line must be after lua headers
|
#include "lua/lua_exports_x12s.inc" // this line must be after lua headers
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#include "lua/lua_exports_x10.inc"
|
||||||
#elif defined(PCBFLAMENCO)
|
#elif defined(PCBFLAMENCO)
|
||||||
#include "lua/lua_exports_flamenco.inc"
|
#include "lua/lua_exports_flamenco.inc"
|
||||||
#elif defined(PCBX9E)
|
#elif defined(PCBX9E)
|
||||||
|
|
|
@ -463,7 +463,7 @@ void perMain()
|
||||||
toplcdRefreshEnd();
|
toplcdRefreshEnd();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(PCBX9E) || defined(PCBHORUS)) && !defined(SIMU)
|
#if defined(BLUETOOTH) && !defined(SIMU)
|
||||||
bluetoothWakeup();
|
bluetoothWakeup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ uint8_t mixWarning;
|
||||||
uint8_t startupWarningState;
|
uint8_t startupWarningState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t calibratedStick[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
int16_t calibratedAnalogs[NUM_CALIBRATED_ANALOGS];
|
||||||
int16_t channelOutputs[MAX_OUTPUT_CHANNELS] = {0};
|
int16_t channelOutputs[MAX_OUTPUT_CHANNELS] = {0};
|
||||||
int16_t ex_chans[MAX_OUTPUT_CHANNELS] = {0}; // Outputs (before LIMITS) of the last perMain;
|
int16_t ex_chans[MAX_OUTPUT_CHANNELS] = {0}; // Outputs (before LIMITS) of the last perMain;
|
||||||
|
|
||||||
|
@ -254,11 +254,11 @@ getvalue_t getValue(mixsrc_t i)
|
||||||
|
|
||||||
#if defined(LUA_INPUTS)
|
#if defined(LUA_INPUTS)
|
||||||
else if (i <= MIXSRC_LAST_POT+NUM_MOUSE_ANALOGS) {
|
else if (i <= MIXSRC_LAST_POT+NUM_MOUSE_ANALOGS) {
|
||||||
return calibratedStick[i-MIXSRC_Rud];
|
return calibratedAnalogs[i-MIXSRC_Rud];
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
else if (i>=MIXSRC_FIRST_STICK && i<=MIXSRC_LAST_POT+NUM_MOUSE_ANALOGS) {
|
else if (i>=MIXSRC_FIRST_STICK && i<=MIXSRC_LAST_POT+NUM_MOUSE_ANALOGS) {
|
||||||
return calibratedStick[i-MIXSRC_Rud];
|
return calibratedAnalogs[i-MIXSRC_Rud];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ void evalInputs(uint8_t mode)
|
||||||
#if defined(HELI) && !defined(VIRTUAL_INPUTS)
|
#if defined(HELI) && !defined(VIRTUAL_INPUTS)
|
||||||
uint16_t d = 0;
|
uint16_t d = 0;
|
||||||
if (g_model.swashR.value) {
|
if (g_model.swashR.value) {
|
||||||
uint32_t v = (int32_t(calibratedStick[ELE_STICK])*calibratedStick[ELE_STICK] + int32_t(calibratedStick[AIL_STICK])*calibratedStick[AIL_STICK]);
|
uint32_t v = (int32_t(calibratedAnalogs[ELE_STICK])*calibratedAnalogs[ELE_STICK] + int32_t(calibratedAnalogs[AIL_STICK])*calibratedAnalogs[AIL_STICK]);
|
||||||
uint32_t q = calc100toRESX(g_model.swashR.value);
|
uint32_t q = calc100toRESX(g_model.swashR.value);
|
||||||
q *= q;
|
q *= q;
|
||||||
if (v > q) {
|
if (v > q) {
|
||||||
|
@ -455,7 +455,7 @@ void evalInputs(uint8_t mode)
|
||||||
|
|
||||||
BeepANACenter mask = (BeepANACenter)1 << ch;
|
BeepANACenter mask = (BeepANACenter)1 << ch;
|
||||||
|
|
||||||
calibratedStick[ch] = v; // for show in expo
|
calibratedAnalogs[ch] = v; // for show in expo
|
||||||
|
|
||||||
// filtering for center beep
|
// filtering for center beep
|
||||||
uint8_t tmp = (uint16_t)abs(v) / 16;
|
uint8_t tmp = (uint16_t)abs(v) / 16;
|
||||||
|
@ -503,7 +503,7 @@ void evalInputs(uint8_t mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
#if defined(VIRTUAL_INPUTS)
|
||||||
calibratedStick[ch] = v;
|
calibratedAnalogs[ch] = v;
|
||||||
#else
|
#else
|
||||||
#if defined(HELI)
|
#if defined(HELI)
|
||||||
if (d && (ch==ELE_STICK || ch==AIL_STICK)) {
|
if (d && (ch==ELE_STICK || ch==AIL_STICK)) {
|
||||||
|
@ -533,7 +533,7 @@ void evalInputs(uint8_t mode)
|
||||||
v = v * (int32_t) RESX / (max((int16_t) 100, (v > 0 ? calib->spanPos : calib->spanNeg)));
|
v = v * (int32_t) RESX / (max((int16_t) 100, (v > 0 ? calib->spanPos : calib->spanNeg)));
|
||||||
if (v < -RESX) v = -RESX;
|
if (v < -RESX) v = -RESX;
|
||||||
if (v > RESX) v = RESX;
|
if (v > RESX) v = RESX;
|
||||||
calibratedStick[ch] = v;
|
calibratedAnalogs[ch] = v;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||||
static int16_t sourcesStates[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
static int16_t sourcesStates[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
if (abs(calibratedStick[i] - sourcesStates[i]) > 512) {
|
if (abs(calibratedAnalogs[i] - sourcesStates[i]) > 512) {
|
||||||
result = MIXSRC_Rud+i;
|
result = MIXSRC_Rud+i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
|
||||||
#if defined(VIRTUAL_INPUTS)
|
#if defined(VIRTUAL_INPUTS)
|
||||||
memcpy(inputsStates, anas, sizeof(inputsStates));
|
memcpy(inputsStates, anas, sizeof(inputsStates));
|
||||||
#endif
|
#endif
|
||||||
memcpy(sourcesStates, calibratedStick, sizeof(sourcesStates));
|
memcpy(sourcesStates, calibratedAnalogs, sizeof(sourcesStates));
|
||||||
}
|
}
|
||||||
|
|
||||||
s_move_last_time = get_tmr10ms();
|
s_move_last_time = get_tmr10ms();
|
||||||
|
@ -1116,15 +1116,15 @@ void checkTHR()
|
||||||
// no other information available at the moment, and good enough to my option (otherwise too much exceptions...)
|
// no other information available at the moment, and good enough to my option (otherwise too much exceptions...)
|
||||||
|
|
||||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
int16_t v = calibratedStick[thrchn];
|
int16_t v = calibratedAnalogs[thrchn];
|
||||||
if (v<=THRCHK_DEADBAND-1024 || g_model.disableThrottleWarning || pwrCheck()==e_power_off || keyDown()) {
|
if (v<=THRCHK_DEADBAND-1024 || g_model.disableThrottleWarning || pwrCheck()==e_power_off || keyDown()) {
|
||||||
startupWarningState = STARTUP_WARNING_THROTTLE+1;
|
startupWarningState = STARTUP_WARNING_THROTTLE+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
calibratedStick[thrchn] = -1024;
|
calibratedAnalogs[thrchn] = -1024;
|
||||||
#if !defined(VIRTUAL_INPUTS)
|
#if !defined(VIRTUAL_INPUTS)
|
||||||
if (thrchn < NUM_STICKS) {
|
if (thrchn < NUM_STICKS) {
|
||||||
rawAnas[thrchn] = anas[thrchn] = calibratedStick[thrchn];
|
rawAnas[thrchn] = anas[thrchn] = calibratedAnalogs[thrchn];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
RAISE_ALERT(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
RAISE_ALERT(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||||
|
@ -1138,7 +1138,7 @@ void checkTHR()
|
||||||
|
|
||||||
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
||||||
|
|
||||||
int16_t v = calibratedStick[thrchn];
|
int16_t v = calibratedAnalogs[thrchn];
|
||||||
if (v <= THRCHK_DEADBAND-1024) {
|
if (v <= THRCHK_DEADBAND-1024) {
|
||||||
return; // prevent warning if throttle input OK
|
return; // prevent warning if throttle input OK
|
||||||
}
|
}
|
||||||
|
@ -1157,7 +1157,7 @@ void checkTHR()
|
||||||
|
|
||||||
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
||||||
|
|
||||||
v = calibratedStick[thrchn];
|
v = calibratedAnalogs[thrchn];
|
||||||
|
|
||||||
#if defined(PWR_BUTTON_DELAY)
|
#if defined(PWR_BUTTON_DELAY)
|
||||||
uint32_t pwr_check = pwrCheck();
|
uint32_t pwr_check = pwrCheck();
|
||||||
|
@ -1371,7 +1371,7 @@ uint8_t checkTrim(event_t event)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
uint16_t s_anaFilt[NUMBER_ANALOG];
|
uint16_t s_anaFilt[NUM_ANALOGS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
|
@ -1387,8 +1387,8 @@ uint16_t BandGap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
JitterMeter<uint16_t> rawJitter[NUMBER_ANALOG];
|
JitterMeter<uint16_t> rawJitter[NUM_ANALOGS];
|
||||||
JitterMeter<uint16_t> avgJitter[NUMBER_ANALOG];
|
JitterMeter<uint16_t> avgJitter[NUM_ANALOGS];
|
||||||
tmr10ms_t jitterResetTime = 0;
|
tmr10ms_t jitterResetTime = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1440,7 +1440,7 @@ void getADC()
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
if (JITTER_MEASURE_ACTIVE() && jitterResetTime < get_tmr10ms()) {
|
if (JITTER_MEASURE_ACTIVE() && jitterResetTime < get_tmr10ms()) {
|
||||||
// reset jitter measurement every second
|
// reset jitter measurement every second
|
||||||
for (uint32_t x=0; x<NUMBER_ANALOG; x++) {
|
for (uint32_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
rawJitter[x].reset();
|
rawJitter[x].reset();
|
||||||
avgJitter[x].reset();
|
avgJitter[x].reset();
|
||||||
}
|
}
|
||||||
|
@ -1452,7 +1452,7 @@ void getADC()
|
||||||
adcRead();
|
adcRead();
|
||||||
DEBUG_TIMER_STOP(debugTimerAdcRead);
|
DEBUG_TIMER_STOP(debugTimerAdcRead);
|
||||||
|
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG; x++) {
|
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
|
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
|
||||||
|
|
||||||
#if defined(VIRTUAL_INPUTS)
|
#if defined(VIRTUAL_INPUTS)
|
||||||
|
@ -1706,9 +1706,9 @@ void doMixerCalculations()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if defined(VIRTUAL_INPUTS)
|
#if defined(VIRTUAL_INPUTS)
|
||||||
val = RESX + calibratedStick[g_model.thrTraceSrc == 0 ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1];
|
val = RESX + calibratedAnalogs[g_model.thrTraceSrc == 0 ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1];
|
||||||
#else
|
#else
|
||||||
val = RESX + (g_model.thrTraceSrc == 0 ? rawAnas[THR_STICK] : calibratedStick[g_model.thrTraceSrc+NUM_STICKS-1]);
|
val = RESX + (g_model.thrTraceSrc == 0 ? rawAnas[THR_STICK] : calibratedAnalogs[g_model.thrTraceSrc+NUM_STICKS-1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1822,7 +1822,7 @@ uint8_t calcStickScroll( uint8_t index )
|
||||||
if ( ( g_eeGeneral.stickMode & 1 ) == 0 )
|
if ( ( g_eeGeneral.stickMode & 1 ) == 0 )
|
||||||
index ^= 3;
|
index ^= 3;
|
||||||
|
|
||||||
value = calibratedStick[index] / 128;
|
value = calibratedAnalogs[index] / 128;
|
||||||
direction = value > 0 ? 0x80 : 0;
|
direction = value > 0 ? 0x80 : 0;
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = -value; // (abs)
|
value = -value; // (abs)
|
||||||
|
@ -2522,7 +2522,7 @@ void opentxInit(OPENTX_INIT_ARGS)
|
||||||
setSticksGain(g_eeGeneral.sticksGain);
|
setSticksGain(g_eeGeneral.sticksGain);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BLUETOOTH)
|
#if defined(PCBSKY9X) && defined(BLUETOOTH)
|
||||||
btInit();
|
btInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2531,7 +2531,10 @@ void opentxInit(OPENTX_INIT_ARGS)
|
||||||
loadFontCache();
|
loadFontCache();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_eeGeneral.backlightMode != e_backlight_mode_off) backlightOn(); // on Tx start turn the light on
|
if (g_eeGeneral.backlightMode != e_backlight_mode_off) {
|
||||||
|
// on Tx start turn the light on
|
||||||
|
backlightOn();
|
||||||
|
}
|
||||||
|
|
||||||
if (!unexpectedShutdown) {
|
if (!unexpectedShutdown) {
|
||||||
opentxStart();
|
opentxStart();
|
||||||
|
|
|
@ -1065,7 +1065,8 @@ int16_t applyLimits(uint8_t channel, int32_t value);
|
||||||
|
|
||||||
void evalInputs(uint8_t mode);
|
void evalInputs(uint8_t mode);
|
||||||
uint16_t anaIn(uint8_t chan);
|
uint16_t anaIn(uint8_t chan);
|
||||||
extern int16_t calibratedStick[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS];
|
|
||||||
|
extern int16_t calibratedAnalogs[NUM_CALIBRATED_ANALOGS];
|
||||||
|
|
||||||
#define FLASH_DURATION 20 /*200ms*/
|
#define FLASH_DURATION 20 /*200ms*/
|
||||||
|
|
||||||
|
@ -1667,12 +1668,12 @@ extern Clipboard clipboard;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
extern uint16_t s_anaFilt[NUMBER_ANALOG];
|
extern uint16_t s_anaFilt[NUM_ANALOGS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
extern JitterMeter<uint16_t> rawJitter[NUMBER_ANALOG];
|
extern JitterMeter<uint16_t> rawJitter[NUM_ANALOGS];
|
||||||
extern JitterMeter<uint16_t> avgJitter[NUMBER_ANALOG];
|
extern JitterMeter<uint16_t> avgJitter[NUM_ANALOGS];
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBHORUS)
|
||||||
#define JITTER_MEASURE_ACTIVE() (menuHandlers[menuLevel] == menuStatsAnalogs)
|
#define JITTER_MEASURE_ACTIVE() (menuHandlers[menuLevel] == menuStatsAnalogs)
|
||||||
#elif defined(PCBTARANIS)
|
#elif defined(PCBTARANIS)
|
||||||
|
|
|
@ -18,42 +18,18 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* \file syscalls.c
|
|
||||||
*
|
|
||||||
* Implementation of newlib syscall.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Headers
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
// #include "board.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Exported variables
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#undef errno
|
#undef errno
|
||||||
extern int errno;
|
extern int errno;
|
||||||
extern int _end;
|
extern int _end;
|
||||||
extern int _heap_end;
|
extern int _heap_end;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
|
||||||
* Exported functions
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
// extern void _exit( int status ) ;
|
|
||||||
// extern void _kill( int pid, int sig ) ;
|
|
||||||
// extern int _getpid ( void ) ;
|
|
||||||
|
|
||||||
unsigned char * heap = (unsigned char *)&_end;
|
unsigned char * heap = (unsigned char *)&_end;
|
||||||
|
|
||||||
extern caddr_t _sbrk(int nbytes)
|
extern caddr_t _sbrk(int nbytes)
|
||||||
|
@ -69,6 +45,7 @@ extern caddr_t _sbrk(int nbytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(SEMIHOSTING)
|
||||||
extern int _gettimeofday(void *p1, void *p2)
|
extern int _gettimeofday(void *p1, void *p2)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -135,4 +112,5 @@ extern int _getpid()
|
||||||
{
|
{
|
||||||
return -1 ;
|
return -1 ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,7 @@ set(TARGET_SRC
|
||||||
${TARGET_SRC}
|
${TARGET_SRC}
|
||||||
pulses_driver.cpp
|
pulses_driver.cpp
|
||||||
keys_driver.cpp
|
keys_driver.cpp
|
||||||
adc_driver.cpp
|
|
||||||
trainer_driver.cpp
|
trainer_driver.cpp
|
||||||
audio_driver.cpp
|
|
||||||
telemetry_driver.cpp
|
telemetry_driver.cpp
|
||||||
)
|
)
|
||||||
set(FIRMWARE_SRC
|
set(FIRMWARE_SRC
|
||||||
|
|
206
radio/src/targets/common/arm/stm32/adc_driver.cpp
Normal file
206
radio/src/targets/common/arm/stm32/adc_driver.cpp
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
// not needed
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1, -1,1,1,1, -1};
|
||||||
|
#elif defined(PCBX9E) && defined(HORUS_STICKS)
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1,1, -1,1,1,1, -1};
|
||||||
|
#elif defined(PCBX9E)
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {1,1,-1,-1, -1,-1,-1,1, -1,1,1,1, -1};
|
||||||
|
const uint8_t ana_mapping[NUM_ANALOGS] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/,
|
||||||
|
10 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/,
|
||||||
|
11 /*SLIDER1*/, 12 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/,
|
||||||
|
9 /*TX_VOLTAGE*/ };
|
||||||
|
#elif defined(PCBX9DP)
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, -1,1, 1};
|
||||||
|
#elif defined(PCBX7)
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1};
|
||||||
|
#elif defined(REV4a)
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,0, -1,1, 1};
|
||||||
|
#else
|
||||||
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,1,0, -1,1, 1};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBX9E)
|
||||||
|
#define NUM_ANALOGS_ADC 10
|
||||||
|
#define NUM_ANALOGS_ADC_EXT (NUM_ANALOGS - 10)
|
||||||
|
#else
|
||||||
|
#define NUM_ANALOGS_ADC NUM_ANALOGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t adcValues[NUM_ANALOGS] __DMA;
|
||||||
|
|
||||||
|
void adcInit()
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
|
|
||||||
|
#if defined(ADC_GPIOA_PINS)
|
||||||
|
GPIO_InitStructure.GPIO_Pin = ADC_GPIOA_PINS;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ADC_GPIOB_PINS)
|
||||||
|
GPIO_InitStructure.GPIO_Pin = ADC_GPIOB_PINS;
|
||||||
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ADC_GPIOC_PINS)
|
||||||
|
GPIO_InitStructure.GPIO_Pin = ADC_GPIOC_PINS;
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ADC_GPIOF_PINS)
|
||||||
|
GPIO_InitStructure.GPIO_Pin = ADC_GPIOF_PINS;
|
||||||
|
GPIO_Init(GPIOF, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ADC_MAIN->CR1 = ADC_CR1_SCAN;
|
||||||
|
ADC_MAIN->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||||
|
ADC_MAIN->SQR1 = (NUM_ANALOGS_ADC-1) << 20; // bits 23:20 = number of conversions
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10) + (ADC_CHANNEL_BATT<<15) + (ADC_CHANNEL_EXT1<<20) + (ADC_CHANNEL_EXT2<<25); // conversions 7 and more
|
||||||
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<20) + (ADC_CHANNEL_POT2<<25); // conversions 1 to 6
|
||||||
|
#elif defined(PCBX9E)
|
||||||
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4<<0) + (ADC_CHANNEL_SLIDER3<<5) + (ADC_CHANNEL_SLIDER4<<10) + (ADC_CHANNEL_BATT<<15); // conversions 7 and more
|
||||||
|
ADC_MAIN->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
|
||||||
|
#elif defined(PCBX7)
|
||||||
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT<<0); // conversions 7 and more
|
||||||
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<25) + (ADC_CHANNEL_POT2<<20); // conversions 1 to 6
|
||||||
|
#else
|
||||||
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10) + (ADC_CHANNEL_BATT<<15); // conversions 7 and more
|
||||||
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<20) + (ADC_CHANNEL_POT2<<25); // conversions 1 to 6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ADC_MAIN->SMPR1 = ADC_SAMPTIME + (ADC_SAMPTIME<<3) + (ADC_SAMPTIME<<6) + (ADC_SAMPTIME<<9) + (ADC_SAMPTIME<<12) + (ADC_SAMPTIME<<15) + (ADC_SAMPTIME<<18) + (ADC_SAMPTIME<<21) + (ADC_SAMPTIME<<24);
|
||||||
|
ADC_MAIN->SMPR2 = ADC_SAMPTIME + (ADC_SAMPTIME<<3) + (ADC_SAMPTIME<<6) + (ADC_SAMPTIME<<9) + (ADC_SAMPTIME<<12) + (ADC_SAMPTIME<<15) + (ADC_SAMPTIME<<18) + (ADC_SAMPTIME<<21) + (ADC_SAMPTIME<<24) + (ADC_SAMPTIME<<27);
|
||||||
|
|
||||||
|
ADC->CCR = 0;
|
||||||
|
|
||||||
|
ADC_DMA_Stream->CR = DMA_SxCR_PL | ADC_DMA_SxCR_CHSEL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
||||||
|
ADC_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC_MAIN->DR);
|
||||||
|
ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(adcValues);
|
||||||
|
ADC_DMA_Stream->NDTR = NUM_ANALOGS_ADC;
|
||||||
|
ADC_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||||
|
|
||||||
|
#if defined(PCBX9E)
|
||||||
|
ADC_EXT->CR1 = ADC_CR1_SCAN;
|
||||||
|
ADC_EXT->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||||
|
ADC_EXT->SQR1 = (NUM_ANALOGS_ADC_EXT-1) << 20;
|
||||||
|
ADC_EXT->SQR2 = 0;
|
||||||
|
ADC_EXT->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10); // conversions 1 to 3
|
||||||
|
ADC_EXT->SMPR1 = 0;
|
||||||
|
ADC_EXT->SMPR2 = (ADC_EXT_SAMPTIME<<(3*ADC_CHANNEL_POT1)) + (ADC_EXT_SAMPTIME<<(3*ADC_CHANNEL_SLIDER1)) + (ADC_EXT_SAMPTIME<<(3*ADC_CHANNEL_SLIDER2));
|
||||||
|
|
||||||
|
ADC_EXT_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
||||||
|
ADC_EXT_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC_EXT->DR);
|
||||||
|
ADC_EXT_DMA_Stream->M0AR = CONVERT_PTR_UINT(adcValues + NUM_ANALOGS_ADC);
|
||||||
|
ADC_EXT_DMA_Stream->NDTR = NUM_ANALOGS_ADC_EXT;
|
||||||
|
ADC_EXT_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void adcSingleRead()
|
||||||
|
{
|
||||||
|
ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
|
ADC_MAIN->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR);
|
||||||
|
ADC_SET_DMA_FLAGS();
|
||||||
|
ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
||||||
|
ADC_MAIN->CR2 |= (uint32_t) ADC_CR2_SWSTART;
|
||||||
|
|
||||||
|
#if defined(PCBX9E)
|
||||||
|
ADC_EXT_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
|
ADC_EXT->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR );
|
||||||
|
ADC_EXT_SET_DMA_FLAGS();
|
||||||
|
ADC_EXT_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
||||||
|
ADC_EXT->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBX9E)
|
||||||
|
for (unsigned int i=0; i<10000; i++) {
|
||||||
|
if (ADC_TRANSFER_COMPLETE() && ADC_EXT_TRANSFER_COMPLETE()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
|
ADC_EXT_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
|
#else
|
||||||
|
for (unsigned int i = 0; i < 10000; i++) {
|
||||||
|
if (ADC_TRANSFER_COMPLETE()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void adcRead()
|
||||||
|
{
|
||||||
|
uint16_t temp[NUM_ANALOGS] = { 0 };
|
||||||
|
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
adcSingleRead();
|
||||||
|
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
|
uint16_t val = adcValues[x];
|
||||||
|
#if defined(JITTER_MEASURE)
|
||||||
|
if (JITTER_MEASURE_ACTIVE()) {
|
||||||
|
rawJitter[x].measure(val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
temp[x] += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
|
adcValues[x] = temp[x] >> 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
void adcStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(SIMU)
|
||||||
|
uint16_t getAnalogValue(uint8_t index)
|
||||||
|
{
|
||||||
|
if (IS_POT(index) && !IS_POT_SLIDER_AVAILABLE(index)) {
|
||||||
|
// Use fixed analog value for non-existing and/or non-connected pots.
|
||||||
|
// Non-connected analog inputs will slightly follow the adjacent connected analog inputs,
|
||||||
|
// which produces ghost readings on these inputs.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#if defined(PCBX9E)
|
||||||
|
index = ana_mapping[index];
|
||||||
|
#endif
|
||||||
|
if (ana_direction[index] < 0)
|
||||||
|
return 4095 - adcValues[index];
|
||||||
|
else
|
||||||
|
return adcValues[index];
|
||||||
|
}
|
||||||
|
#endif // #if !defined(SIMU)
|
|
@ -1,154 +1,153 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* 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
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
const AudioBuffer * nextBuffer = 0;
|
const AudioBuffer * nextBuffer = 0;
|
||||||
|
|
||||||
void setSampleRate(uint32_t frequency)
|
void setSampleRate(uint32_t frequency)
|
||||||
{
|
{
|
||||||
uint32_t timer = (PERI1_FREQUENCY * TIMER_MULT_APB1) / frequency - 1 ; // MCK/8 and 100 000 Hz
|
uint32_t timer = (PERI1_FREQUENCY * TIMER_MULT_APB1) / frequency - 1 ; // MCK/8 and 100 000 Hz
|
||||||
|
|
||||||
AUDIO_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
AUDIO_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
||||||
AUDIO_TIMER->CNT = 0 ;
|
AUDIO_TIMER->CNT = 0 ;
|
||||||
AUDIO_TIMER->ARR = limit<uint32_t>(2, timer, 65535) ;
|
AUDIO_TIMER->ARR = limit<uint32_t>(2, timer, 65535) ;
|
||||||
AUDIO_TIMER->CR1 |= TIM_CR1_CEN ;
|
AUDIO_TIMER->CR1 |= TIM_CR1_CEN ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start TIMER6 at 100000Hz, used for DAC trigger
|
// Start TIMER6 at 100000Hz, used for DAC trigger
|
||||||
void dacTimerInit()
|
void dacTimerInit()
|
||||||
{
|
{
|
||||||
AUDIO_TIMER->PSC = 0 ; // Max speed
|
AUDIO_TIMER->PSC = 0 ; // Max speed
|
||||||
AUDIO_TIMER->ARR = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 100000 - 1 ; // 10 uS, 100 kHz
|
AUDIO_TIMER->ARR = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 100000 - 1 ; // 10 uS, 100 kHz
|
||||||
AUDIO_TIMER->CR2 = 0 ;
|
AUDIO_TIMER->CR2 = 0 ;
|
||||||
AUDIO_TIMER->CR2 = 0x20 ;
|
AUDIO_TIMER->CR2 = 0x20 ;
|
||||||
AUDIO_TIMER->CR1 = TIM_CR1_CEN ;
|
AUDIO_TIMER->CR1 = TIM_CR1_CEN ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure DAC0 (or DAC1 for REVA)
|
// Configure DAC0 (or DAC1 for REVA)
|
||||||
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
|
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
|
||||||
// So maybe it is automatically done
|
// So maybe it is automatically done
|
||||||
void dacInit()
|
void dacInit()
|
||||||
{
|
{
|
||||||
dacTimerInit();
|
dacTimerInit();
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_OUTPUT_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_OUTPUT_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
GPIO_Init(AUDIO_OUTPUT_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_OUTPUT_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
// Chan 7, 16-bit wide, Medium priority, memory increments
|
// Chan 7, 16-bit wide, Medium priority, memory increments
|
||||||
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||||
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||||
AUDIO_DMA_Stream->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 |
|
AUDIO_DMA_Stream->CR = DMA_SxCR_CHSEL_0 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_2 | DMA_SxCR_PL_0 |
|
||||||
DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_CIRC ;
|
DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_CIRC ;
|
||||||
AUDIO_DMA_Stream->PAR = CONVERT_PTR_UINT(&DAC->DHR12R1);
|
AUDIO_DMA_Stream->PAR = CONVERT_PTR_UINT(&DAC->DHR12R1);
|
||||||
// AUDIO_DMA_Stream->M0AR = CONVERT_PTR_UINT(Sine_values);
|
// AUDIO_DMA_Stream->M0AR = CONVERT_PTR_UINT(Sine_values);
|
||||||
AUDIO_DMA_Stream->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
AUDIO_DMA_Stream->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||||
// AUDIO_DMA_Stream->NDTR = 100 ;
|
// AUDIO_DMA_Stream->NDTR = 100 ;
|
||||||
|
|
||||||
DAC->DHR12R1 = 2010 ;
|
DAC->DHR12R1 = 2010 ;
|
||||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||||
DAC->CR = DAC_CR_TEN1 | DAC_CR_EN1 ; // Enable DAC
|
DAC->CR = DAC_CR_TEN1 | DAC_CR_EN1 ; // Enable DAC
|
||||||
NVIC_EnableIRQ(AUDIO_TIM_IRQn); // TODO needed?
|
NVIC_EnableIRQ(AUDIO_TIM_IRQn); // TODO needed?
|
||||||
NVIC_SetPriority(AUDIO_TIM_IRQn, 7);
|
NVIC_SetPriority(AUDIO_TIM_IRQn, 7);
|
||||||
NVIC_EnableIRQ(AUDIO_DMA_Stream_IRQn);
|
NVIC_EnableIRQ(AUDIO_DMA_Stream_IRQn);
|
||||||
NVIC_SetPriority(AUDIO_DMA_Stream_IRQn, 7);
|
NVIC_SetPriority(AUDIO_DMA_Stream_IRQn, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioConsumeCurrentBuffer()
|
void audioConsumeCurrentBuffer()
|
||||||
{
|
{
|
||||||
if (nextBuffer == 0) {
|
if (nextBuffer == 0) {
|
||||||
|
|
||||||
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
|
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
|
||||||
if (nextBuffer) {
|
if (nextBuffer) {
|
||||||
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
||||||
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||||
AUDIO_DMA_Stream->M0AR = CONVERT_PTR_UINT(nextBuffer->data);
|
AUDIO_DMA_Stream->M0AR = CONVERT_PTR_UINT(nextBuffer->data);
|
||||||
AUDIO_DMA_Stream->NDTR = nextBuffer->size;
|
AUDIO_DMA_Stream->NDTR = nextBuffer->size;
|
||||||
AUDIO_DMA_Stream->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel and interrupt
|
AUDIO_DMA_Stream->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel and interrupt
|
||||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||||
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
void dacStart()
|
||||||
void dacStart()
|
{
|
||||||
{
|
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||||
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
AUDIO_DMA_Stream->CR |= DMA_SxCR_CIRC | DMA_SxCR_EN ; // Enable DMA channel
|
||||||
AUDIO_DMA_Stream->CR |= DMA_SxCR_CIRC | DMA_SxCR_EN ; // Enable DMA channel
|
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
||||||
DAC->CR |= DAC_CR_EN1 | DAC_CR_DMAEN1 ; // Enable DAC
|
}
|
||||||
}
|
|
||||||
|
void dacStop()
|
||||||
void dacStop()
|
{
|
||||||
{
|
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_CIRC ;
|
||||||
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_CIRC ;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// Sound routines
|
||||||
// Sound routines
|
void audioInit()
|
||||||
void audioInit()
|
{
|
||||||
{
|
dacInit();
|
||||||
dacInit();
|
}
|
||||||
}
|
|
||||||
|
void audioEnd()
|
||||||
void audioEnd()
|
{
|
||||||
{
|
DAC->CR = 0 ;
|
||||||
DAC->CR = 0 ;
|
AUDIO_TIMER->CR1 = 0 ;
|
||||||
AUDIO_TIMER->CR1 = 0 ;
|
// Also need to turn off any possible interrupts
|
||||||
// Also need to turn off any possible interrupts
|
NVIC_DisableIRQ(AUDIO_TIM_IRQn) ;
|
||||||
NVIC_DisableIRQ(AUDIO_TIM_IRQn) ;
|
NVIC_DisableIRQ(AUDIO_DMA_Stream_IRQn) ;
|
||||||
NVIC_DisableIRQ(AUDIO_DMA_Stream_IRQn) ;
|
}
|
||||||
}
|
|
||||||
|
extern "C" void AUDIO_TIM_IRQHandler()
|
||||||
extern "C" void AUDIO_TIM_IRQHandler()
|
{
|
||||||
{
|
DEBUG_INTERRUPT(INT_AUDIO);
|
||||||
DEBUG_INTERRUPT(INT_AUDIO);
|
DAC->CR &= ~DAC_CR_DMAEN1 ; // Stop DMA requests
|
||||||
DAC->CR &= ~DAC_CR_DMAEN1 ; // Stop DMA requests
|
#if defined(STM32F2)
|
||||||
#if !defined(PCBX9E)
|
DAC->CR &= ~DAC_CR_DMAUDRIE1 ; // Stop underrun interrupt
|
||||||
DAC->CR &= ~DAC_CR_DMAUDRIE1 ; // Stop underrun interrupt
|
#endif
|
||||||
#endif
|
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
||||||
DAC->SR = DAC_SR_DMAUDR1 ; // Write 1 to clear flag
|
}
|
||||||
}
|
|
||||||
|
extern "C" void AUDIO_DMA_Stream_IRQHandler()
|
||||||
extern "C" void AUDIO_DMA_Stream_IRQHandler()
|
{
|
||||||
{
|
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_TCIE ; // Stop interrupt
|
||||||
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_TCIE ; // Stop interrupt
|
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear flags
|
||||||
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear flags
|
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
||||||
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
|
||||||
|
if (nextBuffer) audioQueue.buffersFifo.freeNextFilledBuffer();
|
||||||
if (nextBuffer) audioQueue.buffersFifo.freeNextFilledBuffer();
|
|
||||||
|
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
|
||||||
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
|
if (nextBuffer) {
|
||||||
if (nextBuffer) {
|
AUDIO_DMA_Stream->M0AR = CONVERT_PTR_UINT(nextBuffer->data);
|
||||||
AUDIO_DMA_Stream->M0AR = CONVERT_PTR_UINT(nextBuffer->data);
|
AUDIO_DMA_Stream->NDTR = nextBuffer->size;
|
||||||
AUDIO_DMA_Stream->NDTR = nextBuffer->size;
|
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||||
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
AUDIO_DMA_Stream->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel
|
||||||
AUDIO_DMA_Stream->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE ; // Enable DMA channel
|
DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag
|
||||||
DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif // #if !defined(SIMU)
|
||||||
#endif // #if !defined(SIMU)
|
|
|
@ -22,12 +22,14 @@
|
||||||
#define NUM_POTS 3
|
#define NUM_POTS 3
|
||||||
#define NUM_SLIDERS 0
|
#define NUM_SLIDERS 0
|
||||||
#define NUM_XPOTS 0
|
#define NUM_XPOTS 0
|
||||||
|
|
||||||
enum Analogs {
|
enum Analogs {
|
||||||
STICK1,
|
STICK1,
|
||||||
STICK2,
|
STICK2,
|
||||||
STICK3,
|
STICK3,
|
||||||
STICK4,
|
STICK4,
|
||||||
POT1,
|
POT_FIRST,
|
||||||
|
POT1 = POT_FIRST,
|
||||||
POT2,
|
POT2,
|
||||||
POT3,
|
POT3,
|
||||||
POT_LAST = POT3,
|
POT_LAST = POT3,
|
||||||
|
@ -41,8 +43,22 @@ enum Analogs {
|
||||||
X14051,
|
X14051,
|
||||||
#endif
|
#endif
|
||||||
TX_VOLTAGE,
|
TX_VOLTAGE,
|
||||||
NUMBER_ANALOG
|
NUM_ANALOGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CalibratedAnalogs {
|
||||||
|
CALIBRATED_STICK1,
|
||||||
|
CALIBRATED_STICK2,
|
||||||
|
CALIBRATED_STICK3,
|
||||||
|
CALIBRATED_STICK4,
|
||||||
|
CALIBRATED_POT_FIRST,
|
||||||
|
CALIBRATED_POT1 = CALIBRATED_POT_FIRST,
|
||||||
|
CALIBRATED_POT2,
|
||||||
|
CALIBRATED_POT3,
|
||||||
|
CALIBRATED_POT_LAST = CALIBRATED_POT3,
|
||||||
|
NUM_CALIBRATED_ANALOGS
|
||||||
|
};
|
||||||
|
|
||||||
void adcInit();
|
void adcInit();
|
||||||
void adcPrepareBandgap();
|
void adcPrepareBandgap();
|
||||||
void getADC();
|
void getADC();
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
set(PCBREV "13" CACHE STRING "PCB Revision")
|
|
||||||
set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS")
|
|
||||||
option(DISK_CACHE "Enable SD card disk cache" YES)
|
option(DISK_CACHE "Enable SD card disk cache" YES)
|
||||||
if(${PCBREV} GREATER 10)
|
|
||||||
option(INTERNAL_GPS "Internal GPS installed" YES)
|
|
||||||
else()
|
|
||||||
option(INTERNAL_GPS "Internal GPS installed" NO)
|
|
||||||
if(NOT INTERNAL_GPS)
|
|
||||||
message("Horus: Internal GPS is optional, use INTERNAL_GPS=YES option to enable it")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
option(BLUETOOTH_CLI_PASSTHROUGH "Enable direct communicaton with Bluetooth module from CLI" NO)
|
option(BLUETOOTH_CLI_PASSTHROUGH "Enable direct communicaton with Bluetooth module from CLI" NO)
|
||||||
|
option(PWR_BUTTON_DISABLED "Disable the Power Button (for debugging with JTAG)" NO)
|
||||||
|
|
||||||
set(CPU_TYPE STM32F4)
|
set(CPU_TYPE STM32F4)
|
||||||
set(HSE_VALUE 12000000)
|
set(HSE_VALUE 12000000)
|
||||||
|
@ -19,9 +10,6 @@ set(HAPTIC YES)
|
||||||
set(GUI_DIR 480x272)
|
set(GUI_DIR 480x272)
|
||||||
set(TARGET_DIR horus)
|
set(TARGET_DIR horus)
|
||||||
set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld)
|
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(RAMBACKUP YES)
|
set(RAMBACKUP YES)
|
||||||
set(LUA YES)
|
set(LUA YES)
|
||||||
set(PPM_LIMITS_SYMETRICAL YES)
|
set(PPM_LIMITS_SYMETRICAL YES)
|
||||||
|
@ -33,7 +21,46 @@ if(SPLASH STREQUAL OFF)
|
||||||
message(FATAL_ERROR "Option SPLASH=OFF not supported on Horus")
|
message(FATAL_ERROR "Option SPLASH=OFF not supported on Horus")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DPCBHORUS -DPCBREV=${PCBREV} -DSTM32F429_439xx -DSDRAM -DCOLORLCD -DPPM_PIN_UART -DPPM_PIN_TIMER)
|
if(PWR_BUTTON_DISABLED)
|
||||||
|
add_definitions(-DPWR_BUTTON_DISABLED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (PCB STREQUAL X10)
|
||||||
|
set(FLAVOUR x10)
|
||||||
|
add_definitions(-DPCBX10)
|
||||||
|
add_definitions(-DSOFTWARE_VOLUME)
|
||||||
|
set(TARGET_SRC
|
||||||
|
${TARGET_SRC}
|
||||||
|
../common/arm/stm32/audio_dac_driver.cpp
|
||||||
|
../common/arm/stm32/adc_driver.cpp
|
||||||
|
)
|
||||||
|
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} x10_bitmaps)
|
||||||
|
set(LUA_EXPORT lua_export_x10)
|
||||||
|
elseif (PCB STREQUAL X12S)
|
||||||
|
set(FLAVOUR x12s)
|
||||||
|
set(PCBREV "13" CACHE STRING "PCB Revision")
|
||||||
|
if(${PCBREV} GREATER 10)
|
||||||
|
option(INTERNAL_GPS "Internal GPS installed" YES)
|
||||||
|
else()
|
||||||
|
option(INTERNAL_GPS "Internal GPS installed" NO)
|
||||||
|
if(NOT INTERNAL_GPS)
|
||||||
|
message("Horus: Internal GPS is optional, use INTERNAL_GPS=YES option to enable it")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS")
|
||||||
|
add_definitions(-DPCBX12S)
|
||||||
|
set(TARGET_SRC
|
||||||
|
${TARGET_SRC}
|
||||||
|
audio_spi_driver.cpp
|
||||||
|
adc_driver.cpp
|
||||||
|
gps_driver.cpp
|
||||||
|
)
|
||||||
|
set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} x12s_bitmaps)
|
||||||
|
set(LUA_EXPORT lua_export_x12s)
|
||||||
|
add_definitions(-DPCBREV=${PCBREV})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DPCBHORUS -DSTM32F429_439xx -DSDRAM -DCOLORLCD -DPPM_PIN_UART -DPPM_PIN_TIMER)
|
||||||
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
||||||
add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
|
add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
|
||||||
|
|
||||||
|
@ -81,18 +108,23 @@ set(TARGET_SRC
|
||||||
board.cpp
|
board.cpp
|
||||||
led_driver.cpp
|
led_driver.cpp
|
||||||
extmodule_driver.cpp
|
extmodule_driver.cpp
|
||||||
gps_driver.cpp
|
|
||||||
)
|
)
|
||||||
set(FIRMWARE_TARGET_SRC
|
set(FIRMWARE_TARGET_SRC
|
||||||
${FIRMWARE_TARGET_SRC}
|
${FIRMWARE_TARGET_SRC}
|
||||||
sdio_sd.c
|
sdio_sd.c
|
||||||
lcd_driver.cpp
|
lcd_driver.cpp
|
||||||
backlight_driver.cpp
|
backlight_driver.cpp
|
||||||
bluetooth_driver.cpp
|
|
||||||
pwr_driver.cpp
|
pwr_driver.cpp
|
||||||
sdram_driver.c
|
sdram_driver.c
|
||||||
startup_stm32f40_41xxx.s
|
startup_stm32f40_41xxx.s
|
||||||
)
|
)
|
||||||
|
if(PCB STREQUAL X12S)
|
||||||
|
set(FIRMWARE_TARGET_SRC
|
||||||
|
${FIRMWARE_TARGET_SRC}
|
||||||
|
bluetooth_driver.cpp
|
||||||
|
)
|
||||||
|
add_definitions(-DBLUETOOTH)
|
||||||
|
endif()
|
||||||
if(BLUETOOTH_CLI_PASSTHROUGH)
|
if(BLUETOOTH_CLI_PASSTHROUGH)
|
||||||
add_definitions(-DBLUETOOTH_CLI_PASSTHROUGH)
|
add_definitions(-DBLUETOOTH_CLI_PASSTHROUGH)
|
||||||
message("Horus: Bluetooth pass-trough enabled")
|
message("Horus: Bluetooth pass-trough enabled")
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
uint16_t adcValues[NUM_ANALOGS] __DMA;
|
||||||
|
|
||||||
#define ADC_CS_HIGH() (ADC_SPI_GPIO->BSRRL = ADC_SPI_PIN_CS)
|
#define ADC_CS_HIGH() (ADC_SPI_GPIO->BSRRL = ADC_SPI_PIN_CS)
|
||||||
#define ADC_CS_LOW() (ADC_SPI_GPIO->BSRRH = ADC_SPI_PIN_CS)
|
#define ADC_CS_LOW() (ADC_SPI_GPIO->BSRRH = ADC_SPI_PIN_CS)
|
||||||
|
|
||||||
|
@ -40,8 +42,6 @@
|
||||||
|
|
||||||
#define SAMPTIME 2 // sample time = 28 cycles
|
#define SAMPTIME 2 // sample time = 28 cycles
|
||||||
|
|
||||||
uint16_t adcValues[NUMBER_ANALOG] __DMA;
|
|
||||||
|
|
||||||
uint16_t SPIx_ReadWriteByte(uint16_t value)
|
uint16_t SPIx_ReadWriteByte(uint16_t value)
|
||||||
{
|
{
|
||||||
while (SPI_I2S_GetFlagStatus(ADC_SPI, SPI_I2S_FLAG_TXE) == RESET);
|
while (SPI_I2S_GetFlagStatus(ADC_SPI, SPI_I2S_FLAG_TXE) == RESET);
|
||||||
|
@ -115,7 +115,7 @@ void adcInit()
|
||||||
|
|
||||||
ADC3->CR1 = ADC_CR1_SCAN;
|
ADC3->CR1 = ADC_CR1_SCAN;
|
||||||
ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||||
ADC3->SQR1 = (2-1) << 20; // NUMBER_ANALOG Channels
|
ADC3->SQR1 = (2-1) << 20;
|
||||||
ADC3->SQR2 = 0;
|
ADC3->SQR2 = 0;
|
||||||
ADC3->SQR3 = ADC_IN_MOUSE1 + (ADC_IN_MOUSE2<<5);
|
ADC3->SQR3 = ADC_IN_MOUSE1 + (ADC_IN_MOUSE2<<5);
|
||||||
ADC3->SMPR1 = 0;
|
ADC3->SMPR1 = 0;
|
||||||
|
@ -212,7 +212,7 @@ bool adcOnChipReadFinished()
|
||||||
|
|
||||||
void adcRead()
|
void adcRead()
|
||||||
{
|
{
|
||||||
uint16_t temp[NUMBER_ANALOG-MOUSE1] = { 0 };
|
uint16_t temp[NUM_ANALOGS-MOUSE1] = { 0 };
|
||||||
uint8_t noInternalReads = 0;
|
uint8_t noInternalReads = 0;
|
||||||
|
|
||||||
adcOnChipReadStart();
|
adcOnChipReadStart();
|
||||||
|
@ -221,7 +221,7 @@ void adcRead()
|
||||||
for (uint32_t index=0; index<MOUSE1; index++) {
|
for (uint32_t index=0; index<MOUSE1; index++) {
|
||||||
adcValues[index] = adcReadNextSPIChannel(index);
|
adcValues[index] = adcReadNextSPIChannel(index);
|
||||||
if (noInternalReads < 4 && adcOnChipReadFinished()) {
|
if (noInternalReads < 4 && adcOnChipReadFinished()) {
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG-MOUSE1; x++) {
|
for (uint8_t x=0; x<NUM_ANALOGS-MOUSE1; x++) {
|
||||||
uint16_t val = adcValues[MOUSE1+x];
|
uint16_t val = adcValues[MOUSE1+x];
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
if (JITTER_MEASURE_ACTIVE()) {
|
if (JITTER_MEASURE_ACTIVE()) {
|
||||||
|
@ -242,13 +242,13 @@ void adcRead()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG-MOUSE1; x++) {
|
for (uint8_t x=0; x<NUM_ANALOGS-MOUSE1; x++) {
|
||||||
adcValues[MOUSE1+x] = temp[x] >> 2;
|
adcValues[MOUSE1+x] = temp[x] >> 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,-1, -1,-1, -1,1, 0,0,0};
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, -1,-1, -1,1, 0,0,0};
|
||||||
|
|
||||||
uint16_t getAnalogValue(uint8_t index)
|
uint16_t getAnalogValue(uint8_t index)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,428 +1,428 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* 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
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
|
|
||||||
#define VS_WRITE_COMMAND 0x02
|
#define VS_WRITE_COMMAND 0x02
|
||||||
#define VS_READ_COMMAND 0x03
|
#define VS_READ_COMMAND 0x03
|
||||||
|
|
||||||
#define SPI_MODE 0x00
|
#define SPI_MODE 0x00
|
||||||
#define SPI_STATUS 0x01
|
#define SPI_STATUS 0x01
|
||||||
#define SPI_BASS 0x02
|
#define SPI_BASS 0x02
|
||||||
#define SPI_CLOCKF 0x03
|
#define SPI_CLOCKF 0x03
|
||||||
#define SPI_DECODE_TIME 0x04
|
#define SPI_DECODE_TIME 0x04
|
||||||
#define SPI_AUDATA 0x05
|
#define SPI_AUDATA 0x05
|
||||||
#define SPI_WRAM 0x06
|
#define SPI_WRAM 0x06
|
||||||
#define SPI_WRAMADDR 0x07
|
#define SPI_WRAMADDR 0x07
|
||||||
#define SPI_HDAT0 0x08
|
#define SPI_HDAT0 0x08
|
||||||
#define SPI_HDAT1 0x09
|
#define SPI_HDAT1 0x09
|
||||||
#define SPI_AIADDR 0x0a
|
#define SPI_AIADDR 0x0a
|
||||||
#define SPI_VOL 0x0b
|
#define SPI_VOL 0x0b
|
||||||
#define SPI_AICTRL0 0x0c
|
#define SPI_AICTRL0 0x0c
|
||||||
#define SPI_AICTRL1 0x0d
|
#define SPI_AICTRL1 0x0d
|
||||||
#define SPI_AICTRL2 0x0e
|
#define SPI_AICTRL2 0x0e
|
||||||
#define SPI_AICTRL3 0x0f
|
#define SPI_AICTRL3 0x0f
|
||||||
|
|
||||||
#define SM_DIFF 0x01
|
#define SM_DIFF 0x01
|
||||||
#define SM_LAYER12 0x02
|
#define SM_LAYER12 0x02
|
||||||
#define SM_RESET 0x04
|
#define SM_RESET 0x04
|
||||||
#define SM_CANCEL 0x08
|
#define SM_CANCEL 0x08
|
||||||
#define SM_EARSPEAKER_LO 0x10
|
#define SM_EARSPEAKER_LO 0x10
|
||||||
#define SM_TESTS 0x20
|
#define SM_TESTS 0x20
|
||||||
#define SM_STREAM 0x40
|
#define SM_STREAM 0x40
|
||||||
#define SM_EARSPEAKER_HI 0x80
|
#define SM_EARSPEAKER_HI 0x80
|
||||||
#define SM_DACT 0x100
|
#define SM_DACT 0x100
|
||||||
#define SM_SDIORD 0x200
|
#define SM_SDIORD 0x200
|
||||||
#define SM_SDISHARE 0x400
|
#define SM_SDISHARE 0x400
|
||||||
#define SM_SDINEW 0x800
|
#define SM_SDINEW 0x800
|
||||||
#define SM_ADPCM 0x1000
|
#define SM_ADPCM 0x1000
|
||||||
#define SM_LINE1 0x4000
|
#define SM_LINE1 0x4000
|
||||||
#define SM_CLK_RANGE 0x8000
|
#define SM_CLK_RANGE 0x8000
|
||||||
|
|
||||||
#define SPI_SPEED_2 0
|
#define SPI_SPEED_2 0
|
||||||
#define SPI_SPEED_4 1
|
#define SPI_SPEED_4 1
|
||||||
#define SPI_SPEED_8 2
|
#define SPI_SPEED_8 2
|
||||||
#define SPI_SPEED_16 3
|
#define SPI_SPEED_16 3
|
||||||
#define SPI_SPEED_32 4
|
#define SPI_SPEED_32 4
|
||||||
#define SPI_SPEED_64 5
|
#define SPI_SPEED_64 5
|
||||||
#define SPI_SPEED_128 6
|
#define SPI_SPEED_128 6
|
||||||
#define SPI_SPEED_256 7
|
#define SPI_SPEED_256 7
|
||||||
|
|
||||||
#define MP3_BUFFER_SIZE 32
|
#define MP3_BUFFER_SIZE 32
|
||||||
|
|
||||||
#define CS_HIGH() do { AUDIO_CS_GPIO->BSRRL = AUDIO_CS_GPIO_PIN; } while (0)
|
#define CS_HIGH() do { AUDIO_CS_GPIO->BSRRL = AUDIO_CS_GPIO_PIN; } while (0)
|
||||||
#define CS_LOW() do { AUDIO_CS_GPIO->BSRRH = AUDIO_CS_GPIO_PIN; } while (0)
|
#define CS_LOW() do { AUDIO_CS_GPIO->BSRRH = AUDIO_CS_GPIO_PIN; } while (0)
|
||||||
#define XDCS_HIGH() do { AUDIO_XDCS_GPIO->BSRRL = AUDIO_XDCS_GPIO_PIN; } while (0)
|
#define XDCS_HIGH() do { AUDIO_XDCS_GPIO->BSRRL = AUDIO_XDCS_GPIO_PIN; } while (0)
|
||||||
#define XDCS_LOW() do { AUDIO_XDCS_GPIO->BSRRH = AUDIO_XDCS_GPIO_PIN; } while (0)
|
#define XDCS_LOW() do { AUDIO_XDCS_GPIO->BSRRH = AUDIO_XDCS_GPIO_PIN; } while (0)
|
||||||
#define RST_HIGH() do { AUDIO_RST_GPIO->BSRRL = AUDIO_RST_GPIO_PIN; } while (0)
|
#define RST_HIGH() do { AUDIO_RST_GPIO->BSRRL = AUDIO_RST_GPIO_PIN; } while (0)
|
||||||
#define RST_LOW() do { AUDIO_RST_GPIO->BSRRH = AUDIO_RST_GPIO_PIN; } while (0)
|
#define RST_LOW() do { AUDIO_RST_GPIO->BSRRH = AUDIO_RST_GPIO_PIN; } while (0)
|
||||||
|
|
||||||
#define READ_DREQ() (GPIO_ReadInputDataBit(AUDIO_DREQ_GPIO, AUDIO_DREQ_GPIO_PIN))
|
#define READ_DREQ() (GPIO_ReadInputDataBit(AUDIO_DREQ_GPIO, AUDIO_DREQ_GPIO_PIN))
|
||||||
|
|
||||||
void audioSpiInit(void)
|
void audioSpiInit(void)
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
SPI_InitTypeDef SPI_InitStructure;
|
SPI_InitTypeDef SPI_InitStructure;
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_SPI_MISO_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_SPI_MISO_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
GPIO_Init(AUDIO_SPI_MISO_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_SPI_MISO_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_SPI_SCK_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_SPI_SCK_GPIO_PIN;
|
||||||
GPIO_Init(AUDIO_SPI_SCK_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_SPI_SCK_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_SPI_MOSI_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_SPI_MOSI_GPIO_PIN;
|
||||||
GPIO_Init(AUDIO_SPI_MOSI_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_SPI_MOSI_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_CS_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_CS_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_Init(AUDIO_CS_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_CS_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_XDCS_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_XDCS_GPIO_PIN;
|
||||||
GPIO_Init(AUDIO_XDCS_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_XDCS_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_RST_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_RST_GPIO_PIN;
|
||||||
GPIO_Init(AUDIO_RST_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_RST_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_DREQ_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_DREQ_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||||
GPIO_Init(AUDIO_DREQ_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_DREQ_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_PinAFConfig(AUDIO_SPI_SCK_GPIO, AUDIO_SPI_SCK_GPIO_PinSource, AUDIO_SPI_GPIO_AF);
|
GPIO_PinAFConfig(AUDIO_SPI_SCK_GPIO, AUDIO_SPI_SCK_GPIO_PinSource, AUDIO_SPI_GPIO_AF);
|
||||||
GPIO_PinAFConfig(AUDIO_SPI_MISO_GPIO, AUDIO_SPI_MISO_GPIO_PinSource, AUDIO_SPI_GPIO_AF);
|
GPIO_PinAFConfig(AUDIO_SPI_MISO_GPIO, AUDIO_SPI_MISO_GPIO_PinSource, AUDIO_SPI_GPIO_AF);
|
||||||
GPIO_PinAFConfig(AUDIO_SPI_MOSI_GPIO, AUDIO_SPI_MOSI_GPIO_PinSource, AUDIO_SPI_GPIO_AF);
|
GPIO_PinAFConfig(AUDIO_SPI_MOSI_GPIO, AUDIO_SPI_MOSI_GPIO_PinSource, AUDIO_SPI_GPIO_AF);
|
||||||
|
|
||||||
RCC_ClocksTypeDef RCC_Clocks;
|
RCC_ClocksTypeDef RCC_Clocks;
|
||||||
RCC_GetClocksFreq(&RCC_Clocks);
|
RCC_GetClocksFreq(&RCC_Clocks);
|
||||||
|
|
||||||
SPI_I2S_DeInit(AUDIO_SPI);
|
SPI_I2S_DeInit(AUDIO_SPI);
|
||||||
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||||
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
|
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
|
||||||
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
|
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
|
||||||
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
|
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
|
||||||
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
|
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
|
||||||
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
|
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
|
||||||
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
|
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
|
||||||
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
|
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
|
||||||
SPI_InitStructure.SPI_CRCPolynomial = 7;
|
SPI_InitStructure.SPI_CRCPolynomial = 7;
|
||||||
SPI_Init(AUDIO_SPI, &SPI_InitStructure);
|
SPI_Init(AUDIO_SPI, &SPI_InitStructure);
|
||||||
SPI_Cmd(AUDIO_SPI, ENABLE);
|
SPI_Cmd(AUDIO_SPI, ENABLE);
|
||||||
|
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_RXNE);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_RXNE);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TXE);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TXE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioSpiSetSpeed(uint8_t speed)
|
void audioSpiSetSpeed(uint8_t speed)
|
||||||
{
|
{
|
||||||
AUDIO_SPI->CR1 &= 0XFFC7; // Fsck=Fcpu/256
|
AUDIO_SPI->CR1 &= 0XFFC7; // Fsck=Fcpu/256
|
||||||
switch(speed) {
|
switch(speed) {
|
||||||
case SPI_SPEED_2:
|
case SPI_SPEED_2:
|
||||||
AUDIO_SPI->CR1 |= 0<<3; // Fsck=Fpclk/2=36Mhz
|
AUDIO_SPI->CR1 |= 0<<3; // Fsck=Fpclk/2=36Mhz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_4:
|
case SPI_SPEED_4:
|
||||||
AUDIO_SPI->CR1 |= 1<<3; // Fsck=Fpclk/4=18Mhz
|
AUDIO_SPI->CR1 |= 1<<3; // Fsck=Fpclk/4=18Mhz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_8:
|
case SPI_SPEED_8:
|
||||||
AUDIO_SPI->CR1 |= 2<<3; // Fsck=Fpclk/8=9Mhz
|
AUDIO_SPI->CR1 |= 2<<3; // Fsck=Fpclk/8=9Mhz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_16:
|
case SPI_SPEED_16:
|
||||||
AUDIO_SPI->CR1 |= 3<<3; // Fsck=Fpclk/16=4.5Mhz
|
AUDIO_SPI->CR1 |= 3<<3; // Fsck=Fpclk/16=4.5Mhz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_32:
|
case SPI_SPEED_32:
|
||||||
AUDIO_SPI->CR1 |= 4<<3; // Fsck=Fpclk/32=2.25Mhz
|
AUDIO_SPI->CR1 |= 4<<3; // Fsck=Fpclk/32=2.25Mhz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_64:
|
case SPI_SPEED_64:
|
||||||
AUDIO_SPI->CR1 |= 5<<3; // Fsck=Fpclk/16=1.125Mhz
|
AUDIO_SPI->CR1 |= 5<<3; // Fsck=Fpclk/16=1.125Mhz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_128:
|
case SPI_SPEED_128:
|
||||||
AUDIO_SPI->CR1 |= 6<<3; // Fsck=Fpclk/16=562.5Khz
|
AUDIO_SPI->CR1 |= 6<<3; // Fsck=Fpclk/16=562.5Khz
|
||||||
break;
|
break;
|
||||||
case SPI_SPEED_256:
|
case SPI_SPEED_256:
|
||||||
AUDIO_SPI->CR1 |= 7<<3; // Fsck=Fpclk/16=281.25Khz
|
AUDIO_SPI->CR1 |= 7<<3; // Fsck=Fpclk/16=281.25Khz
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AUDIO_SPI->CR1 |= 1<<6;
|
AUDIO_SPI->CR1 |= 1<<6;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t audioSpiReadWriteByte(uint8_t value)
|
uint8_t audioSpiReadWriteByte(uint8_t value)
|
||||||
{
|
{
|
||||||
uint16_t time_out = 0x0FFF;
|
uint16_t time_out = 0x0FFF;
|
||||||
while (SPI_I2S_GetFlagStatus(AUDIO_SPI, SPI_I2S_FLAG_TXE) == RESET) {
|
while (SPI_I2S_GetFlagStatus(AUDIO_SPI, SPI_I2S_FLAG_TXE) == RESET) {
|
||||||
if (--time_out == 0) {
|
if (--time_out == 0) {
|
||||||
// reset SPI
|
// reset SPI
|
||||||
SPI_Cmd(AUDIO_SPI, DISABLE);
|
SPI_Cmd(AUDIO_SPI, DISABLE);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_OVR);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_OVR);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_BSY);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_BSY);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, I2S_FLAG_UDR);
|
SPI_I2S_ClearFlag(AUDIO_SPI, I2S_FLAG_UDR);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TIFRFE);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TIFRFE);
|
||||||
SPI_Cmd(AUDIO_SPI, ENABLE);
|
SPI_Cmd(AUDIO_SPI, ENABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SPI_I2S_SendData(AUDIO_SPI, value);
|
SPI_I2S_SendData(AUDIO_SPI, value);
|
||||||
|
|
||||||
time_out = 0x0FFF;
|
time_out = 0x0FFF;
|
||||||
while (SPI_I2S_GetFlagStatus(AUDIO_SPI, SPI_I2S_FLAG_RXNE) == RESET) {
|
while (SPI_I2S_GetFlagStatus(AUDIO_SPI, SPI_I2S_FLAG_RXNE) == RESET) {
|
||||||
if (--time_out == 0) {
|
if (--time_out == 0) {
|
||||||
// reset SPI
|
// reset SPI
|
||||||
SPI_Cmd(AUDIO_SPI, DISABLE);
|
SPI_Cmd(AUDIO_SPI, DISABLE);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_OVR);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_OVR);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_BSY);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_BSY);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, I2S_FLAG_UDR);
|
SPI_I2S_ClearFlag(AUDIO_SPI, I2S_FLAG_UDR);
|
||||||
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TIFRFE);
|
SPI_I2S_ClearFlag(AUDIO_SPI, SPI_I2S_FLAG_TIFRFE);
|
||||||
SPI_Cmd(AUDIO_SPI, ENABLE);
|
SPI_Cmd(AUDIO_SPI, ENABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SPI_I2S_ReceiveData(AUDIO_SPI);
|
return SPI_I2S_ReceiveData(AUDIO_SPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t audioWaitDreq(int32_t delay_us)
|
uint8_t audioWaitDreq(int32_t delay_us)
|
||||||
{
|
{
|
||||||
while (READ_DREQ() == 0) {
|
while (READ_DREQ() == 0) {
|
||||||
if (delay_us-- == 0) return 0;
|
if (delay_us-- == 0) return 0;
|
||||||
delay_01us(10);
|
delay_01us(10);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t audioSpiReadReg(uint8_t address)
|
uint16_t audioSpiReadReg(uint8_t address)
|
||||||
{
|
{
|
||||||
if (!audioWaitDreq(100))
|
if (!audioWaitDreq(100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
audioSpiSetSpeed(SPI_SPEED_64);
|
audioSpiSetSpeed(SPI_SPEED_64);
|
||||||
XDCS_HIGH();
|
XDCS_HIGH();
|
||||||
CS_LOW();
|
CS_LOW();
|
||||||
audioSpiReadWriteByte(VS_READ_COMMAND);
|
audioSpiReadWriteByte(VS_READ_COMMAND);
|
||||||
audioSpiReadWriteByte(address);
|
audioSpiReadWriteByte(address);
|
||||||
uint16_t result = audioSpiReadWriteByte(0xff) << 8;
|
uint16_t result = audioSpiReadWriteByte(0xff) << 8;
|
||||||
result += audioSpiReadWriteByte(0xff);
|
result += audioSpiReadWriteByte(0xff);
|
||||||
delay_01us(100); // 10us
|
delay_01us(100); // 10us
|
||||||
CS_HIGH();
|
CS_HIGH();
|
||||||
audioSpiSetSpeed(SPI_SPEED_8);
|
audioSpiSetSpeed(SPI_SPEED_8);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t audioSpiReadCmd(uint8_t address)
|
uint16_t audioSpiReadCmd(uint8_t address)
|
||||||
{
|
{
|
||||||
if (!audioWaitDreq(100))
|
if (!audioWaitDreq(100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
audioSpiSetSpeed(SPI_SPEED_64);
|
audioSpiSetSpeed(SPI_SPEED_64);
|
||||||
XDCS_HIGH();
|
XDCS_HIGH();
|
||||||
CS_LOW();
|
CS_LOW();
|
||||||
audioSpiReadWriteByte(VS_READ_COMMAND);
|
audioSpiReadWriteByte(VS_READ_COMMAND);
|
||||||
audioSpiReadWriteByte(address);
|
audioSpiReadWriteByte(address);
|
||||||
uint16_t result = audioSpiReadWriteByte(0) << 8;
|
uint16_t result = audioSpiReadWriteByte(0) << 8;
|
||||||
result |= audioSpiReadWriteByte(0);
|
result |= audioSpiReadWriteByte(0);
|
||||||
delay_01us(50); // 5us
|
delay_01us(50); // 5us
|
||||||
CS_HIGH();
|
CS_HIGH();
|
||||||
audioSpiSetSpeed(SPI_SPEED_8);
|
audioSpiSetSpeed(SPI_SPEED_8);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t audioSpiWriteCmd(uint8_t address, uint16_t data)
|
uint8_t audioSpiWriteCmd(uint8_t address, uint16_t data)
|
||||||
{
|
{
|
||||||
if (!audioWaitDreq(100))
|
if (!audioWaitDreq(100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
audioSpiSetSpeed(SPI_SPEED_64);
|
audioSpiSetSpeed(SPI_SPEED_64);
|
||||||
XDCS_HIGH();
|
XDCS_HIGH();
|
||||||
CS_LOW();
|
CS_LOW();
|
||||||
audioSpiReadWriteByte(VS_WRITE_COMMAND);
|
audioSpiReadWriteByte(VS_WRITE_COMMAND);
|
||||||
audioSpiReadWriteByte(address);
|
audioSpiReadWriteByte(address);
|
||||||
audioSpiReadWriteByte(data >> 8);
|
audioSpiReadWriteByte(data >> 8);
|
||||||
audioSpiReadWriteByte(data);
|
audioSpiReadWriteByte(data);
|
||||||
delay_01us(50); // 5us
|
delay_01us(50); // 5us
|
||||||
CS_HIGH();
|
CS_HIGH();
|
||||||
audioSpiSetSpeed(SPI_SPEED_8);
|
audioSpiSetSpeed(SPI_SPEED_8);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioResetDecodeTime(void)
|
void audioResetDecodeTime(void)
|
||||||
{
|
{
|
||||||
audioSpiWriteCmd(SPI_DECODE_TIME, 0x0000);
|
audioSpiWriteCmd(SPI_DECODE_TIME, 0x0000);
|
||||||
audioSpiWriteCmd(SPI_DECODE_TIME, 0x0000);
|
audioSpiWriteCmd(SPI_DECODE_TIME, 0x0000);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t audioHardReset(void)
|
uint8_t audioHardReset(void)
|
||||||
{
|
{
|
||||||
XDCS_HIGH();
|
XDCS_HIGH();
|
||||||
CS_HIGH();
|
CS_HIGH();
|
||||||
RST_LOW();
|
RST_LOW();
|
||||||
delay_ms(100); // 100ms
|
delay_ms(100); // 100ms
|
||||||
RST_HIGH();
|
RST_HIGH();
|
||||||
|
|
||||||
if (!audioWaitDreq(100))
|
if (!audioWaitDreq(100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
delay_ms(20); // 20ms
|
delay_ms(20); // 20ms
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t audioSoftReset(void)
|
uint8_t audioSoftReset(void)
|
||||||
{
|
{
|
||||||
audioSpiSetSpeed(SPI_SPEED_64);
|
audioSpiSetSpeed(SPI_SPEED_64);
|
||||||
if (!audioWaitDreq(100))
|
if (!audioWaitDreq(100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
audioSpiReadWriteByte(0x00); // start the transfer
|
audioSpiReadWriteByte(0x00); // start the transfer
|
||||||
|
|
||||||
audioSpiWriteCmd(SPI_MODE, 0x0816); // SOFT RESET, new model
|
audioSpiWriteCmd(SPI_MODE, 0x0816); // SOFT RESET, new model
|
||||||
if (!audioWaitDreq(100))
|
if (!audioWaitDreq(100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// wait for set up successful
|
// wait for set up successful
|
||||||
uint8_t retry = 0;
|
uint8_t retry = 0;
|
||||||
while (audioSpiReadReg(SPI_CLOCKF) != 0x9800 && retry < 100) {
|
while (audioSpiReadReg(SPI_CLOCKF) != 0x9800 && retry < 100) {
|
||||||
retry++;
|
retry++;
|
||||||
audioSpiWriteCmd(SPI_CLOCKF, 0x9800);
|
audioSpiWriteCmd(SPI_CLOCKF, 0x9800);
|
||||||
}
|
}
|
||||||
|
|
||||||
audioResetDecodeTime(); // reset the decoding time
|
audioResetDecodeTime(); // reset the decoding time
|
||||||
audioSpiSetSpeed(SPI_SPEED_8);
|
audioSpiSetSpeed(SPI_SPEED_8);
|
||||||
XDCS_LOW();
|
XDCS_LOW();
|
||||||
audioSpiReadWriteByte(0X0);
|
audioSpiReadWriteByte(0X0);
|
||||||
audioSpiReadWriteByte(0X0);
|
audioSpiReadWriteByte(0X0);
|
||||||
audioSpiReadWriteByte(0X0);
|
audioSpiReadWriteByte(0X0);
|
||||||
audioSpiReadWriteByte(0X0);
|
audioSpiReadWriteByte(0X0);
|
||||||
delay_01us(100); // 10us
|
delay_01us(100); // 10us
|
||||||
XDCS_HIGH();
|
XDCS_HIGH();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t audioSpiWriteData(const uint8_t * buffer, uint32_t size)
|
uint32_t audioSpiWriteData(const uint8_t * buffer, uint32_t size)
|
||||||
{
|
{
|
||||||
XDCS_LOW();
|
XDCS_LOW();
|
||||||
|
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
while (index < size && READ_DREQ() != 0) {
|
while (index < size && READ_DREQ() != 0) {
|
||||||
for (int i=0; i<MP3_BUFFER_SIZE && index<size; i++) {
|
for (int i=0; i<MP3_BUFFER_SIZE && index<size; i++) {
|
||||||
audioSpiReadWriteByte(buffer[index++]);
|
audioSpiReadWriteByte(buffer[index++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioSpiWriteBuffer(const uint8_t * buffer, uint32_t size)
|
void audioSpiWriteBuffer(const uint8_t * buffer, uint32_t size)
|
||||||
{
|
{
|
||||||
const uint8_t * p = buffer;
|
const uint8_t * p = buffer;
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
uint32_t written = audioSpiWriteData(p, size);
|
uint32_t written = audioSpiWriteData(p, size);
|
||||||
p += written;
|
p += written;
|
||||||
size -= written;
|
size -= written;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t RiffHeader[] = {
|
const uint8_t RiffHeader[] = {
|
||||||
0x52, 0x49, 0x46, 0x46, 0xff, 0xff, 0xff, 0xff, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20,
|
0x52, 0x49, 0x46, 0x46, 0xff, 0xff, 0xff, 0xff, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20,
|
||||||
0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00,
|
0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00,
|
||||||
0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
};
|
};
|
||||||
|
|
||||||
void audioSendRiffHeader()
|
void audioSendRiffHeader()
|
||||||
{
|
{
|
||||||
audioSpiWriteBuffer(RiffHeader, sizeof(RiffHeader));
|
audioSpiWriteBuffer(RiffHeader, sizeof(RiffHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioInit()
|
void audioInit()
|
||||||
{
|
{
|
||||||
audioSpiInit();
|
audioSpiInit();
|
||||||
audioHardReset();
|
audioHardReset();
|
||||||
audioSoftReset();
|
audioSoftReset();
|
||||||
audioSpiSetSpeed(SPI_SPEED_8);
|
audioSpiSetSpeed(SPI_SPEED_8);
|
||||||
|
|
||||||
delay_01us(10000); // 1ms
|
delay_01us(10000); // 1ms
|
||||||
audioSendRiffHeader();
|
audioSendRiffHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * currentBuffer = NULL;
|
uint8_t * currentBuffer = NULL;
|
||||||
uint32_t currentSize = 0;
|
uint32_t currentSize = 0;
|
||||||
int16_t newVolume = -1;
|
int16_t newVolume = -1;
|
||||||
|
|
||||||
void audioSetCurrentBuffer(const AudioBuffer * buffer)
|
void audioSetCurrentBuffer(const AudioBuffer * buffer)
|
||||||
{
|
{
|
||||||
currentBuffer = (uint8_t *)buffer->data;
|
currentBuffer = (uint8_t *)buffer->data;
|
||||||
currentSize = buffer->size * 2;
|
currentSize = buffer->size * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioConsumeCurrentBuffer()
|
void audioConsumeCurrentBuffer()
|
||||||
{
|
{
|
||||||
if (newVolume >= 0) {
|
if (newVolume >= 0) {
|
||||||
uint8_t value = newVolume;
|
uint8_t value = newVolume;
|
||||||
audioSpiWriteCmd(SPI_VOL, (value << 8) + value);
|
audioSpiWriteCmd(SPI_VOL, (value << 8) + value);
|
||||||
// audioSendRiffHeader();
|
// audioSendRiffHeader();
|
||||||
newVolume = -1;
|
newVolume = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentBuffer) {
|
if (!currentBuffer) {
|
||||||
audioSetCurrentBuffer(audioQueue.buffersFifo.getNextFilledBuffer());
|
audioSetCurrentBuffer(audioQueue.buffersFifo.getNextFilledBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentBuffer) {
|
if (currentBuffer) {
|
||||||
uint32_t written = audioSpiWriteData(currentBuffer, currentSize);
|
uint32_t written = audioSpiWriteData(currentBuffer, currentSize);
|
||||||
currentBuffer += written;
|
currentBuffer += written;
|
||||||
currentSize -= written;
|
currentSize -= written;
|
||||||
if (currentSize == 0) {
|
if (currentSize == 0) {
|
||||||
audioQueue.buffersFifo.freeNextFilledBuffer();
|
audioQueue.buffersFifo.freeNextFilledBuffer();
|
||||||
currentBuffer = NULL;
|
currentBuffer = NULL;
|
||||||
currentSize = 0;
|
currentSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust this value for a volume level just above the silence
|
// adjust this value for a volume level just above the silence
|
||||||
// values is attenuation in dB, higher value - less volume
|
// values is attenuation in dB, higher value - less volume
|
||||||
// max value is 126
|
// max value is 126
|
||||||
#define VOLUME_MIN_DB 40
|
#define VOLUME_MIN_DB 40
|
||||||
|
|
||||||
void setScaledVolume(uint8_t volume)
|
void setScaledVolume(uint8_t volume)
|
||||||
{
|
{
|
||||||
if (volume > VOLUME_LEVEL_MAX) {
|
if (volume > VOLUME_LEVEL_MAX) {
|
||||||
volume = VOLUME_LEVEL_MAX;
|
volume = VOLUME_LEVEL_MAX;
|
||||||
}
|
}
|
||||||
// maximum volume is 0x00 and total silence is 0xFE
|
// maximum volume is 0x00 and total silence is 0xFE
|
||||||
if (volume == 0) {
|
if (volume == 0) {
|
||||||
setVolume(0xFE); // silence
|
setVolume(0xFE); // silence
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32_t vol = (VOLUME_MIN_DB * 2) - ((uint32_t)volume * (VOLUME_MIN_DB * 2)) / VOLUME_LEVEL_MAX;
|
uint32_t vol = (VOLUME_MIN_DB * 2) - ((uint32_t)volume * (VOLUME_MIN_DB * 2)) / VOLUME_LEVEL_MAX;
|
||||||
setVolume(vol);
|
setVolume(vol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVolume(uint8_t volume)
|
void setVolume(uint8_t volume)
|
||||||
{
|
{
|
||||||
newVolume = volume;
|
newVolume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getVolume()
|
int32_t getVolume()
|
||||||
{
|
{
|
||||||
return -1; // TODO
|
return -1; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -24,45 +24,45 @@ void backlightInit()
|
||||||
{
|
{
|
||||||
// PIN init
|
// PIN init
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
if (IS_HORUS_PROD()) {
|
GPIO_InitStructure.GPIO_Pin = BL_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Pin = PROD_BL_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
GPIO_Init(BL_GPIO, &GPIO_InitStructure);
|
||||||
GPIO_Init(BL_GPIO, &GPIO_InitStructure);
|
GPIO_PinAFConfig(BL_GPIO, BL_GPIO_PinSource, BL_GPIO_AF);
|
||||||
GPIO_PinAFConfig(BL_GPIO, PROD_BL_GPIO_PinSource, PROD_BL_GPIO_AF);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
GPIO_InitStructure.GPIO_Pin = BETA_BL_GPIO_PIN;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
|
||||||
GPIO_Init(BL_GPIO, &GPIO_InitStructure);
|
|
||||||
GPIO_PinAFConfig(BL_GPIO, BETA_BL_GPIO_PinSource, BETA_BL_GPIO_AF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TIMER init
|
// TIMER init
|
||||||
|
#if defined(PCBX12S)
|
||||||
if (IS_HORUS_PROD()) {
|
if (IS_HORUS_PROD()) {
|
||||||
PROD_BL_TIMER->ARR = 100;
|
BL_TIMER->ARR = 100;
|
||||||
PROD_BL_TIMER->PSC = PROD_BL_TIMER_FREQ / 10000 - 1; // 1kHz
|
BL_TIMER->PSC = BL_TIMER_FREQ / 10000 - 1; // 1kHz
|
||||||
PROD_BL_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
|
BL_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
|
||||||
PROD_BL_TIMER->CCER = TIM_CCER_CC4E;
|
BL_TIMER->CCER = TIM_CCER_CC4E;
|
||||||
PROD_BL_TIMER->CCR4 = 0;
|
BL_TIMER->CCR4 = 0;
|
||||||
PROD_BL_TIMER->EGR = 0;
|
BL_TIMER->EGR = 0;
|
||||||
PROD_BL_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
BL_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BETA_BL_TIMER->ARR = 100;
|
BL_TIMER->ARR = 100;
|
||||||
BETA_BL_TIMER->PSC = BETA_BL_TIMER_FREQ / 10000 - 1; // 1kHz
|
BL_TIMER->PSC = BL_TIMER_FREQ / 10000 - 1; // 1kHz
|
||||||
BETA_BL_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2; // PWM
|
BL_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2; // PWM
|
||||||
BETA_BL_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC1NE;
|
BL_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC1NE;
|
||||||
BETA_BL_TIMER->CCR1 = 100;
|
BL_TIMER->CCR1 = 100;
|
||||||
BETA_BL_TIMER->EGR = 1;
|
BL_TIMER->EGR = 1;
|
||||||
BETA_BL_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
|
BL_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
|
||||||
BETA_BL_TIMER->BDTR |= TIM_BDTR_MOE;
|
BL_TIMER->BDTR |= TIM_BDTR_MOE;
|
||||||
}
|
}
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
BL_TIMER->ARR = 100;
|
||||||
|
BL_TIMER->PSC = BL_TIMER_FREQ / 10000 - 1; // 1kHz
|
||||||
|
BL_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3PE; // PWM mode 1
|
||||||
|
BL_TIMER->CCER = TIM_CCER_CC3E | TIM_CCER_CC3NE;
|
||||||
|
BL_TIMER->CCR3 = 100;
|
||||||
|
BL_TIMER->EGR = TIM_EGR_UG;
|
||||||
|
BL_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
|
||||||
|
BL_TIMER->BDTR |= TIM_BDTR_MOE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlightEnable(uint8_t dutyCycle)
|
void backlightEnable(uint8_t dutyCycle)
|
||||||
|
@ -71,10 +71,14 @@ void backlightEnable(uint8_t dutyCycle)
|
||||||
dutyCycle = 5;
|
dutyCycle = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
if (IS_HORUS_PROD()) {
|
if (IS_HORUS_PROD()) {
|
||||||
PROD_BL_TIMER->CCR4 = dutyCycle;
|
BL_TIMER->CCR4 = dutyCycle;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BETA_BL_TIMER->CCR1 = (100 - dutyCycle);
|
BL_TIMER->CCR1 = (100 - dutyCycle);
|
||||||
}
|
}
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
BL_TIMER->CCR3 = (100 - dutyCycle);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,16 @@ extern "C" void INTERRUPT_1MS_IRQHandler()
|
||||||
DEBUG_INTERRUPT(INT_1MS);
|
DEBUG_INTERRUPT(INT_1MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
extern "C" void initialise_monitor_handles();
|
||||||
|
#endif
|
||||||
|
|
||||||
void boardInit()
|
void boardInit()
|
||||||
{
|
{
|
||||||
|
#if defined(SEMIHOSTING)
|
||||||
|
initialise_monitor_handles();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
|
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
|
||||||
PCBREV_RCC_AHB1Periph |
|
PCBREV_RCC_AHB1Periph |
|
||||||
|
@ -115,7 +123,8 @@ void boardInit()
|
||||||
HAPTIC_RCC_AHB1Periph |
|
HAPTIC_RCC_AHB1Periph |
|
||||||
INTMODULE_RCC_AHB1Periph |
|
INTMODULE_RCC_AHB1Periph |
|
||||||
EXTMODULE_RCC_AHB1Periph |
|
EXTMODULE_RCC_AHB1Periph |
|
||||||
GPS_RCC_AHB1Periph,
|
GPS_RCC_AHB1Periph |
|
||||||
|
BL_RCC_AHB1Periph,
|
||||||
ENABLE);
|
ENABLE);
|
||||||
|
|
||||||
RCC_APB1PeriphClockCmd(INTERRUPT_1MS_RCC_APB1Periph |
|
RCC_APB1PeriphClockCmd(INTERRUPT_1MS_RCC_APB1Periph |
|
||||||
|
@ -127,23 +136,18 @@ void boardInit()
|
||||||
AUDIO_RCC_APB1Periph |
|
AUDIO_RCC_APB1Periph |
|
||||||
INTMODULE_RCC_APB1Periph |
|
INTMODULE_RCC_APB1Periph |
|
||||||
EXTMODULE_RCC_APB1Periph |
|
EXTMODULE_RCC_APB1Periph |
|
||||||
GPS_RCC_APB1Periph,
|
GPS_RCC_APB1Periph |
|
||||||
|
BL_RCC_APB1Periph,
|
||||||
ENABLE);
|
ENABLE);
|
||||||
RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph |
|
RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph |
|
||||||
ADC_RCC_APB2Periph |
|
ADC_RCC_APB2Periph |
|
||||||
HAPTIC_RCC_APB2Periph |
|
HAPTIC_RCC_APB2Periph |
|
||||||
INTMODULE_RCC_APB2Periph |
|
INTMODULE_RCC_APB2Periph |
|
||||||
EXTMODULE_RCC_APB2Periph,
|
EXTMODULE_RCC_APB2Periph |
|
||||||
|
BL_RCC_APB2Periph,
|
||||||
ENABLE);
|
ENABLE);
|
||||||
|
|
||||||
pwrInit();
|
pwrInit();
|
||||||
|
|
||||||
// must be called after pwrInit() because the PCBREV GPIO is initialized there
|
|
||||||
if (IS_HORUS_PROD())
|
|
||||||
RCC_APB1PeriphClockCmd(PROD_BL_RCC_APB1Periph,ENABLE);
|
|
||||||
else
|
|
||||||
RCC_APB2PeriphClockCmd(BETA_BL_RCC_APB2Periph,ENABLE);
|
|
||||||
|
|
||||||
delaysInit();
|
delaysInit();
|
||||||
|
|
||||||
// FrSky removed the volume chip in latest board, that's why it doesn't answer!
|
// FrSky removed the volume chip in latest board, that's why it doesn't answer!
|
||||||
|
@ -172,13 +176,23 @@ void boardInit()
|
||||||
init1msTimer();
|
init1msTimer();
|
||||||
usbInit();
|
usbInit();
|
||||||
hapticInit();
|
hapticInit();
|
||||||
|
|
||||||
|
#if defined(BLUETOOTH)
|
||||||
bluetoothInit(BLUETOOTH_FACTORY_BAUDRATE);
|
bluetoothInit(BLUETOOTH_FACTORY_BAUDRATE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
gpsInit(GPS_USART_BAUDRATE);
|
gpsInit(GPS_USART_BAUDRATE);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM4_STOP|DBGMCU_TIM5_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM7_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM9_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM11_STOP|DBGMCU_TIM12_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM4_STOP|DBGMCU_TIM5_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM7_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM9_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM11_STOP|DBGMCU_TIM12_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
ledInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
ledBlue();
|
ledBlue();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,13 @@ extern "C" {
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h"
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h"
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h"
|
#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h"
|
||||||
|
|
||||||
#if __clang__
|
#if __clang__
|
||||||
// Restore warnings about registers
|
// Restore warnings about registers
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
@ -109,7 +115,7 @@ void delay_ms(uint32_t ms);
|
||||||
|
|
||||||
// PCBREV driver
|
// PCBREV driver
|
||||||
#define IS_HORUS_PROD() GPIO_ReadInputDataBit(PCBREV_GPIO, PCBREV_GPIO_PIN)
|
#define IS_HORUS_PROD() GPIO_ReadInputDataBit(PCBREV_GPIO, PCBREV_GPIO_PIN)
|
||||||
#if defined(SIMU)
|
#if defined(SIMU) || defined(PCBX10)
|
||||||
#define IS_FIRMWARE_COMPATIBLE_WITH_BOARD() true
|
#define IS_FIRMWARE_COMPATIBLE_WITH_BOARD() true
|
||||||
#elif PCBREV >= 13
|
#elif PCBREV >= 13
|
||||||
#define IS_FIRMWARE_COMPATIBLE_WITH_BOARD() IS_HORUS_PROD()
|
#define IS_FIRMWARE_COMPATIBLE_WITH_BOARD() IS_HORUS_PROD()
|
||||||
|
@ -311,8 +317,12 @@ void watchdogInit(unsigned int duration);
|
||||||
|
|
||||||
// ADC driver
|
// ADC driver
|
||||||
#define NUM_POTS 3
|
#define NUM_POTS 3
|
||||||
#define NUM_SLIDERS 4
|
#define NUM_XPOTS NUM_POTS
|
||||||
#define NUM_XPOTS 3
|
#if defined(PCBX10)
|
||||||
|
#define NUM_SLIDERS 2
|
||||||
|
#else
|
||||||
|
#define NUM_SLIDERS 4
|
||||||
|
#endif
|
||||||
enum Analogs {
|
enum Analogs {
|
||||||
STICK1,
|
STICK1,
|
||||||
STICK2,
|
STICK2,
|
||||||
|
@ -323,18 +333,50 @@ enum Analogs {
|
||||||
POT2,
|
POT2,
|
||||||
POT3,
|
POT3,
|
||||||
POT_LAST = POT3,
|
POT_LAST = POT3,
|
||||||
SLIDER1,
|
SLIDER_FIRST,
|
||||||
|
SLIDER1 = SLIDER_FIRST,
|
||||||
SLIDER2,
|
SLIDER2,
|
||||||
SLIDER3,
|
#if defined(PCBX12S)
|
||||||
SLIDER4,
|
SLIDER_FRONT_LEFT = SLIDER_FIRST,
|
||||||
|
SLIDER_FRONT_RIGHT,
|
||||||
|
SLIDER_REAR_LEFT,
|
||||||
|
SLIDER_REAR_RIGHT,
|
||||||
|
#else
|
||||||
|
SLIDER_REAR_LEFT,
|
||||||
|
SLIDER_REAR_RIGHT,
|
||||||
|
#endif
|
||||||
|
SLIDER_LAST = SLIDER_FIRST + NUM_SLIDERS - 1,
|
||||||
TX_VOLTAGE,
|
TX_VOLTAGE,
|
||||||
MOUSE1,
|
MOUSE1,
|
||||||
MOUSE2,
|
MOUSE2,
|
||||||
NUMBER_ANALOG
|
NUM_ANALOGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CalibratedAnalogs {
|
||||||
|
CALIBRATED_STICK1,
|
||||||
|
CALIBRATED_STICK2,
|
||||||
|
CALIBRATED_STICK3,
|
||||||
|
CALIBRATED_STICK4,
|
||||||
|
CALIBRATED_POT1,
|
||||||
|
CALIBRATED_POT2,
|
||||||
|
CALIBRATED_POT3,
|
||||||
|
#if defined(PCBX12S)
|
||||||
|
CALIBRATED_SLIDER_FRONT_LEFT,
|
||||||
|
CALIBRATED_SLIDER_FRONT_RIGHT,
|
||||||
|
CALIBRATED_SLIDER_REAR_LEFT,
|
||||||
|
CALIBRATED_SLIDER_REAR_RIGHT,
|
||||||
|
#else
|
||||||
|
CALIBRATED_SLIDER_REAR_LEFT,
|
||||||
|
CALIBRATED_SLIDER_REAR_RIGHT,
|
||||||
|
#endif
|
||||||
|
CALIBRATED_MOUSE1,
|
||||||
|
CALIBRATED_MOUSE2,
|
||||||
|
NUM_CALIBRATED_ANALOGS
|
||||||
|
};
|
||||||
|
|
||||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
||||||
#define IS_SLIDER(x) ((x)>=SLIDER1 && (x)<=SLIDER4)
|
#define IS_SLIDER(x) ((x)>=SLIDER_FIRST && (x)<=SLIDER_LAST)
|
||||||
extern uint16_t adcValues[NUMBER_ANALOG];
|
extern uint16_t adcValues[NUM_ANALOGS];
|
||||||
void adcInit(void);
|
void adcInit(void);
|
||||||
void adcRead(void);
|
void adcRead(void);
|
||||||
uint16_t getAnalogValue(uint8_t index);
|
uint16_t getAnalogValue(uint8_t index);
|
||||||
|
@ -360,9 +402,13 @@ uint32_t pwrPressedDuration(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Led driver
|
// Led driver
|
||||||
|
void ledInit(void);
|
||||||
void ledOff(void);
|
void ledOff(void);
|
||||||
void ledRed(void);
|
void ledRed(void);
|
||||||
void ledBlue(void);
|
void ledBlue(void);
|
||||||
|
#if defined(PCBX10)
|
||||||
|
void ledGreen();
|
||||||
|
#endif
|
||||||
|
|
||||||
// LCD driver
|
// LCD driver
|
||||||
#define LCD_W 480
|
#define LCD_W 480
|
||||||
|
@ -370,9 +416,9 @@ void ledBlue(void);
|
||||||
#define LCD_DEPTH 16
|
#define LCD_DEPTH 16
|
||||||
void lcdInit(void);
|
void lcdInit(void);
|
||||||
void lcdRefresh(void);
|
void lcdRefresh(void);
|
||||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
||||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
||||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
||||||
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
||||||
void lcdStoreBackupBuffer(void);
|
void lcdStoreBackupBuffer(void);
|
||||||
int lcdRestoreBackupBuffer(void);
|
int lcdRestoreBackupBuffer(void);
|
||||||
|
@ -398,9 +444,15 @@ void usbInit(void);
|
||||||
void usbStart(void);
|
void usbStart(void);
|
||||||
void usbStop(void);
|
void usbStop(void);
|
||||||
void usbSerialPutc(uint8_t c);
|
void usbSerialPutc(uint8_t c);
|
||||||
#define USB_NAME "FrSky Horus"
|
#if defined(PCBX12S)
|
||||||
#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */
|
#define USB_NAME "FrSky Horus"
|
||||||
#define USB_PRODUCT 'H', 'o', 'r', 'u', 's', ' ', ' ', ' ' /* 8 Bytes */
|
#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */
|
||||||
|
#define USB_PRODUCT 'H', 'o', 'r', 'u', 's', ' ', ' ', ' ' /* 8 Bytes */
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define USB_NAME "FrSky HX10"
|
||||||
|
#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */
|
||||||
|
#define USB_PRODUCT 'X', '1', '0', ' ', ' ', ' ', ' ', ' ' /* 8 Bytes */
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus) && !defined(SIMU)
|
#if defined(__cplusplus) && !defined(SIMU)
|
||||||
}
|
}
|
||||||
|
@ -411,7 +463,11 @@ void audioInit(void);
|
||||||
void audioConsumeCurrentBuffer(void);
|
void audioConsumeCurrentBuffer(void);
|
||||||
#define audioDisableIrq() // interrupts must stay enabled on Horus
|
#define audioDisableIrq() // interrupts must stay enabled on Horus
|
||||||
#define audioEnableIrq() // interrupts must stay enabled on Horus
|
#define audioEnableIrq() // interrupts must stay enabled on Horus
|
||||||
|
#if defined(PCBX12S)
|
||||||
#define setSampleRate(freq)
|
#define setSampleRate(freq)
|
||||||
|
#else
|
||||||
|
void setSampleRate(uint32_t frequency);
|
||||||
|
#endif
|
||||||
void setScaledVolume(uint8_t volume);
|
void setScaledVolume(uint8_t volume);
|
||||||
void setVolume(uint8_t volume);
|
void setVolume(uint8_t volume);
|
||||||
int32_t getVolume(void);
|
int32_t getVolume(void);
|
||||||
|
|
|
@ -23,20 +23,35 @@
|
||||||
|
|
||||||
// Keys
|
// Keys
|
||||||
#define KEYS_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOH | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ)
|
#define KEYS_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOH | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ)
|
||||||
#define KEYS_GPIO_REG_MENU GPIOC->IDR
|
#if defined(PCBX12S)
|
||||||
#define KEYS_GPIO_PIN_MENU GPIO_Pin_13 // PC.13
|
#define KEYS_GPIO_REG_PGUP GPIOC->IDR
|
||||||
#define KEYS_GPIO_REG_EXIT GPIOI->IDR
|
#define KEYS_GPIO_PIN_PGUP GPIO_Pin_13 // PC.13
|
||||||
#define KEYS_GPIO_PIN_EXIT GPIO_Pin_8 // PI.08
|
#define KEYS_GPIO_REG_PGDN GPIOI->IDR
|
||||||
#define KEYS_GPIO_REG_LEFT GPIOI->IDR
|
#define KEYS_GPIO_PIN_PGDN GPIO_Pin_8 // PI.08
|
||||||
#define KEYS_GPIO_PIN_LEFT GPIO_Pin_7 // PI.07
|
#define KEYS_GPIO_REG_LEFT GPIOI->IDR
|
||||||
#define KEYS_GPIO_REG_ENTER GPIOC->IDR
|
#define KEYS_GPIO_PIN_LEFT GPIO_Pin_7 // PI.07
|
||||||
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_1 // PC.01
|
#define KEYS_GPIO_REG_ENTER GPIOC->IDR
|
||||||
#define KEYS_GPIO_REG_UP GPIOG->IDR
|
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_1 // PC.01
|
||||||
#define KEYS_GPIO_PIN_UP GPIO_Pin_13 // PG.13
|
#define KEYS_GPIO_REG_UP GPIOG->IDR
|
||||||
#define KEYS_GPIO_REG_DOWN GPIOI->IDR
|
#define KEYS_GPIO_PIN_UP GPIO_Pin_13 // PG.13
|
||||||
#define KEYS_GPIO_PIN_DOWN GPIO_Pin_6 // PI.06
|
#define KEYS_GPIO_REG_DOWN GPIOI->IDR
|
||||||
#define KEYS_GPIO_REG_RIGHT GPIOC->IDR
|
#define KEYS_GPIO_PIN_DOWN GPIO_Pin_6 // PI.06
|
||||||
#define KEYS_GPIO_PIN_RIGHT GPIO_Pin_4 // PC.04
|
#define KEYS_GPIO_REG_RIGHT GPIOC->IDR
|
||||||
|
#define KEYS_GPIO_PIN_RIGHT GPIO_Pin_4 // PC.04
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define KEYS_GPIO_REG_PGDN GPIOI->IDR
|
||||||
|
#define KEYS_GPIO_PIN_PGDN GPIO_Pin_11 // PI.11
|
||||||
|
#define KEYS_GPIO_REG_LEFT GPIOI->IDR
|
||||||
|
#define KEYS_GPIO_PIN_LEFT GPIO_Pin_7 // PI.07
|
||||||
|
#define KEYS_GPIO_REG_ENTER GPIOI->IDR
|
||||||
|
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_8 // PI.08
|
||||||
|
#define KEYS_GPIO_REG_UP GPIOI->IDR
|
||||||
|
#define KEYS_GPIO_PIN_UP GPIO_Pin_4 // PI.04
|
||||||
|
#define KEYS_GPIO_REG_DOWN GPIOI->IDR
|
||||||
|
#define KEYS_GPIO_PIN_DOWN GPIO_Pin_6 // PI.06
|
||||||
|
#define KEYS_GPIO_REG_RIGHT GPIOI->IDR
|
||||||
|
#define KEYS_GPIO_PIN_RIGHT GPIO_Pin_5 // PI.05
|
||||||
|
#endif
|
||||||
|
|
||||||
// Rotary Encoder
|
// Rotary Encoder
|
||||||
#define ROTARY_ENCODER_GPIO GPIOH
|
#define ROTARY_ENCODER_GPIO GPIOH
|
||||||
|
@ -74,63 +89,147 @@
|
||||||
#define SWITCHES_GPIO_REG_H GPIOG->IDR
|
#define SWITCHES_GPIO_REG_H GPIOG->IDR
|
||||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_7 // PG.07
|
#define SWITCHES_GPIO_PIN_H GPIO_Pin_7 // PG.07
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
#define SWITCHES_GPIO_REG_GMBL GPIOH->IDR
|
||||||
|
#define SWITCHES_GPIO_PIN_GMBL GPIO_Pin_14
|
||||||
|
#define SWITCHES_GPIO_REG_GMBR GPIOH->IDR
|
||||||
|
#define SWITCHES_GPIO_PIN_GMBR GPIO_Pin_15
|
||||||
|
#endif
|
||||||
|
|
||||||
// Trims
|
// Trims
|
||||||
#define TRIMS_GPIO_REG_RHL GPIOC->IDR
|
#if defined(PCBX12S)
|
||||||
#define TRIMS_GPIO_PIN_RHL GPIO_Pin_0 // PC.00
|
#define TRIMS_GPIO_REG_RHL GPIOC->IDR
|
||||||
#define TRIMS_GPIO_REG_RHR GPIOI->IDR
|
#define TRIMS_GPIO_PIN_RHL GPIO_Pin_0 // PC.00
|
||||||
#define TRIMS_GPIO_PIN_RHR GPIO_Pin_4 // PI.04
|
#define TRIMS_GPIO_REG_RHR GPIOI->IDR
|
||||||
#define TRIMS_GPIO_REG_RVD GPIOG->IDR
|
#define TRIMS_GPIO_PIN_RHR GPIO_Pin_4 // PI.04
|
||||||
#define TRIMS_GPIO_PIN_RVD GPIO_Pin_12 // PG.12
|
#define TRIMS_GPIO_REG_RVD GPIOG->IDR
|
||||||
#define TRIMS_GPIO_REG_RVU GPIOJ->IDR
|
#define TRIMS_GPIO_PIN_RVD GPIO_Pin_12 // PG.12
|
||||||
#define TRIMS_GPIO_PIN_RVU GPIO_Pin_14 // PJ.14
|
#define TRIMS_GPIO_REG_RVU GPIOJ->IDR
|
||||||
#define TRIMS_GPIO_REG_LVD GPIOJ->IDR
|
#define TRIMS_GPIO_PIN_RVU GPIO_Pin_14 // PJ.14
|
||||||
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_13 // PJ.13
|
#define TRIMS_GPIO_REG_LVD GPIOJ->IDR
|
||||||
#define TRIMS_GPIO_REG_LHL GPIOD->IDR
|
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_13 // PJ.13
|
||||||
#define TRIMS_GPIO_PIN_LHL GPIO_Pin_3 // PD.03
|
#define TRIMS_GPIO_REG_LHL GPIOD->IDR
|
||||||
#define TRIMS_GPIO_REG_LVU GPIOJ->IDR
|
#define TRIMS_GPIO_PIN_LHL GPIO_Pin_3 // PD.03
|
||||||
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_12 // PJ.12
|
#define TRIMS_GPIO_REG_LVU GPIOJ->IDR
|
||||||
#define TRIMS_GPIO_REG_LHR GPIOD->IDR
|
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_12 // PJ.12
|
||||||
#define TRIMS_GPIO_PIN_LHR GPIO_Pin_7 // PD.07
|
#define TRIMS_GPIO_REG_LHR GPIOD->IDR
|
||||||
#define TRIMS_GPIO_REG_RSD GPIOJ->IDR
|
#define TRIMS_GPIO_PIN_LHR GPIO_Pin_7 // PD.07
|
||||||
#define TRIMS_GPIO_PIN_RSD GPIO_Pin_8 // PJ.08
|
#define TRIMS_GPIO_REG_RSD GPIOJ->IDR
|
||||||
#define TRIMS_GPIO_REG_RSU GPIOD->IDR
|
#define TRIMS_GPIO_PIN_RSD GPIO_Pin_8 // PJ.08
|
||||||
#define TRIMS_GPIO_PIN_RSU GPIO_Pin_13 // PD.13
|
#define TRIMS_GPIO_REG_RSU GPIOD->IDR
|
||||||
#define TRIMS_GPIO_REG_LSD GPIOB->IDR
|
#define TRIMS_GPIO_PIN_RSU GPIO_Pin_13 // PD.13
|
||||||
#define TRIMS_GPIO_PIN_LSD GPIO_Pin_14 // PB.14
|
#define TRIMS_GPIO_REG_LSD GPIOB->IDR
|
||||||
#define TRIMS_GPIO_REG_LSU GPIOB->IDR
|
#define TRIMS_GPIO_PIN_LSD GPIO_Pin_14 // PB.14
|
||||||
#define TRIMS_GPIO_PIN_LSU GPIO_Pin_13 // PB.13
|
#define TRIMS_GPIO_REG_LSU GPIOB->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LSU GPIO_Pin_13 // PB.13
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define TRIMS_GPIO_REG_LHL GPIOB->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LHL GPIO_Pin_8 // PB.08
|
||||||
|
#define TRIMS_GPIO_REG_LHR GPIOB->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LHR GPIO_Pin_9 // PB.09
|
||||||
|
#define TRIMS_GPIO_REG_LVD GPIOG->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_12 // PG.12
|
||||||
|
#define TRIMS_GPIO_REG_LVU GPIOJ->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_14 // PJ.14
|
||||||
|
#define TRIMS_GPIO_REG_RVD GPIOJ->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_RVD GPIO_Pin_13 // PJ.13
|
||||||
|
#define TRIMS_GPIO_REG_RHL GPIOD->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_RHL GPIO_Pin_3 // PD.03
|
||||||
|
#define TRIMS_GPIO_REG_RVU GPIOJ->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_RVU GPIO_Pin_12 // PJ.12
|
||||||
|
#define TRIMS_GPIO_REG_RHR GPIOD->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_RHR GPIO_Pin_7 // PD.07
|
||||||
|
#define TRIMS_GPIO_REG_LSU GPIOJ->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LSU GPIO_Pin_8 // PJ.08
|
||||||
|
#define TRIMS_GPIO_REG_LSD GPIOD->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_LSD GPIO_Pin_13 // PD.13
|
||||||
|
#define TRIMS_GPIO_REG_RSU GPIOB->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_RSU GPIO_Pin_14 // PB.14
|
||||||
|
#define TRIMS_GPIO_REG_RSD GPIOB->IDR
|
||||||
|
#define TRIMS_GPIO_PIN_RSD GPIO_Pin_13 // PB.13
|
||||||
|
#endif
|
||||||
|
|
||||||
// Index of all keys
|
// Index of all keys
|
||||||
#define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_LSD | TRIMS_GPIO_PIN_LSU)
|
#if defined(PCBX12S)
|
||||||
#define KEYS_GPIOC_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_RIGHT | TRIMS_GPIO_PIN_RHL)
|
#define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_LSD | TRIMS_GPIO_PIN_LSU)
|
||||||
#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_H | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RSU)
|
#define KEYS_GPIOC_PINS (KEYS_GPIO_PIN_PGUP | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_RIGHT | TRIMS_GPIO_PIN_RHL)
|
||||||
#define KEYS_GPIOE_PINS (SWITCHES_GPIO_PIN_E_L)
|
#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_H | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RSU)
|
||||||
#define KEYS_GPIOG_PINS (KEYS_GPIO_PIN_UP | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_RVD)
|
#define KEYS_GPIOE_PINS (SWITCHES_GPIO_PIN_E_L)
|
||||||
#define KEYS_GPIOH_PINS (SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_F | ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B)
|
#define KEYS_GPIOG_PINS (KEYS_GPIO_PIN_UP | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_RVD)
|
||||||
#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_L | TRIMS_GPIO_PIN_RHR)
|
#define KEYS_GPIOH_PINS (SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_F | ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B)
|
||||||
#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RSD)
|
#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_PGDN | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_L | TRIMS_GPIO_PIN_RHR)
|
||||||
|
#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RSD)
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_RSU | TRIMS_GPIO_PIN_RSD | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR)
|
||||||
|
#define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_LHL)
|
||||||
|
#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_H | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR | TRIMS_GPIO_PIN_LSD)
|
||||||
|
#define KEYS_GPIOE_PINS (SWITCHES_GPIO_PIN_E_L)
|
||||||
|
#define KEYS_GPIOG_PINS (SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_LVD)
|
||||||
|
#define KEYS_GPIOH_PINS (SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_F | ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B | SWITCHES_GPIO_PIN_GMBR | SWITCHES_GPIO_PIN_GMBL)
|
||||||
|
#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_RIGHT | KEYS_GPIO_PIN_UP | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_PGDN | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_L)
|
||||||
|
#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_LSU)
|
||||||
|
#endif
|
||||||
|
|
||||||
// ADC
|
// ADC
|
||||||
#define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2)
|
#if defined(PCBX12S)
|
||||||
#define ADC_RCC_APB2Periph (RCC_APB2Periph_SPI4 | RCC_APB2Periph_ADC3)
|
#define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2)
|
||||||
#define ADC_SPI SPI4
|
#define ADC_RCC_APB2Periph (RCC_APB2Periph_SPI4 | RCC_APB2Periph_ADC3)
|
||||||
#define ADC_GPIO_AF GPIO_AF_SPI4
|
#define ADC_SPI SPI4
|
||||||
#define ADC_SPI_GPIO GPIOE
|
#define ADC_GPIO_AF GPIO_AF_SPI4
|
||||||
#define ADC_SPI_PIN_SCK GPIO_Pin_2 // PE.02
|
#define ADC_SPI_GPIO GPIOE
|
||||||
#define ADC_SPI_PIN_CS GPIO_Pin_4 // PE.04
|
#define ADC_SPI_PIN_SCK GPIO_Pin_2 // PE.02
|
||||||
#define ADC_SPI_PIN_MOSI GPIO_Pin_6 // PE.06
|
#define ADC_SPI_PIN_CS GPIO_Pin_4 // PE.04
|
||||||
#define ADC_SPI_PIN_MISO GPIO_Pin_5 // PE.05
|
#define ADC_SPI_PIN_MOSI GPIO_Pin_6 // PE.06
|
||||||
#define ADC_SPI_PinSource_SCK GPIO_PinSource2
|
#define ADC_SPI_PIN_MISO GPIO_Pin_5 // PE.05
|
||||||
#define ADC_SPI_PinSource_MISO GPIO_PinSource5
|
#define ADC_SPI_PinSource_SCK GPIO_PinSource2
|
||||||
#define ADC_SPI_PinSource_MOSI GPIO_PinSource6
|
#define ADC_SPI_PinSource_MISO GPIO_PinSource5
|
||||||
#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.08 ADC3_IN6 J5 MOUSE_X
|
#define ADC_SPI_PinSource_MOSI GPIO_PinSource6
|
||||||
#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.09 ADC3_IN7 J6 MOUSE_Y
|
#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.08 ADC3_IN6 J5 MOUSE_X
|
||||||
#define ADC_GPIO_MOUSE GPIOF
|
#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.09 ADC3_IN7 J6 MOUSE_Y
|
||||||
#define ADC_IN_MOUSE1 6
|
#define ADC_GPIO_MOUSE GPIOF
|
||||||
#define ADC_IN_MOUSE2 7
|
#define ADC_IN_MOUSE1 6
|
||||||
#define ADC_DMA DMA2
|
#define ADC_IN_MOUSE2 7
|
||||||
#define ADC_DMA_Stream DMA2_Stream0
|
#define ADC_DMA DMA2
|
||||||
#define ADC_SAMPTIME 3
|
#define ADC_DMA_Stream DMA2_Stream0
|
||||||
|
#define ADC_SAMPTIME 3
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2)
|
||||||
|
#define ADC_RCC_APB2Periph (RCC_APB2Periph_ADC3)
|
||||||
|
#define ADC_GPIO_PIN_STICK_LH GPIO_Pin_0 // PC.00
|
||||||
|
#define ADC_GPIO_PIN_STICK_LV GPIO_Pin_1 // PC.01
|
||||||
|
#define ADC_GPIO_PIN_STICK_RH GPIO_Pin_2 // PC.02
|
||||||
|
#define ADC_GPIO_PIN_STICK_RV GPIO_Pin_3 // PC.03
|
||||||
|
#define ADC_GPIO_PIN_SLIDER1 GPIO_Pin_6 // PF.06
|
||||||
|
#define ADC_GPIO_PIN_SLIDER2 GPIO_Pin_3 // PA.03
|
||||||
|
#define ADC_GPIO_PIN_BATT GPIO_Pin_7 // PF.07
|
||||||
|
#define ADC_GPIO_PIN_POT3 GPIO_Pin_0 // PA.00
|
||||||
|
#define ADC_GPIO_PIN_POT1 GPIO_Pin_2 // PA.02
|
||||||
|
#define ADC_GPIO_PIN_POT2 GPIO_Pin_1 // PA.01
|
||||||
|
#define ADC_GPIO_PIN_EXT1 GPIO_Pin_8 // PF.08
|
||||||
|
#define ADC_GPIO_PIN_EXT2 GPIO_Pin_9 // PF.09
|
||||||
|
#define ADC_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
||||||
|
#define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
||||||
|
#define ADC_GPIOF_PINS (GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9)
|
||||||
|
#define ADC_CHANNEL_STICK_LH ADC_Channel_10 // ADC1_IN10
|
||||||
|
#define ADC_CHANNEL_STICK_LV ADC_Channel_11 // ADC1_IN11
|
||||||
|
#define ADC_CHANNEL_STICK_RH ADC_Channel_12 // ADC1_IN12
|
||||||
|
#define ADC_CHANNEL_STICK_RV ADC_Channel_13 // ADC1_IN13
|
||||||
|
#define ADC_CHANNEL_SLIDER1 ADC_Channel_4 // ADC1_IN4
|
||||||
|
#define ADC_CHANNEL_SLIDER2 ADC_Channel_3 // ADC1_IN3
|
||||||
|
#define ADC_CHANNEL_BATT ADC_Channel_5 // ADC1_IN5
|
||||||
|
#define ADC_CHANNEL_POT3 ADC_Channel_0 // ADC1_IN0
|
||||||
|
#define ADC_CHANNEL_POT1 ADC_Channel_2 // ADC1_IN2
|
||||||
|
#define ADC_CHANNEL_POT2 ADC_Channel_1 // ADC1_IN1
|
||||||
|
#define ADC_CHANNEL_EXT1 ADC_Channel_6 // ADC1_IN6
|
||||||
|
#define ADC_CHANNEL_EXT2 ADC_Channel_7 // ADC1_IN7
|
||||||
|
#define ADC_MAIN ADC3
|
||||||
|
#define ADC_SAMPTIME 3
|
||||||
|
#define ADC_DMA DMA2
|
||||||
|
#define ADC_DMA_SxCR_CHSEL DMA_SxCR_CHSEL_1
|
||||||
|
#define ADC_DMA_Stream DMA2_Stream0
|
||||||
|
#define ADC_SET_DMA_FLAGS() ADC_DMA->LIFCR = (DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0)
|
||||||
|
#define ADC_TRANSFER_COMPLETE() (ADC_DMA->LISR & DMA_LISR_TCIF0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ
|
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ
|
||||||
|
@ -138,15 +237,30 @@
|
||||||
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
|
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
|
||||||
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
|
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
|
||||||
|
|
||||||
|
#if defined(PCBX10)
|
||||||
|
#define SPORT_PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOH
|
||||||
|
#define SPORT_PWR_GPIO GPIOH
|
||||||
|
#define SPORT_PWR_GPIO_PIN GPIO_Pin_13 // PH.13
|
||||||
|
#endif
|
||||||
|
|
||||||
// PCBREV
|
// PCBREV
|
||||||
#define PCBREV_RCC_AHB1Periph RCC_AHB1Periph_GPIOI
|
#define PCBREV_RCC_AHB1Periph RCC_AHB1Periph_GPIOI
|
||||||
#define PCBREV_GPIO GPIOI
|
#define PCBREV_GPIO GPIOI
|
||||||
#define PCBREV_GPIO_PIN GPIO_Pin_11 // PI.11
|
#define PCBREV_GPIO_PIN GPIO_Pin_11 // PI.11
|
||||||
|
|
||||||
// Led
|
// Led
|
||||||
#define LED_RCC_AHB1Periph RCC_AHB1Periph_GPIOI
|
#if defined(PCBX12S)
|
||||||
#define LED_GPIO GPIOI
|
#define LED_RCC_AHB1Periph RCC_AHB1Periph_GPIOI
|
||||||
#define LED_GPIO_PIN GPIO_Pin_5 // PI.05
|
#define LED_GPIO GPIOI
|
||||||
|
#define LED_GPIO_PIN GPIO_Pin_5 // PI.05
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define LED_RCC_AHB1Periph RCC_AHB1Periph_GPIOE
|
||||||
|
#define LED_GPIO GPIOE
|
||||||
|
#define LED_RED_GPIO_PIN GPIO_Pin_5
|
||||||
|
#define LED_GREEN_GPIO_PIN GPIO_Pin_4
|
||||||
|
#define LED_BLUE_GPIO_PIN GPIO_Pin_6
|
||||||
|
#define LED_GPIO_PIN (LED_RED_GPIO_PIN | LED_GREEN_GPIO_PIN | LED_BLUE_GPIO_PIN)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Serial Port (DEBUG)
|
// Serial Port (DEBUG)
|
||||||
#define SERIAL_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
#define SERIAL_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
||||||
|
@ -175,8 +289,10 @@
|
||||||
#define TELEMETRY_GPIO_PinSource_RX GPIO_PinSource6
|
#define TELEMETRY_GPIO_PinSource_RX GPIO_PinSource6
|
||||||
#define TELEMETRY_GPIO_AF GPIO_AF_USART2
|
#define TELEMETRY_GPIO_AF GPIO_AF_USART2
|
||||||
#define TELEMETRY_USART USART2
|
#define TELEMETRY_USART USART2
|
||||||
|
#if defined(PCBX12S)
|
||||||
#define TELEMETRY_DMA_Stream_RX DMA1_Stream5
|
#define TELEMETRY_DMA_Stream_RX DMA1_Stream5
|
||||||
#define TELEMETRY_DMA_Channel_RX DMA_Channel_4
|
#define TELEMETRY_DMA_Channel_RX DMA_Channel_4
|
||||||
|
#endif
|
||||||
#define TELEMETRY_DMA_Stream_TX DMA1_Stream6
|
#define TELEMETRY_DMA_Stream_TX DMA1_Stream6
|
||||||
#define TELEMETRY_DMA_Channel_TX DMA_Channel_4
|
#define TELEMETRY_DMA_Channel_TX DMA_Channel_4
|
||||||
#define TELEMETRY_DMA_TX_Stream_IRQ DMA1_Stream6_IRQn
|
#define TELEMETRY_DMA_TX_Stream_IRQ DMA1_Stream6_IRQn
|
||||||
|
@ -198,30 +314,48 @@
|
||||||
// LCD
|
// LCD
|
||||||
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ | RCC_AHB1Periph_GPIOK | RCC_AHB1Periph_DMA2D)
|
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ | RCC_AHB1Periph_GPIOK | RCC_AHB1Periph_DMA2D)
|
||||||
#define LCD_RCC_APB2Periph RCC_APB2Periph_LTDC
|
#define LCD_RCC_APB2Periph RCC_APB2Periph_LTDC
|
||||||
#define LCD_GPIO_NRST GPIOF
|
#if defined(PCBX12S)
|
||||||
#define LCD_GPIO_PIN_NRST GPIO_Pin_10 // PF.10
|
#define LCD_GPIO_NRST GPIOF
|
||||||
|
#define LCD_GPIO_PIN_NRST GPIO_Pin_10 // PF.10
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define LCD_GPIO_NRST GPIOI
|
||||||
|
#define LCD_GPIO_PIN_NRST GPIO_Pin_10 // PI.10
|
||||||
|
#endif
|
||||||
#define LTDC_IRQ_PRIO 4
|
#define LTDC_IRQ_PRIO 4
|
||||||
#define DMA_SCREEN_IRQ_PRIO 6
|
#define DMA_SCREEN_IRQ_PRIO 6
|
||||||
|
|
||||||
// Backlight
|
// Backlight
|
||||||
#define BL_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
#if defined(PCBX12S)
|
||||||
#define BL_GPIO GPIOA
|
#define BL_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
||||||
// Production board
|
#define BL_GPIO GPIOA
|
||||||
#define PROD_BL_TIMER TIM5
|
#if PCBREV >= 13
|
||||||
#define PROD_BL_GPIO_PIN GPIO_Pin_3 // PA.03
|
#define BL_TIMER TIM5
|
||||||
#define PROD_BL_GPIO_PinSource GPIO_PinSource3
|
#define BL_GPIO_PIN GPIO_Pin_3 // PA.03
|
||||||
#define PROD_BL_RCC_APB1Periph RCC_APB1Periph_TIM5
|
#define BL_GPIO_PinSource GPIO_PinSource3
|
||||||
#define PROD_BL_RCC_APB2Periph 0
|
#define BL_RCC_APB1Periph RCC_APB1Periph_TIM5
|
||||||
#define PROD_BL_GPIO_AF GPIO_AF_TIM5
|
#define BL_RCC_APB2Periph 0
|
||||||
#define PROD_BL_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
#define BL_GPIO_AF GPIO_AF_TIM5
|
||||||
// Beta board
|
#define BL_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
||||||
#define BETA_BL_TIMER TIM8
|
#else
|
||||||
#define BETA_BL_GPIO_PIN GPIO_Pin_5 // PA.05
|
#define BL_TIMER TIM8
|
||||||
#define BETA_BL_GPIO_PinSource GPIO_PinSource5
|
#define BL_GPIO_PIN GPIO_Pin_5 // PA.05
|
||||||
#define BETA_BL_RCC_APB1Periph 0
|
#define BL_GPIO_PinSource GPIO_PinSource5
|
||||||
#define BETA_BL_RCC_APB2Periph RCC_APB2Periph_TIM8
|
#define BL_RCC_APB1Periph 0
|
||||||
#define BETA_BL_GPIO_AF GPIO_AF_TIM8
|
#define BL_RCC_APB2Periph RCC_APB2Periph_TIM8
|
||||||
#define BETA_BL_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
#define BL_GPIO_AF GPIO_AF_TIM8
|
||||||
|
#define BL_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||||
|
#endif
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define BL_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||||
|
#define BL_GPIO GPIOB
|
||||||
|
#define BL_TIMER TIM8
|
||||||
|
#define BL_GPIO_PIN GPIO_Pin_1 // PB.01
|
||||||
|
#define BL_GPIO_PinSource GPIO_PinSource1
|
||||||
|
#define BL_RCC_APB1Periph 0
|
||||||
|
#define BL_RCC_APB2Periph RCC_APB2Periph_TIM8
|
||||||
|
#define BL_GPIO_AF GPIO_AF_TIM8
|
||||||
|
#define BL_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||||
|
#endif
|
||||||
|
|
||||||
// SD
|
// SD
|
||||||
#define SD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
|
#define SD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
|
||||||
|
@ -242,46 +376,78 @@
|
||||||
#define SD_SDIO_TRANSFER_CLK_DIV SD_SDIO_CLK_DIV(24000000)
|
#define SD_SDIO_TRANSFER_CLK_DIV SD_SDIO_CLK_DIV(24000000)
|
||||||
|
|
||||||
// EEPROM
|
// EEPROM
|
||||||
#if PCBREV >= 13
|
#if defined(PCBX12S) && PCBREV >= 13
|
||||||
#define EEPROM_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
#define EEPROM_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
||||||
#define EEPROM_RCC_APB1Periph RCC_APB1Periph_SPI1
|
#define EEPROM_RCC_APB1Periph RCC_APB1Periph_SPI1
|
||||||
#define EEPROM_SPI_CS_GPIO GPIOA
|
#define EEPROM_SPI_CS_GPIO GPIOA
|
||||||
#define EEPROM_SPI_CS_GPIO_PIN GPIO_Pin_15 // PA.15
|
#define EEPROM_SPI_CS_GPIO_PIN GPIO_Pin_15 // PA.15
|
||||||
#define EEPROM_SPI_SCK_GPIO GPIOA
|
#define EEPROM_SPI_SCK_GPIO GPIOA
|
||||||
#define EEPROM_SPI_SCK_GPIO_PIN GPIO_Pin_5 // PA.05
|
#define EEPROM_SPI_SCK_GPIO_PIN GPIO_Pin_5 // PA.05
|
||||||
#define EEPROM_SPI_SCK_GPIO_PinSource GPIO_PinSource5
|
#define EEPROM_SPI_SCK_GPIO_PinSource GPIO_PinSource5
|
||||||
#define EEPROM_SPI_MISO_GPIO GPIOA
|
#define EEPROM_SPI_MISO_GPIO GPIOA
|
||||||
#define EEPROM_SPI_MISO_GPIO_PIN GPIO_Pin_6 // PA.06
|
#define EEPROM_SPI_MISO_GPIO_PIN GPIO_Pin_6 // PA.06
|
||||||
#define EEPROM_SPI_MISO_GPIO_PinSource GPIO_PinSource6
|
#define EEPROM_SPI_MISO_GPIO_PinSource GPIO_PinSource6
|
||||||
#define EEPROM_SPI_MOSI_GPIO GPIOA
|
#define EEPROM_SPI_MOSI_GPIO GPIOA
|
||||||
#define EEPROM_SPI_MOSI_GPIO_PIN GPIO_Pin_7 // PA.07
|
#define EEPROM_SPI_MOSI_GPIO_PIN GPIO_Pin_7 // PA.07
|
||||||
#define EEPROM_SPI_MOSI_GPIO_PinSource GPIO_PinSource7
|
#define EEPROM_SPI_MOSI_GPIO_PinSource GPIO_PinSource7
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define EEPROM_RCC_AHB1Periph RCC_AHB1Periph_GPIOI
|
||||||
|
#define EEPROM_RCC_APB1Periph RCC_APB1Periph_SPI2
|
||||||
|
#define EEPROM_SPI_CS_GPIO GPIOI
|
||||||
|
#define EEPROM_SPI_CS_GPIO_PIN GPIO_Pin_0 // PI.00
|
||||||
|
#define EEPROM_SPI_SCK_GPIO GPIOI
|
||||||
|
#define EEPROM_SPI_SCK_GPIO_PIN GPIO_Pin_1 // PI.01
|
||||||
|
#define EEPROM_SPI_SCK_GPIO_PinSource GPIO_PinSource1
|
||||||
|
#define EEPROM_SPI_MISO_GPIO GPIOI
|
||||||
|
#define EEPROM_SPI_MISO_GPIO_PIN GPIO_Pin_2 // PI.02
|
||||||
|
#define EEPROM_SPI_MISO_GPIO_PinSource GPIO_PinSource2
|
||||||
|
#define EEPROM_SPI_MOSI_GPIO GPIOI
|
||||||
|
#define EEPROM_SPI_MOSI_GPIO_PIN GPIO_Pin_3 // PI.03
|
||||||
|
#define EEPROM_SPI_MOSI_GPIO_PinSource GPIO_PinSource3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
#define AUDIO_RCC_AHB1Periph (RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOH)
|
#if defined(PCBX12S)
|
||||||
#define AUDIO_RCC_APB1Periph RCC_APB1Periph_SPI2
|
#define AUDIO_RCC_AHB1Periph (RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOH)
|
||||||
#define AUDIO_SHUTDOWN_GPIO GPIOI
|
#define AUDIO_RCC_APB1Periph RCC_APB1Periph_SPI2
|
||||||
#define AUDIO_SHUTDOWN_GPIO_PIN GPIO_Pin_9 // PI.09
|
#define AUDIO_SHUTDOWN_GPIO GPIOI
|
||||||
#define AUDIO_XDCS_GPIO GPIOI
|
#define AUDIO_SHUTDOWN_GPIO_PIN GPIO_Pin_9 // PI.09
|
||||||
#define AUDIO_XDCS_GPIO_PIN GPIO_Pin_0 // PI.00
|
#define AUDIO_XDCS_GPIO GPIOI
|
||||||
#define AUDIO_CS_GPIO GPIOH
|
#define AUDIO_XDCS_GPIO_PIN GPIO_Pin_0 // PI.00
|
||||||
#define AUDIO_CS_GPIO_PIN GPIO_Pin_13 // PH.13
|
#define AUDIO_CS_GPIO GPIOH
|
||||||
#define AUDIO_DREQ_GPIO GPIOH
|
#define AUDIO_CS_GPIO_PIN GPIO_Pin_13 // PH.13
|
||||||
#define AUDIO_DREQ_GPIO_PIN GPIO_Pin_14 // PH.14
|
#define AUDIO_DREQ_GPIO GPIOH
|
||||||
#define AUDIO_RST_GPIO GPIOH
|
#define AUDIO_DREQ_GPIO_PIN GPIO_Pin_14 // PH.14
|
||||||
#define AUDIO_RST_GPIO_PIN GPIO_Pin_15 // PH.15
|
#define AUDIO_RST_GPIO GPIOH
|
||||||
#define AUDIO_SPI SPI2
|
#define AUDIO_RST_GPIO_PIN GPIO_Pin_15 // PH.15
|
||||||
#define AUDIO_SPI_GPIO_AF GPIO_AF_SPI2
|
#define AUDIO_SPI SPI2
|
||||||
#define AUDIO_SPI_SCK_GPIO GPIOI
|
#define AUDIO_SPI_GPIO_AF GPIO_AF_SPI2
|
||||||
#define AUDIO_SPI_SCK_GPIO_PIN GPIO_Pin_1 // PI.01
|
#define AUDIO_SPI_SCK_GPIO GPIOI
|
||||||
#define AUDIO_SPI_SCK_GPIO_PinSource GPIO_PinSource1
|
#define AUDIO_SPI_SCK_GPIO_PIN GPIO_Pin_1 // PI.01
|
||||||
#define AUDIO_SPI_MISO_GPIO GPIOI
|
#define AUDIO_SPI_SCK_GPIO_PinSource GPIO_PinSource1
|
||||||
#define AUDIO_SPI_MISO_GPIO_PIN GPIO_Pin_2 // PI.02
|
#define AUDIO_SPI_MISO_GPIO GPIOI
|
||||||
#define AUDIO_SPI_MISO_GPIO_PinSource GPIO_PinSource2
|
#define AUDIO_SPI_MISO_GPIO_PIN GPIO_Pin_2 // PI.02
|
||||||
#define AUDIO_SPI_MOSI_GPIO GPIOI
|
#define AUDIO_SPI_MISO_GPIO_PinSource GPIO_PinSource2
|
||||||
#define AUDIO_SPI_MOSI_GPIO_PIN GPIO_Pin_3 // PI.03
|
#define AUDIO_SPI_MOSI_GPIO GPIOI
|
||||||
#define AUDIO_SPI_MOSI_GPIO_PinSource GPIO_PinSource3
|
#define AUDIO_SPI_MOSI_GPIO_PIN GPIO_Pin_3 // PI.03
|
||||||
|
#define AUDIO_SPI_MOSI_GPIO_PinSource GPIO_PinSource3
|
||||||
|
#elif defined (PCBX10)
|
||||||
|
#define AUDIO_RCC_APB1Periph (RCC_APB1Periph_TIM6 | RCC_APB1Periph_DAC)
|
||||||
|
#define AUDIO_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_DMA1)
|
||||||
|
#define AUDIO_MUTE_GPIO GPIOA
|
||||||
|
#define AUDIO_MUTE_GPIO_PIN GPIO_Pin_7 // PA.07
|
||||||
|
#define AUDIO_OUTPUT_GPIO GPIOA
|
||||||
|
#define AUDIO_OUTPUT_GPIO_PIN GPIO_Pin_4 // PA.04
|
||||||
|
#define AUDIO_GPIO_AF GPIO_AF_DAC1
|
||||||
|
#define AUDIO_GPIO_PinSource GPIO_PinSource4
|
||||||
|
#define AUDIO_DMA_Stream DMA1_Stream5
|
||||||
|
#define AUDIO_DMA_Stream_IRQn DMA1_Stream5_IRQn
|
||||||
|
#define AUDIO_TIM_IRQn TIM6_DAC_IRQn
|
||||||
|
#define AUDIO_TIM_IRQHandler TIM6_DAC_IRQHandler
|
||||||
|
#define AUDIO_DMA_Stream_IRQHandler DMA1_Stream5_IRQHandler
|
||||||
|
#define AUDIO_TIMER TIM6
|
||||||
|
#define AUDIO_DMA DMA1
|
||||||
|
#endif
|
||||||
|
|
||||||
// I2C Bus
|
// I2C Bus
|
||||||
#define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
#define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||||
|
@ -296,13 +462,23 @@
|
||||||
#define I2C_SPEED 400000
|
#define I2C_SPEED 400000
|
||||||
|
|
||||||
// Haptic
|
// Haptic
|
||||||
#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
#if defined(PCBX12S)
|
||||||
#define HAPTIC_RCC_APB2Periph RCC_APB2ENR_TIM9EN
|
#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
||||||
#define HAPTIC_GPIO GPIOA
|
#define HAPTIC_RCC_APB2Periph RCC_APB2ENR_TIM9EN
|
||||||
#define HAPTIC_GPIO_PIN GPIO_Pin_2
|
#define HAPTIC_GPIO GPIOA
|
||||||
#define HAPTIC_GPIO_TIMER TIM9
|
#define HAPTIC_GPIO_PIN GPIO_Pin_2
|
||||||
#define HAPTIC_GPIO_AF GPIO_AF_TIM9
|
#define HAPTIC_GPIO_TIMER TIM9
|
||||||
#define HAPTIC_GPIO_PinSource GPIO_PinSource2
|
#define HAPTIC_GPIO_AF GPIO_AF_TIM9
|
||||||
|
#define HAPTIC_GPIO_PinSource GPIO_PinSource2
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||||
|
#define HAPTIC_RCC_APB2Periph RCC_APB2ENR_TIM8EN
|
||||||
|
#define HAPTIC_GPIO GPIOB
|
||||||
|
#define HAPTIC_GPIO_PIN GPIO_Pin_0 // PB.00
|
||||||
|
#define HAPTIC_GPIO_TIMER TIM8
|
||||||
|
#define HAPTIC_GPIO_AF GPIO_AF_TIM8
|
||||||
|
#define HAPTIC_GPIO_PinSource GPIO_PinSource0
|
||||||
|
#endif
|
||||||
|
|
||||||
// Internal Module
|
// Internal Module
|
||||||
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
|
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
|
||||||
|
@ -323,58 +499,58 @@
|
||||||
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
|
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
|
||||||
#define INTMODULE_DMA_CHANNEL DMA_Channel_4
|
#define INTMODULE_DMA_CHANNEL DMA_Channel_4
|
||||||
#if PCBREV >= 13
|
#if PCBREV >= 13
|
||||||
#define INTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
|
#define INTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
|
||||||
#define INTMODULE_RCC_APB2Periph RCC_APB2Periph_USART1
|
#define INTMODULE_RCC_APB2Periph RCC_APB2Periph_USART1
|
||||||
#define INTMODULE_TIMER TIM2
|
#define INTMODULE_TIMER TIM2
|
||||||
#define INTMODULE_TIMER_IRQn TIM2_IRQn
|
#define INTMODULE_TIMER_IRQn TIM2_IRQn
|
||||||
#define INTMODULE_TIMER_IRQHandler TIM2_IRQHandler
|
#define INTMODULE_TIMER_IRQHandler TIM2_IRQHandler
|
||||||
#define INTMODULE_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
#define INTMODULE_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
||||||
#else
|
#else
|
||||||
#define INTMODULE_RCC_APB1Periph 0
|
#define INTMODULE_RCC_APB1Periph 0
|
||||||
#define INTMODULE_RCC_APB2Periph (RCC_APB2Periph_TIM1 | RCC_APB2Periph_USART1)
|
#define INTMODULE_RCC_APB2Periph (RCC_APB2Periph_TIM1 | RCC_APB2Periph_USART1)
|
||||||
#define INTMODULE_TIMER TIM1
|
#define INTMODULE_TIMER TIM1
|
||||||
#define INTMODULE_TIMER_IRQn TIM1_CC_IRQn
|
#define INTMODULE_TIMER_IRQn TIM1_CC_IRQn
|
||||||
#define INTMODULE_TIMER_IRQHandler TIM1_CC_IRQHandler
|
#define INTMODULE_TIMER_IRQHandler TIM1_CC_IRQHandler
|
||||||
#define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
#define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// External Module
|
// External Module
|
||||||
#define EXTMODULE_PWR_GPIO GPIOB
|
#define EXTMODULE_PWR_GPIO GPIOB
|
||||||
#define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_3 // PB.03
|
#define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_3 // PB.03
|
||||||
#if PCBREV >= 13
|
#if PCBREV >= 13
|
||||||
#define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
|
#define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
|
||||||
#define EXTMODULE_RCC_APB1Periph 0
|
#define EXTMODULE_RCC_APB1Periph 0
|
||||||
#define EXTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1
|
#define EXTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1
|
||||||
#define EXTMODULE_PPM_GPIO GPIOA
|
#define EXTMODULE_PPM_GPIO GPIOA
|
||||||
#define EXTMODULE_PPM_GPIO_PIN GPIO_Pin_10 // PA.10
|
#define EXTMODULE_PPM_GPIO_PIN GPIO_Pin_10 // PA.10
|
||||||
#define EXTMODULE_PPM_GPIO_PinSource GPIO_PinSource10
|
#define EXTMODULE_PPM_GPIO_PinSource GPIO_PinSource10
|
||||||
#define EXTMODULE_PPM_GPIO_AF GPIO_AF_TIM1
|
#define EXTMODULE_PPM_GPIO_AF GPIO_AF_TIM1
|
||||||
#define EXTMODULE_TIMER TIM1
|
#define EXTMODULE_TIMER TIM1
|
||||||
#define EXTMODULE_TIMER_IRQn TIM1_CC_IRQn
|
#define EXTMODULE_TIMER_IRQn TIM1_CC_IRQn
|
||||||
#define EXTMODULE_TIMER_IRQHandler TIM1_CC_IRQHandler
|
#define EXTMODULE_TIMER_IRQHandler TIM1_CC_IRQHandler
|
||||||
#define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
#define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
|
||||||
#define EXTMODULE_DMA_CHANNEL DMA_Channel_6
|
#define EXTMODULE_DMA_CHANNEL DMA_Channel_6
|
||||||
#define EXTMODULE_DMA_STREAM DMA2_Stream5
|
#define EXTMODULE_DMA_STREAM DMA2_Stream5
|
||||||
#define EXTMODULE_DMA_IRQn DMA2_Stream5_IRQn
|
#define EXTMODULE_DMA_IRQn DMA2_Stream5_IRQn
|
||||||
#define EXTMODULE_DMA_IRQHandler DMA2_Stream5_IRQHandler
|
#define EXTMODULE_DMA_IRQHandler DMA2_Stream5_IRQHandler
|
||||||
#define EXTMODULE_DMA_FLAG_TC DMA_IT_TCIF5
|
#define EXTMODULE_DMA_FLAG_TC DMA_IT_TCIF5
|
||||||
#else
|
#else
|
||||||
#define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
#define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
||||||
#define EXTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
|
#define EXTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
|
||||||
#define EXTMODULE_RCC_APB2Periph 0
|
#define EXTMODULE_RCC_APB2Periph 0
|
||||||
#define EXTMODULE_PPM_GPIO GPIOA
|
#define EXTMODULE_PPM_GPIO GPIOA
|
||||||
#define EXTMODULE_PPM_GPIO_PIN GPIO_Pin_15 // PA.15
|
#define EXTMODULE_PPM_GPIO_PIN GPIO_Pin_15 // PA.15
|
||||||
#define EXTMODULE_PPM_GPIO_PinSource GPIO_PinSource15
|
#define EXTMODULE_PPM_GPIO_PinSource GPIO_PinSource15
|
||||||
#define EXTMODULE_PPM_GPIO_AF GPIO_AF_TIM2
|
#define EXTMODULE_PPM_GPIO_AF GPIO_AF_TIM2
|
||||||
#define EXTMODULE_TIMER TIM2
|
#define EXTMODULE_TIMER TIM2
|
||||||
#define EXTMODULE_TIMER_IRQn TIM2_IRQn
|
#define EXTMODULE_TIMER_IRQn TIM2_IRQn
|
||||||
#define EXTMODULE_TIMER_IRQHandler TIM2_IRQHandler
|
#define EXTMODULE_TIMER_IRQHandler TIM2_IRQHandler
|
||||||
#define EXTMODULE_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
#define EXTMODULE_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
|
||||||
#define EXTMODULE_DMA_CHANNEL DMA_Channel_3
|
#define EXTMODULE_DMA_CHANNEL DMA_Channel_3
|
||||||
#define EXTMODULE_DMA_STREAM DMA1_Stream7
|
#define EXTMODULE_DMA_STREAM DMA1_Stream7
|
||||||
#define EXTMODULE_DMA_IRQn DMA1_Stream7_IRQn
|
#define EXTMODULE_DMA_IRQn DMA1_Stream7_IRQn
|
||||||
#define EXTMODULE_DMA_IRQHandler DMA1_Stream7_IRQHandler
|
#define EXTMODULE_DMA_IRQHandler DMA1_Stream7_IRQHandler
|
||||||
#define EXTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
|
#define EXTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Trainer Port
|
// Trainer Port
|
||||||
|
@ -410,28 +586,30 @@
|
||||||
#define TIMER_2MHz_TIMER TIM7
|
#define TIMER_2MHz_TIMER TIM7
|
||||||
|
|
||||||
// Bluetooth
|
// Bluetooth
|
||||||
#define BT_RCC_APB2Periph RCC_APB2Periph_USART6
|
#if defined(PCBX12S)
|
||||||
#define BT_USART USART6
|
#define BT_RCC_APB2Periph RCC_APB2Periph_USART6
|
||||||
#define BT_GPIO_AF GPIO_AF_USART6
|
#define BT_USART USART6
|
||||||
#define BT_USART_IRQn USART6_IRQn
|
#define BT_GPIO_AF GPIO_AF_USART6
|
||||||
#define BT_GPIO_TXRX GPIOG
|
#define BT_USART_IRQn USART6_IRQn
|
||||||
#define BT_TX_GPIO_PIN GPIO_Pin_14 // PG.14
|
#define BT_GPIO_TXRX GPIOG
|
||||||
#define BT_RX_GPIO_PIN GPIO_Pin_9 // PG.09
|
#define BT_TX_GPIO_PIN GPIO_Pin_14 // PG.14
|
||||||
#if PCBREV >= 13
|
#define BT_RX_GPIO_PIN GPIO_Pin_9 // PG.09
|
||||||
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOG)
|
#if PCBREV >= 13
|
||||||
#define BT_EN_GPIO GPIOI
|
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOG)
|
||||||
#define BT_EN_GPIO_PIN GPIO_Pin_10 // PI.10
|
#define BT_EN_GPIO GPIOI
|
||||||
#else
|
#define BT_EN_GPIO_PIN GPIO_Pin_10 // PI.10
|
||||||
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOG)
|
#else
|
||||||
#define BT_EN_GPIO GPIOA
|
#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOG)
|
||||||
#define BT_EN_GPIO_PIN GPIO_Pin_6 // PA.06
|
#define BT_EN_GPIO GPIOA
|
||||||
|
#define BT_EN_GPIO_PIN GPIO_Pin_6 // PA.06
|
||||||
|
#endif
|
||||||
|
#define BT_BRTS_GPIO GPIOG
|
||||||
|
#define BT_BRTS_GPIO_PIN GPIO_Pin_10 // PG.10
|
||||||
|
#define BT_BCTS_GPIO GPIOG
|
||||||
|
#define BT_BCTS_GPIO_PIN GPIO_Pin_11 // PG.11
|
||||||
|
#define BT_TX_GPIO_PinSource GPIO_PinSource14
|
||||||
|
#define BT_RX_GPIO_PinSource GPIO_PinSource9
|
||||||
#endif
|
#endif
|
||||||
#define BT_BRTS_GPIO GPIOG
|
|
||||||
#define BT_BRTS_GPIO_PIN GPIO_Pin_10 // PG.10
|
|
||||||
#define BT_BCTS_GPIO GPIOG
|
|
||||||
#define BT_BCTS_GPIO_PIN GPIO_Pin_11 // PG.11
|
|
||||||
#define BT_TX_GPIO_PinSource GPIO_PinSource14
|
|
||||||
#define BT_RX_GPIO_PinSource GPIO_PinSource9
|
|
||||||
|
|
||||||
// GPS
|
// GPS
|
||||||
#define GPS_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
#define GPS_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
||||||
|
|
|
@ -26,9 +26,11 @@ uint32_t readKeys()
|
||||||
{
|
{
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
|
|
||||||
if (~KEYS_GPIO_REG_MENU & KEYS_GPIO_PIN_MENU)
|
#if defined(PCBX12S)
|
||||||
|
if (~KEYS_GPIO_REG_PGUP & KEYS_GPIO_PIN_PGUP)
|
||||||
result |= 1 << KEY_PGUP;
|
result |= 1 << KEY_PGUP;
|
||||||
if (~KEYS_GPIO_REG_EXIT & KEYS_GPIO_PIN_EXIT)
|
#endif
|
||||||
|
if (~KEYS_GPIO_REG_PGDN & KEYS_GPIO_PIN_PGDN)
|
||||||
result |= 1 << KEY_PGDN;
|
result |= 1 << KEY_PGDN;
|
||||||
if (~KEYS_GPIO_REG_ENTER & KEYS_GPIO_PIN_ENTER)
|
if (~KEYS_GPIO_REG_ENTER & KEYS_GPIO_PIN_ENTER)
|
||||||
result |= 1 << KEY_ENTER;
|
result |= 1 << KEY_ENTER;
|
||||||
|
|
|
@ -376,8 +376,13 @@ void lcdInit(void)
|
||||||
LCD_SetTransparency(255);
|
LCD_SetTransparency(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
DMA2D_InitTypeDef DMA2D_InitStruct;
|
||||||
|
@ -400,8 +405,15 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16
|
||||||
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
srcx = srcw - (srcx + w);
|
||||||
|
srcy = srch - (srcy + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
DMA2D_InitTypeDef DMA2D_InitStruct;
|
||||||
|
@ -433,8 +445,15 @@ void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, cons
|
||||||
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX10)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
srcx = srcw - (srcx + w);
|
||||||
|
srcy = srch - (srcy + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
DMA2D_InitTypeDef DMA2D_InitStruct;
|
||||||
|
@ -512,33 +531,33 @@ void DMAcopy(void * src, void * dest, int len)
|
||||||
{
|
{
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
DMA2D_InitTypeDef DMA2D_InitStruct;
|
||||||
DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M;
|
DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M;
|
||||||
DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565;
|
DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565;
|
||||||
DMA2D_InitStruct.DMA2D_OutputMemoryAdd = CONVERT_PTR_UINT(dest);
|
DMA2D_InitStruct.DMA2D_OutputMemoryAdd = CONVERT_PTR_UINT(dest);
|
||||||
DMA2D_InitStruct.DMA2D_OutputGreen = 0;
|
DMA2D_InitStruct.DMA2D_OutputGreen = 0;
|
||||||
DMA2D_InitStruct.DMA2D_OutputBlue = 0;
|
DMA2D_InitStruct.DMA2D_OutputBlue = 0;
|
||||||
DMA2D_InitStruct.DMA2D_OutputRed = 0;
|
DMA2D_InitStruct.DMA2D_OutputRed = 0;
|
||||||
DMA2D_InitStruct.DMA2D_OutputAlpha = 0;
|
DMA2D_InitStruct.DMA2D_OutputAlpha = 0;
|
||||||
DMA2D_InitStruct.DMA2D_OutputOffset = 0;
|
DMA2D_InitStruct.DMA2D_OutputOffset = 0;
|
||||||
DMA2D_InitStruct.DMA2D_NumberOfLine = LCD_H;
|
DMA2D_InitStruct.DMA2D_NumberOfLine = LCD_H;
|
||||||
DMA2D_InitStruct.DMA2D_PixelPerLine = LCD_W;
|
DMA2D_InitStruct.DMA2D_PixelPerLine = LCD_W;
|
||||||
DMA2D_Init(&DMA2D_InitStruct);
|
DMA2D_Init(&DMA2D_InitStruct);
|
||||||
|
|
||||||
DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct;
|
DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct;
|
||||||
DMA2D_FG_StructInit(&DMA2D_FG_InitStruct);
|
DMA2D_FG_StructInit(&DMA2D_FG_InitStruct);
|
||||||
DMA2D_FG_InitStruct.DMA2D_FGMA = CONVERT_PTR_UINT(src);
|
DMA2D_FG_InitStruct.DMA2D_FGMA = CONVERT_PTR_UINT(src);
|
||||||
DMA2D_FG_InitStruct.DMA2D_FGO = 0;
|
DMA2D_FG_InitStruct.DMA2D_FGO = 0;
|
||||||
DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565;
|
DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565;
|
||||||
DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE;
|
DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE;
|
||||||
DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0;
|
DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0;
|
||||||
DMA2D_FGConfig(&DMA2D_FG_InitStruct);
|
DMA2D_FGConfig(&DMA2D_FG_InitStruct);
|
||||||
|
|
||||||
/* Start Transfer */
|
/* Start Transfer */
|
||||||
DMA2D_StartTransfer();
|
DMA2D_StartTransfer();
|
||||||
|
|
||||||
/* Wait for CTC Flag activation */
|
/* Wait for CTC Flag activation */
|
||||||
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdStoreBackupBuffer()
|
void lcdStoreBackupBuffer()
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
void ledOn()
|
void ledInit()
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN;
|
||||||
|
@ -31,6 +31,7 @@ void ledOn()
|
||||||
GPIO_Init(LED_GPIO, &GPIO_InitStructure);
|
GPIO_Init(LED_GPIO, &GPIO_InitStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
void ledOff()
|
void ledOff()
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
@ -44,12 +45,36 @@ void ledOff()
|
||||||
|
|
||||||
void ledRed()
|
void ledRed()
|
||||||
{
|
{
|
||||||
ledOn();
|
ledInit();
|
||||||
GPIO_SetBits(LED_GPIO, LED_GPIO_PIN);
|
GPIO_SetBits(LED_GPIO, LED_GPIO_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ledBlue()
|
void ledBlue()
|
||||||
{
|
{
|
||||||
ledOn();
|
ledInit();
|
||||||
GPIO_ResetBits(LED_GPIO, LED_GPIO_PIN);
|
GPIO_ResetBits(LED_GPIO, LED_GPIO_PIN);
|
||||||
}
|
}
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
void ledOff()
|
||||||
|
{
|
||||||
|
GPIO_ResetBits(LED_GPIO, LED_GPIO_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledRed()
|
||||||
|
{
|
||||||
|
ledOff();
|
||||||
|
GPIO_SetBits(LED_GPIO, LED_RED_GPIO_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledGreen()
|
||||||
|
{
|
||||||
|
ledOff();
|
||||||
|
GPIO_SetBits(LED_GPIO, LED_GREEN_GPIO_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledBlue()
|
||||||
|
{
|
||||||
|
ledOff();
|
||||||
|
GPIO_SetBits(LED_GPIO, LED_BLUE_GPIO_PIN);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -35,28 +35,34 @@ void pwrInit()
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
|
#if defined(PCBX12S)
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
// TODO should not be here!
|
||||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
// TODO and X10 code missing
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_SHUTDOWN_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_SHUTDOWN_GPIO_PIN;
|
||||||
GPIO_Init(AUDIO_SHUTDOWN_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_SHUTDOWN_GPIO, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Init Module PWR
|
// Init Module PWR
|
||||||
GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN);
|
GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN);
|
||||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_PWR_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = INTMODULE_PWR_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
|
||||||
GPIO_Init(INTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
GPIO_Init(INTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN);
|
GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN);
|
||||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_PWR_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = EXTMODULE_PWR_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
|
||||||
GPIO_Init(EXTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
GPIO_Init(EXTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||||
|
|
||||||
|
#if !defined(PWR_BUTTON_DISABLED)
|
||||||
|
// Init PWR SWITCH PIN
|
||||||
|
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
|
||||||
|
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Init PCBREV PIN
|
// Init PCBREV PIN
|
||||||
|
// TODO to be removed on X10?
|
||||||
GPIO_ResetBits(PCBREV_GPIO, PCBREV_GPIO_PIN);
|
GPIO_ResetBits(PCBREV_GPIO, PCBREV_GPIO_PIN);
|
||||||
GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
|
||||||
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
// Init SD-DETECT PIN
|
// Init SD-DETECT PIN
|
||||||
|
@ -80,6 +86,7 @@ void pwrOn()
|
||||||
|
|
||||||
void pwrOff()
|
void pwrOff()
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX12S)
|
||||||
// Shutdown the Audio amp
|
// Shutdown the Audio amp
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.GPIO_Pin = AUDIO_SHUTDOWN_GPIO_PIN;
|
GPIO_InitStructure.GPIO_Pin = AUDIO_SHUTDOWN_GPIO_PIN;
|
||||||
|
@ -89,6 +96,7 @@ void pwrOff()
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||||
GPIO_Init(AUDIO_SHUTDOWN_GPIO, &GPIO_InitStructure);
|
GPIO_Init(AUDIO_SHUTDOWN_GPIO, &GPIO_InitStructure);
|
||||||
GPIO_ResetBits(AUDIO_SHUTDOWN_GPIO, AUDIO_SHUTDOWN_GPIO_PIN);
|
GPIO_ResetBits(AUDIO_SHUTDOWN_GPIO, AUDIO_SHUTDOWN_GPIO_PIN);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Shutdown the Haptic
|
// Shutdown the Haptic
|
||||||
hapticDone();
|
hapticDone();
|
||||||
|
@ -100,7 +108,11 @@ void pwrOff()
|
||||||
|
|
||||||
uint32_t pwrPressed()
|
uint32_t pwrPressed()
|
||||||
{
|
{
|
||||||
|
#if defined(PWR_BUTTON_DISABLED)
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwrResetHandler()
|
void pwrResetHandler()
|
||||||
|
|
|
@ -20,11 +20,14 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
DMAFifo<TELEMETRY_FIFO_SIZE> telemetryDMAFifo __DMA (TELEMETRY_DMA_Stream_RX);
|
|
||||||
Fifo<uint8_t, TELEMETRY_FIFO_SIZE> telemetryNoDMAFifo;
|
Fifo<uint8_t, TELEMETRY_FIFO_SIZE> telemetryNoDMAFifo;
|
||||||
uint8_t telemetryFifoMode;
|
|
||||||
uint32_t telemetryErrors = 0;
|
uint32_t telemetryErrors = 0;
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
|
DMAFifo<TELEMETRY_FIFO_SIZE> telemetryDMAFifo __DMA (TELEMETRY_DMA_Stream_RX);
|
||||||
|
uint8_t telemetryFifoMode;
|
||||||
|
#endif
|
||||||
|
|
||||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||||
{
|
{
|
||||||
if (baudrate == 0) {
|
if (baudrate == 0) {
|
||||||
|
@ -72,9 +75,10 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
USART_Init(TELEMETRY_USART, &USART_InitStructure);
|
USART_Init(TELEMETRY_USART, &USART_InitStructure);
|
||||||
|
|
||||||
|
#if defined(PCBX12S)
|
||||||
telemetryFifoMode = mode;
|
telemetryFifoMode = mode;
|
||||||
|
|
||||||
if (mode & TELEMETRY_SERIAL_WITHOUT_DMA) {
|
if (mode & TELEMETRY_SERIAL_WITHOUT_DMA) {
|
||||||
USART_Cmd(TELEMETRY_USART, ENABLE);
|
USART_Cmd(TELEMETRY_USART, ENABLE);
|
||||||
USART_ITConfig(TELEMETRY_USART, USART_IT_RXNE, ENABLE);
|
USART_ITConfig(TELEMETRY_USART, USART_IT_RXNE, ENABLE);
|
||||||
|
@ -110,6 +114,12 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||||
USART_Cmd(TELEMETRY_USART, ENABLE);
|
USART_Cmd(TELEMETRY_USART, ENABLE);
|
||||||
DMA_Cmd(TELEMETRY_DMA_Stream_RX, ENABLE);
|
DMA_Cmd(TELEMETRY_DMA_Stream_RX, ENABLE);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
USART_Cmd(TELEMETRY_USART, ENABLE);
|
||||||
|
USART_ITConfig(TELEMETRY_USART, USART_IT_RXNE, ENABLE);
|
||||||
|
NVIC_SetPriority(TELEMETRY_USART_IRQn, 6);
|
||||||
|
NVIC_EnableIRQ(TELEMETRY_USART_IRQn);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void telemetryPortSetDirectionOutput()
|
void telemetryPortSetDirectionOutput()
|
||||||
|
@ -207,8 +217,12 @@ extern "C" void TELEMETRY_USART_IRQHandler(void)
|
||||||
// TODO we should have telemetry in an higher layer, functions above should move to a sport_driver.cpp
|
// TODO we should have telemetry in an higher layer, functions above should move to a sport_driver.cpp
|
||||||
uint8_t telemetryGetByte(uint8_t * byte)
|
uint8_t telemetryGetByte(uint8_t * byte)
|
||||||
{
|
{
|
||||||
|
#if defined(PCBX12S)
|
||||||
if (telemetryFifoMode & TELEMETRY_SERIAL_WITHOUT_DMA)
|
if (telemetryFifoMode & TELEMETRY_SERIAL_WITHOUT_DMA)
|
||||||
return telemetryNoDMAFifo.pop(*byte);
|
return telemetryNoDMAFifo.pop(*byte);
|
||||||
else
|
else
|
||||||
return telemetryDMAFifo.pop(*byte);
|
return telemetryDMAFifo.pop(*byte);
|
||||||
|
#else
|
||||||
|
return telemetryNoDMAFifo.pop(*byte);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,8 +256,10 @@ class OpenTxSimulatorFactory: public SimulatorFactory
|
||||||
|
|
||||||
virtual Board::Type type()
|
virtual Board::Type type()
|
||||||
{
|
{
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBX12S)
|
||||||
return Board::BOARD_HORUS;
|
return Board::BOARD_X12S;
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
return Board::BOARD_X10;
|
||||||
#elif defined(PCBFLAMENCO)
|
#elif defined(PCBFLAMENCO)
|
||||||
return Board::BOARD_FLAMENCO;
|
return Board::BOARD_FLAMENCO;
|
||||||
#elif defined(PCBX7)
|
#elif defined(PCBX7)
|
||||||
|
|
|
@ -167,9 +167,17 @@ void simuSetKey(uint8_t key, bool state)
|
||||||
KEY_CASE(KEY_MENU, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
KEY_CASE(KEY_MENU, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
||||||
KEY_CASE(KEY_EXIT, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT)
|
KEY_CASE(KEY_EXIT, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT)
|
||||||
#endif
|
#endif
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBX12S)
|
||||||
KEY_CASE(KEY_PGUP, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
KEY_CASE(KEY_PGUP, KEYS_GPIO_REG_PGUP, KEYS_GPIO_PIN_PGUP)
|
||||||
KEY_CASE(KEY_PGDN, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT)
|
KEY_CASE(KEY_PGDN, KEYS_GPIO_REG_PGDN, KEYS_GPIO_PIN_PGDN)
|
||||||
|
KEY_CASE(KEY_ENTER, KEYS_GPIO_REG_ENTER, KEYS_GPIO_PIN_ENTER)
|
||||||
|
KEY_CASE(KEY_TELEM, KEYS_GPIO_REG_RIGHT, KEYS_GPIO_PIN_RIGHT)
|
||||||
|
KEY_CASE(KEY_RADIO, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT)
|
||||||
|
KEY_CASE(KEY_MODEL, KEYS_GPIO_REG_UP, KEYS_GPIO_PIN_UP)
|
||||||
|
KEY_CASE(KEY_EXIT, KEYS_GPIO_REG_DOWN, KEYS_GPIO_PIN_DOWN)
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
// KEY_CASE(KEY_PGUP, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
||||||
|
// KEY_CASE(KEY_PGDN, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT)
|
||||||
KEY_CASE(KEY_ENTER, KEYS_GPIO_REG_ENTER, KEYS_GPIO_PIN_ENTER)
|
KEY_CASE(KEY_ENTER, KEYS_GPIO_REG_ENTER, KEYS_GPIO_PIN_ENTER)
|
||||||
KEY_CASE(KEY_TELEM, KEYS_GPIO_REG_RIGHT, KEYS_GPIO_PIN_RIGHT)
|
KEY_CASE(KEY_TELEM, KEYS_GPIO_REG_RIGHT, KEYS_GPIO_PIN_RIGHT)
|
||||||
KEY_CASE(KEY_RADIO, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT)
|
KEY_CASE(KEY_RADIO, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT)
|
||||||
|
|
|
@ -106,6 +106,7 @@ set(TARGET_SRC
|
||||||
sdcard_driver.cpp
|
sdcard_driver.cpp
|
||||||
massstorage.cpp
|
massstorage.cpp
|
||||||
serial2_driver.cpp
|
serial2_driver.cpp
|
||||||
|
audio_driver.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FIRMWARE_SRC
|
set(FIRMWARE_SRC
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
uint16_t adcValues[NUMBER_ANALOG];
|
uint16_t adcValues[NUM_ANALOGS];
|
||||||
|
|
||||||
#if defined(FRSKY_STICKS)
|
#if defined(FRSKY_STICKS)
|
||||||
const char ana_direction[NUMBER_ANALOG] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0};
|
const char ana_direction[NUM_ANALOGS] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void adcSingleRead()
|
||||||
for (uint8_t i=0; i<4; i++)
|
for (uint8_t i=0; i<4; i++)
|
||||||
padc = ADC;
|
padc = ADC;
|
||||||
y = padc->ADC_ISR; // Clear EOC flags
|
y = padc->ADC_ISR; // Clear EOC flags
|
||||||
for (y = NUMBER_ANALOG+1; --y > 0;) {
|
for (y = NUM_ANALOGS+1; --y > 0;) {
|
||||||
padc->ADC_CR = 2; // Start conversion
|
padc->ADC_CR = 2; // Start conversion
|
||||||
x = 0;
|
x = 0;
|
||||||
while ((padc->ADC_ISR & 0x01000000) == 0) {
|
while ((padc->ADC_ISR & 0x01000000) == 0) {
|
||||||
|
@ -105,7 +105,7 @@ void adcSingleRead()
|
||||||
// adc direction correct
|
// adc direction correct
|
||||||
#if defined(FRSKY_STICKS)
|
#if defined(FRSKY_STICKS)
|
||||||
uint32_t i ;
|
uint32_t i ;
|
||||||
for (i=0; i<NUMBER_ANALOG; i++) {
|
for (i=0; i<NUM_ANALOGS; i++) {
|
||||||
if (ana_direction[i]) {
|
if (ana_direction[i]) {
|
||||||
adcValues[i] = 4096-adcValues[i];
|
adcValues[i] = 4096-adcValues[i];
|
||||||
}
|
}
|
||||||
|
@ -115,11 +115,11 @@ void adcSingleRead()
|
||||||
|
|
||||||
void adcRead()
|
void adcRead()
|
||||||
{
|
{
|
||||||
uint16_t temp[NUMBER_ANALOG] = { 0 };
|
uint16_t temp[NUM_ANALOGS] = { 0 };
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
adcSingleRead();
|
adcSingleRead();
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG; x++) {
|
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
uint16_t val = adcValues[x];
|
uint16_t val = adcValues[x];
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
if (JITTER_MEASURE_ACTIVE()) {
|
if (JITTER_MEASURE_ACTIVE()) {
|
||||||
|
@ -130,7 +130,7 @@ void adcRead()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG; x++) {
|
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
|
||||||
adcValues[x] = temp[x] >> 2;
|
adcValues[x] = temp[x] >> 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,19 @@ enum Analogs {
|
||||||
#if !defined(REVA)
|
#if !defined(REVA)
|
||||||
TX_CURRENT,
|
TX_CURRENT,
|
||||||
#endif
|
#endif
|
||||||
NUMBER_ANALOG
|
NUM_ANALOGS
|
||||||
|
};
|
||||||
|
enum CalibratedAnalogs {
|
||||||
|
CALIBRATED_STICK1,
|
||||||
|
CALIBRATED_STICK2,
|
||||||
|
CALIBRATED_STICK3,
|
||||||
|
CALIBRATED_STICK4,
|
||||||
|
CALIBRATED_POT_FIRST,
|
||||||
|
CALIBRATED_POT1 = CALIBRATED_POT_FIRST,
|
||||||
|
CALIBRATED_POT2,
|
||||||
|
CALIBRATED_POT3,
|
||||||
|
CALIBRATED_POT_LAST = CALIBRATED_POT3,
|
||||||
|
NUM_CALIBRATED_ANALOGS
|
||||||
};
|
};
|
||||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST)
|
||||||
#define IS_SLIDER(x) false
|
#define IS_SLIDER(x) false
|
||||||
|
|
|
@ -12,6 +12,7 @@ if(PCB STREQUAL X9E)
|
||||||
set(FLAVOUR x9e)
|
set(FLAVOUR x9e)
|
||||||
add_definitions(-DSTM32F40_41xxx -DPCBX9E)
|
add_definitions(-DSTM32F40_41xxx -DPCBX9E)
|
||||||
add_definitions(-DEEPROM_VARIANT=0x8000)
|
add_definitions(-DEEPROM_VARIANT=0x8000)
|
||||||
|
add_definitions(-DBLUETOOTH)
|
||||||
set(FIRMWARE_TARGET_SRC
|
set(FIRMWARE_TARGET_SRC
|
||||||
${FIRMWARE_TARGET_SRC}
|
${FIRMWARE_TARGET_SRC}
|
||||||
top_lcd_driver.cpp
|
top_lcd_driver.cpp
|
||||||
|
@ -111,6 +112,8 @@ set(TARGET_SRC
|
||||||
${LED_DRIVER}
|
${LED_DRIVER}
|
||||||
backlight_driver.cpp
|
backlight_driver.cpp
|
||||||
extmodule_driver.cpp
|
extmodule_driver.cpp
|
||||||
|
../common/arm/stm32/audio_dac_driver.cpp
|
||||||
|
../common/arm/stm32/adc_driver.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FIRMWARE_SRC
|
set(FIRMWARE_SRC
|
||||||
|
|
|
@ -1,199 +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"
|
|
||||||
|
|
||||||
// Sample time should exceed 1uS
|
|
||||||
#define SAMPTIME 2 // sample time = 28 cycles
|
|
||||||
#define SAMPTIME_LONG 3 // sample time = 56 cycles
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
|
||||||
#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(PCBX9E)
|
|
||||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,1,-1,-1, -1,-1,-1,1, -1,1,1,1, -1};
|
|
||||||
#elif defined(PCBX9DP)
|
|
||||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,-1, -1,1, 1};
|
|
||||||
#elif defined(PCBX7)
|
|
||||||
const int8_t ana_direction[NUMBER_ANALOG] = {-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};
|
|
||||||
#else
|
|
||||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,0, -1,1, 1};
|
|
||||||
#endif
|
|
||||||
#endif // #if !defined(SIMU)
|
|
||||||
|
|
||||||
#if defined(PCBX9E)
|
|
||||||
#define NUMBER_ANALOG_ADC1 10
|
|
||||||
#define NUMBER_ANALOG_ADC3 (NUMBER_ANALOG - 10)
|
|
||||||
#if !defined(SIMU)
|
|
||||||
// mapping from adcValues order to enum Analogs
|
|
||||||
const uint8_t ana_mapping[NUMBER_ANALOG] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/,
|
|
||||||
10 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/,
|
|
||||||
11 /*SLIDER1*/, 12 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/,
|
|
||||||
9 /*TX_VOLTAGE*/ };
|
|
||||||
#endif // !defined(SIMU)
|
|
||||||
#else
|
|
||||||
#define NUMBER_ANALOG_ADC1 NUMBER_ANALOG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t adcValues[NUMBER_ANALOG] __DMA;
|
|
||||||
|
|
||||||
void adcInit()
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
GPIO_InitStructure.GPIO_Pin = ADC_GPIOA_PINS;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = ADC_GPIOB_PINS;
|
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = ADC_GPIOC_PINS;
|
|
||||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
#if defined(PCBX9E)
|
|
||||||
GPIO_InitStructure.GPIO_Pin = ADC_GPIOF_PINS;
|
|
||||||
GPIO_Init(GPIOF, &GPIO_InitStructure);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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(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
|
|
||||||
#elif defined(PCBX7)
|
|
||||||
ADC1->SQR2 = (ADC_CHANNEL_BATT<<0); // 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_POT1<<25) + (ADC_CHANNEL_POT2<<20); // conversions 1 to 6
|
|
||||||
#else
|
|
||||||
ADC1->SQR2 = (ADC_CHANNEL_POT3<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<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_POT1<<20) + (ADC_CHANNEL_POT2<<25); // conversions 1 to 6
|
|
||||||
#endif
|
|
||||||
ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24);
|
|
||||||
ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27);
|
|
||||||
|
|
||||||
ADC->CCR = 0;
|
|
||||||
|
|
||||||
ADC1_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
|
||||||
ADC1_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC1->DR);
|
|
||||||
ADC1_DMA_Stream->M0AR = CONVERT_PTR_UINT(adcValues);
|
|
||||||
ADC1_DMA_Stream->NDTR = NUMBER_ANALOG_ADC1;
|
|
||||||
ADC1_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
|
||||||
|
|
||||||
#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
|
|
||||||
ADC3->SQR2 = 0;
|
|
||||||
ADC3->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10); // conversions 1 to 3
|
|
||||||
ADC3->SMPR1 = 0;
|
|
||||||
ADC3->SMPR2 = (SAMPTIME_LONG<<(3*ADC_CHANNEL_POT1)) + (SAMPTIME_LONG<<(3*ADC_CHANNEL_SLIDER1)) + (SAMPTIME_LONG<<(3*ADC_CHANNEL_SLIDER2));
|
|
||||||
|
|
||||||
ADC3_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
|
||||||
ADC3_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC3->DR);
|
|
||||||
ADC3_DMA_Stream->M0AR = CONVERT_PTR_UINT(adcValues + NUMBER_ANALOG_ADC1);
|
|
||||||
ADC3_DMA_Stream->NDTR = NUMBER_ANALOG_ADC3;
|
|
||||||
ADC3_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void adcSingleRead()
|
|
||||||
{
|
|
||||||
ADC1_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
|
||||||
ADC1->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR);
|
|
||||||
ADC1_DMA->HIFCR = ADC1_DMA_FLAGS; // Write ones to clear bits
|
|
||||||
ADC1_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
|
||||||
ADC1->CR2 |= (uint32_t) ADC_CR2_SWSTART;
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ADC1_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
|
||||||
ADC3_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
|
||||||
#else
|
|
||||||
for (unsigned int i = 0; i < 10000; i++) {
|
|
||||||
if (ADC1_DMA->HISR & ADC1_DMA_FLAG_TC) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ADC1_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void adcRead()
|
|
||||||
{
|
|
||||||
uint16_t temp[NUMBER_ANALOG] = { 0 };
|
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
|
||||||
adcSingleRead();
|
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG; x++) {
|
|
||||||
uint16_t val = adcValues[x];
|
|
||||||
#if defined(JITTER_MEASURE)
|
|
||||||
if (JITTER_MEASURE_ACTIVE()) {
|
|
||||||
rawJitter[x].measure(val);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
temp[x] += val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint8_t x=0; x<NUMBER_ANALOG; x++) {
|
|
||||||
adcValues[x] = temp[x] >> 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
void adcStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(SIMU)
|
|
||||||
uint16_t getAnalogValue(uint8_t index)
|
|
||||||
{
|
|
||||||
if (IS_POT(index) && !IS_POT_SLIDER_AVAILABLE(index)) {
|
|
||||||
// Use fixed analog value for non-existing and/or non-connected pots.
|
|
||||||
// Non-connected analog inputs will slightly follow the adjacent connected analog inputs,
|
|
||||||
// which produces ghost readings on these inputs.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#if defined(PCBX9E)
|
|
||||||
index = ana_mapping[index];
|
|
||||||
#endif
|
|
||||||
if (ana_direction[index] < 0)
|
|
||||||
return 4095 - adcValues[index];
|
|
||||||
else
|
|
||||||
return adcValues[index];
|
|
||||||
}
|
|
||||||
#endif // #if !defined(SIMU)
|
|
|
@ -373,11 +373,25 @@ enum Analogs {
|
||||||
SLIDER2,
|
SLIDER2,
|
||||||
#endif
|
#endif
|
||||||
TX_VOLTAGE,
|
TX_VOLTAGE,
|
||||||
NUMBER_ANALOG
|
NUM_ANALOGS
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_POTS (POT_LAST-POT_FIRST+1)
|
#define NUM_POTS (POT_LAST-POT_FIRST+1)
|
||||||
#define NUM_SLIDERS (TX_VOLTAGE-POT_LAST-1)
|
|
||||||
#define NUM_XPOTS NUM_POTS
|
#define NUM_XPOTS NUM_POTS
|
||||||
|
#define NUM_SLIDERS (TX_VOLTAGE-POT_LAST-1)
|
||||||
|
|
||||||
|
enum CalibratedAnalogs {
|
||||||
|
CALIBRATED_STICK1,
|
||||||
|
CALIBRATED_STICK2,
|
||||||
|
CALIBRATED_STICK3,
|
||||||
|
CALIBRATED_STICK4,
|
||||||
|
CALIBRATED_POT_FIRST,
|
||||||
|
CALIBRATED_POT_LAST = CALIBRATED_POT_FIRST + NUM_POTS - 1,
|
||||||
|
CALIBRATED_SLIDER_FIRST,
|
||||||
|
CALIBRATED_SLIDER_LAST = CALIBRATED_SLIDER_FIRST + NUM_SLIDERS - 1,
|
||||||
|
NUM_CALIBRATED_ANALOGS
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(PCBX9D)
|
#if defined(PCBX9D)
|
||||||
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT2) // POT3 is only defined in software
|
#define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT2) // POT3 is only defined in software
|
||||||
#else
|
#else
|
||||||
|
@ -386,7 +400,7 @@ enum Analogs {
|
||||||
#define IS_SLIDER(x) ((x)>POT_LAST && (x)<TX_VOLTAGE)
|
#define IS_SLIDER(x) ((x)>POT_LAST && (x)<TX_VOLTAGE)
|
||||||
void adcInit(void);
|
void adcInit(void);
|
||||||
void adcRead(void);
|
void adcRead(void);
|
||||||
extern uint16_t adcValues[NUMBER_ANALOG];
|
extern uint16_t adcValues[NUM_ANALOGS];
|
||||||
uint16_t getAnalogValue(uint8_t index);
|
uint16_t getAnalogValue(uint8_t index);
|
||||||
uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps
|
uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps
|
||||||
|
|
||||||
|
@ -412,7 +426,12 @@ uint32_t pwrPressedDuration(void);
|
||||||
#else
|
#else
|
||||||
uint32_t pwroffPressed(void);
|
uint32_t pwroffPressed(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
#define UNEXPECTED_SHUTDOWN() false
|
||||||
|
#else
|
||||||
#define UNEXPECTED_SHUTDOWN() (WAS_RESET_BY_WATCHDOG() || g_eeGeneral.unexpectedShutdown)
|
#define UNEXPECTED_SHUTDOWN() (WAS_RESET_BY_WATCHDOG() || g_eeGeneral.unexpectedShutdown)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Backlight driver
|
// Backlight driver
|
||||||
void backlightInit(void);
|
void backlightInit(void);
|
||||||
|
|
|
@ -348,10 +348,14 @@
|
||||||
#endif
|
#endif
|
||||||
#define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
|
#define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
|
||||||
#define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
|
#define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
|
||||||
#define ADC1_DMA DMA2
|
#define ADC_MAIN ADC1
|
||||||
#define ADC1_DMA_Stream DMA2_Stream4
|
#define ADC_DMA DMA2
|
||||||
#define ADC1_DMA_FLAGS (DMA_HIFCR_CTCIF4 | DMA_HIFCR_CHTIF4 | DMA_HIFCR_CTEIF4 | DMA_HIFCR_CDMEIF4 | DMA_HIFCR_CFEIF4)
|
#define ADC_DMA_SxCR_CHSEL 0
|
||||||
#define ADC1_DMA_FLAG_TC DMA_HISR_TCIF4
|
#define ADC_DMA_Stream DMA2_Stream4
|
||||||
|
#define ADC_SET_DMA_FLAGS() ADC_DMA->HIFCR = (DMA_HIFCR_CTCIF4 | DMA_HIFCR_CHTIF4 | DMA_HIFCR_CTEIF4 | DMA_HIFCR_CDMEIF4 | DMA_HIFCR_CFEIF4)
|
||||||
|
#define ADC_TRANSFER_COMPLETE() (ADC_DMA->HISR & DMA_HISR_TCIF4)
|
||||||
|
#define ADC_SAMPTIME 2 // sample time = 28 cycles
|
||||||
|
|
||||||
#if defined(PCBX9E)
|
#if defined(PCBX9E)
|
||||||
#define ADC_GPIO_PIN_POT1 GPIO_Pin_8 // PF.08
|
#define ADC_GPIO_PIN_POT1 GPIO_Pin_8 // PF.08
|
||||||
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
||||||
|
@ -375,10 +379,12 @@
|
||||||
#define ADC_CHANNEL_SLIDER3 ADC_Channel_6 // ADC1_IN6
|
#define ADC_CHANNEL_SLIDER3 ADC_Channel_6 // ADC1_IN6
|
||||||
#define ADC_CHANNEL_SLIDER4 ADC_Channel_9 // ADC1_IN9
|
#define ADC_CHANNEL_SLIDER4 ADC_Channel_9 // ADC1_IN9
|
||||||
#define ADC_CHANNEL_BATT ADC_Channel_10 // ADC1_IN10
|
#define ADC_CHANNEL_BATT ADC_Channel_10 // ADC1_IN10
|
||||||
#define ADC3_DMA DMA2
|
#define ADC_EXT ADC3
|
||||||
#define ADC3_DMA_Stream DMA2_Stream0
|
#define ADC_EXT_DMA DMA2
|
||||||
#define ADC3_DMA_FLAGS (DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0)
|
#define ADC_EXT_DMA_Stream DMA2_Stream0
|
||||||
#define ADC3_DMA_FLAG_TC DMA_LISR_TCIF0
|
#define ADC_EXT_SET_DMA_FLAGS() ADC_DMA->LIFCR = (DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0)
|
||||||
|
#define ADC_EXT_TRANSFER_COMPLETE() (ADC_DMA->LISR & DMA_LISR_TCIF0)
|
||||||
|
#define ADC_EXT_SAMPTIME 3 // sample time = 56 cycles
|
||||||
#elif defined(PCBX9DP)
|
#elif defined(PCBX9DP)
|
||||||
#define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
|
#define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
|
||||||
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
||||||
|
|
|
@ -258,7 +258,7 @@ void tasksStart()
|
||||||
cliStart();
|
cliStart();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BLUETOOTH)
|
#if defined(BLUETOOTH) && defined(PCBSKY9X)
|
||||||
btTaskId = CoCreateTask(btTask, NULL, 15, &bluetoothStack.stack[BLUETOOTH_STACK_SIZE-1], BLUETOOTH_STACK_SIZE);
|
btTaskId = CoCreateTask(btTask, NULL, 15, &bluetoothStack.stack[BLUETOOTH_STACK_SIZE-1], BLUETOOTH_STACK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ NOINLINE void processFrskyTelemetryData(uint8_t data)
|
||||||
{
|
{
|
||||||
static uint8_t dataState = STATE_DATA_IDLE;
|
static uint8_t dataState = STATE_DATA_IDLE;
|
||||||
|
|
||||||
#if defined(BLUETOOTH)
|
#if defined(PCBSKY9X) && defined(BLUETOOTH)
|
||||||
// TODO if (g_model.bt_telemetry)
|
// TODO if (g_model.bt_telemetry)
|
||||||
btPushByte(data);
|
btPushByte(data);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -272,7 +272,9 @@ PACK(struct FrskyTelemetryData {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBX9DP) || defined(PCBX9E)
|
#if defined(PCBX10)
|
||||||
|
#define IS_SWR_VALUE_VALID() (false)
|
||||||
|
#elif defined(PCBX9DP) || defined(PCBX9E)
|
||||||
#define IS_SWR_VALUE_VALID() (telemetryData.xjtVersion != 0 && telemetryData.xjtVersion != 0xff)
|
#define IS_SWR_VALUE_VALID() (telemetryData.xjtVersion != 0 && telemetryData.xjtVersion != 0xff)
|
||||||
#else
|
#else
|
||||||
#define IS_SWR_VALUE_VALID() (true)
|
#define IS_SWR_VALUE_VALID() (true)
|
||||||
|
|
|
@ -3,7 +3,7 @@ foreach(translation ${translations})
|
||||||
get_filename_component(language ${translation} NAME_WE)
|
get_filename_component(language ${translation} NAME_WE)
|
||||||
get_filename_component(path ${translation} DIRECTORY)
|
get_filename_component(path ${translation} DIRECTORY)
|
||||||
set(target ${language}.h)
|
set(target ${language}.h)
|
||||||
if(NOT(PCB STREQUAL HORUS) AND language STREQUAL "cz")
|
if(NOT(PCB STREQUAL X12S OR PCB STREQUAL X10) AND language STREQUAL "cz")
|
||||||
set(language cz_reduced)
|
set(language cz_reduced)
|
||||||
endif()
|
endif()
|
||||||
if(PYTHONINTERP_FOUND)
|
if(PYTHONINTERP_FOUND)
|
||||||
|
|
|
@ -518,9 +518,12 @@
|
||||||
#define TR_TRIMS_VSRCRAW "TrmR""TrmE""TrmT""TrmA"
|
#define TR_TRIMS_VSRCRAW "TrmR""TrmE""TrmT""TrmA"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBHORUS)
|
#if defined(PCBX12S)
|
||||||
#define TR_POTS_VSRCRAW "\310S1\0""\3106P\0""\310S2\0""\313L1\0""\313L2\0""\311LS\0""\311RS\0""\310JSx""\310JSy"
|
#define TR_POTS_VSRCRAW "\310S1\0""\3106P\0""\310S2\0""\313L1\0""\313L2\0""\311LS\0""\311RS\0""\310JSx""\310JSy"
|
||||||
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0"
|
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0"
|
||||||
|
#elif defined(PCBX10)
|
||||||
|
#define TR_POTS_VSRCRAW "\310S1\0""\3106P\0""\310S2\0""\311LS\0""\311RS\0""None""None""\310EX1""\310EX2"
|
||||||
|
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0"
|
||||||
#elif defined(PCBFLAMENCO)
|
#elif defined(PCBFLAMENCO)
|
||||||
#define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 "
|
#define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 "
|
||||||
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 "
|
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 "
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
SET SRCDIR=%~dp0%\..\..
|
|
||||||
|
|
||||||
cd %SRCDIR%
|
|
||||||
git fetch
|
|
||||||
git checkout next
|
|
||||||
git reset --hard origin/next
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
rmdir build /s /q
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
|
|
||||||
SET COMMON_OPTIONS=-DCMAKE_PREFIX_PATH=C:\Qt\5.6\msvc2015 -DALLOW_NIGHTLY_BUILDS=YES -DVERSION_SUFFIX=%1 -DGVARS=YES -DHELI=YES
|
|
||||||
SET STM32_OPTIONS=%COMMON_OPTIONS% -DLUA=YES
|
|
||||||
|
|
||||||
cmake %COMMON_OPTIONS% -DPCB=9X %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %COMMON_OPTIONS% -DPCB=GRUVIN9X %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %COMMON_OPTIONS% -DPCB=MEGA2560 %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %COMMON_OPTIONS% -DPCB=SKY9X %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %COMMON_OPTIONS% -DPCB=9XRPRO %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %STM32_OPTIONS% -DPCB=TARANIS %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %STM32_OPTIONS% -DPCB=TARANIS -DPCBREV=REVPLUS %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %STM32_OPTIONS% -DPCB=TARANIS -DPCBREV=REV9E %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
|
|
||||||
cmake %STM32_OPTIONS% -DPCB=HORUS %SRCDIR%
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
|
||||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" companion\src\installer.vcxproj /t:Rebuild /p:Configuration=Release
|
|
|
@ -123,9 +123,15 @@ elif options[optcount] == "x9e":
|
||||||
maxsize = 65536 * 8
|
maxsize = 65536 * 8
|
||||||
board = BOARD_TARANIS
|
board = BOARD_TARANIS
|
||||||
board_family = BOARD_FAMILY_ARM
|
board_family = BOARD_FAMILY_ARM
|
||||||
elif options[optcount] == "horus":
|
elif options[optcount] == "x10":
|
||||||
command_options["PCB"] = "HORUS"
|
command_options["PCB"] = "X10"
|
||||||
firmware_options = options_horus
|
firmware_options = options_x10
|
||||||
|
maxsize = 2 * 1024 * 1024
|
||||||
|
board = BOARD_HORUS
|
||||||
|
board_family = BOARD_FAMILY_ARM
|
||||||
|
elif options[optcount] == "x12s":
|
||||||
|
command_options["PCB"] = "X12S"
|
||||||
|
firmware_options = options_x12s
|
||||||
maxsize = 2 * 1024 * 1024
|
maxsize = 2 * 1024 * 1024
|
||||||
board = BOARD_HORUS
|
board = BOARD_HORUS
|
||||||
board_family = BOARD_FAMILY_ARM
|
board_family = BOARD_FAMILY_ARM
|
||||||
|
|
|
@ -292,7 +292,7 @@ options_taranisx9e = {
|
||||||
"multimodule": ("MULTIMODULE", "YES", "NO")
|
"multimodule": ("MULTIMODULE", "YES", "NO")
|
||||||
}
|
}
|
||||||
|
|
||||||
options_horus = {
|
options_x12s = {
|
||||||
"noheli": ("HELI", "NO", "YES"),
|
"noheli": ("HELI", "NO", "YES"),
|
||||||
"ppmus": ("PPM_UNIT", "US", "PERCENT_PREC1"),
|
"ppmus": ("PPM_UNIT", "US", "PERCENT_PREC1"),
|
||||||
"lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"),
|
"lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"),
|
||||||
|
@ -307,3 +307,18 @@ options_horus = {
|
||||||
"multimodule": ("MULTIMODULE", "YES", "NO"),
|
"multimodule": ("MULTIMODULE", "YES", "NO"),
|
||||||
"pcbdev": ("PCBREV", "10", None),
|
"pcbdev": ("PCBREV", "10", None),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options_x10 = {
|
||||||
|
"noheli": ("HELI", "NO", "YES"),
|
||||||
|
"ppmus": ("PPM_UNIT", "US", "PERCENT_PREC1"),
|
||||||
|
"lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"),
|
||||||
|
"luac": ("LUA_COMPILER", "YES", "NO"),
|
||||||
|
"nogvars": ("GVARS", "NO", "YES"),
|
||||||
|
"faimode": ("FAI", "YES", None),
|
||||||
|
"faichoice": ("FAI", "CHOICE", None),
|
||||||
|
"nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"),
|
||||||
|
"massstorage": ("USB", "MASSSTORAGE", None),
|
||||||
|
"cli": ("USB", "SERIAL", None),
|
||||||
|
"eu": ("SUPPORT_D16_EU_ONLY", "YES", "NO"),
|
||||||
|
"multimodule": ("MULTIMODULE", "YES", "NO"),
|
||||||
|
}
|
||||||
|
|
|
@ -53,6 +53,16 @@ with open(sys.argv[2], "w") as f:
|
||||||
values.append(str(val))
|
values.append(str(val))
|
||||||
f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values)))
|
f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values)))
|
||||||
f.write("const Bitmap %s(BMP_ARGB4444, %d, %d, __%s);\n" % (constant, width, height, constant))
|
f.write("const Bitmap %s(BMP_ARGB4444, %d, %d, __%s);\n" % (constant, width, height, constant))
|
||||||
|
elif what == "4/4/4/4-R":
|
||||||
|
constant = sys.argv[2].upper()[:-4]
|
||||||
|
values = []
|
||||||
|
for y in range(height):
|
||||||
|
for x in range(width):
|
||||||
|
pixel = image.pixel(width-x-1, height-y-1)
|
||||||
|
val = ((Qt.qAlpha(pixel) // 16) << 12) + ((Qt.qRed(pixel) // 16) << 8) + ((Qt.qGreen(pixel) // 16) << 4) + ((Qt.qBlue(pixel) // 16) << 0)
|
||||||
|
values.append(str(val))
|
||||||
|
f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values)))
|
||||||
|
f.write("const Bitmap %s(BMP_ARGB4444, %d, %d, __%s);\n" % (constant, width, height, constant))
|
||||||
elif what == "5/6/5":
|
elif what == "5/6/5":
|
||||||
constant = sys.argv[2].upper()[:-4]
|
constant = sys.argv[2].upper()[:-4]
|
||||||
values = []
|
values = []
|
||||||
|
@ -63,6 +73,16 @@ with open(sys.argv[2], "w") as f:
|
||||||
values.append(str(val))
|
values.append(str(val))
|
||||||
f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values)))
|
f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values)))
|
||||||
f.write("const Bitmap %s(BMP_RGB565, %d, %d, __%s);\n" % (constant, width, height, constant))
|
f.write("const Bitmap %s(BMP_RGB565, %d, %d, __%s);\n" % (constant, width, height, constant))
|
||||||
|
elif what == "5/6/5-R":
|
||||||
|
constant = sys.argv[2].upper()[:-4]
|
||||||
|
values = []
|
||||||
|
for y in range(height):
|
||||||
|
for x in range(width):
|
||||||
|
pixel = image.pixel(width-x-1, height-y-1)
|
||||||
|
val = ((Qt.qRed(pixel) >> 3) << 11) + ((Qt.qGreen(pixel) >> 2) << 5) + ((Qt.qBlue(pixel) >> 3) << 0)
|
||||||
|
values.append(str(val))
|
||||||
|
f.write("const uint16_t __%s[] __ALIGNED = { %s };\n" % (constant, ",".join(values)))
|
||||||
|
f.write("const Bitmap %s(BMP_RGB565, %d, %d, __%s);\n" % (constant, width, height, constant))
|
||||||
elif what == "5/6/5/8":
|
elif what == "5/6/5/8":
|
||||||
colors = []
|
colors = []
|
||||||
writeSize(f, width, height)
|
writeSize(f, width, height)
|
||||||
|
|
|
@ -68,7 +68,10 @@ make -j${JOBS} libsimulator
|
||||||
cmake ${STM32_OPTIONS} -DPCB=X9E ${SRCDIR}
|
cmake ${STM32_OPTIONS} -DPCB=X9E ${SRCDIR}
|
||||||
make -j${JOBS} libsimulator
|
make -j${JOBS} libsimulator
|
||||||
|
|
||||||
cmake ${STM32_OPTIONS} -DPCB=HORUS ${SRCDIR}
|
cmake ${STM32_OPTIONS} -DPCB=X10 ${SRCDIR}
|
||||||
|
make -j${JOBS} libsimulator
|
||||||
|
|
||||||
|
cmake ${STM32_OPTIONS} -DPCB=X12S ${SRCDIR}
|
||||||
make -j${JOBS} libsimulator
|
make -j${JOBS} libsimulator
|
||||||
|
|
||||||
make -j${JOBS} package
|
make -j${JOBS} package
|
||||||
|
|
|
@ -162,19 +162,28 @@ if [[ " X9E X9 ALL " =~ " ${FLAVOR} " ]] ; then
|
||||||
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ " X12Sr10 X12 ALL " =~ " ${FLAVOR} " ]] ; then
|
if [[ " X10 HORUS ALL " =~ " ${FLAVOR} " ]] ; then
|
||||||
# OpenTX on Horus beta boards
|
# OpenTX on X10 boards
|
||||||
rm -rf *
|
rm -rf *
|
||||||
cmake ${COMMON_OPTIONS} -DPCB=HORUS -DPCBREV=10 -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
|
cmake ${COMMON_OPTIONS} -DPCB=X10 -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
|
||||||
make -j${CORES} ${FIRMARE_TARGET}
|
make -j${CORES} ${FIRMARE_TARGET}
|
||||||
make -j${CORES} simu
|
make -j${CORES} simu
|
||||||
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ " X12S X12 ALL " =~ " ${FLAVOR} " ]] ; then
|
if [[ " X12Sr10 HORUS ALL " =~ " ${FLAVOR} " ]] ; then
|
||||||
|
# OpenTX on Horus beta boards
|
||||||
|
rm -rf *
|
||||||
|
cmake ${COMMON_OPTIONS} -DPCB=X12S -DPCBREV=10 -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
|
||||||
|
make -j${CORES} ${FIRMARE_TARGET}
|
||||||
|
make -j${CORES} simu
|
||||||
|
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ " X12S HORUS ALL " =~ " ${FLAVOR} " ]] ; then
|
||||||
# OpenTX on Horus
|
# OpenTX on Horus
|
||||||
rm -rf *
|
rm -rf *
|
||||||
cmake ${COMMON_OPTIONS} -DPCB=HORUS -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
|
cmake ${COMMON_OPTIONS} -DPCB=X12S -DHELI=YES -DLUA=YES -DGVARS=YES ${SRCDIR}
|
||||||
make -j${CORES} ${FIRMARE_TARGET}
|
make -j${CORES} ${FIRMARE_TARGET}
|
||||||
make -j${CORES} simu
|
make -j${CORES} simu
|
||||||
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
make -j${CORES} gtests ; ./gtests ${TEST_OPTIONS}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue