Full memory optimization for ring buffer

This commit is contained in:
Andy CA6JAU 2018-07-16 17:20:26 -04:00
parent 1fec6e5f77
commit ab929d2bd2
5 changed files with 24 additions and 20 deletions

View file

@ -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;

View file

@ -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));
}

View file

@ -39,6 +39,7 @@ public:
private:
CDMRSlotRX m_slotRX;
uint8_t m_control_old;
};
#endif

View file

@ -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);
}
}

View file

@ -70,6 +70,7 @@ private:
uint16_t m_poPtr;
uint32_t m_frameCount;
bool m_abort[2U];
uint8_t m_control_old;
void createData(uint8_t slotIndex);
void createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex);