diff --git a/gpioclk.cpp b/gpioclk.cpp index 077f4c2..7391d7b 100644 --- a/gpioclk.cpp +++ b/gpioclk.cpp @@ -49,17 +49,13 @@ using namespace std; #define F_XTAL (19200000.0) #define F_PLLD_CLK (500000000.0) -//Now we autodetect it via makefile. +// Choose proper base address depending on RPI1/RPI2 setting from makefile. #ifdef RPI2 - #define BCM2708_PERI_BASE 0x3f000000 #pragma message "Raspberry Pi 2 detected." - #else - #define BCM2708_PERI_BASE 0x20000000 #pragma message "Raspberry Pi 1 detected." - #endif #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ diff --git a/wspr.cpp b/wspr.cpp index 66677db..64d9dfa 100644 --- a/wspr.cpp +++ b/wspr.cpp @@ -69,19 +69,15 @@ using namespace std; #define WSPR_RAND_OFFSET 80 #define WSPR15_RAND_OFFSET 8 -//Now we autodetect it via makefile. +// Choose proper base address depending on RPI1/RPI2 setting from makefile. #ifdef RPI2 - #define BCM2708_PERI_BASE 0x3f000000 #define MEM_FLAG 0x04 #pragma message "Raspberry Pi 2 detected." - #else - #define BCM2708_PERI_BASE 0x20000000 #define MEM_FLAG 0x0c #pragma message "Raspberry Pi 1 detected." - #endif #define PAGE_SIZE (4*1024) @@ -105,7 +101,7 @@ volatile unsigned *allof7e = NULL; #define CLRBIT(base, bit) ACCESS(base) &= ~(1<=mbox.pool_size) return 1; - unsigned offset = mbox.pool_cnt*4096; - *vAddr = (void*)(((unsigned)mbox.virt_addr) + offset); - *pAddr = (void*)(((unsigned)mbox.bus_addr) + offset); - //printf("getRealMemoryPageFromPool bus_addr=%x virt_addr=%x\n", (unsigned)*pAddr,(unsigned)*vAddr); - mbox.pool_cnt++; - return 0; + if(mbox.pool_cnt>=mbox.pool_size) return 1; + unsigned offset = mbox.pool_cnt*4096; + *vAddr = (void*)(((unsigned)mbox.virt_addr) + offset); + *pAddr = (void*)(((unsigned)mbox.bus_addr) + offset); + //printf("getRealMemoryPageFromPool bus_addr=%x virt_addr=%x\n", (unsigned)*pAddr,(unsigned)*vAddr); + mbox.pool_cnt++; + return 0; } void deallocMemPool() { - if(mbox.virt_addr) //it will be 0 by default as in .bss - { - unmapmem(mbox.virt_addr, mbox.pool_size*4096); - mem_unlock(mbox.handle, mbox.mem_ref); - mem_free(mbox.handle, mbox.mem_ref); - } + if(mbox.virt_addr) //it will be 0 by default as in .bss + { + unmapmem(mbox.virt_addr, mbox.pool_size*4096); + mem_unlock(mbox.handle, mbox.mem_ref); + mem_free(mbox.handle, mbox.mem_ref); + } } void txon() @@ -628,8 +624,19 @@ void wspr(const char* call, const char* l_pre, const char* dbm, unsigned char* s unsigned long n2=(ng<<7)|(p+64+nadd); // pack n1,n2,zero-tail into 50 bits - char packed[11] = {n1>>20, n1>>12, n1>>4, ((n1&0x0f)<<4)|((n2>>18)&0x0f), -n2>>10, n2>>2, (n2&0x03)<<6, 0, 0, 0, 0}; + char packed[11] = { + static_cast(n1>>20), + static_cast(n1>>12), + static_cast(n1>>4), + static_cast(((n1&0x0f)<<4)|((n2>>18)&0x0f)), + static_cast(n2>>10), + static_cast(n2>>2), + static_cast((n2&0x03)<<6), + 0, + 0, + 0, + 0 + }; // convolutional encoding K=32, r=1/2, Layland-Lushbaugh polynomials int k = 0; @@ -1069,7 +1076,7 @@ int main(const int argc, char * const argv[]) { int mem_fd; char *gpio_mem, *gpio_map; volatile unsigned *gpio = NULL; - + setup_io(mem_fd,gpio_mem,gpio_map,gpio); setup_gpios(gpio); allof7e = (unsigned *)mmap( @@ -1103,7 +1110,7 @@ int main(const int argc, char * const argv[]) { cout << "Press CTRL-C to exit!" << endl; txon(); - int bufPtr=0; + int bufPtr=0; vector dma_table_freq; // Set to non-zero value to ensure setupDMATab is called at least once. double ppm_prev=123456;