Add ramp for smooth transition on FSK
This commit is contained in:
parent
19956d2635
commit
5475c41ccf
5 changed files with 246 additions and 221 deletions
|
@ -283,9 +283,9 @@ void SimpleTestAm(uint64_t Freq)
|
||||||
void SimpleTestOOK(uint64_t Freq)
|
void SimpleTestOOK(uint64_t Freq)
|
||||||
{
|
{
|
||||||
|
|
||||||
int SR = 1000;
|
int SR = 10; //10 HZ
|
||||||
int FifoSize = 21; //24
|
int FifoSize = 21; //24
|
||||||
ookburst ook(Freq, SR, 14, FifoSize);
|
ookburst ook(Freq, SR, 14, FifoSize,100);
|
||||||
|
|
||||||
unsigned char TabSymbol[FifoSize] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0};
|
unsigned char TabSymbol[FifoSize] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0};
|
||||||
|
|
||||||
|
@ -733,6 +733,6 @@ int main(int argc, char *argv[])
|
||||||
//SimpleTestBurstFsk(Freq);
|
//SimpleTestBurstFsk(Freq);
|
||||||
//SimpleTestOOKTiming(Freq);
|
//SimpleTestOOKTiming(Freq);
|
||||||
//AlectoOOK(Freq);
|
//AlectoOOK(Freq);
|
||||||
//RfSwitchOOK(Freq);
|
RfSwitchOOK(Freq);
|
||||||
SimpleTestAtv(Freq);
|
//SimpleTestAtv(Freq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,24 +20,25 @@ This program is free software: you can redistribute it and/or modify
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
fskburst::fskburst(uint64_t TuneFrequency,uint32_t SymbolRate,float Deviation,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+3,2,1),freqdeviation(Deviation)
|
fskburst::fskburst(uint64_t TuneFrequency, float SymbolRate, float Deviation, int Channel, uint32_t FifoSize, size_t upsample,float RatioRamp) : bufferdma(Channel, FifoSize * upsample + 3, 2, 1), freqdeviation(Deviation), SR_upsample(upsample)
|
||||||
{
|
{
|
||||||
|
|
||||||
clkgpio::SetAdvancedPllMode(true);
|
clkgpio::SetAdvancedPllMode(true);
|
||||||
clkgpio::SetCenterFrequency(TuneFrequency,SymbolRate); // Write Mult Int and Frac : FixMe carrier is already there
|
clkgpio::SetCenterFrequency(TuneFrequency, Deviation*10); // Write Mult Int and Frac : FixMe carrier is already there
|
||||||
clkgpio::SetFrequency(0);
|
clkgpio::SetFrequency(0);
|
||||||
disableclk(4);
|
disableclk(4);
|
||||||
syncwithpwm = false;
|
syncwithpwm = false;
|
||||||
|
Ramp = SR_upsample * RatioRamp; //Ramp time = 10%
|
||||||
|
|
||||||
if (syncwithpwm)
|
if (syncwithpwm)
|
||||||
{
|
{
|
||||||
pwmgpio::SetPllNumber(clk_plld, 1);
|
pwmgpio::SetPllNumber(clk_plld, 1);
|
||||||
pwmgpio::SetFrequency(SymbolRate);
|
pwmgpio::SetFrequency(SymbolRate * (float)SR_upsample);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pcmgpio::SetPllNumber(clk_plld, 1);
|
pcmgpio::SetPllNumber(clk_plld, 1);
|
||||||
pcmgpio::SetFrequency(SymbolRate);
|
pcmgpio::SetFrequency(SymbolRate * (float)SR_upsample);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Should be obligatory place before setdmaalgo
|
//Should be obligatory place before setdmaalgo
|
||||||
|
@ -45,9 +46,6 @@ This program is free software: you can redistribute it and/or modify
|
||||||
dbg_printf(1, "FSK Origin fsel %x\n", Originfsel);
|
dbg_printf(1, "FSK Origin fsel %x\n", Originfsel);
|
||||||
|
|
||||||
SetDmaAlgo();
|
SetDmaAlgo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fskburst::~fskburst()
|
fskburst::~fskburst()
|
||||||
|
@ -71,22 +69,18 @@ This program is free software: you can redistribute it and/or modify
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetEasyCB(cbp++, 0, dma_pcm, 64 + 1);
|
SetEasyCB(cbp++, 0, dma_pcm, 64 + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEasyCB(cbp++, buffersize * registerbysample - 2, dma_fsel, 1); //Enable clk
|
SetEasyCB(cbp++, buffersize * registerbysample - 2, dma_fsel, 1); //Enable clk
|
||||||
|
|
||||||
|
|
||||||
for (uint32_t samplecnt = 0; samplecnt < buffersize - 2; samplecnt++)
|
for (uint32_t samplecnt = 0; samplecnt < buffersize - 2; samplecnt++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Write a frequency sample
|
// Write a frequency sample
|
||||||
SetEasyCB(cbp++, samplecnt * registerbysample, dma_pllc_frac, 1); //FReq
|
SetEasyCB(cbp++, samplecnt * registerbysample, dma_pllc_frac, 1); //FReq
|
||||||
|
|
||||||
// Delay
|
// Delay
|
||||||
SetEasyCB(cbp++, samplecnt * registerbysample, syncwithpwm ? dma_pwm : dma_pcm, 1);
|
SetEasyCB(cbp++, samplecnt * registerbysample, syncwithpwm ? dma_pwm : dma_pcm, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
lastcbp = cbp;
|
lastcbp = cbp;
|
||||||
|
|
||||||
|
@ -98,30 +92,52 @@ This program is free software: you can redistribute it and/or modify
|
||||||
}
|
}
|
||||||
void fskburst::SetSymbols(unsigned char *Symbols, uint32_t Size)
|
void fskburst::SetSymbols(unsigned char *Symbols, uint32_t Size)
|
||||||
{
|
{
|
||||||
if(Size>buffersize-3) {dbg_printf(1,"Buffer overflow\n");return;}
|
if (Size > buffersize - 3)
|
||||||
|
{
|
||||||
|
dbg_printf(1, "Buffer overflow\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dma_cb_t *cbp = cbarray;
|
dma_cb_t *cbp = cbarray;
|
||||||
cbp += 2; // Skip the first 2 CB (initialisation)
|
cbp += 2; // Skip the first 2 CB (initialisation)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < Size; i++)
|
for (unsigned int i = 0; i < Size; i++)
|
||||||
{
|
{
|
||||||
sampletab[i]=(0x5A<<24)|GetMasterFrac(freqdeviation*Symbols[i]);
|
for (size_t j = 0; j < SR_upsample - Ramp; j++)
|
||||||
|
{
|
||||||
|
sampletab[i * SR_upsample + j] = (0x5A << 24) | GetMasterFrac(freqdeviation * Symbols[i]);
|
||||||
cbp++; //SKIP FREQ CB
|
cbp++; //SKIP FREQ CB
|
||||||
cbp->next = mem_virt_to_phys(cbp + 1);
|
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||||
cbp++;
|
cbp++;
|
||||||
}
|
}
|
||||||
|
for (size_t j = 0 ; j < Ramp; j++)
|
||||||
|
{
|
||||||
|
if (i < Size - 1)
|
||||||
|
{
|
||||||
|
sampletab[i * SR_upsample + j + SR_upsample - Ramp] = (0x5A << 24) | GetMasterFrac(freqdeviation * Symbols[i] + j* (freqdeviation * Symbols[i + 1] - freqdeviation * Symbols[i]) / (float)Ramp);
|
||||||
|
dbg_printf(2, "Ramp %f ->%f : %d %f\n",freqdeviation * Symbols[i],freqdeviation * Symbols[i+1], j,freqdeviation * Symbols[i] + j* (freqdeviation * Symbols[i + 1] - freqdeviation * Symbols[i]) / (float)Ramp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sampletab[i * SR_upsample + j + SR_upsample -Ramp] = (0x5A << 24) | GetMasterFrac(freqdeviation * Symbols[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cbp++; //SKIP FREQ CB
|
||||||
|
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||||
|
cbp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
cbp--;
|
cbp--;
|
||||||
cbp->next = mem_virt_to_phys(lastcbp);
|
cbp->next = mem_virt_to_phys(lastcbp);
|
||||||
|
|
||||||
|
|
||||||
dma::start();
|
dma::start();
|
||||||
while (isrunning()) //Block function : return until sent completely signal
|
while (isrunning()) //Block function : return until sent completely signal
|
||||||
{
|
{
|
||||||
//dbg_printf(1,"GPIO %x\n",clkgpio::gengpio.gpioreg[GPFSEL0]);
|
//dbg_printf(1,"GPIO %x\n",clkgpio::gengpio.gpioreg[GPFSEL0]);
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
dbg_printf(1, "FSK burst end Tx\n", cbp->src, cbp->dst, cbp->next);
|
dbg_printf(1, "FSK burst end Tx\n", cbp->src, cbp->dst, cbp->next);
|
||||||
usleep(100); //To be sure last symbol Tx ?
|
usleep(100); //To be sure last symbol Tx ?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@ class fskburst:public bufferdma,public clkgpio,public pwmgpio,public pcmgpio
|
||||||
uint32_t Originfsel;
|
uint32_t Originfsel;
|
||||||
bool syncwithpwm;
|
bool syncwithpwm;
|
||||||
dma_cb_t *lastcbp;
|
dma_cb_t *lastcbp;
|
||||||
|
size_t SR_upsample=0;
|
||||||
|
size_t Ramp=0;
|
||||||
public:
|
public:
|
||||||
fskburst(uint64_t TuneFrequency,uint32_t SymbolRate,float Deviation,int Channel,uint32_t FifoSize);
|
fskburst(uint64_t TuneFrequency,float SymbolRate,float Deviation,int Channel,uint32_t FifoSize,size_t upsample=1,float RatioRamp=0);
|
||||||
~fskburst();
|
~fskburst();
|
||||||
void SetDmaAlgo();
|
void SetDmaAlgo();
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ This program is free software: you can redistribute it and/or modify
|
||||||
#include "ookburst.h"
|
#include "ookburst.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
ookburst::ookburst(uint64_t TuneFrequency, float SymbolRate, int Channel, uint32_t FifoSize, size_t upsample, float RatioRamp) : bufferdma(Channel, FifoSize * upsample + 2, 2, 1),SR_upsample(upsample)
|
||||||
ookburst::ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+2,2,1)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
clkgpio::SetAdvancedPllMode(true);
|
clkgpio::SetAdvancedPllMode(true);
|
||||||
|
@ -30,24 +29,21 @@ This program is free software: you can redistribute it and/or modify
|
||||||
clkgpio::SetFrequency(0);
|
clkgpio::SetFrequency(0);
|
||||||
|
|
||||||
syncwithpwm = false;
|
syncwithpwm = false;
|
||||||
|
Ramp = SR_upsample * RatioRamp; //Ramp time
|
||||||
|
|
||||||
if (syncwithpwm)
|
if (syncwithpwm)
|
||||||
{
|
{
|
||||||
pwmgpio::SetPllNumber(clk_plld, 1);
|
pwmgpio::SetPllNumber(clk_plld, 1);
|
||||||
pwmgpio::SetFrequency(SymbolRate);
|
pwmgpio::SetFrequency(SymbolRate * (float)upsample);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pcmgpio::SetPllNumber(clk_plld, 1);
|
pcmgpio::SetPllNumber(clk_plld, 1);
|
||||||
pcmgpio::SetFrequency(SymbolRate);
|
pcmgpio::SetFrequency(SymbolRate * float(upsample));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Originfsel = clkgpio::gengpio.gpioreg[GPFSEL0];
|
Originfsel = clkgpio::gengpio.gpioreg[GPFSEL0];
|
||||||
SetDmaAlgo();
|
SetDmaAlgo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ookburst::~ookburst()
|
ookburst::~ookburst()
|
||||||
|
@ -67,7 +63,6 @@ This program is free software: you can redistribute it and/or modify
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetEasyCB(cbp++, 0, dma_pcm, 64 + 1);
|
SetEasyCB(cbp++, 0, dma_pcm, 64 + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t samplecnt = 0; samplecnt < buffersize - 2; samplecnt++)
|
for (uint32_t samplecnt = 0; samplecnt < buffersize - 2; samplecnt++)
|
||||||
|
@ -77,8 +72,6 @@ This program is free software: you can redistribute it and/or modify
|
||||||
SetEasyCB(cbp++, samplecnt * registerbysample, dma_fsel, 1);
|
SetEasyCB(cbp++, samplecnt * registerbysample, dma_fsel, 1);
|
||||||
// Delay
|
// Delay
|
||||||
SetEasyCB(cbp++, samplecnt * registerbysample, syncwithpwm ? dma_pwm : dma_pcm, 1);
|
SetEasyCB(cbp++, samplecnt * registerbysample, syncwithpwm ? dma_pwm : dma_pcm, 1);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
lastcbp = cbp;
|
lastcbp = cbp;
|
||||||
|
|
||||||
|
@ -86,43 +79,55 @@ This program is free software: you can redistribute it and/or modify
|
||||||
sampletab[buffersize * registerbysample - 1] = (Originfsel & ~(7 << 12)) | (0 << 12); //Disable Clk
|
sampletab[buffersize * registerbysample - 1] = (Originfsel & ~(7 << 12)) | (0 << 12); //Disable Clk
|
||||||
SetEasyCB(cbp, buffersize * registerbysample - 1, dma_fsel, 1);
|
SetEasyCB(cbp, buffersize * registerbysample - 1, dma_fsel, 1);
|
||||||
cbp->next = 0; // Stop DMA
|
cbp->next = 0; // Stop DMA
|
||||||
|
|
||||||
}
|
}
|
||||||
void ookburst::SetSymbols(unsigned char *Symbols, uint32_t Size)
|
void ookburst::SetSymbols(unsigned char *Symbols, uint32_t Size)
|
||||||
{
|
{
|
||||||
if(Size>buffersize-2) {dbg_printf(1,"Buffer overflow\n");return;}
|
if (Size > buffersize - 2)
|
||||||
|
{
|
||||||
|
dbg_printf(1, "Buffer overflow\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dma_cb_t *cbp = cbarray;
|
dma_cb_t *cbp = cbarray;
|
||||||
cbp++; // Skip the first which is the Fiiling of Fifo
|
cbp++; // Skip the first which is the Fiiling of Fifo
|
||||||
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < Size; i++)
|
for (unsigned i = 0; i < Size; i++)
|
||||||
{
|
{
|
||||||
|
for (size_t j = 0; j < SR_upsample - Ramp; j++)
|
||||||
sampletab[i]=(Symbols[i]==0)?((Originfsel & ~(7 << 12)) | (0 << 12)):((Originfsel & ~(7 << 12)) | (4 << 12));
|
{
|
||||||
|
sampletab[i * SR_upsample + j] = (Symbols[i] == 0) ? ((Originfsel & ~(7 << 12)) | (0 << 12)) : ((Originfsel & ~(7 << 12)) | (4 << 12));
|
||||||
cbp++; //SKIP FSEL CB
|
cbp++; //SKIP FSEL CB
|
||||||
cbp->next = mem_virt_to_phys(cbp + 1);
|
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||||
|
|
||||||
//dbg_printf(1,"cbp : sample %d pointer %p src %x dest %x next %x\n",i,cbp,cbp->src,cbp->dst,cbp->next);
|
|
||||||
cbp++;
|
cbp++;
|
||||||
|
}
|
||||||
|
for (size_t j = 0; j < Ramp; j++)
|
||||||
|
{
|
||||||
|
if (i < Size - 1)
|
||||||
|
{
|
||||||
|
sampletab[i * SR_upsample + j + SR_upsample - Ramp] = (Symbols[i] == 0) ? ((Originfsel & ~(7 << 12)) | (0 << 12)) : ((Originfsel & ~(7 << 12)) | (4 << 12));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sampletab[i * SR_upsample + j + SR_upsample - Ramp] = (Symbols[i] == 0) ? ((Originfsel & ~(7 << 12)) | (0 << 12)) : ((Originfsel & ~(7 << 12)) | (4 << 12));
|
||||||
|
}
|
||||||
|
|
||||||
|
cbp++; //SKIP FREQ CB
|
||||||
|
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||||
|
cbp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cbp--;
|
cbp--;
|
||||||
cbp->next = mem_virt_to_phys(lastcbp);
|
cbp->next = mem_virt_to_phys(lastcbp);
|
||||||
|
|
||||||
|
|
||||||
dma::start();
|
dma::start();
|
||||||
|
|
||||||
|
|
||||||
while (isrunning()) //Block function : return until sent completely signal
|
while (isrunning()) //Block function : return until sent completely signal
|
||||||
{
|
{
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
usleep(100); //To be sure last symbol Tx ?
|
usleep(100); //To be sure last symbol Tx ?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//****************************** OOK BURST TIMING *****************************************
|
//****************************** OOK BURST TIMING *****************************************
|
||||||
|
|
|
@ -12,8 +12,10 @@ class ookburst:public bufferdma,public clkgpio,public pwmgpio,public pcmgpio
|
||||||
uint32_t Originfsel;
|
uint32_t Originfsel;
|
||||||
bool syncwithpwm;
|
bool syncwithpwm;
|
||||||
dma_cb_t *lastcbp;
|
dma_cb_t *lastcbp;
|
||||||
|
size_t SR_upsample=1;
|
||||||
|
size_t Ramp=0.0;
|
||||||
public:
|
public:
|
||||||
ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize);
|
ookburst(uint64_t TuneFrequency,float SymbolRate,int Channel,uint32_t FifoSize, size_t upsample=1,float RatioRamp=0.0);
|
||||||
~ookburst();
|
~ookburst();
|
||||||
void SetDmaAlgo();
|
void SetDmaAlgo();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue