Add debug level

This commit is contained in:
F5OEO 2019-01-06 11:51:02 +00:00
parent 326d51cbbc
commit 66bbdd78f9
17 changed files with 128 additions and 169 deletions

View file

@ -723,7 +723,7 @@ int main(int argc, char *argv[])
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
dbg_setlevel(0);
//SimpleTest(Freq);
//SimpleTestbpsk(Freq);
//SimpleTestFileIQ(Freq);
@ -733,6 +733,6 @@ int main(int argc, char *argv[])
//SimpleTestBurstFsk(Freq);
//SimpleTestOOKTiming(Freq);
//AlectoOOK(Freq);
//RfSwitchOOK(Freq);
SimpleTestAtv(Freq);
RfSwitchOOK(Freq);
//SimpleTestAtv(Freq);
}

View file

@ -5,10 +5,10 @@ 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 ookburst.cpp ookburst.h atv.h atv.cpp util.h
$(CC) $(CFLAGS) -c -o mailbox.o mailbox.c
#$(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 ookburst.cpp atv.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 atv.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 atv.cpp util.cpp mailbox.c
$(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 atv.o util.o mailbox.o
install: librpitx

View file

@ -89,7 +89,7 @@ void amdmasync::SetDmaAlgo()
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void amdmasync::SetAmSample(uint32_t Index,float Amplitude) //-1;1
@ -102,7 +102,7 @@ void amdmasync::SetAmSample(uint32_t Index,float Amplitude) //-1;1
if(IntAmplitudePAD>7) IntAmplitudePAD=7;
if(IntAmplitudePAD<0) IntAmplitudePAD=0;
//fprintf(stderr,"Amplitude=%f PAD %d\n",Amplitude,IntAmplitudePAD);
//dbg_printf(1,"Amplitude=%f PAD %d\n",Amplitude,IntAmplitudePAD);
sampletab[Index*registerbysample]=(0x5A<<24) + (IntAmplitudePAD&0x7) + (1<<4) + (0<<3); // Amplitude PAD
//sampletab[Index*registerbysample+2]=(Originfsel & ~(7 << 12)) | (4 << 12); //Alternate is CLK
@ -136,18 +136,18 @@ void amdmasync::SetAmSamples(float *sample,size_t Size)
int TimeToSleep=1e6*((int)buffersize*3/4-Available)/SampleRate-OSGranularity; // Sleep for theorically fill 3/4 of Fifo
if(TimeToSleep>0)
{
//fprintf(stderr,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
//dbg_printf(1,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
usleep(TimeToSleep);
}
else
{
//fprintf(stderr,"No Sleep %d\n",TimeToSleep);
//dbg_printf(1,"No Sleep %d\n",TimeToSleep);
sched_yield();
}
clock_gettime(CLOCK_REALTIME, &gettime_now);
time_difference = gettime_now.tv_nsec - start_time;
if(time_difference<0) time_difference+=1E9;
//fprintf(stderr,"Measure samplerate=%d\n",(int)((GetBufferAvailable()-Available)*1e9/time_difference));
//dbg_printf(1,"Measure samplerate=%d\n",(int)((GetBufferAvailable()-Available)*1e9/time_difference));
Available=GetBufferAvailable();
int Index=GetUserMemIndex();
int ToWrite=((int)Size-(int)NbWritten)<Available?Size-NbWritten:Available;

View file

@ -158,7 +158,7 @@ void atv::SetDmaAlgo()
}
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
fprintf(stderr, "Last cbp : %d \n", ((unsigned int)(cbp) - (unsigned int)(cbarray)) / sizeof(dma_cb_t));
dbg_printf(1, "Last cbp : %d \n", ((unsigned int)(cbp) - (unsigned int)(cbarray)) / sizeof(dma_cb_t));
}
void atv::SetFrame(unsigned char *Luminance, size_t Lines)

View file

