mirror of
https://github.com/g4klx/MMDVM_HS.git
synced 2025-12-06 07:02:00 +01:00
Full memory optimization for ring buffer
This commit is contained in:
parent
1fec6e5f77
commit
ab929d2bd2
|
|
@ -36,7 +36,7 @@ m_full(false),
|
|||
m_overflow(false)
|
||||
{
|
||||
m_bits = new uint8_t[length / 8U];
|
||||
m_control = new uint8_t[length];
|
||||
m_control = new uint8_t[length / 8U];
|
||||
}
|
||||
|
||||
uint16_t CBitRB::getSpace() const
|
||||
|
|
@ -74,7 +74,7 @@ bool CBitRB::put(uint8_t bit, uint8_t control)
|
|||
}
|
||||
|
||||
WRITE_BIT1(m_bits, m_head, bit);
|
||||
m_control[m_head] = control;
|
||||
WRITE_BIT1(m_control, m_head, control);
|
||||
|
||||
m_head++;
|
||||
if (m_head >= m_length)
|
||||
|
|
@ -92,7 +92,7 @@ bool CBitRB::get(uint8_t& bit, uint8_t& control)
|
|||
return false;
|
||||
|
||||
bit = READ_BIT1(m_bits, m_tail);
|
||||
control = m_control[m_tail];
|
||||
control = READ_BIT1(m_control, m_tail);
|
||||
|
||||
m_full = false;
|
||||
|
||||
|
|
|
|||
18
DMRRX.cpp
18
DMRRX.cpp
|
|
@ -24,23 +24,21 @@
|
|||
#include "Globals.h"
|
||||
#include "DMRRX.h"
|
||||
|
||||
CDMRRX::CDMRRX()
|
||||
CDMRRX::CDMRRX() :
|
||||
m_control_old(0U)
|
||||
{
|
||||
}
|
||||
|
||||
void CDMRRX::databit(bool bit, const uint8_t control)
|
||||
{
|
||||
switch (control) {
|
||||
case MARK_SLOT1:
|
||||
m_slotRX.start(false);
|
||||
break;
|
||||
case MARK_SLOT2:
|
||||
if (control != m_control_old) {
|
||||
m_control_old = control;
|
||||
if (control)
|
||||
m_slotRX.start(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
else
|
||||
m_slotRX.start(false);
|
||||
}
|
||||
|
||||
|
||||
io.setDecode(m_slotRX.databit(bit));
|
||||
}
|
||||
|
||||
|
|
|
|||
1
DMRRX.h
1
DMRRX.h
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
private:
|
||||
CDMRSlotRX m_slotRX;
|
||||
uint8_t m_control_old;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
18
DMRTX.cpp
18
DMRTX.cpp
|
|
@ -59,7 +59,8 @@ m_poBuffer(),
|
|||
m_poLen(0U),
|
||||
m_poPtr(0U),
|
||||
m_frameCount(0U),
|
||||
m_abort()
|
||||
m_abort(),
|
||||
m_control_old(0U)
|
||||
{
|
||||
::memcpy(m_newShortLC, EMPTY_SHORT_LC, 12U);
|
||||
::memcpy(m_shortLC, EMPTY_SHORT_LC, 12U);
|
||||
|
|
@ -218,21 +219,24 @@ void CDMRTX::writeByte(uint8_t c, uint8_t control)
|
|||
{
|
||||
uint8_t bit;
|
||||
uint8_t mask = 0x80U;
|
||||
uint8_t control_tmp;
|
||||
uint8_t control_tmp = m_control_old;
|
||||
|
||||
for (uint8_t i = 0U; i < 8U; i++, c <<= 1) {
|
||||
if ((c & mask) == mask)
|
||||
bit = 1U;
|
||||
else
|
||||
bit = 0U;
|
||||
|
||||
control_tmp = MARK_NONE;
|
||||
|
||||
if( i == 7U || i == 6U)
|
||||
control_tmp = control;
|
||||
if(i == 7U) {
|
||||
if (control == MARK_SLOT2)
|
||||
control_tmp = true;
|
||||
else if (control == MARK_SLOT1)
|
||||
control_tmp = false;
|
||||
|
||||
m_control_old = control_tmp;
|
||||
}
|
||||
|
||||
io.write(&bit, 1, &control_tmp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue