Browse Source

refactor: Move DShot decode macro to main file

Mathias Rasmussen 4 years ago
parent
commit
3d42e06d8a
  1. 30
      Bluejay.asm
  2. 30
      Common.inc

30
Bluejay.asm

@ -388,6 +388,36 @@ IF MCU_48MHZ < 2 AND PWM_FREQ < 3
PWM_BITS_H EQU (2 + MCU_48MHZ - PWM_CENTERED - PWM_FREQ)
ENDIF
Decode_DShot_2Bit MACRO dest, decode_fail
movx A, @Temp1
mov Temp7, A
clr C
subb A, Temp6 ; Subtract previous timestamp
clr C
subb A, Temp2
jc decode_fail ; Check that bit is longer than minimum
subb A, Temp2 ; Check if bit is zero or one
mov A, dest ; Shift bit into data byte
rlc A
mov dest, A
inc Temp1 ; Next bit
movx A, @Temp1
mov Temp6, A
clr C
subb A, Temp7
clr C
subb A, Temp2
jc decode_fail
subb A, Temp2
mov A, dest
rlc A
mov dest, A
inc Temp1
ENDM
;**** **** **** **** ****
Interrupt_Table_Definition ; SiLabs interrupts
CSEG AT 80h ; Code segment after interrupt vectors

30
Common.inc

@ -154,36 +154,6 @@ CSEG AT 73h ; Timer3 overflow/compare interrupt
jmp t3_int
ENDM
Decode_DShot_2Bit MACRO dest, decode_fail
movx A, @Temp1
mov Temp7, A
clr C
subb A, Temp6 ; Subtract previous timestamp
clr C
subb A, Temp2
jc decode_fail ; Check that bit is longer than minimum
subb A, Temp2 ; Check if bit is zero or one
mov A, dest ; Shift bit into data byte
rlc A
mov dest, A
inc Temp1 ; Next bit
movx A, @Temp1
mov Temp6, A
clr C
subb A, Temp7
clr C
subb A, Temp2
jc decode_fail
subb A, Temp2
mov A, dest
rlc A
mov dest, A
inc Temp1
ENDM
Initialize_PCA MACRO
mov PCA0CN0, #40h ; PCA enabled
mov PCA0MD, #08h ; PCA clock is system clock

Loading…
Cancel
Save