@ -32,13 +32,13 @@ extern "C"
dma::dma(int Channel,uint32_t CBSize,uint32_t UserMemSize) // Fixme! Need to check to be 256 Aligned for UserMem
{
fprintf(stderr,"Channel %d CBSize %u UsermemSize %u\n",Channel,CBSize,UserMemSize);
dbg_printf(1,"Channel %d CBSize %u UsermemSize %u\n",Channel,CBSize,UserMemSize);
channel=Channel;
mbox.handle = mbox_open();
if (mbox.handle < 0)
{
fprintf(stderr,"Failed to open mailbox\n");
dbg_printf(1,"Failed to open mailbox\n");
}
cbsize=CBSize;
@ -47,20 +47,20 @@ dma::dma(int Channel,uint32_t CBSize,uint32_t UserMemSize) // Fixme! Need to che
GetRpiInfo(); // Fill mem_flag and dram_phys_base
uint32_t MemoryRequired=CBSize*sizeof(dma_cb_t)+UserMemSize*sizeof(uint32_t);
int NumPages=(MemoryRequired/PAGE_SIZE)+1;
fprintf(stderr,"%d Size NUM PAGES %d PAGE_SIZE %d\n",MemoryRequired,NumPages,PAGE_SIZE);
dbg_printf(1,"%d Size NUM PAGES %d PAGE_SIZE %d\n",MemoryRequired,NumPages,PAGE_SIZE);
mbox.mem_ref = mem_alloc(mbox.handle, NumPages* PAGE_SIZE, PAGE_SIZE, mem_flag);
/* TODO: How do we know that succeeded? */
//fprintf(stderr,"mem_ref %x\n", mbox.mem_ref);
//dbg_printf(1,"mem_ref %x\n", mbox.mem_ref);
mbox.bus_addr = mem_lock(mbox.handle, mbox.mem_ref);
//fprintf(stderr,"bus_addr = %x\n", mbox.bus_addr);
//dbg_printf(1,"bus_addr = %x\n", mbox.bus_addr);
mbox.virt_addr = (uint8_t *)mapmem(BUS_TO_PHYS(mbox.bus_addr), NumPages* PAGE_SIZE);
//fprintf(stderr,"virt_addr %p\n", mbox.virt_addr);
//dbg_printf(1,"virt_addr %p\n", mbox.virt_addr);
virtbase = (uint8_t *)((uint32_t *)mbox.virt_addr);
//fprintf(stderr,"virtbase %p\n", virtbase);
//dbg_printf(1,"virtbase %p\n", virtbase);
cbarray = (dma_cb_t *)virtbase; // We place DMA Control Blocks (CB) at beginning of virtual memory
//fprintf(stderr,"cbarray %p\n", cbarray);
//dbg_printf(1,"cbarray %p\n", cbarray);
usermem= (unsigned int *)(virtbase+CBSize*sizeof(dma_cb_t)); // user memory is placed after
//fprintf(stderr,"usermem %p\n", usermem);
//dbg_printf(1,"usermem %p\n", usermem);
dma_reg.gpioreg[DMA_CS+channel*0x40] = BCM2708_DMA_RESET|DMA_CS_INT; // Remove int flag
usleep(100);
@ -90,7 +90,7 @@ void dma::GetRpiInfo()
}
else
{
fprintf(stderr,"Unknown Raspberry architecture\n");
dbg_printf(1,"Unknown Raspberry architecture\n");
}
}
@ -148,7 +148,7 @@ int dma::stop()
int dma::getcbposition()
{
volatile uint32_t dmacb=(uint32_t)(dma_reg.gpioreg[DMA_CONBLK_AD+channel*0x40]);
//fprintf(stderr,"cb=%x\n",dmacb);
//dbg_printf(1,"cb=%x\n",dmacb);
if(dmacb>0)
return mem_phys_to_virt(dmacb)-(size_t)virtbase;
else
@ -163,7 +163,7 @@ bool dma::isrunning()
bool dma::isunderflow()
{
//if((dma_reg.gpioreg[DMA_CS+channel*0x40]&DMA_CS_INT)>0) fprintf(stderr,"Status:%x\n",dma_reg.gpioreg[DMA_CS+channel*0x40]);
//if((dma_reg.gpioreg[DMA_CS+channel*0x40]&DMA_CS_INT)>0) dbg_printf(1,"Status:%x\n",dma_reg.gpioreg[DMA_CS+channel*0x40]);
return ((dma_reg.gpioreg[DMA_CS+channel*0x40]&DMA_CS_INT)>0);
}
@ -200,7 +200,7 @@ bufferdma::bufferdma(int Channel,uint32_t tbuffersize,uint32_t tcbbysample,uint3
buffersize=tbuffersize;
cbbysample=tcbbysample;
registerbysample=tregisterbysample;
fprintf(stderr,"BufferSize %d , cb %d user %d\n",buffersize,buffersize*cbbysample,buffersize*registerbysample);
dbg_printf(1,"BufferSize %d , cb %d user %d\n",buffersize,buffersize*cbbysample,buffersize*registerbysample);
current_sample=0;
last_sample=0;
@ -227,29 +227,29 @@ int bufferdma::GetBufferAvailable()
}
else
{
fprintf(stderr,"DMA WEIRD STATE\n");
dbg_printf(1,"DMA WEIRD STATE\n");
current_sample=0;
}
//fprintf(stderr,"CurrentCB=%d\n",current_sample);
//dbg_printf(1,"CurrentCB=%d\n",current_sample);
diffsample=current_sample-last_sample;
if(diffsample<0) diffsample+=buffersize;
//fprintf(stderr,"cur %d last %d diff%d\n",current_sample,last_sample,diffsample);
//dbg_printf(1,"cur %d last %d diff%d\n",current_sample,last_sample,diffsample);
}
else
{
//last_sample=buffersize-1;
diffsample=buffersize;
current_sample=0;
//fprintf(stderr,"Warning DMA stopped \n");
//fprintf(stderr,"S:cur %d last %d diff%d\n",current_sample,last_sample,diffsample);
//dbg_printf(1,"Warning DMA stopped \n");
//dbg_printf(1,"S:cur %d last %d diff%d\n",current_sample,last_sample,diffsample);
}
/*
if(isunderflow())
{
fprintf(stderr,"cur %d last %d \n",current_sample,last_sample);
fprintf(stderr,"Underflow\n");
dbg_printf(1,"cur %d last %d \n",current_sample,last_sample);
dbg_printf(1,"Underflow\n");
}*/
return diffsample;
@ -260,7 +260,7 @@ int bufferdma::GetUserMemIndex()
{
int IndexAvailable=-1;
//fprintf(stderr,"Avail=%d\n",GetBufferAvailable());
//dbg_printf(1,"Avail=%d\n",GetBufferAvailable());
if(GetBufferAvailable()>0)
{
IndexAvailable=last_sample+1;

View file

@ -75,7 +75,7 @@ void dsp::pushsample(std::complex<float> sample)
amplitude=abs(sample);
double phase=atan2(sample.imag(),sample.real());
//fprintf(stderr,"phase %f\n",phase);
//dbg_printf(1,"phase %f\n",phase);
phase=unwrap(prev_phase,phase);
double dp= phase-prev_phase;

View file

@ -44,7 +44,7 @@ void fmdmasync::SetDmaAlgo()
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);
//dbg_printf(1,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
cbp++;
@ -56,13 +56,13 @@ void fmdmasync::SetDmaAlgo()
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);
//dbg_printf(1,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
cbp++;
}
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void fmdmasync::FillMemory(uint32_t FreqDivider,uint32_t FreqFractionnal)

