Browse Source

refactor: Use custom flags to clean up some layouts

main
Mathias Rasmussen 4 years ago
parent
commit
d4ddbb3967
  1. 16
      targets/Base.inc
  2. 23
      targets/E.inc
  3. 10
      targets/O.inc
  4. 76
      targets/W.inc

16
targets/Base.inc

@ -19,15 +19,6 @@ $if NOT CUSTOM_PWM_SETUP
Initialize_Xbar MACRO Initialize_Xbar MACRO
mov XBR2, #40h ;; Xbar enabled mov XBR2, #40h ;; Xbar enabled
mov XBR1, #02h ;; CEX0 and CEX1 routed to pins mov XBR1, #02h ;; CEX0 and CEX1 routed to pins
IF ESCNO = E_
All_pwmFETs_off ; For unlocking of HIP2103/4 driver circuits
call wait100ms
AcomFET_on
BcomFET_on
CcomFET_on
call wait1ms
All_comFETs_off
ENDIF
ENDM ENDM
Set_Pwm_Polarity MACRO Set_Pwm_Polarity MACRO
@ -54,6 +45,8 @@ CMP_MD EQU CMP1MD
CMP_MX EQU CMP1MX CMP_MX EQU CMP1MX
ENDIF ENDIF
$if NOT CUSTOM_COMP_SETUP
Initialize_Comparator MACRO Initialize_Comparator MACRO
mov CMP_CN0, #80h ;; Comparator enabled, no hysteresis mov CMP_CN0, #80h ;; Comparator enabled, no hysteresis
mov CMP_MD, #00h ;; Comparator response time 100ns mov CMP_MD, #00h ;; Comparator response time 100ns
@ -61,11 +54,10 @@ ENDM
Read_Comp_Out MACRO Read_Comp_Out MACRO
mov A, CMP_CN0 ;; Read comparator output mov A, CMP_CN0 ;; Read comparator output
IF ESCNO == O_
cpl A
ENDIF
ENDM ENDM
$endif
; Set comparator multiplexer to phase A ; Set comparator multiplexer to phase A
Set_Comp_Phase_A MACRO Set_Comp_Phase_A MACRO
mov CMP_MX, #((A_Mux SHL 4) + Comp_Com) mov CMP_MX, #((A_Mux SHL 4) + Comp_Com)

23
targets/E.inc

@ -91,7 +91,7 @@ A_pwm EQU 0 ;o
COMP_PORT EQU 0 COMP_PORT EQU 0
$set(CUSTOM_LED)
$set(CUSTOM_PWM_SETUP, CUSTOM_LED)
$include (Base.inc) $include (Base.inc)
@ -121,6 +121,27 @@ P2_SKIP EQU 0FFh
; MCU specific macros * ; MCU specific macros *
;********************** ;**********************
Initialize_Xbar MACRO
mov XBR2, #40h ;; Xbar enabled
mov XBR1, #02h ;; CEX0 and CEX1 routed to pins
All_pwmFETs_off ;; For unlocking of HIP2103/4 driver circuits
call wait100ms
AcomFET_on
BcomFET_on
CcomFET_on
call wait1ms
All_comFETs_off
ENDM
Set_Pwm_Polarity MACRO
IF PCA0_POWER_MODULE == PCA0CPM0
mov PCA0POL, #((COMPWM_ACTIVE_HIGH SHL 1) + (1 - PWM_ACTIVE_HIGH))
ELSE
mov PCA0POL, #(((1 - PWM_ACTIVE_HIGH) SHL 1) + COMPWM_ACTIVE_HIGH)
ENDIF
ENDM
Set_LED_0 MACRO Set_LED_0 MACRO
setb P0.LED_0 setb P0.LED_0
ENDM ENDM

10
targets/O.inc

@ -91,7 +91,7 @@ A_pwm EQU 0 ;o
COMP_PORT EQU 0 COMP_PORT EQU 0
$set(CUSTOM_COMP_SETUP)
$include (Base.inc) $include (Base.inc)
P1_DIGITAL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com) P1_DIGITAL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com)
@ -100,6 +100,14 @@ P1_PUSHPULL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) +
P1_SKIP EQU 0FFh P1_SKIP EQU 0FFh
Initialize_Comparator MACRO
mov CMP_CN0, #80h ;; Comparator enabled, no hysteresis
mov CMP_MD, #40h ;; Comparator response time 100ns, Output polarity inverted
ENDM
Read_Comp_Out MACRO
mov A, CMP_CN0 ;; Read comparator output
ENDM

