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 608ba4b326..90e8476b72 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" @@ -103,6 +104,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" @@ -2751,6 +2753,9 @@ const cliResourceValue_t resourceTable[] = { #ifdef USE_INVERTER { OWNER_INVERTER, PG_SERIAL_PIN_CONFIG, offsetof(serialPinConfig_t, ioTagInverter[0]), SERIAL_PORT_MAX_INDEX }, #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..f0cb0e4c8f 100644 --- a/src/main/io/transponder_ir.c +++ b/src/main/io/transponder_ir.c @@ -29,6 +29,7 @@ #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,6 +38,7 @@ #include "io/transponder_ir.h" +#if 0 PG_REGISTER_WITH_RESET_TEMPLATE(transponderConfig_t, transponderConfig, PG_TRANSPONDER_CONFIG, 0); PG_RESET_TEMPLATE(transponderConfig_t, transponderConfig, @@ -44,6 +46,27 @@ PG_RESET_TEMPLATE(transponderConfig_t, transponderConfig, .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 ); +#endif +PG_REGISTER_WITH_RESET_FN(transponderConfig_t, transponderConfig, PG_TRANSPONDER_CONFIG, 0); + +void pgResetFn_transponderConfig(transponderConfig_t *transponderConfig) +{ + transponderConfig_t configTemplate = { + .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 + }; + + memcpy(transponderConfig, &configTemplate, sizeof(*transponderConfig)); + + for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) { + if (timerHardware[i].usageFlags & TIM_USE_TRANSPONDER) { + transponderConfig->ioTag = timerHardware[i].tag; + return; + } + } + transponderConfig->ioTag = IO_TAG_NONE; +} static bool transponderInitialised = false; static bool transponderRepeat = false; @@ -95,7 +118,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 {