Browse Source

style: Rename pwm/com fets on/off macros

main
Mathias Rasmussen 4 years ago
parent
commit
eda8846976
  1. 78
      Bluejay.asm
  2. 40
      Layouts/Base.inc
  3. 10
      Layouts/E.inc
  4. 28
      Layouts/W.inc

78
Bluejay.asm

@ -1280,21 +1280,21 @@ beep_start:
beep_on_off:
clr A
BcomFET_off ; BcomFET off
B_Com_Fet_Off ; BcomFET off
djnz ACC, $ ; Allow some time after comfet is turned off
BpwmFET_on ; BpwmFET on (in order to charge the driver of the BcomFET)
B_Pwm_Fet_On ; BpwmFET on (in order to charge the driver of the BcomFET)
djnz ACC, $ ; Let the pwmfet be turned on a while
BpwmFET_off ; BpwmFET off again
B_Pwm_Fet_Off ; BpwmFET off again
djnz ACC, $ ; Allow some time after pwmfet is turned off
BcomFET_on ; BcomFET on
B_Com_Fet_On ; BcomFET on
djnz ACC, $ ; Allow some time after comfet is turned on
mov A, Temp2 ; Turn on pwmfet
jb ACC.0, beep_a_pwm_on
ApwmFET_on
A_Pwm_Fet_On
beep_a_pwm_on:
jnb ACC.0, beep_c_pwm_on
CpwmFET_on
C_Pwm_Fet_On
beep_c_pwm_on:
mov A, Beep_Strength ; On time according to beep strength
@ -1302,10 +1302,10 @@ beep_c_pwm_on:
mov A, Temp2 ; Turn off pwmfet
jb ACC.0, beep_a_pwm_off
ApwmFET_off
A_Pwm_Fet_Off
beep_a_pwm_off:
jnb ACC.0, beep_c_pwm_off
CpwmFET_off
C_Pwm_Fet_Off
beep_c_pwm_off:
mov A, #150 ; Off for 25 us
@ -1321,7 +1321,7 @@ beep_off: ; Fets off loop
djnz Temp4, beep_start ; Number of beep pulses (duration)
BcomFET_off
B_Com_Fet_Off
ret
@ -1380,8 +1380,8 @@ led_3_done:
;
;**** **** **** **** **** **** **** **** **** **** **** **** ****
switch_power_off:
All_pwmFETs_Off ; Turn off all pwm fets
All_comFETs_Off ; Turn off all commutation fets
All_Pwm_Fets_Off ; Turn off all pwm fets
All_Com_Fets_Off ; Turn off all commutation fets
Set_Pwms_Off
ret
@ -2355,7 +2355,7 @@ wait_for_comm:
subb A, Demag_Pwr_Off_Thresh
jc wait_for_comm_wait ; Cut power if many consecutive demags. This will help retain sync during hard accelerations
All_pwmFETs_off
All_Pwm_Fets_Off
Set_Pwms_Off
wait_for_comm_wait:
@ -2381,8 +2381,8 @@ comm1_comm2: ; C->A
jb Flag_Pgm_Dir_Rev, comm1_comm2_rev
clr IE_EA ; Disable all interrupts
BcomFET_off ; Turn off comfet
AcomFET_on ; Turn on comfet
B_Com_Fet_Off ; Turn off comfet
A_Com_Fet_On ; Turn on comfet
Set_Pwm_C ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_B ; Set comparator phase
@ -2390,8 +2390,8 @@ comm1_comm2: ; C->A
comm1_comm2_rev: ; A->C
clr IE_EA ; Disable all interrupts
BcomFET_off ; Turn off comfet
CcomFET_on ; Turn on comfet (reverse)
B_Com_Fet_Off ; Turn off comfet
C_Com_Fet_On ; Turn on comfet (reverse)
Set_Pwm_A ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_B ; Set comparator phase
@ -2402,18 +2402,18 @@ comm2_comm3: ; B->A
jb Flag_Pgm_Dir_Rev, comm2_comm3_rev
clr IE_EA ; Disable all interrupts
CpwmFET_off ; Turn off pwmfet
C_Pwm_Fet_Off ; Turn off pwmfet
Set_Pwm_B ; To reapply power after a demag cut
AcomFET_on
A_Com_Fet_On
setb IE_EA
Set_Comp_Phase_C ; Set comparator phase
ret
comm2_comm3_rev: ; B->C
clr IE_EA ; Disable all interrupts
ApwmFET_off ; Turn off pwmfet (reverse)
A_Pwm_Fet_Off ; Turn off pwmfet (reverse)
Set_Pwm_B ; To reapply power after a demag cut
CcomFET_on
C_Com_Fet_On
setb IE_EA
Set_Comp_Phase_A ; Set comparator phase (reverse)
ret
@ -2423,8 +2423,8 @@ comm3_comm4: ; B->C
jb Flag_Pgm_Dir_Rev, comm3_comm4_rev
clr IE_EA ; Disable all interrupts
AcomFET_off ; Turn off comfet
CcomFET_on ; Turn on comfet
A_Com_Fet_Off ; Turn off comfet
C_Com_Fet_On ; Turn on comfet
Set_Pwm_B ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_A ; Set comparator phase
@ -2432,8 +2432,8 @@ comm3_comm4: ; B->C
comm3_comm4_rev: ; B->A
clr IE_EA ; Disable all interrupts
CcomFET_off ; Turn off comfet (reverse)
AcomFET_on ; Turn on comfet (reverse)
C_Com_Fet_Off ; Turn off comfet (reverse)
A_Com_Fet_On ; Turn on comfet (reverse)
Set_Pwm_B ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_C ; Set comparator phase (reverse)
@ -2444,18 +2444,18 @@ comm4_comm5: ; A->C
jb Flag_Pgm_Dir_Rev, comm4_comm5_rev
clr IE_EA ; Disable all interrupts
BpwmFET_off ; Turn off pwmfet
B_Pwm_Fet_Off ; Turn off pwmfet
Set_Pwm_A ; To reapply power after a demag cut
CcomFET_on
C_Com_Fet_On
setb IE_EA
Set_Comp_Phase_B ; Set comparator phase
ret
comm4_comm5_rev: ; C->A
clr IE_EA ; Disable all interrupts
BpwmFET_off ; Turn off pwmfet
B_Pwm_Fet_Off ; Turn off pwmfet
Set_Pwm_C
AcomFET_on ; To reapply power after a demag cut
A_Com_Fet_On ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_B ; Set comparator phase
ret
@ -2465,8 +2465,8 @@ comm5_comm6: ; A->B
jb Flag_Pgm_Dir_Rev, comm5_comm6_rev
clr IE_EA ; Disable all interrupts
CcomFET_off ; Turn off comfet
BcomFET_on ; Turn on comfet
C_Com_Fet_Off ; Turn off comfet
B_Com_Fet_On ; Turn on comfet
Set_Pwm_A ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_C ; Set comparator phase
@ -2474,8 +2474,8 @@ comm5_comm6: ; A->B
comm5_comm6_rev: ; C->B
clr IE_EA ; Disable all interrupts
AcomFET_off ; Turn off comfet (reverse)
BcomFET_on ; Turn on comfet
A_Com_Fet_Off ; Turn off comfet (reverse)
B_Com_Fet_On ; Turn on comfet
Set_Pwm_C ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_A ; Set comparator phase (reverse)
@ -2486,18 +2486,18 @@ comm6_comm1: ; C->B
jb Flag_Pgm_Dir_Rev, comm6_comm1_rev
clr IE_EA ; Disable all interrupts
ApwmFET_off ; Turn off pwmfet
A_Pwm_Fet_Off ; Turn off pwmfet
Set_Pwm_C
BcomFET_on ; To reapply power after a demag cut
B_Com_Fet_On ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_A ; Set comparator phase
ret
comm6_comm1_rev: ; A->B
clr IE_EA ; Disable all interrupts
CpwmFET_off ; Turn off pwmfet (reverse)
C_Pwm_Fet_Off ; Turn off pwmfet (reverse)
Set_Pwm_A
BcomFET_on ; To reapply power after a demag cut
B_Com_Fet_On ; To reapply power after a demag cut
setb IE_EA
Set_Comp_Phase_C ; Set comparator phase (reverse)
ret
@ -4104,9 +4104,9 @@ ENDIF
mov A, @Temp1
jz run_to_wait_for_power_on_brake_done
AcomFET_on
BcomFET_on
CcomFET_on
A_Com_Fet_On
B_Com_Fet_On
C_Com_Fet_On
run_to_wait_for_power_on_brake_done:
jnb Flag_Rcp_Stop, ($+6) ; Check if RCP is zero, then it is a normal stop

