Wokring ook , fixe fskburst

This commit is contained in:
F5OEO 2018-12-19 10:16:40 +00:00
parent 887470a7be
commit 1be11a70e3
3 changed files with 107 additions and 53 deletions

View file

@ -302,22 +302,21 @@ void SimpleTestAm(uint64_t Freq)
void SimpleTestOOK(uint64_t Freq)
{
int SR=2000;
int FifoSize=2000;
int SR=1000;
int FifoSize=21; //24
ookburst ook(Freq,SR,14,FifoSize);
unsigned char TabSymbol[FifoSize];
for(size_t i=0;i<FifoSize/2;i++)
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};
/*for(size_t i=0;i<FifoSize;i++)
{
TabSymbol[i]=i%2;
}
for(size_t i=0;i<FifoSize/2;i++)
{
TabSymbol[i+FifoSize/2]=0;
}
while(running)
}*/
//while(running)
{
ook.SetSymbols(TabSymbol,FifoSize);
// sleep(2);
}
}
@ -326,30 +325,18 @@ void SimpleTestBurstFsk(uint64_t Freq)
{
//int SR=40625;
int SR=40625;
float Deviation=26370;
int FiFoSize=4000;
fskburst fsktest(Freq,SR,Deviation,14,FiFoSize);
int SR=1000;
float Deviation=2000;
int FifoSize=21;
fskburst fsktest(Freq,SR,Deviation,14,FifoSize);
unsigned char TabSymbol[FiFoSize];
int BurstSize=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};
while(running)
//while(running)
{
int i;
int BurstLen=rand()%FiFoSize;
for(i=0;i<BurstLen;i++)
{
TabSymbol[i]=rand()%2;
}
fsktest.SetSymbols(TabSymbol,BurstLen);
sleep(1);
/*for(i=0;i<FiFoSize;i++)
{
TabSymbol[i]=1;
}
fsktest.SetSymbols(TabSymbol,FiFoSize);
sleep(1);*/
fsktest.SetSymbols(TabSymbol,FifoSize);
}
@ -384,8 +371,8 @@ int main(int argc, char* argv[])
//SimpleTestFileIQ(Freq);
//SimpleTestDMA(Freq);
//SimpleTestAm(Freq);
SimpleTestOOK(Freq);
//SimpleTestBurstFsk(Freq);
//SimpleTestOOK(Freq);
SimpleTestBurstFsk(Freq);
}

View file

@ -17,15 +17,15 @@ This program is free software: you can redistribute it and/or modify
#include "stdio.h"
#include "fskburst.h"
#include <unistd.h>
fskburst::fskburst(uint64_t TuneFrequency,uint32_t SymbolRate,float Deviation,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+2,2,1),freqdeviation(Deviation)
fskburst::fskburst(uint64_t TuneFrequency,uint32_t SymbolRate,float Deviation,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+3,2,1),freqdeviation(Deviation)
{
clkgpio::SetAdvancedPllMode(true);
clkgpio::SetCenterFrequency(TuneFrequency,SymbolRate); // Write Mult Int and Frac : FixMe carrier is already there
clkgpio::SetFrequency(0);
//clkgpio::enableclk(4); // GPIO 4 CLK by default
syncwithpwm=false;
if(syncwithpwm)
@ -57,6 +57,31 @@ This program is free software: you can redistribute it and/or modify
sampletab[buffersize*registerbysample-1]=(Originfsel & ~(7 << 12)) | (0 << 12); //Disable Clk
dma_cb_t *cbp = cbarray;
// We must fill the FIFO (PWM or PCM) to be Synchronized from start
// PWM FIFO = 16
// PCM FIFO = 64
if(syncwithpwm)
{
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP |BCM2708_DMA_D_DREQ | BCM2708_DMA_PER_MAP(DREQ_PWM);
cbp->src = mem_virt_to_phys(cbarray); // Data is not important as we use it only to feed the PWM
cbp->dst = 0x7E000000 + (PWM_FIFO<<2) + PWM_BASE ;
cbp->length = 4*(16+1);
cbp->stride = 0;
cbp->next = mem_virt_to_phys(cbp + 1);
cbp++;
}
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 PCM
cbp->dst = 0x7E000000 + (PCM_FIFO_A<<2) + PCM_BASE ;
cbp->length = 4*(64+1);
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++;
}
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP ;
cbp->src = mem_virt_to_phys(&usermem[buffersize*registerbysample-2]);
cbp->dst = 0x7E000000 + (GPFSEL0<<2)+GENERAL_BASE;
@ -110,21 +135,28 @@ This program is free software: you can redistribute it and/or modify
}
void fskburst::SetSymbols(unsigned char *Symbols,uint32_t Size)
{
if(Size>buffersize-2) {fprintf(stderr,"Buffer overflow\n");return;}
if(Size>buffersize-3) {fprintf(stderr,"Buffer overflow\n");return;}
dma_cb_t *cbp=cbarray+1+1;
dma_cb_t *cbp=cbarray;
cbp+=2; // Skip the first 2 CB (initialisation)
for(unsigned int i=0;i<Size;i++)
{
sampletab[i]=(0x5A<<24)|GetMasterFrac((Symbols[i]==0)?-freqdeviation:freqdeviation);
cbp = &cbarray[i*cbbysample+1+1];
cbp++;//SKIP FREQ CB
cbp->next = mem_virt_to_phys(cbp + 1);
cbp++;
}
cbp--;
cbp->next = mem_virt_to_phys(lastcbp);
dma::start();
while(isrunning()) //Block function : return until sent completely signal
{
usleep(100);
}
usleep(100);//To be sure last symbol Tx ?
}

