From 21d5351ad62f47a8507a180cfbee31c8d5295169 Mon Sep 17 00:00:00 2001 From: Mathias Rasmussen Date: Wed, 27 Jan 2021 21:31:13 +0100 Subject: [PATCH] refactor: Simplify pwm polarity setup Changes DT=0 on some layouts --- targets/A.inc | 9 ++------- targets/B.inc | 13 ++----------- targets/Base.inc | 7 +++++++ targets/C.inc | 9 ++------- targets/D.inc | 11 +++-------- targets/E.inc | 9 ++------- targets/F.inc | 9 ++------- targets/G.inc | 9 ++------- targets/H.inc | 13 ++----------- targets/I.inc | 9 ++------- targets/J.inc | 9 ++------- targets/K.inc | 11 +++-------- targets/L.inc | 9 ++------- targets/M.inc | 9 ++------- targets/N.inc | 13 ++----------- targets/O.inc | 11 +++-------- targets/P.inc | 9 ++------- targets/Q.inc | 9 ++------- targets/R.inc | 9 ++------- targets/S.inc | 13 ++----------- targets/T.inc | 13 ++----------- targets/U.inc | 9 ++------- targets/V.inc | 13 ++----------- targets/Z.inc | 15 +++------------ 24 files changed, 57 insertions(+), 193 deletions(-) diff --git a/targets/A.inc b/targets/A.inc index 44018a9..0f3bc87 100644 --- a/targets/A.inc +++ b/targets/A.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/B.inc b/targets/B.inc index fa2b460..24c9ad4 100644 --- a/targets/B.inc +++ b/targets/B.inc @@ -54,18 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #00h ; Pwm noninverted -ELSE + ; Damping inverted, pwm noninverted -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 -ENDIF -ENDM + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/Base.inc b/targets/Base.inc index 5176dcf..8338548 100644 --- a/targets/Base.inc +++ b/targets/Base.inc @@ -29,6 +29,13 @@ cON LIT 'clr' cOFF LIT 'setb' ENDIF +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 IF COMP_PORT == 0 CMP_CN0 EQU CMP0CN0 diff --git a/targets/C.inc b/targets/C.inc index 812f1b2..143ac02 100644 --- a/targets/C.inc +++ b/targets/C.inc @@ -55,14 +55,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/D.inc b/targets/D.inc index cd389ba..5261922 100644 --- a/targets/D.inc +++ b/targets/D.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 0 -Set_Pwm_Polarity MACRO - ;mov PCA0POL, #00h ; Damping noninverted, pwm noninverted -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 + +; Damping noninverted, pwm noninverted + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/E.inc b/targets/E.inc index 0bee447..32835b0 100644 --- a/targets/E.inc +++ b/targets/E.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/F.inc b/targets/F.inc index 5dd2236..31fbe91 100644 --- a/targets/F.inc +++ b/targets/F.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/G.inc b/targets/G.inc index e47c4c4..579cd2a 100644 --- a/targets/G.inc +++ b/targets/G.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/H.inc b/targets/H.inc index 5ae6a56..5d1a636 100644 --- a/targets/H.inc +++ b/targets/H.inc @@ -54,18 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #00h ; Pwm noninverted -ELSE + ; Damping inverted, pwm noninverted -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 -ENDIF -ENDM + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/I.inc b/targets/I.inc index ee67c3f..0cca726 100644 --- a/targets/I.inc +++ b/targets/I.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/J.inc b/targets/J.inc index 1dd9446..36f64ee 100644 --- a/targets/J.inc +++ b/targets/J.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/K.inc b/targets/K.inc index ca64436..1ad0801 100644 --- a/targets/K.inc +++ b/targets/K.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 0 -Set_Pwm_Polarity MACRO - ;mov PCA0POL, #00h ; Damping noninverted, pwm noninverted -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 + +; Damping noninverted, pwm noninverted + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/L.inc b/targets/L.inc index a943494..3a9b805 100644 --- a/targets/L.inc +++ b/targets/L.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/M.inc b/targets/M.inc index 2ab7d62..da0240a 100644 --- a/targets/M.inc +++ b/targets/M.inc @@ -54,14 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/N.inc b/targets/N.inc index 4873702..a966f3b 100644 --- a/targets/N.inc +++ b/targets/N.inc @@ -54,18 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #00h ; Pwm noninverted -ELSE + ; Damping inverted, pwm noninverted -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 -ENDIF -ENDM + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/O.inc b/targets/O.inc index 18d4696..825e03e 100644 --- a/targets/O.inc +++ b/targets/O.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 0 -Set_Pwm_Polarity MACRO -; mov PCA0POL, #00h ; Damping noninverted, pwm noninverted -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 + +; Damping noninverted, pwm noninverted + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/P.inc b/targets/P.inc index 1a9b589..2d20044 100644 --- a/targets/P.inc +++ b/targets/P.inc @@ -54,14 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/Q.inc b/targets/Q.inc index ce34806..b2fcd3e 100644 --- a/targets/Q.inc +++ b/targets/Q.inc @@ -55,14 +55,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/R.inc b/targets/R.inc index a9bc9ea..6a1566d 100644 --- a/targets/R.inc +++ b/targets/R.inc @@ -53,14 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/S.inc b/targets/S.inc index b1d07c7..fb8f200 100644 --- a/targets/S.inc +++ b/targets/S.inc @@ -53,17 +53,8 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #00h ; Pwm noninverted -ELSE -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 -ENDIF -ENDM + + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/T.inc b/targets/T.inc index 14f5e76..2da73d3 100644 --- a/targets/T.inc +++ b/targets/T.inc @@ -54,18 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #00h ; Pwm noninverted -ELSE + ; Damping inverted, pwm noninverted -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 -ENDIF -ENDM + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/U.inc b/targets/U.inc index 7c4717f..17368ed 100644 --- a/targets/U.inc +++ b/targets/U.inc @@ -54,14 +54,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO + ; Damping inverted, pwm noninverted -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 + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/V.inc b/targets/V.inc index fd505d7..fca1bcb 100644 --- a/targets/V.inc +++ b/targets/V.inc @@ -55,18 +55,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 1 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #00h ; Pwm noninverted -ELSE + ; Damping inverted, pwm noninverted -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 -ENDIF - ENDM + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0 diff --git a/targets/Z.inc b/targets/Z.inc index ad81ee0..59d53d7 100644 --- a/targets/Z.inc +++ b/targets/Z.inc @@ -53,18 +53,9 @@ P0_SKIP EQU 0FFh PWM_ACTIVE_HIGH EQU 0 COMPWM_ACTIVE_HIGH EQU 1 -Set_Pwm_Polarity MACRO -IF FETON_DELAY == 0 - mov PCA0POL, #02h ; Pwm inverted -ELSE -; mov PCA0POL, #03h ; Damping inverted, pwm inverted -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 -ENDIF -ENDM + +; Damping inverted, pwm inverted + IF FETON_DELAY == 0 PCA0_POWER_MODULE EQU PCA0CPM0