View file

@ -62,80 +62,38 @@ This program is free software: you can redistribute it and/or modify
// 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++;
SetEasyCB(cbp++,0,dma_pwm,16+1);
}
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++;
SetEasyCB(cbp++,0,dma_pcm,64+1);
}
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;
cbp->length = 4;
cbp->stride = 0;
cbp->next = mem_virt_to_phys(cbp + 1); // Stop DMA
cbp++;
SetEasyCB(cbp++,buffersize*registerbysample-2,dma_fsel,1);//Enable clk
for (uint32_t samplecnt = 0; samplecnt < buffersize-2; samplecnt++)
{
// Write a frequency sample
cbp->info = BCM2708_DMA_NO_WIDE_BURSTS | BCM2708_DMA_WAIT_RESP ;
cbp->src = mem_virt_to_phys(&usermem[samplecnt*registerbysample]);
cbp->dst = 0x7E000000 + (PLLC_FRAC<<2) + CLK_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++;
// Write a frequency sample
SetEasyCB(cbp++,samplecnt*registerbysample,dma_pllc_frac,1);//Enable clk
// 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++;
SetEasyCB(cbp++,samplecnt*registerbysample,syncwithpwm?dma_pwm:dma_pcm,1);
}
lastcbp=cbp;
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;
SetEasyCB(cbp,buffersize*registerbysample-1,dma_fsel,1);//Disable clk
cbp->next = 0; // Stop DMA
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void fskburst::SetSymbols(unsigned char *Symbols,uint32_t Size)
{
if(Size>buffersize-3) {fprintf(stderr,"Buffer overflow\n");return;}
if(Size>buffersize-3) {dbg_printf(1,"Buffer overflow\n");return;}
dma_cb_t *cbp=cbarray;
cbp+=2; // Skip the first 2 CB (initialisation)

View file

@ -24,6 +24,7 @@ extern "C" {
#include <unistd.h>
#include <sys/timex.h>
#include <math.h>
#include "util.h"
gpio::gpio(uint32_t base, uint32_t len)
{
@ -120,7 +121,7 @@ uint64_t clkgpio::GetPllFrequency(int PllNo)
Freq = XOSC_FREQUENCY * ((uint64_t)gpioreg[PLLH_CTRL] & 0x3ff) + XOSC_FREQUENCY * (uint64_t)gpioreg[PLLH_FRAC] / (1 << 20);
break;
}
//fprintf(stderr, "Freq = %llu\n", Freq);
//dbg_printf(1, "Freq = %llu\n", Freq);
return Freq;
}
@ -131,7 +132,7 @@ int clkgpio::SetClkDivFrac(uint32_t Div, uint32_t Frac)
gpioreg[GPCLK_DIV] = 0x5A000000 | ((Div) << 12) | Frac;
usleep(100);
//fprintf(stderr, "Clk Number %d div %d frac %d\n", pllnumber, Div, Frac);
//dbg_printf(1, "Clk Number %d div %d frac %d\n", pllnumber, Div, Frac);
return 0;
}
@ -139,7 +140,7 @@ int clkgpio::SetClkDivFrac(uint32_t Div, uint32_t Frac)
int clkgpio::SetMasterMultFrac(uint32_t Mult, uint32_t Frac)
{
//fprintf(stderr,"Master Mult %d Frac %d\n",Mult,Frac);
//dbg_printf(1,"Master Mult %d Frac %d\n",Mult,Frac);
gpioreg[PLLC_CTRL] = (0x5a << 24) | (0x21 << 12) | Mult; //PDIV=1
usleep(100);
gpioreg[PLLC_FRAC] = 0x5A000000 | Frac;
@ -170,7 +171,7 @@ 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))
fprintf(stderr, "Frequency out of range\n");
dbg_printf(1, "Frequency out of range\n");
printf("DIV/FRAC %u/%u \n", FreqDivider, FreqFractionnal);
SetClkDivFrac(FreqDivider, FreqFractionnal);
@ -221,12 +222,12 @@ int clkgpio::ComputeBestLO(uint64_t Frequency, int Bandwidth)
bool cross_boundary=false;
if(Frequency<MIN_PLL_RATE/4095)
{
fprintf(stderr, "Frequency too low !!!!!!\n");
dbg_printf(1, "Frequency too low !!!!!!\n");
return -1;
}
if(Frequency*2>MAX_PLL_RATE)
{
fprintf(stderr, "Frequency too high !!!!!!\n");
dbg_printf(1, "Frequency too high !!!!!!\n");
return -1;
}
if(Frequency*2>MIN_PLL_RATE_USE_PDIV)
@ -247,7 +248,7 @@ int clkgpio::ComputeBestLO(uint64_t Frequency, int Bandwidth)
min_int_multiplier = ((int)((double)(Frequency - Bandwidth) * divider * xtal_freq_recip));
if (min_int_multiplier != max_int_multiplier)
{
//fprintf(stderr,"Warning : cross boundary frequency\n");
//dbg_printf(1,"Warning : cross boundary frequency\n");
best_divider=divider;
cross_boundary=true;
continue; // don't cross integer boundary
@ -265,13 +266,13 @@ int clkgpio::ComputeBestLO(uint64_t Frequency, int Bandwidth)
if (best_divider!=0)
{
PllFixDivider = best_divider;
if(cross_boundary) fprintf(stderr,"Warning : cross boundary frequency\n");
fprintf(stderr, "Found PLL solution for frequency %4.1fMHz : divider:%d VCO: %4.1fMHz\n", (Frequency/1e6), PllFixDivider,(Frequency/1e6) *((PllFixDivider==1)?2.0:(double)PllFixDivider));
if(cross_boundary) dbg_printf(1,"Warning : cross boundary frequency\n");
dbg_printf(1, "Found PLL solution for frequency %4.1fMHz : divider:%d VCO: %4.1fMHz\n", (Frequency/1e6), PllFixDivider,(Frequency/1e6) *((PllFixDivider==1)?2.0:(double)PllFixDivider));
return 0;
}
else
{
fprintf(stderr, "Central frequency not available !!!!!!\n");
dbg_printf(1, "Central frequency not available !!!!!!\n");
return -1;
}
}
@ -332,13 +333,13 @@ int clkgpio::SetCenterFrequency(uint64_t Frequency, int Bandwidth)
{
ana[i] = gpioreg[(A2W_PLLC_ANA0 ) + i];
usleep(100);
//fprintf(stderr,"PLLC %d =%x\n",i,ana[i]);
//dbg_printf(1,"PLLC %d =%x\n",i,ana[i]);
ana[i] &= ~(1<<14);
}
if(PllFixDivider==1)
{
fprintf(stderr,"Use PLL Prediv\n");
dbg_printf(1,"Use PLL Prediv\n");
ana[1] |= (1 << 14); // use prediv means Frequency*2
}
else
@ -357,22 +358,22 @@ int clkgpio::SetCenterFrequency(uint64_t Frequency, int Bandwidth)
{
ana[i]|=(0x5A << 24) ;
gpioreg[(A2W_PLLC_ANA0 ) + i] = ana[i];
//fprintf(stderr,"Write %d = %x\n",i,ana[i]);
//dbg_printf(1,"Write %d = %x\n",i,ana[i]);
usleep(100);
}
/*
for (int i = 3; i >= 0; i--)
{
fprintf(stderr,"PLLC after %d =%x\n",i,gpioreg[(A2W_PLLC_ANA0 ) + i]);
dbg_printf(1,"PLLC after %d =%x\n",i,gpioreg[(A2W_PLLC_ANA0 ) + i]);
}
*/
SetFrequency(0);
usleep(100);
if ((gpioreg[CM_LOCK] & CM_LOCK_FLOCKC) > 0)
fprintf(stderr, "Master PLLC Locked\n");
dbg_printf(1, "Master PLLC Locked\n");
else
fprintf(stderr, "Warning ! Master PLLC NOT Locked !!!!\n");
dbg_printf(1, "Warning ! Master PLLC NOT Locked !!!!\n");
usleep(100);
gpioreg[GPCLK_CNTL] = 0x5A000000 | (Mash << 9) | pllnumber | (1 << 4); //4 is START CLK
@ -445,7 +446,7 @@ void clkgpio::SetPLLMasterLoop(int Ki,int Kp,int Ka)
//Fixe me : Should make a OR with old value
ana[1]&=(uint32_t)~((0x7<<A2W_PLL_KI_SHIFT)|(0xF<<A2W_PLL_KP_SHIFT)|(0x7<<A2W_PLL_KA_SHIFT));
ana[1]|=(Ki<<A2W_PLL_KI_SHIFT)|(Kp<<A2W_PLL_KP_SHIFT)|(Ka<<A2W_PLL_KA_SHIFT);
fprintf(stderr,"Loop parameter =%x\n",ana[1]);
dbg_printf(1,"Loop parameter =%x\n",ana[1]);
for (int i = 3; i >= 0; i--)
{
gpioreg[(A2W_PLLC_ANA0 ) + i] = (0x5A << 24) | ana[i];
@ -574,7 +575,7 @@ void clkgpio::enableclk(int gpio)
gengpio.setmode(gpio, fsel_alt0);
break;
default:
fprintf(stderr, "gpio %d has no clk - available(4,20,32,34)\n", gpio);
dbg_printf(1, "gpio %d has no clk - available(4,20,32,34)\n", gpio);
break;
}
usleep(100);
@ -603,13 +604,13 @@ void clkgpio::SetppmFromNTP()
if (status != TIME_OK)
{
fprintf(stderr, "Warning: NTP calibrate failed\n");
dbg_printf(1, "Warning: NTP calibrate failed\n");
}
else
{
ntp_ppm = (double)ntx.freq / (double)(1 << 16);
fprintf(stderr, "Info:NTP find ppm=%f\n", ntp_ppm);
dbg_printf(1, "Info:NTP find ppm=%f\n", ntp_ppm);
if (fabs(ntp_ppm) < 200)
Setppm(ntp_ppm);
}
@ -680,7 +681,7 @@ void pwmgpio::enablepwm(int gpio, int PwmNumber)
break;
default:
fprintf(stderr, "gpio %d has no pwm - available(12,18,40)\n", gpio);
dbg_printf(1, "gpio %d has no pwm - available(12,18,40)\n", gpio);
break;
}
}
@ -701,7 +702,7 @@ void pwmgpio::enablepwm(int gpio, int PwmNumber)
gengpio.setmode(gpio, fsel_alt0);
break;
default:
fprintf(stderr, "gpio %d has no pwm - available(13,19,41,45)\n", gpio);
dbg_printf(1, "gpio %d has no pwm - available(13,19,41,45)\n", gpio);
break;
}
}
@ -741,8 +742,8 @@ int pwmgpio::SetFrequency(uint64_t Frequency)
uint32_t FreqDivider = (uint32_t)Freqresult;
uint32_t FreqFractionnal = (uint32_t)(4096 * (Freqresult - (double)FreqDivider));
if ((FreqDivider > 4096) || (FreqDivider < 2))
fprintf(stderr, "Frequency out of range\n");
fprintf(stderr, "PWM clk=%d / %d\n", FreqDivider, FreqFractionnal);
dbg_printf(1, "Frequency out of range\n");
dbg_printf(1, "PWM clk=%d / %d\n", FreqDivider, FreqFractionnal);
clk.gpioreg[PWMCLK_DIV] = 0x5A000000 | ((FreqDivider) << 12) | FreqFractionnal;
usleep(100);
@ -764,10 +765,10 @@ int pwmgpio::SetPrediv(int predivisor) //Mode should be only for SYNC or a Data
Prediv = predivisor;
if (Prediv > 32)
{
fprintf(stderr, "PWM Prediv is max 32\n");
dbg_printf(1, "PWM Prediv is max 32\n");
Prediv = 2;
}
fprintf(stderr, "PWM Prediv %d\n", Prediv);
dbg_printf(1, "PWM Prediv %d\n", Prediv);
gpioreg[PWM_RNG1] = Prediv; // 250 -> 8KHZ
usleep(100);
gpioreg[PWM_RNG2] = Prediv; // 32 Mandatory for Serial Mode without gap
@ -836,7 +837,7 @@ int pcmgpio::ComputePrediv(uint64_t Frequency)
double Freqresult = (double)Pllfrequency / (double)(Frequency * prediv);
if ((Freqresult < 4096.0) && (Freqresult > 2.0))
{
fprintf(stderr, "PCM prediv = %d\n", prediv);
dbg_printf(1, "PCM prediv = %d\n", prediv);
break;
}
}
@ -849,9 +850,9 @@ int pcmgpio::SetFrequency(uint64_t Frequency)
double Freqresult = (double)Pllfrequency / (double)(Frequency * Prediv);
uint32_t FreqDivider = (uint32_t)Freqresult;
uint32_t FreqFractionnal = (uint32_t)(4096 * (Freqresult - (double)FreqDivider));
fprintf(stderr, "PCM clk=%d / %d\n", FreqDivider, FreqFractionnal);
dbg_printf(1, "PCM clk=%d / %d\n", FreqDivider, FreqFractionnal);
if ((FreqDivider > 4096) || (FreqDivider < 2))
fprintf(stderr, "PCM Frequency out of range\n");
dbg_printf(1, "PCM Frequency out of range\n");
clk.gpioreg[PCMCLK_DIV] = 0x5A000000 | ((FreqDivider) << 12) | FreqFractionnal;
SetPrediv(Prediv);
return 0;
@ -861,7 +862,7 @@ int pcmgpio::SetPrediv(int predivisor) //Carefull we use a 10 fixe divisor for n
{
if (predivisor > 1000)
{
fprintf(stderr, "PCM prediv should be <1000");
dbg_printf(1, "PCM prediv should be <1000");
predivisor = 1000;
}

View file

@ -95,14 +95,14 @@ void iqdmasync::SetDmaAlgo()
//@3 Delay
SetEasyCB(cbp,samplecnt*registerbysample,syncwithpwm?dma_pwm:dma_pcm,1);
//fprintf(stderr,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
cbp++;
}
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
@ -130,7 +130,7 @@ void iqdmasync::SetIQSample(uint32_t Index,std::complex<float> sample,int Harmon
sampletab[Index*registerbysample+2]=(Originfsel & ~(7 << 12)) | (4 << 12); //Alternate is CLK : Fixme : do not work with clk2
}
//fprintf(stderr,"amp%f %d\n",mydsp.amplitude,IntAmplitudePAD);
//dbg_printf(1,"amp%f %d\n",mydsp.amplitude,IntAmplitudePAD);
PushSample(Index);
}
@ -146,7 +146,7 @@ void iqdmasync::SetFreqAmplitudeSample(uint32_t Index,std::complex<float> sample
if(IntAmplitude<0) {IntAmplitudePAD=0;IntAmplitude=-1;}
sampletab[Index*registerbysample+1]=(0x5A<<24) + (IntAmplitudePAD&0x7) + (1<<4) + (0<<3); // Amplitude PAD
//fprintf(stderr,"amp%d PAD %d\n",IntAmplitude,IntAmplitudePAD);
//dbg_printf(1,"amp%d PAD %d\n",IntAmplitude,IntAmplitudePAD);
//sampletab[Index*registerbysample+2]=(Originfsel & ~(7 << 12)) | (4 << 12); //Alternate is CLK
if(IntAmplitude==-1)
@ -158,7 +158,7 @@ void iqdmasync::SetFreqAmplitudeSample(uint32_t Index,std::complex<float> sample
sampletab[Index*registerbysample+2]=(Originfsel & ~(7 << 12)) | (4 << 12); //Alternate is CLK : Fixme : do not work with clk2
}
//fprintf(stderr,"amp%f %d\n",mydsp.amplitude,IntAmplitudePAD);
//dbg_printf(1,"amp%f %d\n",mydsp.amplitude,IntAmplitudePAD);
PushSample(Index);
}
@ -187,12 +187,12 @@ void iqdmasync::SetIQSamples(std::complex<float> *sample,size_t Size,int Harmoni
int TimeToSleep=1e6*((int)buffersize*3/4-Available)/(float)SampleRate/*-OSGranularity*/; // Sleep for theorically fill 3/4 of Fifo
if(TimeToSleep>0)
{
//fprintf(stderr,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
//dbg_printf(1,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
usleep(TimeToSleep);
}
else
{
fprintf(stderr,"No Sleep %d\n",TimeToSleep);
dbg_printf(1,"No Sleep %d\n",TimeToSleep);
//sched_yield();
}
@ -201,7 +201,7 @@ void iqdmasync::SetIQSamples(std::complex<float> *sample,size_t Size,int Harmoni
clock_gettime(CLOCK_REALTIME, &gettime_now);
time_difference = gettime_now.tv_nsec - start_time;
if(time_difference<0) time_difference+=1E9;
//fprintf(stderr,"Available %d Measure samplerate=%d\n",GetBufferAvailable(),(int)((GetBufferAvailable()-Available)*1e9/time_difference));
//dbg_printf(1,"Available %d Measure samplerate=%d\n",GetBufferAvailable(),(int)((GetBufferAvailable()-Available)*1e9/time_difference));
debug--;
}
Available=GetBufferAvailable();

View file

@ -39,7 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/stat.h>
#include "mailbox.h"
#include "util.h"
void *mapmem(unsigned base, unsigned size)
@ -49,7 +49,7 @@ void *mapmem(unsigned base, unsigned size)
base = base - offset;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
fprintf(stderr,"can't open /dev/mem\nThis program should be run as root. Try prefixing command with: sudo\n");
dbg_printf(1,"can't open /dev/mem\nThis program should be run as root. Try prefixing command with: sudo\n");
exit (-1);
}
void *mem = mmap(
@ -60,10 +60,10 @@ void *mapmem(unsigned base, unsigned size)
mem_fd,
base);
#ifdef DEBUG
fprintf(stderr,"base=0x%x, mem=%p\n", base, mem);
dbg_printf(1,"base=0x%x, mem=%p\n", base, mem);
#endif
if (mem == MAP_FAILED) {
fprintf(stderr,"mmap error %p\n", mem);
dbg_printf(1,"mmap error %p\n", mem);
exit (-1);
}
close(mem_fd);
@ -74,7 +74,7 @@ void *unmapmem(void *addr, unsigned size)
{
int s = munmap(addr, size);
if (s != 0) {
fprintf(stderr,"munmap error %d\n", s);
dbg_printf(1,"munmap error %d\n", s);
exit (-1);
}
@ -90,7 +90,7 @@ static int mbox_property(int file_desc, void *buf)
int ret_val = ioctl(file_desc, IOCTL_MBOX_PROPERTY, buf);
if (ret_val < 0) {
fprintf(stderr,"ioctl_set_msg failed:%d\n", ret_val);
dbg_printf(1,"ioctl_set_msg failed:%d\n", ret_val);
}
#ifdef DEBUG
@ -262,9 +262,9 @@ unsigned get_clocks(int file_desc ) //FixMe !!!!!!
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
fprintf(stderr,"Clock size = %d\n",p[4]&0xFFF);
for(i=0;i<128/4;i++) fprintf(stderr,"%x ",p[i]);
fprintf(stderr,"\n");
dbg_printf(1,"Clock size = %d\n",p[4]&0xFFF);
for(i=0;i<128/4;i++) dbg_printf(1,"%x ",p[i]);
dbg_printf(1,"\n");
return p[5];
}
@ -274,7 +274,7 @@ int mbox_open() {
// Open a char device file used for communicating with kernel mbox driver.
file_desc = open(VCIO_DEVICE_FILE_NAME, 0);
if(file_desc >= 0) {
fprintf(stderr,"Using mbox device " VCIO_DEVICE_FILE_NAME ".\n");
dbg_printf(1,"Using mbox device " VCIO_DEVICE_FILE_NAME ".\n");
return file_desc;
}
@ -282,14 +282,14 @@ int mbox_open() {
unlink(LOCAL_DEVICE_FILE_NAME);
if(mknod(LOCAL_DEVICE_FILE_NAME, S_IFCHR|0600, makedev(MAJOR_NUM_A, 0)) >= 0 &&
(file_desc = open(LOCAL_DEVICE_FILE_NAME, 0)) >= 0) {
fprintf(stderr,"Using local mbox device file with major %d.\n", MAJOR_NUM_A);
dbg_printf(1,"Using local mbox device file with major %d.\n", MAJOR_NUM_A);
return file_desc;
}
unlink(LOCAL_DEVICE_FILE_NAME);
if(mknod(LOCAL_DEVICE_FILE_NAME, S_IFCHR|0600, makedev(MAJOR_NUM_B, 0)) >= 0 &&
(file_desc = open(LOCAL_DEVICE_FILE_NAME, 0)) >= 0) {
fprintf(stderr,"Using local mbox device file with major %d.\n", MAJOR_NUM_B);
dbg_printf(1,"Using local mbox device file with major %d.\n", MAJOR_NUM_B);
return file_desc;
}

View file

@ -38,6 +38,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define PAGE_SIZE (4*1024)
extern "C"
{
int mbox_open();
void mbox_close(int file_desc);
@ -54,4 +56,5 @@ unsigned execute_code(int file_desc, unsigned code, unsigned r0, unsigned r1, un
unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control, unsigned noflush, unsigned timeout);
unsigned qpu_enable(int file_desc, unsigned enable);
unsigned get_clocks(int file_desc );
}
#endif

View file

@ -86,14 +86,14 @@ void ngfmdmasync::SetDmaAlgo()
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void ngfmdmasync::SetFrequencySample(uint32_t Index,float Frequency)
{
Index=Index%buffersize;
sampletab[Index]=(0x5A<<24)|GetMasterFrac(Frequency);
//fprintf(stderr,"Frac=%d\n",GetMasterFrac(Frequency));
//dbg_printf(1,"Frac=%d\n",GetMasterFrac(Frequency));
PushSample(Index);
}
@ -114,19 +114,19 @@ void ngfmdmasync::SetFrequencySamples(float *sample,size_t Size)
int TimeToSleep=1e6*((int)buffersize*3/4-Available)/SampleRate-OSGranularity; // Sleep for theorically fill 3/4 of Fifo
if(TimeToSleep>0)
{
fprintf(stderr,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
dbg_printf(1,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
usleep(TimeToSleep);
}
else
{
fprintf(stderr,"No Sleep %d\n",TimeToSleep);
dbg_printf(1,"No Sleep %d\n",TimeToSleep);
sched_yield();
}
clock_gettime(CLOCK_REALTIME, &gettime_now);
time_difference = gettime_now.tv_nsec - start_time;
if(time_difference<0) time_difference+=1E9;
int NewAvailable=GetBufferAvailable();
fprintf(stderr,"Newavailable %d Measure samplerate=%d\n",NewAvailable,(int)((GetBufferAvailable()-Available)*1e9/time_difference));
dbg_printf(1,"Newavailable %d Measure samplerate=%d\n",NewAvailable,(int)((GetBufferAvailable()-Available)*1e9/time_difference));
Available=NewAvailable;
int Index=GetUserMemIndex();
int ToWrite=((int)Size-(int)NbWritten)<Available?Size-NbWritten:Available;

View file

@ -89,7 +89,7 @@ This program is free software: you can redistribute it and/or modify
}
void ookburst::SetSymbols(unsigned char *Symbols,uint32_t Size)
{
if(Size>buffersize-2) {fprintf(stderr,"Buffer overflow\n");return;}
if(Size>buffersize-2) {dbg_printf(1,"Buffer overflow\n");return;}
dma_cb_t *cbp=cbarray;
cbp++; // Skip the first which is the Fiiling of Fifo
@ -103,7 +103,7 @@ This program is free software: you can redistribute it and/or modify
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);
//dbg_printf(1,"cbp : sample %d pointer %p src %x dest %x next %x\n",i,cbp,cbp->src,cbp->dst,cbp->next);
cbp++;
}
@ -148,7 +148,7 @@ This program is free software: you can redistribute it and/or modify
ookrenderbuffer[n++]=TabSymbols[i].value;
if(n>=m_MaxMessage)
{
fprintf(stderr,"OOK Message too long abort time(%d/%d)\n",n,m_MaxMessage);
dbg_printf(1,"OOK Message too long abort time(%d/%d)\n",n,m_MaxMessage);
return;
}
}

View file

@ -20,6 +20,7 @@ This program is free software: you can redistribute it and/or modify
#include "phasedmasync.h"
#include <unistd.h>
#include <time.h>
#include "util.h"
//Stable tune for this pwm mode is up to 90MHZ
@ -32,11 +33,11 @@ phasedmasync::phasedmasync(uint64_t TuneFrequency,uint32_t SampleRateIn,int Numb
tunefreq=TuneFrequency*NumberOfPhase;
#define MAX_PWM_RATE 360000000
if(tunefreq>MAX_PWM_RATE) fprintf(stderr,"Critical error : Frequency to high > %d\n",MAX_PWM_RATE/NumberOfPhase);
if(tunefreq>MAX_PWM_RATE) dbg_printf(1,"Critical error : Frequency to high > %d\n",MAX_PWM_RATE/NumberOfPhase);
if((NumberOfPhase==2)||(NumberOfPhase==4)||(NumberOfPhase==8)||(NumberOfPhase==16)||(NumberOfPhase==32))
NumbPhase=NumberOfPhase;
else
fprintf(stderr,"PWM critical error: %d is not a legal number of phase\n",NumberOfPhase);
dbg_printf(1,"PWM critical error: %d is not a legal number of phase\n",NumberOfPhase);
clkgpio::SetAdvancedPllMode(true);
clkgpio::ComputeBestLO(tunefreq,0); // compute PWM divider according to MasterPLL clkgpio::PllFixDivider
@ -46,7 +47,7 @@ phasedmasync::phasedmasync(uint64_t TuneFrequency,uint32_t SampleRateIn,int Numb
freqctl&=0xFFFFF; // Fractionnal is 20bits
uint32_t FracMultiply=freqctl&0xFFFFF;
clkgpio::SetMasterMultFrac(IntMultiply,FracMultiply);
fprintf(stderr,"PWM Mult %d Frac %d Div %d\n",IntMultiply,FracMultiply,clkgpio::PllFixDivider);
dbg_printf(1,"PWM Mult %d Frac %d Div %d\n",IntMultiply,FracMultiply,clkgpio::PllFixDivider);
pwmgpio::clk.gpioreg[PWMCLK_DIV] = 0x5A000000 | ((clkgpio::PllFixDivider)<<12) |pwmgpio::pllnumber; // PWM clock input divider
@ -76,13 +77,13 @@ phasedmasync::phasedmasync(uint64_t TuneFrequency,uint32_t SampleRateIn,int Numb
case 8:ZeroPhase=0xF0F0F0F0;break;//1,1,1,1,0,0,0,0 //8
case 16:ZeroPhase=0xFF00FF00;break;//1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0 //16
case 32:ZeroPhase=0xFFFF0000;break;//1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 //32
default:fprintf(stderr,"Zero phase not initialized\n");break;
default:dbg_printf(1,"Zero phase not initialized\n");break;
}
for(int i=0;i<NumbPhase;i++)
{
TabPhase[i]=ZeroPhase;
//fprintf(stderr,"Phase[%d]=%x\n",i,TabPhase[i]);
//dbg_printf(1,"Phase[%d]=%x\n",i,TabPhase[i]);
ZeroPhase=(ZeroPhase<<1)|(ZeroPhase>>31);
}
@ -108,7 +109,7 @@ void phasedmasync::SetDmaAlgo()
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);
//dbg_printf(1,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
cbp++;
@ -118,13 +119,13 @@ void phasedmasync::SetDmaAlgo()
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);
//dbg_printf(1,"cbp : sample %x src %x dest %x next %x\n",samplecnt,cbp->src,cbp->dst,cbp->next);
cbp++;
}
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void phasedmasync::SetPhase(uint32_t Index,int Phase)
@ -162,12 +163,12 @@ void phasedmasync::SetPhaseSamples(int *sample,size_t Size)
int TimeToSleep=1e6*((int)buffersize*3/4-Available)/(float)SampleRate/*-OSGranularity*/; // Sleep for theorically fill 3/4 of Fifo
if(TimeToSleep>0)
{
//fprintf(stderr,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
//dbg_printf(1,"buffer size %d Available %d SampleRate %d Sleep %d\n",buffersize,Available,SampleRate,TimeToSleep);
usleep(TimeToSleep);
}
else
{
//fprintf(stderr,"No Sleep %d\n",TimeToSleep);
//dbg_printf(1,"No Sleep %d\n",TimeToSleep);
//sched_yield();
}
@ -176,7 +177,7 @@ void phasedmasync::SetPhaseSamples(int *sample,size_t Size)
clock_gettime(CLOCK_REALTIME, &gettime_now);
time_difference = gettime_now.tv_nsec - start_time;
if(time_difference<0) time_difference+=1E9;
//fprintf(stderr,"Available %d Measure samplerate=%d\n",GetBufferAvailable(),(int)((GetBufferAvailable()-Available)*1e9/time_difference));
//dbg_printf(1,"Available %d Measure samplerate=%d\n",GetBufferAvailable(),(int)((GetBufferAvailable()-Available)*1e9/time_difference));
debug--;
}
Available=GetBufferAvailable();

View file

@ -69,7 +69,7 @@ void serialdmasync::SetDmaAlgo()
cbp--;
cbp->next = mem_virt_to_phys(cbarray); // We loop to the first CB
//fprintf(stderr,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
//dbg_printf(1,"Last cbp : src %x dest %x next %x\n",cbp->src,cbp->dst,cbp->next);
}
void serialdmasync::SetSample(uint32_t Index,int Sample)

View file

@ -4,11 +4,7 @@
#include <stdio.h>
#include <stdarg.h>
void dbg_printf(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
void dbg_setlevel(int Level);
void dbg_printf(int Level, const char *fmt, ...);
#endif