mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-09-21 20:39:35 +00:00
archive: freeze IR-protocol WIP before stepwise integration
This commit is contained in:
@ -20,7 +20,7 @@ static constexpr uint16_t kIrDeviceAddr = 0;
|
||||
static constexpr uint8_t kCmdVersion = 0x5E;
|
||||
static constexpr uint32_t kSerialBaud = 115200;
|
||||
static constexpr uint32_t kSendPeriodMs = 500;
|
||||
static constexpr uint8_t kMaxPayload = bytePerPack;
|
||||
static constexpr uint8_t kMaxPayload = irproto::kMaxDataPayloadBytes;
|
||||
static constexpr uint8_t kMaxParamBytes = kMaxPayload - 1;
|
||||
|
||||
static IR_Encoder enc(PIN_IR_ENC_FORWARD, kIrDeviceAddr, nullptr);
|
||||
@ -30,15 +30,23 @@ static HardwareTimer irTimer(TIM17);
|
||||
namespace {
|
||||
constexpr size_t kIrDmaStreams = 1;
|
||||
constexpr uint16_t kIrDmaTxWordCount = 4096U;
|
||||
constexpr size_t kIrDmaTxMaxGateRuns = 1024U;
|
||||
// This example accepts the full uint8_t carrier-multiply configuration range.
|
||||
constexpr uint16_t kIrDmaMaxCarrierMultiply = UINT8_MAX;
|
||||
constexpr size_t kIrDmaTxMaxGateRuns =
|
||||
irproto::maxPhysicalGateRunCapacity(kIrDmaMaxCarrierMultiply);
|
||||
static uint32_t s_irDmaWords[kIrDmaTxWordCount];
|
||||
static IR_Encoder::IR_TxGateRun s_irGateRuns[kIrDmaTxMaxGateRuns];
|
||||
} // namespace
|
||||
|
||||
static IrDmaTxStm32<kIrDmaStreams> dmaBackend;
|
||||
static bool txBusy(void * /*ctx*/) { return dmaBackend.busy(); }
|
||||
static bool txStart(void * /*ctx*/, IR_Encoder *e, const uint8_t *packet, uint8_t len) {
|
||||
return dmaBackend.start(e, packet, len);
|
||||
static IR_SendStatus txStart(void * /*ctx*/,
|
||||
IR_Encoder *e,
|
||||
const uint8_t *packet,
|
||||
uint8_t len,
|
||||
const IR_TxPlan& plan,
|
||||
uint32_t operationId) {
|
||||
return dmaBackend.startTracked(e, packet, len, plan, operationId);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -51,7 +59,11 @@ static bool s_sendLongerFrame = false;
|
||||
// 24 байта total: msg(1)+addr(2)+addr(2)+data(17)+crc(2), где data=0x5E + 16 ASCII.
|
||||
static const char kPayload16[] = "Car_v4.3.9_[12MH";
|
||||
// 25 байт total: как выше, но data=0x5E + 17 ASCII.
|
||||
static const char kPayload17[] = "Car_v4.3.9_[12MHz]_G491";
|
||||
static const char kPayload17[] = "Car_v4.3.9_[12MHz";
|
||||
static_assert(sizeof(kPayload16) - 1U == 16U, "24-byte frame fixture changed");
|
||||
static_assert(sizeof(kPayload17) - 1U == 17U, "25-byte frame fixture changed");
|
||||
static_assert(kMaxParamBytes == irproto::kMaxDataPayloadBytes - 1U,
|
||||
"longData command parameter capacity must follow the DATA wire contract");
|
||||
|
||||
static void rebuildIrPayload() {
|
||||
s_irPayload[0] = kCmdVersion;
|
||||
@ -110,7 +122,7 @@ void setup() {
|
||||
Serial.println(F("[IR_DMA] init FAILED"));
|
||||
return;
|
||||
}
|
||||
IR_Encoder::setExternalTxBackend(txStart, txBusy, nullptr);
|
||||
IR_Encoder::setExternalTxBackendV2(txStart, txBusy, nullptr);
|
||||
#elif LONGDATA_LEGACY_ISR
|
||||
IR_Encoder::begin(&irTimer, 1, TIM17_IRQn, 0);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user