76
targets/W.inc

@ -28,14 +28,6 @@
;**** **** **** **** **** ;**** **** **** **** ****
;**** **** **** **** ****
; Bootloader definitions
;**** **** **** **** ****
RTX_PORT EQU P0 ; Receive/Transmit port
RTX_MDOUT EQU P0MDOUT ; Set to 1 for PUSHPULL
RTX_MDIN EQU P0MDIN ; Set to 1 for DIGITAL
RTX_SKIP EQU P0SKIP ; Set to 1 for SKIP
RTX_PIN EQU 7 ; RTX pin
;********************* ;*********************
@ -56,13 +48,8 @@ P0_PUSHPULL EQU 0
P0_SKIP EQU 0FFh P0_SKIP EQU 0FFh
Set_Pwm_Polarity MACRO
IF FETON_DELAY == 0
mov PCA0POL, #00h ; Pwm noninverted
ELSE
mov PCA0POL, #01h ; Damping inverted, pwm noninverted
ENDIF
ENDM
PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted
COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted
IF FETON_DELAY == 0 IF FETON_DELAY == 0
PCA0_POWER_MODULE EQU PCA0CPM0 PCA0_POWER_MODULE EQU PCA0CPM0
@ -94,6 +81,14 @@ C_pwm EQU 4 ;o
; EQU 2 ;i ; EQU 2 ;i
; EQU 1 ;i ; EQU 1 ;i
; EQU 0 ;i ; EQU 0 ;i
; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port
COMP_PORT EQU 0
$set(CUSTOM_PWM_PHASE, CUSTOM_FET_TOGGLING)
$include (Base.inc)
; pwm outputs start as analog in -> floating ; pwm outputs start as analog in -> floating
; this ensures all mosfet drivers start with floating outputs ; this ensures all mosfet drivers start with floating outputs
P1_DIGITAL EQU NOT((1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm)) P1_DIGITAL EQU NOT((1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm))
@ -186,20 +181,6 @@ ENDM
Set_Comp_Phase_A MACRO
mov CMP0MX, #((A_Mux) SHL 4)+((Comp_Com) SHL 0);
ENDM
Set_Comp_Phase_B MACRO
mov CMP0MX, #((B_Mux) SHL 4)+((Comp_Com) SHL 0);
ENDM
Set_Comp_Phase_C MACRO
mov CMP0MX, #((C_Mux) SHL 4)+((Comp_Com) SHL 0);
ENDM
Read_Comp_Out MACRO
mov A, CMP0CN0 ; Read comparator output
ENDM
;********************* ;*********************
; PORT 2 definitions * ; PORT 2 definitions *
@ -209,40 +190,3 @@ DebugPin EQU 0 ;o
P2_DIGITAL EQU (1 SHL DebugPin) P2_DIGITAL EQU (1 SHL DebugPin)
P2_PUSHPULL EQU (1 SHL DebugPin) P2_PUSHPULL EQU (1 SHL DebugPin)
P2_SKIP EQU 0FFh P2_SKIP EQU 0FFh
;**********************
; MCU specific macros *
;**********************
Initialize_Xbar MACRO
mov XBR2, #40h ; Xbar enabled
mov XBR1, #02h ; CEX0 and CEX1 routed to pins
ENDM
Initialize_Comparator MACRO
mov CMP0CN0, #80h ; Comparator enabled, no hysteresis
mov CMP0MD, #00h ; Comparator response time 100ns
ENDM
Set_LED_0 MACRO
ENDM
Clear_LED_0 MACRO
ENDM
Set_LED_1 MACRO
ENDM
Clear_LED_1 MACRO
ENDM
Set_LED_2 MACRO
ENDM
Clear_LED_2 MACRO
ENDM
Set_LED_3 MACRO
ENDM
Clear_LED_3 MACRO
ENDM
Loading…
Cancel
Save