40
Layouts/Base.inc

@ -215,14 +215,14 @@ $endif
;**** **** **** **** ****
$if NOT CUSTOM_FET_TOGGLING
ApwmFET_on MACRO
A_Pwm_Fet_On MACRO
pON P_A_pwm
IF DEADTIME == 0
cON P_A_com
ENDIF
ENDM
ApwmFET_off MACRO
A_Pwm_Fet_Off MACRO
IF DEADTIME != 0
pOFF P_A_pwm
ELSE
@ -230,14 +230,14 @@ ELSE
ENDIF
ENDM
BpwmFET_on MACRO
B_Pwm_Fet_On MACRO
pON P_B_pwm
IF DEADTIME == 0
cON P_B_com
ENDIF
ENDM
BpwmFET_off MACRO
B_Pwm_Fet_Off MACRO
IF DEADTIME != 0
pOFF P_B_pwm
ELSE
@ -245,14 +245,14 @@ ELSE
ENDIF
ENDM
CpwmFET_on MACRO
C_Pwm_Fet_On MACRO
pON P_C_pwm
IF DEADTIME == 0
cON P_C_com
ENDIF
ENDM
CpwmFET_off MACRO
C_Pwm_Fet_Off MACRO
IF DEADTIME != 0
pOFF P_C_pwm
ELSE
@ -260,50 +260,50 @@ ELSE
ENDIF
ENDM
All_pwmFETs_Off MACRO
ApwmFET_off
BpwmFET_off
CpwmFET_off
All_Pwm_Fets_Off MACRO
A_Pwm_Fet_Off
B_Pwm_Fet_Off
C_Pwm_Fet_Off
ENDM
AcomFET_on MACRO
A_Com_Fet_On MACRO
IF DEADTIME == 0
pOFF P_A_pwm
ENDIF
cON P_A_com
ENDM
AcomFET_off MACRO
A_Com_Fet_Off MACRO
cOFF P_A_com
ENDM
BcomFET_on MACRO
B_Com_Fet_On MACRO
IF DEADTIME == 0
pOFF P_B_pwm
ENDIF
cON P_B_com
ENDM
BcomFET_off MACRO
B_Com_Fet_Off MACRO
cOFF P_B_com
ENDM
CcomFET_on MACRO
C_Com_Fet_On MACRO
IF DEADTIME == 0
pOFF P_C_pwm
ENDIF
cON P_C_com
ENDM
CcomFET_off MACRO
C_Com_Fet_Off MACRO
cOFF P_C_com
ENDM
All_comFETs_Off MACRO
AcomFET_off
BcomFET_off
CcomFET_off
All_Com_Fets_Off MACRO
A_Com_Fet_Off
B_Com_Fet_Off
C_Com_Fet_Off
ENDM
$endif

