reserve the interface for interrupt & DMA #19420
Unanswered
Happiness-in-Danger
asked this question in
STM32 / Pyboard
Replies: 1 comment 4 replies
-
|
Why use a separate C module at all ? import micropython
def dshot_crc_py(packet12):
# packet12 = 12-bit payload
return (packet12 ^ (packet12 >> 4) ^ (packet12 >> 8)) & 0x0F
# or faster versions :
@micropython.native
def dshot_crc_native(packet12):
return (packet12 ^ (packet12 >> 4) ^ (packet12 >> 8)) & 0x0F
@micropython.viper
def dshot_crc_viper(packet12: int) -> int:
return (packet12 ^ (packet12 >> 4) ^ (packet12 >> 8)) & 0x0F
dshot_crc = dshot_crc_viper # choose the fastest version for your platform
def make_dshot_frame(throttle, telemetry=0):
payload = (throttle << 1) | telemetry
crc = dshot_crc(payload)
return (payload << 4) | crc
for t in range(0, 2048, 27):
frame = make_dshot_frame(t)
print(f"throttle={frame >> 5:b012} telemetry={(frame >> 4) & 1} crc={frame & 0x0F}")Not sure if I have used the correct CRC4 calculation, please verify |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to run auto-signal like DShot. I will write C program and debug in firmware. In micro python I can import it and use my program .
but I can't use interrupt & DMA ,because there are some errors. So I wish there are some interfaces I can use for my program. Thanks
Beta Was this translation helpful? Give feedback.
All reactions