mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-04-28 11:18:15 +00:00
fix timer overflow?
This commit is contained in:
@ -77,9 +77,9 @@ void IrFoxDecoder::first_rx()
|
||||
|
||||
void IrFoxDecoder::listen_start(double t_us)
|
||||
{
|
||||
(void)t_us;
|
||||
const uint32_t irmax = irfox::irTimeoutUs(rise_sync_time_us);
|
||||
if (is_recive_raw && (t_us - prev_rise_us) > irmax * 2.0)
|
||||
// Как IR_DecoderRaw::listenStart: пауза по lastEdgeTime, не по prevRise.
|
||||
if (is_recive_raw && last_edge_time_us > 0.0 && (t_us - last_edge_time_us) > irmax * 2.0)
|
||||
{
|
||||
is_recive_raw = false;
|
||||
first_rx();
|
||||
@ -93,9 +93,12 @@ void IrFoxDecoder::check_timeout(double t_us)
|
||||
const uint32_t irmax = irfox::irTimeoutUs(rise_sync_time_us);
|
||||
if (t_us - last_edge_time_us > irmax * 2.0)
|
||||
{
|
||||
// Как IR_DecoderRaw::checkTimeout после фикса: полный сброс, иначе залипание FSM.
|
||||
is_recive = false;
|
||||
msg_type_receive = 0;
|
||||
last_edge_time_us = t_us;
|
||||
is_recive_raw = false;
|
||||
first_rx();
|
||||
// Не last_edge_time_us = t_us: как IR_DecoderRaw — не расходить с «хвостом» фронтов.
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,9 +124,8 @@ void IrFoxDecoder::write_to_buffer(bool bit, bool pack_trace_invert_fix, uint64_
|
||||
|
||||
if (is_buffer_overflow || is_preamb || is_wrong_pack)
|
||||
{
|
||||
is_recive = false;
|
||||
is_recive_raw = false;
|
||||
msg_type_receive = 0;
|
||||
// Как IR_DecoderRaw::writeToBuffer: полный first_rx() вместо только сброса флагов приёма.
|
||||
first_rx();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -254,7 +256,8 @@ void IrFoxDecoder::processEdge(uint64_t sample, bool rising, uint32_t fs, const
|
||||
|
||||
listen_start(t_us);
|
||||
|
||||
if (have_last_processed && (t_us - last_processed_edge_us) > irmax * 2.0 && is_recive)
|
||||
// Как IR_DecoderRaw: пауза между фронтами по lastEdgeTime при активном приёме кадра.
|
||||
if (last_edge_time_us > 0.0 && (t_us - last_edge_time_us) > irmax * 2.0 && is_recive)
|
||||
check_timeout(t_us);
|
||||
|
||||
last_edge_time_us = t_us;
|
||||
@ -354,7 +357,7 @@ void IrFoxDecoder::processEdge(uint64_t sample, bool rising, uint32_t fs, const
|
||||
}
|
||||
}
|
||||
|
||||
// IR_DecoderRaw::tick (STM32DMA): без firstRX(); старт сырого приёма только этим блоком.
|
||||
// Как IR_DecoderRaw::tick: после длинной паузы старт сырого приёма (без отдельного firstRX — флаги ниже).
|
||||
if (t_us > prev_rise_us && (t_us - prev_rise_us) > irmax * 2.0 && !is_recive_raw)
|
||||
{
|
||||
preamb_front_counter = static_cast<int8_t>(irfox::kPreambFronts - 1);
|
||||
@ -583,6 +586,7 @@ void IrFoxDecoder::processEdge(uint64_t sample, bool rising, uint32_t fs, const
|
||||
void IrFoxDecoder::flushEnd(uint64_t last_sample, uint32_t fs, const IrFoxOnBit& on_bit, const IrFoxOnPacket& on_pkt)
|
||||
{
|
||||
const double t_us = sample_to_us(last_sample, fs);
|
||||
listen_start(t_us);
|
||||
check_timeout(t_us);
|
||||
(void)on_bit;
|
||||
(void)on_pkt;
|
||||
|
||||
Reference in New Issue
Block a user