Skip to content
Snippets Groups Projects
Commit 7e6881cf authored by Damien George's avatar Damien George
Browse files

stmhal/boards/pllvalues.py: Make script work with both Python 2 and 3.

parent 3e1412a1
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@ the CPU frequency to a given value. The algorithm here appears as C code
for the machine.freq() function.
"""
from __future__ import print_function
def close_int(x):
return abs(x - round(x)) < 0.01
......@@ -38,7 +40,10 @@ def compute_pll(hse, sys):
# improved version that doesn't require N/M to be an integer
def compute_pll2(hse, sys):
for P in (2, 4, 6, 8): # allowed values of P
# Loop over the allowed values of P, looking for a valid PLL configuration
# that gives the desired "sys" frequency. We use floats for P to force
# floating point arithmetic on Python 2.
for P in (2.0, 4.0, 6.0, 8.0):
Q = sys * P / 48
# Q must be an integer in a set range
if not (close_int(Q) and 2 <= Q <= 15):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment