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

port to pi4 #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

port to pi4 #19

wants to merge 3 commits into from

Conversation

AdamLaurie
Copy link

as per my commit comments i'm not a c++ guy so feel free to treat this as a starting point and do a nicer job, but it does seem to work! :)

…seems to select regular oscillator, see comments in code).

apologies for moving code around - i'm not a c++ guy and that was the easiest way to get it to compile. i also don't understand
why i'm getting warnings! enjoy!
@@ -301,3 +215,98 @@ bool GPIO::Init() {

return gpio_port_ != MAP_FAILED && clock_reg_ != MAP_FAILED;
}


// BCM2835-ARM-Peripherals.pdf, page 105 onwards.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the diff small, can you move this block back to around line 105 ?

@hzeller
Copy link
Owner

hzeller commented Jan 21, 2022

Thanks, looks like a good starting point. Where did you find a documentation of the frequencies ? That would be good to include in a comment.

@AdamLaurie
Copy link
Author

i got the frequencies through experimentation and observation via oscilloscope, not via documentation. if i move the code back to line 105 compilation fails, as per commit comments. i would love to be more helpful but, again, as per commit comments, i'm not a c++ guy so i have no clue. sorry!

@pjueon
Copy link
Contributor

pjueon commented Feb 11, 2022

Hi, I found this code from librpitx which is a radio frequency transmitter library for raspberry pi and the engine of rpitx.

I don't have any pi 4 device so I couldn't test it, but I think it might be helpful information.
The pi 4 support in rpitx is still in beta mode, but it looks like a lot of people are using it so I think it can be trusted to some extent.

i got the frequencies through experimentation and observation via oscilloscope, not via documentation.

In the code I found, the frequency of the regular oscillator for pi 4 seems to be 54000000 which is close to your observation.
(XOSC_FREQUENCY is 54000000 and pi_is_2711 is true for pi 4 from the code)

I couldn't figure out the other frequency values (pllc, plld, hdmi) from the code. But I'm sure you guys can figure it out (by running it, for example).

@pjueon
Copy link
Contributor

pjueon commented Feb 11, 2022

if i move the code back to line 105 compilation fails, as per commit comments. i would love to be more helpful but, again, as per commit comments, i'm not a c++ guy so i have no clue. sorry!

BTW if you move the definition of enum RaspberryPiModel and add a forward declaration of GetPiModel function before GPIO::StartClock, you can avoid the compilation error.

for example:

// We are not interested in the _exact_ model, just good enough to determine
// What to do.
enum RaspberryPiModel {
  PI_MODEL_1,
  PI_MODEL_2,
  PI_MODEL_3,
  PI_MODEL_4
};

//  just a forward declaration
static RaspberryPiModel GetPiModel();

// BCM2835-ARM-Peripherals.pdf, page 105 onwards.
double GPIO::StartClock(double requested_freq) {
// ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants