diff --git a/radio/src/mixer_scheduler.cpp b/radio/src/mixer_scheduler.cpp index 064a0b52b..e4ec76736 100644 --- a/radio/src/mixer_scheduler.cpp +++ b/radio/src/mixer_scheduler.cpp @@ -22,6 +22,32 @@ #include "opentx.h" #include "mixer_scheduler.h" +bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs) +{ +#if !defined(SIMU) + uint32_t ulNotificationValue; + const TickType_t xMaxBlockTime = pdMS_TO_TICKS( timeoutMs ); + + /* Wait to be notified that the transmission is complete. Note + the first parameter is pdTRUE, which has the effect of clearing + the task's notification value back to 0, making the notification + value act like a binary (rather than a counting) semaphore. */ + ulNotificationValue = ulTaskNotifyTake( pdTRUE, xMaxBlockTime ); + + if( ulNotificationValue == 1 ) { + /* The transmission ended as expected. */ + return false; + + } else { + /* The call to ulTaskNotifyTake() timed out. */ + return true; + } +#else + simuSleep(timeoutMs); + return true; +#endif +} + #if !defined(SIMU) // Global trigger flag @@ -72,27 +98,6 @@ void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs) mixerSchedules[moduleIdx].period = periodUs; } -bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs) -{ - uint32_t ulNotificationValue; - const TickType_t xMaxBlockTime = pdMS_TO_TICKS( timeoutMs ); - - /* Wait to be notified that the transmission is complete. Note - the first parameter is pdTRUE, which has the effect of clearing - the task's notification value back to 0, making the notification - value act like a binary (rather than a counting) semaphore. */ - ulNotificationValue = ulTaskNotifyTake( pdTRUE, xMaxBlockTime ); - - if( ulNotificationValue == 1 ) { - /* The transmission ended as expected. */ - return false; - - } else { - /* The call to ulTaskNotifyTake() timed out. */ - return true; - } -} - void mixerSchedulerISRTrigger() { BaseType_t xHigherPriorityTaskWoken = pdFALSE; diff --git a/radio/src/mixer_scheduler.h b/radio/src/mixer_scheduler.h index afc96d8cc..98d4177bf 100644 --- a/radio/src/mixer_scheduler.h +++ b/radio/src/mixer_scheduler.h @@ -46,12 +46,6 @@ void mixerSchedulerResetTimer(); // Set the scheduling period for a given module void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs); -// Clear the flag before waiting - -// Wait for the scheduler timer to trigger -// returns true if timeout, false otherwise -bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs); - // Enable the timer trigger void mixerSchedulerEnableTrigger(); @@ -73,12 +67,6 @@ void mixerSchedulerISRTrigger(); #define mixerSchedulerSetPeriod(m,p) #define mixerSchedulerClearTrigger() -static inline bool mixerSchedulerWaitForTrigger(uint8_t timeout) -{ - simuSleep(timeout); - return false; -} - #define mixerSchedulerEnableTrigger() #define mixerSchedulerDisableTrigger() @@ -86,3 +74,7 @@ static inline bool mixerSchedulerWaitForTrigger(uint8_t timeout) #define mixerSchedulerISRTrigger() #endif + +// Wait for the scheduler timer to trigger +// returns true if timeout, false otherwise +bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs); diff --git a/radio/src/pulses/afhds2.cpp b/radio/src/pulses/afhds2.cpp index f0cf48fab..9b8c2ce2f 100644 --- a/radio/src/pulses/afhds2.cpp +++ b/radio/src/pulses/afhds2.cpp @@ -25,6 +25,11 @@ #include "intmodule_serial_driver.h" #include "mixer_scheduler.h" +// solely for 'intmoduleFifo' +// TODO: remove this non-sense +#include "opentx.h" +#include "pulses/pxx2.h" + afhds2::afhds2() { // TODO Auto-generated constructor stub @@ -34,7 +39,7 @@ afhds2::~afhds2() { // TODO Auto-generated destructor stub } -etx_serial_init afhds2SerialInitParams = { +const etx_serial_init afhds2SerialInitParams = { .baudrate = INTMODULE_USART_AFHDS2_BAUDRATE, .parity = ETX_Parity_None, .stop_bits = ETX_StopBits_One, @@ -70,10 +75,14 @@ static void afhds2DeInit(void* context) mixerSchedulerSetPeriod(INTERNAL_MODULE, 0); } -static void afhds2SetupPulses(void* context) +static void afhds2SetupPulses(void* context, int16_t* channels, uint8_t nChannels) { (void)context; + // TODO: + (void)channels; + (void)nChannels; + ModuleSyncStatus& status = getModuleSyncStatus(INTERNAL_MODULE); mixerSchedulerSetPeriod(INTERNAL_MODULE, status.isValid() ? status.getAdjustedRefreshRate() @@ -91,7 +100,7 @@ static void afhds2SendPulses(void* context) IntmoduleSerialDriver.sendBuffer(data, size); } -etx_module_driver_t Afhds2InternalDriver = { +const etx_module_driver_t Afhds2InternalDriver = { .protocol = PROTOCOL_CHANNELS_AFHDS2A, .init = afhds2Init, .deinit = afhds2DeInit, diff --git a/radio/src/pulses/afhds2.h b/radio/src/pulses/afhds2.h index cbfe929f6..39a6e762b 100644 --- a/radio/src/pulses/afhds2.h +++ b/radio/src/pulses/afhds2.h @@ -28,6 +28,7 @@ #include #include "hal/serial_driver.h" +#include "hal/module_driver.h" #define AFHDS2_PERIOD (2 * 1000) /* us */ @@ -58,6 +59,7 @@ public: virtual ~afhds2(); }; -extern etx_serial_init afhds2SerialInitParams; +extern const etx_serial_init afhds2SerialInitParams; +extern const etx_module_driver_t Afhds2InternalDriver; #endif /* PULSES_AFHDS2_H_ */ diff --git a/radio/src/pulses/pulses.cpp b/radio/src/pulses/pulses.cpp index 60a25d81e..38c6e8fcb 100755 --- a/radio/src/pulses/pulses.cpp +++ b/radio/src/pulses/pulses.cpp @@ -45,6 +45,10 @@ #include "pulses/multi.h" #endif +#if defined(AFHDS2) +#include "pulses/afhds2.h" +#endif + uint8_t s_pulses_paused = 0; ModuleState moduleState[NUM_MODULES]; InternalModulePulsesData intmodulePulsesData __DMA; @@ -345,7 +349,7 @@ static void enablePulsesInternalModule(uint8_t protocol) break; #endif -#if defined(AFHDS2) +#if defined(INTERNAL_MODULE_AFHDS2A) case PROTOCOL_CHANNELS_AFHDS2A: internalModuleContext = Afhds2InternalDriver.init(INTERNAL_MODULE); internalModuleDriver = &Afhds2InternalDriver; diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index 8fb0a9d16..049545472 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -54,21 +54,6 @@ add_definitions(-DINTERNAL_MODULE_AFHDS2A) set(INTERNAL_MODULES AFHDS2A CACHE STRING "Internal modules") set(DEFAULT_INTERNAL_MODULE FLYSKY CACHE STRING "Default internal module") -set(TARGET_SRC - ${TARGET_SRC} - audio_spi_driver.cpp - ../common/arm/stm32/mixer_scheduler_driver.cpp - ../common/arm/stm32/timers_driver.cpp - ) - -set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - battery_driver.cpp - ../horus/flyskyHallStick_driver.cpp - ../common/arm/stm32/stm32_hal_adc.cpp - ../../hal/adc_driver.cpp - ) - set(BITMAPS_TARGET nv14_bitmaps) set(FONTS_TARGET x12_fonts) set(LCD_DRIVER lcd_driver.cpp) @@ -82,7 +67,6 @@ set(FIRMWARE_DEPENDENCIES datacopy) set(HARDWARE_TOUCH ON) set(SOFTWARE_KEYBOARD ON) - add_definitions(-DSTM32F429_439xx -DSDRAM -DCOLORLCD -DLIBOPENUI -DHARDWARE_TOUCH -DHARDWARE_KEYS -DSOFTWARE_KEYBOARD) add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK) @@ -127,27 +111,6 @@ set(SRC set(GVAR_SCREEN model_gvars.cpp) -set(TARGET_SRC - ${TARGET_SRC} - extmodule_helper.cpp - ../horus/extmodule_driver.cpp - trainer_driver.cpp - ../common/arm/stm32/intmodule_serial_driver.cpp - ../common/arm/stm32/stm32_usart_driver.cpp - ) - -set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ${LCD_DRIVER} - ${TOUCH_DRIVER} - board.cpp - backlight_driver.cpp - sdram_driver.c - startup_stm32f42_43xxx.s - ../common/arm/stm32/pwr_driver.cpp - ../common/arm/stm32/sdio_sd.c - ) - if(BOOTLOADER) set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} @@ -168,6 +131,34 @@ if (MULTIMODULE) ) endif() +set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + board.cpp + startup_stm32f42_43xxx.s + ${LCD_DRIVER} + ${TOUCH_DRIVER} + sdram_driver.c + trainer_driver.cpp + battery_driver.cpp + audio_spi_driver.cpp + backlight_driver.cpp + extmodule_helper.cpp + ../horus/extmodule_driver.cpp + ../horus/flyskyHallStick_driver.cpp + ) + +set(FIRMWARE_SRC + ${FIRMWARE_SRC} + hal/adc_driver.cpp + targets/common/arm/stm32/stm32_hal_adc.cpp + targets/common/arm/stm32/timers_driver.cpp + targets/common/arm/stm32/mixer_scheduler_driver.cpp + targets/common/arm/stm32/intmodule_serial_driver.cpp + targets/common/arm/stm32/stm32_usart_driver.cpp + targets/common/arm/stm32/pwr_driver.cpp + targets/common/arm/stm32/sdio_sd.c + ) + # Make malloc() thread-safe add_definitions(-DTHREADSAFE_MALLOC) diff --git a/radio/src/targets/nv14/board.h b/radio/src/targets/nv14/board.h index efa7d5e53..5c0f23b44 100644 --- a/radio/src/targets/nv14/board.h +++ b/radio/src/targets/nv14/board.h @@ -106,16 +106,31 @@ uint32_t isBootloaderStart(const uint8_t * buffer); // SDRAM driver void SDRAM_Init(); -// Pulses driver +#if !defined(SIMU) + #define INTERNAL_MODULE_OFF() GPIO_SetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN) #define INTERNAL_MODULE_ON() GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN) void EXTERNAL_MODULE_ON(); void EXTERNAL_MODULE_OFF(); -#define EXTERNAL_MODULE_PWR_OFF EXTERNAL_MODULE_OFF #define BLUETOOTH_MODULE_ON() GPIO_ResetBits(BLUETOOTH_ON_GPIO, BLUETOOTH_ON_GPIO_PIN) #define BLUETOOTH_MODULE_OFF() GPIO_SetBits(BLUETOOTH_ON_GPIO, BLUETOOTH_ON_GPIO_PIN) #define IS_INTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN) == Bit_SET) #define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET) + +#else + +#define INTERNAL_MODULE_OFF() +#define INTERNAL_MODULE_ON() +#define EXTERNAL_MODULE_ON() +#define EXTERNAL_MODULE_OFF() +#define BLUETOOTH_MODULE_ON() +#define BLUETOOTH_MODULE_OFF() +#define IS_INTERNAL_MODULE_ON() (false) +#define IS_EXTERNAL_MODULE_ON() (false) + +#endif // defined(SIMU) + +#define EXTERNAL_MODULE_PWR_OFF EXTERNAL_MODULE_OFF #define IS_UART_MODULE(port) (port == INTERNAL_MODULE) #define IS_PXX2_INTERNAL_ENABLED() (false)