add gptimer python
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
CPU_FREQUENCY = 48e6
|
||||
|
||||
|
||||
def headstage_gptimer_get_frequency_load_value(frequency: float) -> int:
|
||||
load = int(CPU_FREQUENCY / frequency) - 1
|
||||
|
||||
if load < 0xFFFF:
|
||||
return load
|
||||
else:
|
||||
return 0xFA0000 | int(load / 250) - 1
|
||||
|
||||
|
||||
def headstage_gptimer_get_timeout_load_value(timeout_us: int) -> int:
|
||||
load = int(timeout_us * CPU_FREQUENCY / 1e6) - 1
|
||||
|
||||
if load < 0xFFFF:
|
||||
return load
|
||||
else:
|
||||
return 0xFA0000 | int(load / 250) - 1
|
||||
|
||||
|
||||
print('0x%06X' % headstage_gptimer_get_frequency_load_value(0.8))
|
||||
Reference in New Issue
Block a user