10
Layouts/E.inc

@ -104,13 +104,13 @@ Initialize_Crossbar MACRO
mov XBR2, #40h ;; Crossbar enabled
mov XBR1, #02h ;; CEX0 and CEX1 routed to pins
All_pwmFETs_off ;; For unlocking of HIP2103/4 driver circuits
All_Pwm_Fets_Off ;; For unlocking of HIP2103/4 driver circuits
call wait100ms
AcomFET_on
BcomFET_on
CcomFET_on
A_Com_Fet_On
B_Com_Fet_On
C_Com_Fet_On
call wait1ms
All_comFETs_off
All_Com_Fets_Off
ENDM
Set_Pwm_Polarity MACRO

28
Layouts/W.inc

@ -89,65 +89,65 @@ P1_PUSHPULL EQU ((1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm))
P1_SKIP EQU 0FFh
ApwmFET_on MACRO
A_Pwm_Fet_On MACRO
setb P1.A_pwm ; set pin to high
orl P1MDIN, #(1 SHL A_pwm) ; enable pin driver
ENDM
ApwmFET_off MACRO
A_Pwm_Fet_Off MACRO
anl P1MDIN, #(NOT(1 SHL A_pwm)) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
BpwmFET_on MACRO
B_Pwm_Fet_On MACRO
setb P1.B_pwm ; set pin to high
orl P1MDIN, #(1 SHL B_pwm) ; enable pin driver
ENDM
BpwmFET_off MACRO
B_Pwm_Fet_Off MACRO
anl P1MDIN, #(NOT(1 SHL B_pwm)) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
CpwmFET_on MACRO
C_Pwm_Fet_On MACRO
setb P1.C_pwm ; set pin to high
orl P1MDIN, #(1 SHL C_pwm) ; enable pin driver
ENDM
CpwmFET_off MACRO
C_Pwm_Fet_Off MACRO
anl P1MDIN, #(NOT(1 SHL C_pwm)) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
All_pwmFETs_Off MACRO
All_Pwm_Fets_Off MACRO
anl P1MDIN, #(NOT((1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm))) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
AcomFET_on MACRO
A_Com_Fet_On MACRO
clr P1.A_pwm ; set pin to low
orl P1MDIN, #(1 SHL A_pwm) ; enable pin driver
ENDM
AcomFET_off MACRO
A_Com_Fet_Off MACRO
anl P1MDIN, #(NOT(1 SHL A_pwm)) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
BcomFET_on MACRO
B_Com_Fet_On MACRO
clr P1.B_pwm ; set pin to low
orl P1MDIN, #(1 SHL B_pwm) ; enable pin driver
ENDM
BcomFET_off MACRO
B_Com_Fet_Off MACRO
anl P1MDIN, #(NOT(1 SHL B_pwm)) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
CcomFET_on MACRO
C_Com_Fet_On MACRO
clr P1.C_pwm ; set pin to low
orl P1MDIN, #(1 SHL C_pwm) ; enable pin driver
ENDM
CcomFET_off MACRO
C_Com_Fet_Off MACRO
anl P1MDIN, #(NOT(1 SHL C_pwm)) ; analog in -> pullup, driver and digital in is disable = floating
ENDM
All_comFETs_Off MACRO
All_Com_Fets_Off MACRO
anl P1MDIN, #(NOT((1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm))) ; analog in -> pullup, driver and digital in is disable = floating
ENDM

Loading…
Cancel
Save