Fix a bug between PAD and FSEL which disturb other GPIO

This commit is contained in:
F5OEO 2019-01-08 14:05:15 +00:00
parent 288ff2299c
commit 62259b6c75
5 changed files with 24 additions and 18 deletions

View file

@ -26,7 +26,7 @@ This program is free software: you can redistribute it and/or modify
clkgpio::SetAdvancedPllMode(true);
clkgpio::SetCenterFrequency(TuneFrequency,SymbolRate); // Write Mult Int and Frac : FixMe carrier is already there
clkgpio::SetFrequency(0);
disableclk(4);
syncwithpwm=false;
if(syncwithpwm)
@ -40,12 +40,14 @@ This program is free software: you can redistribute it and/or modify
pcmgpio::SetFrequency(SymbolRate);
}
//Should be obligatory place before setdmaalgo
Originfsel=clkgpio::gengpio.gpioreg[GPFSEL0];
dbg_printf(1,"FSK Origin fsel %x\n",Originfsel);
SetDmaAlgo();
padgpio pad;
Originfsel=pad.gpioreg[PADS_GPIO_0];
}
fskburst::~fskburst()
@ -54,8 +56,9 @@ This program is free software: you can redistribute it and/or modify
void fskburst::SetDmaAlgo()
{
sampletab[buffersize*registerbysample-2]=(Originfsel & ~(7 << 12)) | (4 << 12); //Enable Clk
sampletab[buffersize*registerbysample-1]=(Originfsel & ~(7 << 12)) | (0 << 12); //Disable Clk
sampletab[buffersize*registerbysample-2]=(Originfsel & ~(7 << 12)) | (4 << 12); //Gpio Clk
sampletab[buffersize*registerbysample-1]=(Originfsel & ~(7 << 12)) | (0 << 12); //Gpio In
dma_cb_t *cbp = cbarray;
// We must fill the FIFO (PWM or PCM) to be Synchronized from start
@ -86,11 +89,12 @@ This program is free software: you can redistribute it and/or modify
}
lastcbp=cbp;
SetEasyCB(cbp,buffersize*registerbysample-1,dma_fsel,1);//Disable clk
cbp->next = 0; // Stop DMA
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
dbg_printf(2,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void fskburst::SetSymbols(unsigned char *Symbols,uint32_t Size)
{
@ -112,9 +116,11 @@ This program is free software: you can redistribute it and/or modify
dma::start();
while(isrunning()) //Block function : return until sent completely signal
{
//dbg_printf(1,"GPIO %x\n",clkgpio::gengpio.gpioreg[GPFSEL0]);
usleep(100);
}
dbg_printf(1,"FSK burst end Tx\n",cbp->src,cbp->dst,cbp->next);
usleep(100);//To be sure last symbol Tx ?
}

View file

@ -173,8 +173,8 @@ int clkgpio::SetFrequency(double Frequency)
uint32_t FreqDivider = (uint32_t)Freqresult;
uint32_t FreqFractionnal = (uint32_t)(4096 * (Freqresult - (double)FreqDivider));
if ((FreqDivider > 4096) || (FreqDivider < 2))
dbg_printf(1, "Frequency out of range\n");
printf("DIV/FRAC %u/%u \n", FreqDivider, FreqFractionnal);
dbg_printf(0, "Frequency out of range\n");
dbg_printf(1,"DIV/FRAC %u/%u \n", FreqDivider, FreqFractionnal);
SetClkDivFrac(FreqDivider, FreqFractionnal);
}

View file

@ -21,7 +21,7 @@ This program is free software: you can redistribute it and/or modify
#include "iqdmasync.h"
#include <unistd.h>
#include <sched.h>
#include "util.h"
iqdmasync::iqdmasync(uint64_t TuneFrequency,uint32_t SR,int Channel,uint32_t FifoSize,int Mode):bufferdma(Channel,FifoSize,4,3)
{
@ -51,8 +51,7 @@ iqdmasync::iqdmasync(uint64_t TuneFrequency,uint32_t SR,int Channel,uint32_t Fif
mydsp.samplerate=SampleRate;
padgpio pad;
Originfsel=pad.gpioreg[PADS_GPIO_0];
Originfsel=clkgpio::gengpio.gpioreg[GPFSEL0];
SetDmaAlgo();
@ -65,8 +64,7 @@ iqdmasync::iqdmasync(uint64_t TuneFrequency,uint32_t SR,int Channel,uint32_t Fif
iqdmasync::~iqdmasync()
{
padgpio pad;
pad.gpioreg[PADS_GPIO_0]=Originfsel;
clkgpio::gengpio.gpioreg[GPFSEL0]=Originfsel;
clkgpio::disableclk(4);
}

View file

@ -27,3 +27,4 @@ This program is free software: you can redistribute it and/or modify
#include "dsp.h"
#include "ookburst.h"
#include "atv.h"
#include "util.h"

View file

@ -18,6 +18,7 @@ This program is free software: you can redistribute it and/or modify
#include "stdio.h"
#include <unistd.h>
#include "ookburst.h"
#include "util.h"
ookburst::ookburst(uint64_t TuneFrequency,uint32_t SymbolRate,int Channel,uint32_t FifoSize):bufferdma(Channel,FifoSize+2,2,1)
@ -42,11 +43,11 @@ This program is free software: you can redistribute it and/or modify
}
Originfsel=clkgpio::gengpio.gpioreg[GPFSEL0];
SetDmaAlgo();
padgpio pad;
Originfsel=pad.gpioreg[PADS_GPIO_0];
}
ookburst::~ookburst()