|
|
|
|
@ -23,19 +23,18 @@
|
|
|
|
|
#include "POCSAGTX.h"
|
|
|
|
|
#include "POCSAGDefines.h"
|
|
|
|
|
|
|
|
|
|
CPOCSAGTX::CPOCSAGTX() :
|
|
|
|
|
m_buffer(1000U),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CPOCSAGTX::CPOCSAGTX(): m_buffer(1000U),
|
|
|
|
|
m_poBuffer(),
|
|
|
|
|
m_poLen(0U),
|
|
|
|
|
m_poPtr(0U),
|
|
|
|
|
m_txDelay(POCSAG_PREAMBLE_LENGTH_BYTES),
|
|
|
|
|
m_delay(false),
|
|
|
|
|
m_cal(false)
|
|
|
|
|
{
|
|
|
|
|
m_cal(false) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPOCSAGTX::process()
|
|
|
|
|
{
|
|
|
|
|
void CPOCSAGTX::process() {
|
|
|
|
|
if (m_cal) {
|
|
|
|
|
m_delay = false;
|
|
|
|
|
createCal();
|
|
|
|
|
@ -47,8 +46,9 @@ void CPOCSAGTX::process()
|
|
|
|
|
m_poLen = m_txDelay;
|
|
|
|
|
} else {
|
|
|
|
|
m_delay = false;
|
|
|
|
|
for (uint8_t i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++)
|
|
|
|
|
for (uint8_t i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) {
|
|
|
|
|
m_poBuffer[i] = m_buffer.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_poLen = POCSAG_FRAME_LENGTH_BYTES;
|
|
|
|
|
}
|
|
|
|
|
@ -62,8 +62,9 @@ void CPOCSAGTX::process()
|
|
|
|
|
if (m_delay) {
|
|
|
|
|
m_poPtr++;
|
|
|
|
|
writeByte(POCSAG_SYNC);
|
|
|
|
|
} else
|
|
|
|
|
} else {
|
|
|
|
|
writeByte(m_poBuffer[m_poPtr++]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
space -= 8U;
|
|
|
|
|
|
|
|
|
|
@ -77,16 +78,15 @@ void CPOCSAGTX::process()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPOCSAGTX::busy()
|
|
|
|
|
{
|
|
|
|
|
if (m_poLen > 0U || m_buffer.getData() > 0U)
|
|
|
|
|
bool CPOCSAGTX::busy() {
|
|
|
|
|
if (m_poLen > 0U || m_buffer.getData() > 0U) {
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t CPOCSAGTX::writeData(const uint8_t* data, uint8_t length)
|
|
|
|
|
{
|
|
|
|
|
uint8_t CPOCSAGTX::writeData(const uint8_t* data, uint8_t length) {
|
|
|
|
|
if (length != POCSAG_FRAME_LENGTH_BYTES)
|
|
|
|
|
return 4U;
|
|
|
|
|
|
|
|
|
|
@ -100,36 +100,34 @@ uint8_t CPOCSAGTX::writeData(const uint8_t* data, uint8_t length)
|
|
|
|
|
return 0U;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPOCSAGTX::writeByte(uint8_t c)
|
|
|
|
|
{
|
|
|
|
|
void CPOCSAGTX::writeByte(uint8_t c) {
|
|
|
|
|
uint8_t bit;
|
|
|
|
|
uint8_t mask = 0x80U;
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0U; i < 8U; i++, c <<= 1) {
|
|
|
|
|
if ((c & mask) == mask)
|
|
|
|
|
if ((c & mask) == mask) {
|
|
|
|
|
bit = 1U;
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
bit = 0U;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
io.write(&bit, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPOCSAGTX::setTXDelay(uint8_t delay)
|
|
|
|
|
{
|
|
|
|
|
void CPOCSAGTX::setTXDelay(uint8_t delay) {
|
|
|
|
|
m_txDelay = POCSAG_PREAMBLE_LENGTH_BYTES + (delay * 3U) / 2U;
|
|
|
|
|
|
|
|
|
|
if (m_txDelay > 150U)
|
|
|
|
|
if (m_txDelay > 150U) {
|
|
|
|
|
m_txDelay = 150U;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t CPOCSAGTX::getSpace() const
|
|
|
|
|
{
|
|
|
|
|
uint8_t CPOCSAGTX::getSpace() const {
|
|
|
|
|
return m_buffer.getSpace() / POCSAG_FRAME_LENGTH_BYTES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t CPOCSAGTX::setCal(const uint8_t* data, uint8_t length)
|
|
|
|
|
{
|
|
|
|
|
uint8_t CPOCSAGTX::setCal(const uint8_t* data, uint8_t length) {
|
|
|
|
|
if (length != 1U)
|
|
|
|
|
return 4U;
|
|
|
|
|
|
|
|
|
|
@ -141,8 +139,7 @@ uint8_t CPOCSAGTX::setCal(const uint8_t* data, uint8_t length)
|
|
|
|
|
return 0U;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPOCSAGTX::createCal()
|
|
|
|
|
{
|
|
|
|
|
void CPOCSAGTX::createCal() {
|
|
|
|
|
// 600 Hz square wave generation
|
|
|
|
|
for (unsigned int i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) {
|
|
|
|
|
m_poBuffer[i] = 0xAAU;
|
|
|
|
|
|