Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default compiler errors #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"ms-azuretools.vscode-docker",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"ms-vscode.cmake-tools"
]

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"cmake.sourceDirectory": "${workspaceFolder}/.",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cSpell.words": [
"Mattos",
"Weigl",
"oskar",
"pifm"
]
}
5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ All rights of the original authors reserved.
* http://www.youtube.com/v/ekcdAX53-S8#!

* https://github.com/richardghirst/PiBits/pull/18

* https://www.reddit.com/r/raspberry_pi/comments/14k5o3/raspberry_pi_fm_transmitter_with_no_additional/
36 changes: 13 additions & 23 deletions pifm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,18 @@ int volume = 4;


// I/O access
volatile unsigned *gpio;
volatile unsigned *allof7e;

// GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y)
#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
#define OUT_GPIO(g) *(gpio+((g)/10)) |= (1<<(((g)%10)*3))
#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))

#define GPIO_SET *(gpio+7) // sets bits which are 1 ignores bits which are 0
#define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0
#define GPIO_GET *(gpio+13) // sets bits which are 1 ignores bits which are 0

#define ACCESS(base) *(volatile int*)((int)allof7e+base-0x7e000000)
#define SETBIT(base, bit) ACCESS(base) |= 1<<bit
#define CLRBIT(base, bit) ACCESS(base) &= ~(1<<bit)

#define CM_GP0CTL (0x7e101070)
#define GPFSEL0 (0x7E200000)
#define CM_GP0DIV (0x7e101074)
#define CLKBASE (0x7E101000)
#define DMABASE (0x7E007000)
#define PWMBASE (0x7e20C000) /* PWM controller */
constexpr auto CM_GP0CTL = 0x7e101070;
constexpr auto GPFSEL0 = 0x7E200000;
constexpr auto CM_GP0DIV = 0x7e101074;
constexpr auto CLKBASE = 0x7E101000;
constexpr auto DMABASE = 0x7E007000;
constexpr auto PWMBASE = 0x7e20C000; /* PWM controller */


struct GPCTL {
Expand All @@ -81,18 +71,18 @@ struct GPCTL {


void getRealMemPage(void** vAddr, void** pAddr) {
void* a = valloc(4096);
int* a = (int*)valloc(4096);

((int*)a)[0] = 1; // use page to force allocation.
a[0] = 1; // use page to force allocation.

mlock(a, 4096); // lock into ram.
mlock((void*)a, 4096); // lock into ram.

*vAddr = a; // yay - we know the virtual address

unsigned long long frameinfo;

int fp = open("/proc/self/pagemap", O_RDONLY);
lseek(fp, ((int)a)/4096*8, SEEK_SET);
lseek(fp, (int)a/4096*8, SEEK_SET);
read(fp, &frameinfo, sizeof(frameinfo));

*pAddr = (void*)((int)(frameinfo*4096));
Expand Down Expand Up @@ -120,7 +110,7 @@ void setup_fm()
PROT_READ|PROT_WRITE,
MAP_SHARED,
mem_fd,
0x20000000 //base
0x20000000 //base - peripheral bus
);

if ((int)allof7e==-1) exit(-1);
Expand Down Expand Up @@ -270,7 +260,7 @@ class PreEmp : public SampleSink {
// this isn't the right filter... But it's close...
// Something todo with a bilinear transform not being right...
PreEmp(float rate, SampleSink* next):
fmconstant(rate * 75.0e-6), // for pre-emphisis filter. 75us time constant
fmconstant(rate * 75.0e-6), // for pre-emphasis filter. 75us time constant
dataold(0),
next(next) { };

Expand Down Expand Up @@ -312,7 +302,7 @@ class Resamp : public SampleSink {
for(int j=0; j<SQUALITY; j++) { // starttime
float x = PI * ((float)j/SQUALITY + (QUALITY-1-i) - (QUALITY-1)/2.0);
if (x==0)
sincLUT[j][i] = 1.0; // sin(0)/(0) == 1, says my limits therory
sincLUT[j][i] = 1.0; // sin(0)/(0) == 1, says my limits theory
else
sincLUT[j][i] = sin(x)/x;
}
Expand Down