From b9430f82b74d88d99cac069a2744946d4a50e128 Mon Sep 17 00:00:00 2001 From: jflyper Date: Sun, 15 Jan 2017 02:14:39 +0900 Subject: [PATCH] Call vtxCommonProcess instead of device dependent periodic service function --- src/main/drivers/vtx_common.c | 9 +++++++++ src/main/drivers/vtx_common.h | 4 ++++ src/main/fc/fc_tasks.c | 6 +++--- src/main/io/vtx_smartaudio.c | 3 ++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/drivers/vtx_common.c b/src/main/drivers/vtx_common.c index 763918c9a..2fa683a5b 100644 --- a/src/main/drivers/vtx_common.c +++ b/src/main/drivers/vtx_common.c @@ -43,6 +43,15 @@ void vtxCommonRegisterDevice(vtxDevice_t *pDevice) vtxDevice = pDevice; } +void vtxCommonProcess(uint32_t currentTimeUs) +{ + if (!vtxDevice) + return; + + if (vtxDevice->vTable->process) + vtxDevice->vTable->process(currentTimeUs); +} + vtxDevType_e vtxCommonGetDeviceType(void) { if (!vtxDevice) diff --git a/src/main/drivers/vtx_common.h b/src/main/drivers/vtx_common.h index 685f02bb5..5c45bbc3e 100644 --- a/src/main/drivers/vtx_common.h +++ b/src/main/drivers/vtx_common.h @@ -51,6 +51,7 @@ typedef struct vtxDevice_s { // {set,get}Pitmode: 0 = OFF, 1 = ON typedef struct vtxVTable_s { + void (*process)(uint32_t currentTimeUs); vtxDevType_e (*getDeviceType)(void); bool (*isReady)(void); @@ -71,6 +72,8 @@ typedef struct vtxVTable_s { void vtxCommonInit(void); void vtxCommonRegisterDevice(vtxDevice_t *pDevice); +// VTable functions +void vtxCommonProcess(uint32_t currentTimeUs); uint8_t vtxCommonGetDeviceType(void); void vtxCommonSetBandChan(uint8_t band, uint8_t chan); void vtxCommonSetPowerByIndex(uint8_t level); @@ -79,4 +82,5 @@ bool vtxCommonGetBandChan(uint8_t *pBand, uint8_t *pChan); bool vtxCommonGetPowerIndex(uint8_t *pIndex); bool vtxCommonGetPitmode(uint8_t *pOnoff); +// Utilities bool vtx58_Freq2Bandchan(vtxDevice_t *pVtxDev, uint16_t freq, uint8_t *pBand, uint8_t *pChan); diff --git a/src/main/fc/fc_tasks.c b/src/main/fc/fc_tasks.c index 644287026..a13b5114d 100644 --- a/src/main/fc/fc_tasks.c +++ b/src/main/fc/fc_tasks.c @@ -32,6 +32,7 @@ #include "drivers/compass.h" #include "drivers/serial.h" #include "drivers/stack_check.h" +#include "drivers/vtx_common.h" #include "fc/config.h" #include "fc/fc_msp.h" @@ -52,7 +53,6 @@ #include "io/osd.h" #include "io/serial.h" #include "io/transponder_ir.h" -#include "io/vtx_smartaudio.h" #include "msp/msp_serial.h" @@ -212,8 +212,8 @@ void taskVtxControl(uint32_t currentTime) if (ARMING_FLAG(ARMED)) return; -#ifdef VTX_SMARTAUDIO - smartAudioProcess(currentTime); +#ifdef VTX_COMMON + vtxCommonProcess(currentTime); #endif } #endif diff --git a/src/main/io/vtx_smartaudio.c b/src/main/io/vtx_smartaudio.c index d5d6abfb8..b9ebad2bf 100644 --- a/src/main/io/vtx_smartaudio.c +++ b/src/main/io/vtx_smartaudio.c @@ -703,7 +703,7 @@ bool smartAudioInit() return true; } -void smartAudioProcess(uint32_t now) +void vtxSAProcess(uint32_t now) { static bool initialSent = false; @@ -825,6 +825,7 @@ bool vtxSAGetPitmode(uint8_t *pOnoff) } static vtxVTable_t saVTable = { + .process = vtxSAProcess, .getDeviceType = vtxSAGetDeviceType, .isReady = vtxSAIsReady, .setBandChan = vtxSASetBandChan,