mirror of https://github.com/g4klx/MMDVM.git
Merge pull request #262 from F4FXL/FM_Ext
Still some work in progress to fix no TX
This commit is contained in:
commit
6d0e57ea88
66
FM.cpp
66
FM.cpp
|
@ -20,10 +20,8 @@
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FM.h"
|
#include "FM.h"
|
||||||
|
|
||||||
const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
|
const uint16_t FM_TX_BLOCK_SIZE = 250U;
|
||||||
|
const uint16_t FM_SERIAL_BLOCK_SIZE = 127U;
|
||||||
#define WRITE_BIT_AUDIO(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
|
|
||||||
#define READ_BIT_AUDIO(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
|
|
||||||
|
|
||||||
CFM::CFM() :
|
CFM::CFM() :
|
||||||
m_callsign(),
|
m_callsign(),
|
||||||
|
@ -64,7 +62,7 @@ m_inputExtRB(2400U) // 100ms of Audio
|
||||||
insertDelay(100U);
|
insertDelay(100U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
void CFM::samples(bool cos, q15_t* samples, uint8_t length)
|
||||||
{
|
{
|
||||||
if (m_useCOS) {
|
if (m_useCOS) {
|
||||||
if (m_cosInvert)
|
if (m_cosInvert)
|
||||||
|
@ -149,19 +147,58 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
|
||||||
currentSample += m_ctcssTX.getAudio();
|
currentSample += m_ctcssTX.getAudio();
|
||||||
|
|
||||||
m_outputRFRB.put(currentSample);
|
m_outputRFRB.put(currentSample);
|
||||||
|
//samples[i] = currentSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX This relays audio correctly, no tones yet, process need to be commented
|
||||||
|
// if (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF || m_state == FS_RELAYING_EXT || m_state == FS_KERCHUNK_EXT)
|
||||||
|
// io.write(STATE_FM, samples, i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFM::process()
|
void CFM::process()
|
||||||
{
|
{
|
||||||
q15_t sample;
|
uint16_t space = io.getSpace() - 2U;
|
||||||
while (io.getSpace() >= 3U && m_outputRFRB.get(sample))
|
uint16_t length = m_outputRFRB.getData();
|
||||||
io.write(STATE_FM, &sample, 1U);
|
if (space > 2 && length >= FM_TX_BLOCK_SIZE ) {
|
||||||
|
|
||||||
uint8_t serialSample;
|
if(length > FM_TX_BLOCK_SIZE)
|
||||||
//write data to serial port
|
length = FM_TX_BLOCK_SIZE;
|
||||||
while (m_downsampler.getPackedData(serialSample))
|
if(space > FM_TX_BLOCK_SIZE)
|
||||||
serial.writeFMData(&serialSample, 1U);
|
space = FM_TX_BLOCK_SIZE;
|
||||||
|
if(length > space)
|
||||||
|
length = space;
|
||||||
|
|
||||||
|
q15_t samples[FM_TX_BLOCK_SIZE];
|
||||||
|
for(uint16_t i = 0U; i < length; i++) {
|
||||||
|
q15_t sample = 0;
|
||||||
|
m_outputRFRB.get(sample);
|
||||||
|
samples[i] = sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
io.write(STATE_FM, samples, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// //Write audio to serial
|
||||||
|
// if (m_downsampler.getData() >= 127 || m_state != STATE_FM) {//if we just left FM mode, so write all what is left in buffer, regardless of the amoutn of data
|
||||||
|
// uint16_t length = m_downsampler.getData();
|
||||||
|
|
||||||
|
// if(length > FM_SERIAL_BLOCK_SIZE)//max message size on serial is 127
|
||||||
|
// length = FM_SERIAL_BLOCK_SIZE;
|
||||||
|
|
||||||
|
// if(length > FM_SERIAL_BLOCK_SIZE)
|
||||||
|
// length = FM_SERIAL_BLOCK_SIZE;
|
||||||
|
|
||||||
|
// uint8_t serialSamples[FM_SERIAL_BLOCK_SIZE];
|
||||||
|
|
||||||
|
// for(uint16_t i = 0U; i < length; i++) {
|
||||||
|
// uint8_t serialSample = 0U;
|
||||||
|
// m_downsampler.getPackedData(serialSample);
|
||||||
|
// serialSamples[i] = serialSample;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// serial.writeFMData(serialSamples, length);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFM::reset()
|
void CFM::reset()
|
||||||
|
@ -290,6 +327,11 @@ void CFM::stateMachine(bool validRFSignal, bool validExtSignal)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_state == FS_LISTENING) {
|
||||||
|
m_outputRFRB.reset();
|
||||||
|
m_downsampler.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFM::clock(uint8_t length)
|
void CFM::clock(uint8_t length)
|
||||||
|
|
3
FM.h
3
FM.h
|
@ -51,7 +51,7 @@ class CFM {
|
||||||
public:
|
public:
|
||||||
CFM();
|
CFM();
|
||||||
|
|
||||||
void samples(bool cos, const q15_t* samples, uint8_t length);
|
void samples(bool cos, q15_t* samples, uint8_t length);
|
||||||
|
|
||||||
void process();
|
void process();
|
||||||
|
|
||||||
|
@ -117,6 +117,7 @@ private:
|
||||||
void clock(uint8_t length);
|
void clock(uint8_t length);
|
||||||
|
|
||||||
void sendCallsign();
|
void sendCallsign();
|
||||||
|
void sendBeeps();
|
||||||
void beginRelaying();
|
void beginRelaying();
|
||||||
|
|
||||||
void insertDelay(uint16_t ms);
|
void insertDelay(uint16_t ms);
|
||||||
|
|
|
@ -28,7 +28,7 @@ m_samplePackPointer(NULL),
|
||||||
m_packIndex(0U),
|
m_packIndex(0U),
|
||||||
m_downSampleIndex(0U)
|
m_downSampleIndex(0U)
|
||||||
{
|
{
|
||||||
m_samplePackPointer = &m_samplePack;
|
m_samplePackPointer = &m_samplePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFMDownsampler::addSample(q15_t sample)
|
void CFMDownsampler::addSample(q15_t sample)
|
||||||
|
@ -55,7 +55,7 @@ void CFMDownsampler::addSample(q15_t sample)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_packIndex++;
|
m_packIndex++;
|
||||||
if(m_packIndex >= 2U)//did we pack to samples ?
|
if(m_packIndex >= 2U)//did we pack two samples ?
|
||||||
m_packIndex = 0U;
|
m_packIndex = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,11 @@ bool CFMDownsampler::getPackedData(uint8_t& data)
|
||||||
return m_ringBuffer.get(data);
|
return m_ringBuffer.get(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t CFMDownsampler::getData()
|
||||||
|
{
|
||||||
|
return m_ringBuffer.getData();
|
||||||
|
}
|
||||||
|
|
||||||
void CFMDownsampler::reset()
|
void CFMDownsampler::reset()
|
||||||
{
|
{
|
||||||
m_downSampleIndex = 0;
|
m_downSampleIndex = 0;
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
CFMDownsampler(uint16_t length);
|
CFMDownsampler(uint16_t length);
|
||||||
void addSample(q15_t sample);
|
void addSample(q15_t sample);
|
||||||
bool getPackedData(uint8_t& data);
|
bool getPackedData(uint8_t& data);
|
||||||
|
uint16_t getData();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
2
IO.cpp
2
IO.cpp
|
@ -264,6 +264,7 @@ void CIO::process()
|
||||||
if (m_txBuffer.getData() == 0U && m_tx) {
|
if (m_txBuffer.getData() == 0U && m_tx) {
|
||||||
m_tx = false;
|
m_tx = false;
|
||||||
setPTTInt(m_pttInvert ? true : false);
|
setPTTInt(m_pttInvert ? true : false);
|
||||||
|
DEBUG1("Process TX OFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
|
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
|
||||||
|
@ -453,6 +454,7 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
||||||
if (!m_tx) {
|
if (!m_tx) {
|
||||||
m_tx = true;
|
m_tx = true;
|
||||||
setPTTInt(m_pttInvert ? false : true);
|
setPTTInt(m_pttInvert ? false : true);
|
||||||
|
DEBUG1("Write TX ON");
|
||||||
}
|
}
|
||||||
|
|
||||||
q15_t txLevel = 0;
|
q15_t txLevel = 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/make
|
#!/usr/bin/make
|
||||||
# makefile for the arduino due (works with arduino IDE 1.6.11)
|
# makefile for the arduino due (works with arduino IDE 1.6.12)
|
||||||
#
|
#
|
||||||
# The original file can be found at https://github.com/pauldreik/arduino-due-makefile
|
# The original file can be found at https://github.com/pauldreik/arduino-due-makefile
|
||||||
#
|
#
|
||||||
|
@ -34,7 +34,7 @@ OBJCOPY:=$(ADIR)/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-n
|
||||||
|
|
||||||
C:=$(CC)
|
C:=$(CC)
|
||||||
#SAM:=arduino/sam/
|
#SAM:=arduino/sam/
|
||||||
SAM:=$(ADIR)/packages/arduino/hardware/sam/1.6.11
|
SAM:=$(ADIR)/packages/arduino/hardware/sam/1.6.12
|
||||||
#CMSIS:=arduino/sam/system/CMSIS/
|
#CMSIS:=arduino/sam/system/CMSIS/
|
||||||
#LIBSAM:=arduino/sam/system/libsam
|
#LIBSAM:=arduino/sam/system/libsam
|
||||||
TMPDIR:=$(PWD)/build
|
TMPDIR:=$(PWD)/build
|
||||||
|
|
Loading…
Reference in New Issue