From 6ac8d50c402821708797cc5648c01c59c08ee517 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 21 Nov 2021 09:35:37 +0100 Subject: [PATCH] Fixed some more mockup drivers --- .../arm/stm32/extmodule_serial_driver.cpp | 2 +- .../arm/stm32/extmodule_serial_driver.h | 2 +- radio/src/targets/simu/CMakeLists.txt | 2 ++ radio/src/targets/simu/bt_driver.cpp | 33 +++++++++++++++++++ radio/src/targets/simu/gyro_driver.cpp | 23 +++++++++++++ radio/src/targets/simu/module_drivers.cpp | 17 ++++++++++ radio/src/tests/CMakeLists.txt | 2 ++ 7 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 radio/src/targets/simu/bt_driver.cpp create mode 100644 radio/src/targets/simu/gyro_driver.cpp diff --git a/radio/src/targets/common/arm/stm32/extmodule_serial_driver.cpp b/radio/src/targets/common/arm/stm32/extmodule_serial_driver.cpp index 50cec65dd..9479bcff9 100644 --- a/radio/src/targets/common/arm/stm32/extmodule_serial_driver.cpp +++ b/radio/src/targets/common/arm/stm32/extmodule_serial_driver.cpp @@ -193,7 +193,7 @@ static void extmoduleWaitForTxCompleted() #endif } -etx_serial_driver_t ExtmoduleSerialDriver = { +const etx_serial_driver_t ExtmoduleSerialDriver = { .init = extmoduleSerialStart, .deinit = extmoduleSerialStop, .sendByte = extmoduleSendByte, diff --git a/radio/src/targets/common/arm/stm32/extmodule_serial_driver.h b/radio/src/targets/common/arm/stm32/extmodule_serial_driver.h index b0e6a0492..fc470cf46 100644 --- a/radio/src/targets/common/arm/stm32/extmodule_serial_driver.h +++ b/radio/src/targets/common/arm/stm32/extmodule_serial_driver.h @@ -37,4 +37,4 @@ void extmoduleFifoError(); void extmodulePxx1SerialStart(); #endif -extern etx_serial_driver_t ExtmoduleSerialDriver; +extern const etx_serial_driver_t ExtmoduleSerialDriver; diff --git a/radio/src/targets/simu/CMakeLists.txt b/radio/src/targets/simu/CMakeLists.txt index 1ebe8a6f1..cfcd16dd9 100644 --- a/radio/src/targets/simu/CMakeLists.txt +++ b/radio/src/targets/simu/CMakeLists.txt @@ -19,6 +19,8 @@ set(SIMU_SRC module_drivers.cpp led_driver.cpp backlight_driver.cpp + gyro_driver.cpp + bt_driver.cpp ) if(SIMU_DISKIO) diff --git a/radio/src/targets/simu/bt_driver.cpp b/radio/src/targets/simu/bt_driver.cpp new file mode 100644 index 000000000..8adb1a07a --- /dev/null +++ b/radio/src/targets/simu/bt_driver.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * 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 "fifo.h" + +//#define BT_TX_FIFO_SIZE 64 +Fifo btTxFifo; +Fifo btRxFifo; + +void bluetoothInit(unsigned int, bool) {} +void bluetoothDisable() {} + +void bluetoothWriteWakeup() {} +bool bluetoothIsWriting() { return false; } + diff --git a/radio/src/targets/simu/gyro_driver.cpp b/radio/src/targets/simu/gyro_driver.cpp new file mode 100644 index 000000000..7b62e80dc --- /dev/null +++ b/radio/src/targets/simu/gyro_driver.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * 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. + */ + +void gyroRead() {} +void gyroRead(unsigned char*) {} diff --git a/radio/src/targets/simu/module_drivers.cpp b/radio/src/targets/simu/module_drivers.cpp index c82c33fc1..9c996e5fd 100644 --- a/radio/src/targets/simu/module_drivers.cpp +++ b/radio/src/targets/simu/module_drivers.cpp @@ -21,19 +21,26 @@ #include "hal/serial_driver.h" #include "intmodule_serial_driver.h" +#include "extmodule_serial_driver.h" #include "io/frsky_pxx2.h" ModuleFifo intmoduleFifo; +ModuleFifo extmoduleFifo; void intmoduleStop() {} void intmoduleFifoError() {} void intmoduleFifoReceive(uint8_t){} + void intmodulePxx1PulsesStart() {} void intmoduleSendNextFramePxx1() {} void extmoduleStop() {} +void extmoduleFifoError() {} +void extmoduleFifoReceive(uint8_t){} + void extmodulePpmStart() {} void extmoduleSerialStart() {} +void extmodulePxx1SerialStart() {} void extmodulePxx1PulsesStart() {} void extmoduleSendInvertedByte(uint8_t) {} void extmoduleSendNextFramePxx1(void const*, unsigned short) {} @@ -70,3 +77,13 @@ const etx_serial_driver_t IntmoduleSerialDriver = { .setReceiveCb = nullptr, .setOnErrorCb = nullptr, }; + +const etx_serial_driver_t ExtmoduleSerialDriver = { + .init = init, + .deinit = deinit, + .sendByte = sendByte, + .sendBuffer = sendBuffer, + .waitForTxCompleted = waitForTxCompleted, + .setReceiveCb = nullptr, + .setOnErrorCb = nullptr, +}; diff --git a/radio/src/tests/CMakeLists.txt b/radio/src/tests/CMakeLists.txt index 412ef6558..cd13421a4 100644 --- a/radio/src/tests/CMakeLists.txt +++ b/radio/src/tests/CMakeLists.txt @@ -64,6 +64,8 @@ if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND) ../targets/simu/module_drivers.cpp ../targets/simu/led_driver.cpp ../targets/simu/backlight_driver.cpp + ../targets/simu/gyro_driver.cpp + ../targets/simu/bt_driver.cpp ) add_dependencies(gtests-radio ${RADIO_DEPENDENCIES} ${FIRMWARE_DEPENDENCIES} gtests-radio-lib) if(PCB STREQUAL X12S OR PCB STREQUAL X10)