diff --git a/src/main/drivers/transponder_ir.c b/src/main/drivers/transponder_ir.c index 9c4a4fcb3e..1b26e691a7 100644 --- a/src/main/drivers/transponder_ir.c +++ b/src/main/drivers/transponder_ir.c @@ -152,16 +152,8 @@ void transponderIrHardwareInit(ioTag_t ioTag, transponder_t *transponder) DMA_ITConfig(dmaRef, DMA_IT_TC, ENABLE); } -bool transponderIrInit(const transponderProvider_e provider) +bool transponderIrInit(const ioTag_t ioTag, const transponderProvider_e provider) { - ioTag_t ioTag = IO_TAG_NONE; - for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) { - if (timerHardware[i].usageFlags & TIM_USE_TRANSPONDER) { - ioTag = timerHardware[i].tag; - break; - } - } - if (!ioTag) { return false; } diff --git a/src/main/drivers/transponder_ir.h b/src/main/drivers/transponder_ir.h index 7f4979e9fc..fe7416a7c4 100644 --- a/src/main/drivers/transponder_ir.h +++ b/src/main/drivers/transponder_ir.h @@ -113,7 +113,7 @@ struct transponderVTable { void (*updateTransponderDMABuffer)(transponder_t *transponder, const uint8_t* transponderData); }; -bool transponderIrInit(const transponderProvider_e provider); +bool transponderIrInit(const ioTag_t ioTag, const transponderProvider_e provider); void transponderIrDisable(void); void transponderIrHardwareInit(ioTag_t ioTag, transponder_t *transponder); diff --git a/src/main/fc/.cli.c.swo b/src/main/fc/.cli.c.swo new file mode 100644 index 0000000000..df03206f51 Binary files /dev/null and b/src/main/fc/.cli.c.swo differ diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 66033bd951..803fd3be7a 100755 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -71,6 +71,7 @@ extern uint8_t __config_end; #include "drivers/sonar_hcsr04.h" #include "drivers/stack_check.h" #include "drivers/system.h" +#include "drivers/transponder_ir.h" #include "drivers/time.h" #include "drivers/timer.h" #include "drivers/vcd.h" @@ -104,6 +105,7 @@ extern uint8_t __config_end; #include "io/ledstrip.h" #include "io/osd.h" #include "io/serial.h" +#include "io/transponder_ir.h" #include "io/vtx_rtc6705.h" #include "io/vtx_control.h" @@ -2849,6 +2851,9 @@ const cliResourceValue_t resourceTable[] = { { OWNER_RX_BIND, PG_RX_CONFIG, offsetof(rxConfig_t, spektrum_bind_pin_override_ioTag), 0 }, { OWNER_RX_BIND_PLUG, PG_RX_CONFIG, offsetof(rxConfig_t, spektrum_bind_plug_ioTag), 0 }, #endif +#ifdef TRANSPONDER + { OWNER_TRANSPONDER, PG_TRANSPONDER_CONFIG, offsetof(transponderConfig_t, ioTag), 0 }, +#endif }; static ioTag_t *getIoTag(const cliResourceValue_t value, uint8_t index) diff --git a/src/main/io/transponder_ir.c b/src/main/io/transponder_ir.c index dc29ad5711..0559dbf75d 100644 --- a/src/main/io/transponder_ir.c +++ b/src/main/io/transponder_ir.c @@ -26,9 +26,11 @@ #ifdef TRANSPONDER #include "build/build_config.h" +#include "config/config_reset.h" #include "config/parameter_group.h" #include "config/parameter_group_ids.h" +#include "drivers/timer.h" #include "drivers/transponder_ir.h" #include "drivers/system.h" #include "drivers/usb_io.h" @@ -37,13 +39,24 @@ #include "io/transponder_ir.h" -PG_REGISTER_WITH_RESET_TEMPLATE(transponderConfig_t, transponderConfig, PG_TRANSPONDER_CONFIG, 0); +PG_REGISTER_WITH_RESET_FN(transponderConfig_t, transponderConfig, PG_TRANSPONDER_CONFIG, 0); -PG_RESET_TEMPLATE(transponderConfig_t, transponderConfig, - .provider = TRANSPONDER_ILAP, - .reserved = 0, - .data = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0x0, 0x0, 0x0 }, // Note, this is NOT a valid transponder code, it's just for testing production hardware -); +void pgResetFn_transponderConfig(transponderConfig_t *transponderConfig) +{ + RESET_CONFIG_2(transponderConfig_t, transponderConfig, + .provider = TRANSPONDER_ILAP, + .reserved = 0, + .data = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0x0, 0x0, 0x0 }, // Note, this is NOT a valid transponder code, it's just for testing production hardware + .ioTag = IO_TAG_NONE + ); + + for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) { + if (timerHardware[i].usageFlags & TIM_USE_TRANSPONDER) { + transponderConfig->ioTag = timerHardware[i].tag; + break; + } + } +} static bool transponderInitialised = false; static bool transponderRepeat = false; @@ -95,7 +108,7 @@ void transponderUpdate(timeUs_t currentTimeUs) void transponderInit(void) { - transponderInitialised = transponderIrInit(transponderConfig()->provider); + transponderInitialised = transponderIrInit(transponderConfig()->ioTag, transponderConfig()->provider); if (!transponderInitialised) { return; } diff --git a/src/main/io/transponder_ir.h b/src/main/io/transponder_ir.h index 155d78eb93..2b67ac0783 100644 --- a/src/main/io/transponder_ir.h +++ b/src/main/io/transponder_ir.h @@ -24,6 +24,7 @@ typedef struct transponderConfig_s { transponderProvider_e provider; uint8_t reserved; uint8_t data[9]; + ioTag_t ioTag; } transponderConfig_t; typedef struct transponderRequirement_s {