View file

@ -20,12 +20,12 @@ This program is free software: you can redistribute it and/or modify
#include "ookburst.h"
ookburst::ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+1,2,1)
ookburst::ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+2,2,1)
{
clkgpio::SetAdvancedPllMode(true);
clkgpio::SetCenterFrequency(TuneFrequency,SymbolRate); // Write Mult Int and Frac : FixMe carrier is already there
clkgpio::SetCenterFrequency(TuneFrequency,0); // Bandwidth is 0 because frequency always the same
clkgpio::SetFrequency(0);
syncwithpwm=false;
@ -56,7 +56,32 @@ This program is free software: you can redistribute it and/or modify
void ookburst::SetDmaAlgo()
{
dma_cb_t *cbp=cbarray;
for (uint32_t samplecnt = 0; samplecnt < buffersize-1; samplecnt++)
// We must fill the FIFO (PWM or PCM) to be Synchronized from start
// PWM FIFO = 16
// PCM FIFO = 64
if(syncwithpwm)
{
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP |BCM2708_DMA_D_DREQ | BCM2708_DMA_PER_MAP(DREQ_PWM);
cbp->src = mem_virt_to_phys(cbarray); // Data is not important as we use it only to feed the PWM
cbp->dst = 0x7E000000 + (PWM_FIFO<<2) + PWM_BASE ;
cbp->length = 4*(16+1);
cbp->stride = 0;
cbp->next = mem_virt_to_phys(cbp + 1);
cbp++;
}
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 PCM
cbp->dst = 0x7E000000 + (PCM_FIFO_A<<2) + PCM_BASE ;
cbp->length = 4*(64+1);
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++;
}
for (uint32_t samplecnt = 0; samplecnt < buffersize-2; samplecnt++)
{
@ -83,7 +108,7 @@ This program is free software: you can redistribute it and/or modify
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);
//fprintf(stderr,"cbp : sample %d pointer %p src %x dest %x next %x\n",samplecnt,cbp,cbp->src,cbp->dst,cbp->next);
cbp++;
}
@ -102,28 +127,38 @@ This program is free software: you can redistribute it and/or modify
}
void ookburst::SetSymbols(unsigned char *Symbols,uint32_t Size)
{
if(Size>buffersize-1) {fprintf(stderr,"Buffer overflow\n");return;}
if(Size>buffersize-2) {fprintf(stderr,"Buffer overflow\n");return;}
dma_cb_t *cbp=cbarray;
for(unsigned int i=0;i<Size;i++)
cbp++; // Skip the first which is the Fiiling of Fifo
unsigned i=0;
for(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++;//SKIP FSEL CB
cbp->next = mem_virt_to_phys(cbp + 1);
//fprintf(stderr,"cbp : sample %d pointer %p src %x dest %x next %x\n",i,cbp,cbp->src,cbp->dst,cbp->next);
cbp++;
}
cbp->next = mem_virt_to_phys(lastcbp);
cbp--;
cbp->next = mem_virt_to_phys(lastcbp);
dma::start();
while(isrunning()) //Block function : return until sent completely signal
{
usleep(100);
}
usleep(100);//To be sure last symbol Tx ?
}