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

Add ENUM for DSHOT commands #117

Merged
merged 1 commit into from
Jun 15, 2023
Merged
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
18 changes: 9 additions & 9 deletions src/Modules/DShot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -83,39 +83,39 @@ dshot_cmd_check_count:

dshot_cmd_direction_normal:
; Set motor spinning direction to normal
cjne Temp1, #7, dshot_cmd_direction_reverse
cjne Temp1, #CMD_DIRECTION_NORMAL, dshot_cmd_direction_reverse

clr Flag_Pgm_Dir_Rev

sjmp dshot_cmd_exit

dshot_cmd_direction_reverse:
; Set motor spinning direction to reversed
cjne Temp1, #8, dshot_cmd_direction_bidir_off
cjne Temp1, #CMD_DIRECTION_REVERSE, dshot_cmd_direction_bidir_off

setb Flag_Pgm_Dir_Rev

sjmp dshot_cmd_exit

dshot_cmd_direction_bidir_off:
; Set motor control mode to normal (not bidirectional)
cjne Temp1, #9, dshot_cmd_direction_bidir_on
cjne Temp1, #CMD_BIDIR_OFF, dshot_cmd_direction_bidir_on

clr Flag_Pgm_Bidir

sjmp dshot_cmd_exit

dshot_cmd_direction_bidir_on:
; Set motor control mode to bidirectional
cjne Temp1, #10, dshot_cmd_extended_telemetry_enable
cjne Temp1, #CMD_BIDIR_ON, dshot_cmd_extended_telemetry_enable

setb Flag_Pgm_Bidir

sjmp dshot_cmd_exit

dshot_cmd_extended_telemetry_enable:
; Enable extended telemetry
cjne Temp1, #13, dshot_cmd_extended_telemetry_disable
cjne Temp1, #CMD_EXTENDED_TELEMETRY_ENABLE, dshot_cmd_extended_telemetry_disable

mov Ext_Telemetry_L, #00h
mov Ext_Telemetry_H, #0Eh ; Send state/event 0 frame to signal telemetry enable
Expand All @@ -126,7 +126,7 @@ dshot_cmd_extended_telemetry_enable:

dshot_cmd_extended_telemetry_disable:
; Disable extended telemetry
cjne Temp1, #14, dshot_cmd_direction_user_normal
cjne Temp1, #CMD_EXTENDED_TELEMETRY_DISABLE, dshot_cmd_direction_user_normal

mov Ext_Telemetry_L, #0FFh
mov Ext_Telemetry_H, #0Eh ; Send state/event 0xff frame to signal telemetry disable
Expand All @@ -137,7 +137,7 @@ dshot_cmd_extended_telemetry_disable:

dshot_cmd_direction_user_normal:
; Set motor spinning direction to user programmed direction
cjne Temp1, #20, dshot_cmd_direction_user_reverse
cjne Temp1, #CMD_DIRECTION_USER_NORMAL, dshot_cmd_direction_user_reverse

mov Temp2, #Pgm_Direction ; Read programmed direction
mov A, @Temp2
Expand All @@ -149,7 +149,7 @@ dshot_cmd_direction_user_normal:

dshot_cmd_direction_user_reverse: ; Temporary reverse
; Set motor spinning direction to reverse of user programmed direction
cjne Temp1, #21, dshot_cmd_save_settings
cjne Temp1, #CMD_DIRECTION_USER_REVERSE, dshot_cmd_save_settings

mov Temp2, #Pgm_Direction ; Read programmed direction
mov A, @Temp2
Expand All @@ -161,7 +161,7 @@ dshot_cmd_direction_user_reverse: ; Temporary reverse
sjmp dshot_cmd_exit

dshot_cmd_save_settings:
cjne Temp1, #12, dshot_cmd_exit
cjne Temp1, #CMD_SAVE_SETTINGS, dshot_cmd_exit

clr A ; Set programmed direction from flags
mov C, Flag_Pgm_Dir_Rev
Expand Down
19 changes: 19 additions & 0 deletions src/Modules/Enums.asm
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,22 @@
PWM_10_BIT EQU 2
PWM_9_BIT EQU 1
PWM_8_BIT EQU 0

;**** **** **** **** **** **** **** **** **** **** **** **** ****
; DSHOT Commands
;**** **** **** **** **** **** **** **** **** **** **** **** ****
CMD_DIRECTION_USER_REVERSE EQU 21
CMD_DIRECTION_USER_NORMAL EQU 20
CMD_EXTENDED_TELEMETRY_DISABLE EQU 14
CMD_EXTENDED_TELEMETRY_ENABLE EQU 13
CMD_SAVE_SETTINGS EQU 12
CMD_BIDIR_ON EQU 10
CMD_BIDIR_OFF EQU 9
CMD_DIRECTION_REVERSE EQU 8
CMD_DIRECTION_NORMAL EQU 7
CMD_ESC_INFO EQU 6
CMD_BEEP_5 EQU 5
CMD_BEEP_4 EQU 4
CMD_BEEP_3 EQU 3
CMD_BEEP_2 EQU 2
CMD_BEEP_1 EQU 1
8 changes: 4 additions & 4 deletions src/Modules/Fx.asm
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,22 @@ beacon_beep:
mov Temp2, #Pgm_Beacon_Strength ; Set beacon beep strength
mov Beep_Strength, @Temp2

cjne Temp1, #1, beacon_beep2
cjne Temp1, #CMD_BEEP_1, beacon_beep2
call beep_f1
sjmp beacon_beep_exit

beacon_beep2:
cjne Temp1, #2, beacon_beep3
cjne Temp1, #CMD_BEEP_2, beacon_beep3
call beep_f2
sjmp beacon_beep_exit

beacon_beep3:
cjne Temp1, #3, beacon_beep4
cjne Temp1, #CMD_BEEP_3, beacon_beep4
call beep_f3
sjmp beacon_beep_exit

beacon_beep4:
cjne Temp1, #4, beacon_beep5
cjne Temp1, #CMD_BEEP_4, beacon_beep5
call beep_f4
sjmp beacon_beep_exit

Expand Down