Initial ook support
This commit is contained in:
parent
aa02b85060
commit
887470a7be
5 changed files with 175 additions and 36 deletions
|
@ -155,7 +155,7 @@ void SimpleTestFileIQ(uint64_t Freq)
|
|||
bool stereo=true;
|
||||
int SR=48000;
|
||||
int FifoSize=512;
|
||||
iqdmasync iqtest(Freq,SR,14,FifoSize);
|
||||
iqdmasync iqtest(Freq,SR,14,FifoSize,MODE_IQ);
|
||||
short IQBuffer[IQBURST*2];
|
||||
std::complex<float> CIQBuffer[IQBURST];
|
||||
while(running)
|
||||
|
@ -303,36 +303,23 @@ void SimpleTestOOK(uint64_t Freq)
|
|||
{
|
||||
|
||||
int SR=2000;
|
||||
int FifoSize=512;
|
||||
amdmasync amtest(Freq,SR,14,FifoSize);
|
||||
|
||||
|
||||
int count=0;
|
||||
int Every=SR/100;
|
||||
float x=0.0;
|
||||
|
||||
int FifoSize=2000;
|
||||
ookburst ook(Freq,SR,14,FifoSize);
|
||||
unsigned char TabSymbol[FifoSize];
|
||||
for(size_t i=0;i<FifoSize/2;i++)
|
||||
{
|
||||
TabSymbol[i]=i%2;
|
||||
}
|
||||
for(size_t i=0;i<FifoSize/2;i++)
|
||||
{
|
||||
TabSymbol[i+FifoSize/2]=0;
|
||||
}
|
||||
while(running)
|
||||
{
|
||||
//usleep(FifoSize*1000000.0*1.0/(8.0*SR));
|
||||
usleep(1);
|
||||
int Available=amtest.GetBufferAvailable();
|
||||
if(Available>256)
|
||||
{
|
||||
int Index=amtest.GetUserMemIndex();
|
||||
for(int i=0;i<Available;i++)
|
||||
{
|
||||
|
||||
if(count<1000)
|
||||
x=0;
|
||||
else
|
||||
x=1.0;
|
||||
amtest.SetAmSample(Index+i,x);
|
||||
count++;
|
||||
if(count>2000) count=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
amtest.stop();
|
||||
ook.SetSymbols(TabSymbol,FifoSize);
|
||||
// sleep(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SimpleTestBurstFsk(uint64_t Freq)
|
||||
|
@ -382,7 +369,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
uint64_t Freq=144200000;
|
||||
if(argc>1)
|
||||
Freq=atol(argv[1]);
|
||||
Freq=atof(argv[1]);
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
struct sigaction sa;
|
||||
|
@ -393,11 +380,11 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
//SimpleTest(Freq);
|
||||
SimpleTestbpsk(Freq);
|
||||
//SimpleTestbpsk(Freq);
|
||||
//SimpleTestFileIQ(Freq);
|
||||
//SimpleTestDMA(Freq);
|
||||
//SimpleTestAm(Freq);
|
||||
//SimpleTestOOK(Freq);
|
||||
SimpleTestOOK(Freq);
|
||||
//SimpleTestBurstFsk(Freq);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ LDFLAGS = -lm -lrt -lpthread
|
|||
CCP = c++
|
||||
CC = cc
|
||||
|
||||
librpitx: librpitx.h gpio.h gpio.cpp dma.h dma.cpp mailbox.c raspberry_pi_revision.c fmdmasync.h fmdmasync.cpp ngfmdmasync.h ngfmdmasync.cpp dsp.h dsp.cpp iqdmasync.h iqdmasync.cpp serialdmasync.h serialdmasync.cpp phasedmasync.h phasedmasync.cpp fskburst.h fskburst.cpp
|
||||
librpitx: librpitx.h gpio.h gpio.cpp dma.h dma.cpp mailbox.c raspberry_pi_revision.c fmdmasync.h fmdmasync.cpp ngfmdmasync.h ngfmdmasync.cpp dsp.h dsp.cpp iqdmasync.h iqdmasync.cpp serialdmasync.h serialdmasync.cpp phasedmasync.h phasedmasync.cpp fskburst.h fskburst.cpp ookburst.cpp ookburst.h
|
||||
$(CC) $(CFLAGS) -c -o mailbox.o mailbox.c
|
||||
$(CC) $(CFLAGS) -c -o raspberry_pi_revision.o raspberry_pi_revision.c
|
||||
$(CCP) $(CXXFLAGS) -c dsp.cpp iqdmasync.cpp ngfmdmasync.cpp fmdmasync.cpp dma.cpp gpio.cpp serialdmasync.cpp phasedmasync.cpp amdmasync.h amdmasync.cpp fskburst.cpp
|
||||
$(AR) rc librpitx.a dsp.o iqdmasync.o ngfmdmasync.o fmdmasync.o dma.o gpio.o mailbox.o raspberry_pi_revision.o serialdmasync.o phasedmasync.o amdmasync.o fskburst.o
|
||||
$(CCP) $(CXXFLAGS) -c dsp.cpp iqdmasync.cpp ngfmdmasync.cpp fmdmasync.cpp dma.cpp gpio.cpp serialdmasync.cpp phasedmasync.cpp amdmasync.h amdmasync.cpp fskburst.cpp ookburst.cpp
|
||||
$(AR) rc librpitx.a dsp.o iqdmasync.o ngfmdmasync.o fmdmasync.o dma.o gpio.o mailbox.o raspberry_pi_revision.o serialdmasync.o phasedmasync.o amdmasync.o fskburst.o ookburst.o
|
||||
|
||||
install: librpitx
|
||||
|
||||
|
|
|
@ -25,4 +25,4 @@ This program is free software: you can redistribute it and/or modify
|
|||
#include "amdmasync.h"
|
||||
#include "fskburst.h"
|
||||
#include "dsp.h"
|
||||
|
||||
#include "ookburst.h"
|
129
src/ookburst.cpp
Normal file
129
src/ookburst.cpp
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
Copyright (C) 2018 Evariste COURJAUD F5OEO
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
#include <unistd.h>
|
||||
#include "ookburst.h"
|
||||
|
||||
|
||||
ookburst::ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+1,2,1)
|
||||
{
|
||||
|
||||
clkgpio::SetAdvancedPllMode(true);
|
||||
|
||||
clkgpio::SetCenterFrequency(TuneFrequency,SymbolRate); // Write Mult Int and Frac : FixMe carrier is already there
|
||||
clkgpio::SetFrequency(0);
|
||||
|
||||
syncwithpwm=false;
|
||||
|
||||
if(syncwithpwm)
|
||||
{
|
||||
pwmgpio::SetPllNumber(clk_plld,1);
|
||||
pwmgpio::SetFrequency(SymbolRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
pcmgpio::SetPllNumber(clk_plld,1);
|
||||
pcmgpio::SetFrequency(SymbolRate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SetDmaAlgo();
|
||||
|
||||
padgpio pad;
|
||||
Originfsel=pad.gpioreg[PADS_GPIO_0];
|
||||
}
|
||||
|
||||
ookburst::~ookburst()
|
||||
{
|
||||
}
|
||||
|
||||
void ookburst::SetDmaAlgo()
|
||||
{
|
||||
dma_cb_t *cbp=cbarray;
|
||||
for (uint32_t samplecnt = 0; samplecnt < buffersize-1; samplecnt++)
|
||||
{
|
||||
|
||||
|
||||
//Set Amplitude to FSEL for amplitude=0
|
||||
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP ;
|
||||
cbp->src = mem_virt_to_phys(&usermem[samplecnt*registerbysample]);
|
||||
cbp->dst = 0x7E000000 + (GPFSEL0<<2)+GENERAL_BASE;
|
||||
cbp->length = 4;
|
||||
cbp->stride = 0;
|
||||
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||
cbp++;
|
||||
|
||||
|
||||
// Delay
|
||||
if(syncwithpwm)
|
||||
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP |BCM2708_DMA_D_DREQ | BCM2708_DMA_PER_MAP(DREQ_PWM);
|
||||
else
|
||||
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP |BCM2708_DMA_D_DREQ | BCM2708_DMA_PER_MAP(DREQ_PCM_TX);
|
||||
cbp->src = mem_virt_to_phys(cbarray); // Data is not important as we use it only to feed the PWM
|
||||
if(syncwithpwm)
|
||||
cbp->dst = 0x7E000000 + (PWM_FIFO<<2) + PWM_BASE ;
|
||||
else
|
||||
cbp->dst = 0x7E000000 + (PCM_FIFO_A<<2) + PCM_BASE ;
|
||||
cbp->length = 4;
|
||||
cbp->stride = 0;
|
||||
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||
//fprintf(stderr,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
|
||||
cbp++;
|
||||
|
||||
}
|
||||
lastcbp=cbp;
|
||||
|
||||
// Last CBP before stopping : disable output
|
||||
sampletab[buffersize*registerbysample-1]=(Originfsel & ~(7 << 12)) | (0 << 12); //Disable Clk
|
||||
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP ;
|
||||
cbp->src = mem_virt_to_phys(&usermem[(buffersize*registerbysample-1)]);
|
||||
cbp->dst = 0x7E000000 + (GPFSEL0<<2)+GENERAL_BASE;
|
||||
cbp->length = 4;
|
||||
cbp->stride = 0;
|
||||
cbp->next = 0; // Stop DMA
|
||||
|
||||
//fprintf(stderr,"Last cbp %p: src %x dest %x next %x\n",cbp,cbp->src,cbp->dst,cbp->next);
|
||||
}
|
||||
void ookburst::SetSymbols(unsigned char *Symbols,uint32_t Size)
|
||||
{
|
||||
if(Size>buffersize-1) {fprintf(stderr,"Buffer overflow\n");return;}
|
||||
|
||||
dma_cb_t *cbp=cbarray;
|
||||
for(unsigned int i=0;i<Size;i++)
|
||||
{
|
||||
|
||||
sampletab[i]=(Symbols[i]==0)?((Originfsel & ~(7 << 12)) | (0 << 12)):((Originfsel & ~(7 << 12)) | (4 << 12));
|
||||
|
||||
cbp = &cbarray[i*cbbysample];
|
||||
cbp->next = mem_virt_to_phys(cbp + 1);
|
||||
|
||||
}
|
||||
cbp->next = mem_virt_to_phys(lastcbp);
|
||||
|
||||
|
||||
dma::start();
|
||||
|
||||
while(isrunning()) //Block function : return until sent completely signal
|
||||
{
|
||||
usleep(100);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
23
src/ookburst.h
Normal file
23
src/ookburst.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef DEF_OOKBURST
|
||||
#define DEF_OOKBURST
|
||||
|
||||
#include "stdint.h"
|
||||
#include "dma.h"
|
||||
#include "gpio.h"
|
||||
|
||||
class ookburst:public bufferdma,public clkgpio,public pwmgpio,public pcmgpio
|
||||
{
|
||||
protected:
|
||||
float timegranularity; //ns
|
||||
uint32_t Originfsel;
|
||||
bool syncwithpwm;
|
||||
dma_cb_t *lastcbp;
|
||||
public:
|
||||
ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize);
|
||||
~ookburst();
|
||||
void SetDmaAlgo();
|
||||
|
||||
void SetSymbols(unsigned char *Symbols,uint32_t Size);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue