From 676c717ad0d2073bee04559f23a5cf293edb8a16 Mon Sep 17 00:00:00 2001 From: Chris L Date: Tue, 6 Jun 2023 00:39:02 +0200 Subject: [PATCH 1/4] Refactored duplicate assignments #99 --- src/Layouts/A.inc | 22 ++++++---------------- src/Layouts/C.inc | 22 ++++++---------------- src/Layouts/D.inc | 22 ++++++---------------- src/Layouts/E.inc | 22 ++++++---------------- src/Layouts/F.inc | 22 ++++++---------------- src/Layouts/G.inc | 22 ++++++---------------- src/Layouts/I.inc | 22 ++++++---------------- src/Layouts/J.inc | 24 +++++++----------------- src/Layouts/L.inc | 22 ++++++---------------- src/Layouts/M.inc | 24 +++++++----------------- src/Layouts/O.inc | 22 ++++++---------------- src/Layouts/P.inc | 22 ++++++---------------- src/Layouts/Q.inc | 22 ++++++---------------- src/Layouts/R.inc | 22 ++++++---------------- src/Layouts/U.inc | 24 +++++++----------------- 15 files changed, 93 insertions(+), 243 deletions(-) diff --git a/src/Layouts/A.inc b/src/Layouts/A.inc index d6c8c24..3781bfb 100644 --- a/src/Layouts/A.inc +++ b/src/Layouts/A.inc @@ -37,23 +37,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/C.inc b/src/Layouts/C.inc index b4bfae8..4e22bd9 100644 --- a/src/Layouts/C.inc +++ b/src/Layouts/C.inc @@ -37,23 +37,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/D.inc b/src/Layouts/D.inc index e4a0f60..d856265 100644 --- a/src/Layouts/D.inc +++ b/src/Layouts/D.inc @@ -40,23 +40,13 @@ COM_ACTIVE_HIGH EQU 0 ; Damping non-inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/E.inc b/src/Layouts/E.inc index 2ffa5fa..655cac5 100644 --- a/src/Layouts/E.inc +++ b/src/Layouts/E.inc @@ -40,23 +40,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/F.inc b/src/Layouts/F.inc index 2c6fc87..f4d9430 100644 --- a/src/Layouts/F.inc +++ b/src/Layouts/F.inc @@ -39,23 +39,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/G.inc b/src/Layouts/G.inc index 8ede68e..e1384be 100644 --- a/src/Layouts/G.inc +++ b/src/Layouts/G.inc @@ -39,23 +39,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/I.inc b/src/Layouts/I.inc index 92734a1..d177d51 100644 --- a/src/Layouts/I.inc +++ b/src/Layouts/I.inc @@ -37,23 +37,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/J.inc b/src/Layouts/J.inc index 5fb8400..1c4931b 100644 --- a/src/Layouts/J.inc +++ b/src/Layouts/J.inc @@ -37,23 +37,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 + +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/L.inc b/src/Layouts/L.inc index fb7a077..114df13 100644 --- a/src/Layouts/L.inc +++ b/src/Layouts/L.inc @@ -39,23 +39,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/M.inc b/src/Layouts/M.inc index 56c52d2..f69a74f 100644 --- a/src/Layouts/M.inc +++ b/src/Layouts/M.inc @@ -37,23 +37,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 + +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/O.inc b/src/Layouts/O.inc index cbd4322..a361650 100644 --- a/src/Layouts/O.inc +++ b/src/Layouts/O.inc @@ -40,23 +40,13 @@ COM_ACTIVE_HIGH EQU 0 ; Damping non-inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 1 ; Comparator output inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/P.inc b/src/Layouts/P.inc index bfa5652..c57bdb2 100644 --- a/src/Layouts/P.inc +++ b/src/Layouts/P.inc @@ -39,23 +39,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/Q.inc b/src/Layouts/Q.inc index d2f4d18..8c23724 100644 --- a/src/Layouts/Q.inc +++ b/src/Layouts/Q.inc @@ -37,23 +37,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 1 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/R.inc b/src/Layouts/R.inc index 59a74ac..5920e97 100644 --- a/src/Layouts/R.inc +++ b/src/Layouts/R.inc @@ -39,23 +39,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions diff --git a/src/Layouts/U.inc b/src/Layouts/U.inc index 5dedcad..ad406bc 100644 --- a/src/Layouts/U.inc +++ b/src/Layouts/U.inc @@ -39,23 +39,13 @@ COM_ACTIVE_HIGH EQU 1 ; Damping inverted COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port COMPARATOR_INVERT EQU 0 ; Comparator output non-inverted -IF DEADTIME == 0 - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ELSE - PCA0CPM_POWER EQU PCA0CPM0 - PCA0CPL_POWER EQU PCA0CPL0 - PCA0CPH_POWER EQU PCA0CPH0 - - PCA0CPM_DAMP EQU PCA0CPM1 - PCA0CPL_DAMP EQU PCA0CPL1 - PCA0CPH_DAMP EQU PCA0CPH1 -ENDIF +PCA0CPM_POWER EQU PCA0CPM0 +PCA0CPL_POWER EQU PCA0CPL0 +PCA0CPH_POWER EQU PCA0CPH0 + +PCA0CPM_DAMP EQU PCA0CPM1 +PCA0CPL_DAMP EQU PCA0CPL1 +PCA0CPH_DAMP EQU PCA0CPH1 ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; PORT 0 definitions From d4889ca0eec453452510fc19555ddcb05499cd5b Mon Sep 17 00:00:00 2001 From: Chris L Date: Tue, 6 Jun 2023 01:12:48 +0200 Subject: [PATCH 2/4] Refactored CSEG definitions into seperate file #99 --- src/BLHeliBootLoad.inc | 13 +++-------- src/Bluejay.asm | 27 +++++---------------- src/Modules/Codespace.asm | 49 +++++++++++++++++++++++++++++++++++++++ src/Modules/Common.asm | 14 ++--------- 4 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 src/Modules/Codespace.asm diff --git a/src/BLHeliBootLoad.inc b/src/BLHeliBootLoad.inc index fcb8128..3edad53 100644 --- a/src/BLHeliBootLoad.inc +++ b/src/BLHeliBootLoad.inc @@ -6,13 +6,6 @@ XTAL EQU 25000000 -; Bootloader segment address -IF MCU_TYPE < 2 - BOOT_START EQU 1C00h -ELSEIF MCU_TYPE == 2 - BOOT_START EQU 0F000h -ENDIF - BOOT_DELAY EQU XTAL/4 ; About 250ms (don't set to fast to avoid connection problems) BOOT_BAUDRATE EQU 19200 ; Only used if no baudrate detection activated,XTAL is than important BOOT_VERSION EQU 6 ; Version 6 (must be not changed) @@ -51,7 +44,7 @@ Byte_Cnth: DS 1 BL_Flash_Key_1: DS 1 ; Flash keys BL_Flash_Key_2: DS 1 -CSEG AT BOOT_START ; Bootloader start +CSEG AT CSEG_BOOT_START ; Bootloader start init: clr IE_EA @@ -236,9 +229,9 @@ mai4: mov Paral, #ERRORPROG clr C mov A, DPL - subb A, #low(BOOT_START) + subb A, #low(CSEG_BOOT_START) mov A, DPH - subb A, #high(BOOT_START) + subb A, #high(CSEG_BOOT_START) jnc mai1 ; Jump if in bootloader segment jb Bit_Reg.0, pro3 ; Jump if program command diff --git a/src/Bluejay.asm b/src/Bluejay.asm index 9c6c986..a97f8c0 100644 --- a/src/Bluejay.asm +++ b/src/Bluejay.asm @@ -139,6 +139,7 @@ IF MCU_TYPE < 3 AND PWM_FREQ < 3 PWM_BITS_H EQU (2 + IS_MCU_48MHZ - PWM_CENTERED - PWM_FREQ) ENDIF +$include (Modules\Codespace.asm) $include (Modules\Common.asm) $include (Modules\Macros.asm) @@ -340,11 +341,7 @@ Temp_Storage: DS 48 ; Temporary storage (internal memory) ; EEPROM code segments ; A segment of the flash is used as "EEPROM", which is not available in SiLabs MCUs ;**** **** **** **** **** **** **** **** **** **** **** **** **** -IF MCU_TYPE == 2 - CSEG AT 3000h -ELSE - CSEG AT 1A00h -ENDIF +CSEG AT CSEG_EEPROM EEPROM_FW_MAIN_REVISION EQU 0 ; Main revision of the firmware EEPROM_FW_SUB_REVISION EQU 19 ; Sub revision of the firmware EEPROM_LAYOUT_REVISION EQU 206 ; Revision of the EEPROM layout @@ -395,22 +392,14 @@ Eep_Pgm_LED_Control: DB DEFAULT_PGM_LED_CONTROL ; EEPROM copy of programmed LED Eep_Pgm_Power_Rating: DB DEFAULT_PGM_POWER_RATING ; EEPROM copy of programmed power rating Eep_Dummy: DB 0FFh ; EEPROM address for safety reason -IF MCU_TYPE == 2 - CSEG AT 3060h -ELSE - CSEG AT 1A60h -ENDIF +CSEG AT CSEG_NAME Eep_Name: DB "Bluejay " ; Name tag (16 Bytes) -IF MCU_TYPE == 2 - CSEG AT 3070h -ELSE - CSEG AT 1A70h -ENDIF +CSEG AT CSEG_MELODY Eep_Pgm_Beep_Melody: DB 2,58,4,32,52,66,13,0,69,45,13,0,52,66,13,0,78,39,211,0,69,45,208,25,52,25,0 Interrupt_Table_Definition ; SiLabs interrupts -CSEG AT 80h ; Code segment after interrupt vectors +CSEG AT CSEG_AFTER_INTERRUPTS ; Code segment after interrupt vectors ; Submodule includes $include (Modules\Isrs.asm) @@ -1061,11 +1050,7 @@ exit_run_mode_brake_done: ; as code flash after offset 1A00 is used for EEPROM storage ; ;**** **** **** **** **** **** **** **** **** **** **** **** **** -IF MCU_TYPE == 2 - CSEG AT 2FFDh -ELSE - CSEG AT 19FDh -ENDIF +CSEG AT CSEG_RESET reset: ljmp pgm_start diff --git a/src/Modules/Codespace.asm b/src/Modules/Codespace.asm new file mode 100644 index 0000000..ad3086a --- /dev/null +++ b/src/Modules/Codespace.asm @@ -0,0 +1,49 @@ +;**** **** **** **** **** **** **** **** **** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyleft 2023 Chris Landa +; +; This file is part of Bluejay. +; +; Bluejay is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; Bluejay is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with Bluejay. If not, see . +; +;**** **** **** **** **** **** **** **** **** **** **** **** **** +; +; Codespace segment definitions for different MCU types +; +;**** **** **** **** **** **** **** **** **** **** **** **** **** + + ; General + CSEG_AFTER_INTERRUPTS EQU 80h + +IF MCU_TYPE == 2 + ; BB51 + CSEG_RESET EQU 2FFDh + CSEG_EEPROM EQU 3000h + CSEG_LAYOUT_TAG EQU 3040h + CSEG_MCU_TAG EQU 3050h + CSEG_NAME EQU 3060h + CSEG_MELODY EQU 3070h + CSEG_BOOT_START EQU 0F000h +ELSE + ; BB1 & BB21 + CSEG_RESET EQU 19FDh + CSEG_EEPROM EQU 1A00h + CSEG_LAYOUT_TAG EQU 1A40h + CSEG_MCU_TAG EQU 1A50h + CSEG_NAME EQU 1A60h + CSEG_MELODY EQU 1A70h + CSEG_BOOT_START EQU 1C00h +ENDIF diff --git a/src/Modules/Common.asm b/src/Modules/Common.asm index 8cda59c..ab2397a 100644 --- a/src/Modules/Common.asm +++ b/src/Modules/Common.asm @@ -140,25 +140,15 @@ DT_C1 EQU "0" + ((DEADTIME / 10) MOD 10) DT_C0 EQU "0" + (DEADTIME MOD 10) ; ESC layout tag -IF MCU_TYPE < 2 - CSEG AT 1A40h -ELSEIF MCU_TYPE == 2 - CSEG AT 3040h -ENDIF - +CSEG AT CSEG_LAYOUT_TAG IF DEADTIME < 100 Eep_ESC_Layout: DB "#",ESC_C,"_",MCU_C,"_",DT_C1,DT_C0,"# " ELSE Eep_ESC_Layout: DB "#",ESC_C,"_",MCU_C,"_",DT_C2,DT_C1,DT_C0,"# " ENDIF -IF MCU_TYPE < 2 - CSEG AT 1A50h -ELSEIF MCU_TYPE == 2 - CSEG AT 3050h -ENDIF - ; Project and MCU tag (16 Bytes) +CSEG AT CSEG_MCU_TAG IF MCU_TYPE == 0 Eep_ESC_MCU: DB "#BLHELI$EFM8B10#" ELSEIF MCU_TYPE == 1 From d2cfb8f9b85e35df3c4ea624af94a7602cba0e7f Mon Sep 17 00:00:00 2001 From: Chris L Date: Tue, 6 Jun 2023 01:55:29 +0200 Subject: [PATCH 3/4] Refactored MCU types and checks #99 --- src/BLHeliBootLoad.inc | 8 ++++---- src/Bluejay.asm | 28 +++++++++++++++------------- src/Layouts/Base.inc | 28 ++++++++++++++-------------- src/Modules/Codespace.asm | 2 +- src/Modules/Common.asm | 32 ++++++++++++++++---------------- src/Modules/Eeprom.asm | 2 +- src/Modules/Isrs.asm | 2 +- src/Modules/Macros.asm | 6 +++--- src/Modules/Mcus.asm | 30 ++++++++++++++++++++++++++++++ src/Modules/Power.asm | 2 +- src/Modules/Scheduler.asm | 2 +- src/Modules/Settings.asm | 2 +- src/Modules/Timing.asm | 14 +++++++------- 13 files changed, 95 insertions(+), 63 deletions(-) create mode 100644 src/Modules/Mcus.asm diff --git a/src/BLHeliBootLoad.inc b/src/BLHeliBootLoad.inc index 3edad53..e020a4b 100644 --- a/src/BLHeliBootLoad.inc +++ b/src/BLHeliBootLoad.inc @@ -59,7 +59,7 @@ init: mov SP, #0c0h ; Stack = 64 upper bytes of RAM ; Initialize clock mov CLKSEL, #00h ; Set clock divider to 1 -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE = MCU_BB2 ; Initialize VDD monitor orl VDM0CN, #080h ; Enable the VDD monitor ENDIF @@ -132,7 +132,7 @@ id5: jz ($+4) ; Check CRC ajmp abd -; Send info about chip/bootloader (BOOT_MSG + BOOT_INFO) + ; Send info about chip/bootloader (BOOT_MSG + BOOT_INFO) mov Parah, #((BOOT_INFO - BOOT_MSG) + 4) in1: clr A @@ -259,9 +259,9 @@ pro4: pro5: clr C mov A, DPH ; Check that address is not in bootloader area -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE = MCU_BB2 subb A, #1Ch -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 subb A, #0F0h ENDIF jc ($+5) diff --git a/src/Bluejay.asm b/src/Bluejay.asm index a97f8c0..8be7d77 100644 --- a/src/Bluejay.asm +++ b/src/Bluejay.asm @@ -72,11 +72,13 @@ ; ;**** **** **** **** **** **** **** **** **** **** **** **** **** +$include (Modules\Mcus.asm) + ; List of enumerated supported ESCs ; PORT 0 | PORT 1 | PWM COM PWM LED ; P0 P1 P2 P3 P4 P5 P6 P7 | P0 P1 P2 P3 P4 P5 P6 P7 | inv inv side n ; ----------------------- | ----------------------- | ------------------------- -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 A_ EQU 1 ; Vn Am Bm Cm __ RX __ __ | Ap Ac Bp Bc Cp Cc __ __ | no no high _ B_ EQU 2 ; Vn Am Bm Cm __ RX __ __ | Cc Cp Bc Bp Ac Ap __ __ | no no high _ C_ EQU 3 ; RX __ Vn Am Bm Cm Ap Ac | Bp Bc Cp Cc __ __ __ __ | no no high _ @@ -106,7 +108,7 @@ IF MCU_TYPE < 2 ENDIF ; BB51 - Required -IF MCU_TYPE = 2 +IF MCU_TYPE == MCU_BB51 A_ EQU 1 ; __ Bm Cm Am Vn RX __ __ | Ap Ac Bp Bc Cp Cc __ __ | no no low _ B_ EQU 2 ; __ Bm Cm Am Vn RX __ __ | Ac Ap Bc Bp Cc Cp __ __ | no yes high _ C_ EQU 3 ; __ Bm Cm Am Vn RX __ __ | Ac Ap Bc Bp Cc Cp __ __ | yes yes high _ @@ -128,13 +130,13 @@ ENDIF PWM_CENTERED EQU DEADTIME > 0 ; Use center aligned pwm on ESCs with dead time -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 IS_MCU_48MHZ EQU 0 ELSE IS_MCU_48MHZ EQU 1 ENDIF -IF MCU_TYPE < 3 AND PWM_FREQ < 3 +IF PWM_FREQ < 3 ; Number of bits in pwm high byte PWM_BITS_H EQU (2 + IS_MCU_48MHZ - PWM_CENTERED - PWM_FREQ) ENDIF @@ -425,7 +427,7 @@ pgm_start: mov WDTCN, #0DEh ; Disable watchdog (WDT) mov WDTCN, #0ADh mov SP, #Stack ; Initialize stack (16 bytes of indirect RAM) -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 orl VDM0CN, #080h ; Enable the VDD monitor ENDIF mov RSTSRC, #06h ; Set missing clock and VDD monitor as a reset source if not 1S capable @@ -443,11 +445,11 @@ ENDIF mov P1, #P1_INIT mov P1SKIP, #P1_SKIP mov P2MDOUT, #P2_PUSHPULL -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 ; Not available on BB1 mov SFRPAGE, #20h mov P2MDIN, #P2_DIGITAL -IF MCU_TYPE == 1 +IF MCU_TYPE == MCU_BB2 ; Not available on BB51 mov P2SKIP, #P2_SKIP ENDIF @@ -484,7 +486,7 @@ init_no_signal: mov Flash_Key_2, #0 call switch_power_off -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 Set_MCU_Clk_24MHz ; Set clock frequency ENDIF @@ -499,7 +501,7 @@ input_high_check: call beep_enter_bootloader -IF MCU_TYPE == 2 +IF MCU_TYPE == MCU_BB51 ljmp 0F000h ; Jump to bootloader ELSE ljmp 1C00h ; Jump to bootloader @@ -553,7 +555,7 @@ setup_dshot: setb IE_EA ; Enable all interrupts ; Setup variables for DShot150 (Only on 24MHz because frame length threshold cannot be scaled up) -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 mov DShot_Timer_Preset, #-64 ; Load DShot sync timer preset (for DShot150) mov DShot_Pwm_Thr, #8 ; Load DShot qualification pwm threshold (for DShot150) mov DShot_Frame_Length_Thr, #160 ; Load DShot frame length criteria @@ -583,7 +585,7 @@ ENDIF jz arming_begin ; Setup variables for DShot600 (Only on 48MHz for performance reasons) -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 mov DShot_Timer_Preset, #-64 ; Load DShot sync timer preset (for DShot600) mov DShot_Pwm_Thr, #8 ; Load DShot pwm threshold (for DShot600) mov DShot_Frame_Length_Thr, #40 ; Load DShot frame length criteria @@ -722,7 +724,7 @@ motor_start: mov Temp_Pwm_Level_Setpoint, Pwm_Limit_Beg ; Begin startup sequence -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 Set_MCU_Clk_48MHz ; Scale DShot criteria for 48MHz @@ -983,7 +985,7 @@ exit_run_mode: mov Flags0, #0 ; Clear run time flags (in case they are used in interrupts) mov Flags1, #0 -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 Set_MCU_Clk_24MHz ; Scale DShot criteria for 24MHz diff --git a/src/Layouts/Base.inc b/src/Layouts/Base.inc index a247c78..b2cdb4d 100644 --- a/src/Layouts/Base.inc +++ b/src/Layouts/Base.inc @@ -130,27 +130,27 @@ ENDM ; Set comparator multiplexer to phase A Set_Comparator_Phase_A MACRO -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov CMP_MX, #((A_Mux SHL 4) + V_Mux) -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov CMP_MX, #12h ENDIF ENDM ; Set comparator multiplexer to phase B Set_Comparator_Phase_B MACRO -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov CMP_MX, #((B_Mux SHL 4) + V_Mux) -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov CMP_MX, #10h ENDIF ENDM ; Set comparator multiplexer to phase C Set_Comparator_Phase_C MACRO -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov CMP_MX, #((C_Mux SHL 4) + V_Mux) -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov CMP_MX, #11h ENDIF ENDM @@ -325,7 +325,7 @@ TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value incr Initialize_Adc MACRO LOCAL initialize_adc_use_internal_1V65_vref initialize_adc_use_vdd_3V3_vref initialize_adc_vref_selected -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov Temp1, #Pgm_Power_Rating cjne @Temp1, #01h, initialize_adc_use_vdd_3V3_vref @@ -336,31 +336,31 @@ initialize_adc_use_vdd_3V3_vref: mov REF0CN, #0Ch ; Set vdd (3.3V) as reference on 2S+. Enable temp sensor and bias initialize_adc_vref_selected: -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 mov ADC0CF, #59h ; ADC clock 2MHz,PGA gain 1 -ELSEIF MCU_TYPE == 1 +ELSEIF MCU_TYPE == MCU_BB2 mov ADC0CF, #0B9h ; ADC clock 2MHz,PGA gain 1 ENDIF -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov CLKGRP0, #18h ; Enable SAR clock,at 12MHz mov ADC0CF1, #0Ah ; 800ns tracking time mov ADC0CF2, #2Fh ; 1.65V reference ENDIF mov ADC0MX, #10h ; Select temp sensor input -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov ADC0CN0, #80h ; ADC enabled mov ADC0CN1, #01h ; Common mode buffer enabled -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov ADC0CN0, #85h ; ADC enabled (gain 0.5,temp sensor enabled) mov ADC0CN1, #20h ; 10bit mode ENDIF ENDM Start_Adc MACRO -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov ADC0CN0, #90h ; Initiate conversion -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov ADC0CN0, #95h ; Initiate conversion (gain 0.5,temp sensor enabled) ENDIF ENDM diff --git a/src/Modules/Codespace.asm b/src/Modules/Codespace.asm index ad3086a..172bf39 100644 --- a/src/Modules/Codespace.asm +++ b/src/Modules/Codespace.asm @@ -28,7 +28,7 @@ ; General CSEG_AFTER_INTERRUPTS EQU 80h -IF MCU_TYPE == 2 +IF MCU_TYPE == MCU_BB51 ; BB51 CSEG_RESET EQU 2FFDh CSEG_EEPROM EQU 3000h diff --git a/src/Modules/Common.asm b/src/Modules/Common.asm index ab2397a..7743629 100644 --- a/src/Modules/Common.asm +++ b/src/Modules/Common.asm @@ -30,11 +30,11 @@ ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; Device SiLabs EFM8BB1x/2x/51 ;**** **** **** **** **** **** **** **** **** **** **** **** **** -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 $include (Silabs/SI_EFM8BB1_Defs.inc) -ELSEIF MCU_TYPE == 1 +ELSEIF MCU_TYPE == MCU_BB2 $include (Silabs/SI_EFM8BB2_Defs.inc) -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 $include (Silabs/SI_EFM8BB51_Defs.inc) ENDIF @@ -45,7 +45,7 @@ ENDIF ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; ESC selection statements ;**** **** **** **** **** **** **** **** **** **** **** **** **** -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE = MCU_BB2 IF ESCNO == A_ $include (Layouts/A.inc) ; Select pinout A ELSEIF ESCNO == B_ @@ -101,7 +101,7 @@ ELSEIF ESCNO == Z_ ENDIF ENDIF -IF MCU_TYPE == 2 +IF MCU_TYPE == MCU_BB51 IF ESCNO == A_ $include (Layouts/BB51/A.inc) ; Select pinout A ELSEIF ESCNO == B_ @@ -112,11 +112,11 @@ ENDIF ENDIF SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 SIGNATURE_002 EQU 0B1h -ELSEIF MCU_TYPE == 1 +ELSEIF MCU_TYPE == MCU_BB2 SIGNATURE_002 EQU 0B2h -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 SIGNATURE_002 EQU 0B5h ENDIF @@ -126,11 +126,11 @@ ENDIF ESC_C EQU "A" + ESCNO - 1 ; ESC target letter ; MCU letter (24Mhz=L, 48Mhz=H, BB51=X) -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 MCU_C EQU "L" -ELSEIF MCU_TYPE == 1 +ELSEIF MCU_TYPE == MCU_BB2 MCU_C EQU "H" -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 MCU_C EQU "X" ENDIF @@ -149,11 +149,11 @@ ENDIF ; Project and MCU tag (16 Bytes) CSEG AT CSEG_MCU_TAG -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 Eep_ESC_MCU: DB "#BLHELI$EFM8B10#" -ELSEIF MCU_TYPE == 1 +ELSEIF MCU_TYPE == MCU_BB2 Eep_ESC_MCU: DB "#BLHELI$EFM8B21#" -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 Eep_ESC_MCU: DB "#BLHELI$EFM8B51#" ENDIF @@ -199,9 +199,9 @@ ENDM Set_MCU_Clk_48MHz MACRO mov SFRPAGE, #10h -IF MCU_TYPE == 1 +IF MCU_TYPE == MCU_BB2 mov PFE0CN, #30h ; Set flash timing for 48MHz and enable prefetch engine -ELSEIF MCU_TYPE == 2 +ELSEIF MCU_TYPE == MCU_BB51 mov PFE0CN, #10h ; Set flash timing for 48MHz ENDIF mov SFRPAGE, #00h diff --git a/src/Modules/Eeprom.asm b/src/Modules/Eeprom.asm index 128ec0e..7b94893 100644 --- a/src/Modules/Eeprom.asm +++ b/src/Modules/Eeprom.asm @@ -166,7 +166,7 @@ write_eeprom_byte_from_acc: mov Temp8, A clr C mov A, DPH ; Check that address is not in bootloader area -IF MCU_TYPE == 2 +IF MCU_TYPE == MCU_BB51 subb A, #0F0h ELSE subb A, #1Ch diff --git a/src/Modules/Isrs.asm b/src/Modules/Isrs.asm index 7383700..9184cad 100644 --- a/src/Modules/Isrs.asm +++ b/src/Modules/Isrs.asm @@ -435,7 +435,7 @@ IF DEADTIME != 0 ; Damping pwm duty cycle will be higher because numbers are inverted clr C mov A, Temp2 ; Skew damping FET timing -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 subb A, #((DEADTIME + 1) SHR 1) ELSE subb A, #(DEADTIME) diff --git a/src/Modules/Macros.asm b/src/Modules/Macros.asm index 1104d2c..3e0539b 100644 --- a/src/Modules/Macros.asm +++ b/src/Modules/Macros.asm @@ -29,13 +29,13 @@ DSHOT_TLM_CLOCK EQU 24500000 ; 24.5MHz DSHOT_TLM_START_DELAY EQU -(5 * 25 / 4) ; Start telemetry after 5 us (~30 us after receiving DShot cmd) -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 DSHOT_TLM_PREDELAY EQU 9 ; 9 Timer0 ticks inherent delay ELSE DSHOT_TLM_PREDELAY EQU 7 ; 7 Timer0 ticks inherent delay ENDIF -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 DSHOT_TLM_CLOCK_48 EQU 49000000 ; 49MHz DSHOT_TLM_START_DELAY_48 EQU -(16 * 49 / 4) ; Start telemetry after 16 us (~30 us after receiving DShot cmd) DSHOT_TLM_PREDELAY_48 EQU 11 ; 11 Timer0 ticks inherent delay @@ -48,7 +48,7 @@ Set_DShot_Tlm_Bitrate MACRO rate mov DShot_GCR_Start_Delay, #DSHOT_TLM_START_DELAY -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 mov DShot_GCR_Pulse_Time_1_Tmp, #(DSHOT_TLM_PREDELAY_48 - (1 * DSHOT_TLM_CLOCK_48 / 4 / rate)) mov DShot_GCR_Pulse_Time_2_Tmp, #(DSHOT_TLM_PREDELAY_48 - (2 * DSHOT_TLM_CLOCK_48 / 4 / rate)) mov DShot_GCR_Pulse_Time_3_Tmp, #(DSHOT_TLM_PREDELAY_48 - (3 * DSHOT_TLM_CLOCK_48 / 4 / rate)) diff --git a/src/Modules/Mcus.asm b/src/Modules/Mcus.asm new file mode 100644 index 0000000..64325d2 --- /dev/null +++ b/src/Modules/Mcus.asm @@ -0,0 +1,30 @@ +;**** **** **** **** **** **** **** **** **** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyleft 2023 Chris Landa +; +; This file is part of Bluejay. +; +; Bluejay is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; Bluejay is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with Bluejay. If not, see . +; +;**** **** **** **** **** **** **** **** **** **** **** **** **** +; +; MCUs +; +;**** **** **** **** **** **** **** **** **** **** **** **** **** + + MCU_BB51 EQU 2 + MCU_BB2 EQU 1 + MCU_BB1 EQU 0 diff --git a/src/Modules/Power.asm b/src/Modules/Power.asm index d435c24..3dbfed5 100644 --- a/src/Modules/Power.asm +++ b/src/Modules/Power.asm @@ -95,7 +95,7 @@ set_pwm_limit_low_rpm_exit: set_pwm_limit_high_rpm: clr C mov A, Comm_Period4x_L -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 subb A, #0A0h ; Limit Comm_Period4x to 160,which is ~510k erpm ELSE subb A, #0E4h ; Limit Comm_Period4x to 228,which is ~358k erpm diff --git a/src/Modules/Scheduler.asm b/src/Modules/Scheduler.asm index fe05a7e..3723275 100644 --- a/src/Modules/Scheduler.asm +++ b/src/Modules/Scheduler.asm @@ -237,7 +237,7 @@ scheduler_steps_odd_temperature_frame: ; For BB51 (MCU_TYPE == 2) 1s power rating code path is mandatory ; ;**** **** **** **** **** **** **** **** **** **** **** **** **** -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 mov Temp1, #Pgm_Power_Rating cjne @Temp1, #01h, scheduler_steps_odd_temperature_frame_power_rating_2s ENDIF diff --git a/src/Modules/Settings.asm b/src/Modules/Settings.asm index 5c7fdea..a4a14c2 100644 --- a/src/Modules/Settings.asm +++ b/src/Modules/Settings.asm @@ -141,7 +141,7 @@ decode_demag_done: ; For BB51 (MCU_TYPE == 2) 1s power rating code path is mandatory ; ;**** **** **** **** **** **** **** **** **** **** **** **** **** -IF MCU_TYPE < 2 +IF MCU_TYPE == MCU_BB1 or MCU_TYPE == MCU_BB2 ; Read power rating and decode temperature limit mov Temp1, #Pgm_Power_Rating cjne @Temp1, #01h, decode_temp_use_adc_use_vdd_3V3_vref diff --git a/src/Modules/Timing.asm b/src/Modules/Timing.asm index 8640628..029a13d 100644 --- a/src/Modules/Timing.asm +++ b/src/Modules/Timing.asm @@ -62,7 +62,7 @@ calc_next_comm_period: setb TMR2CN0_TR2 ; Timer2 enabled setb IE_EA -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 clr C ; Divide time by 2 on 48MHz rrca Temp3 rrca Temp2 @@ -80,7 +80,7 @@ ENDIF mov A, Temp2 subb A, Prev_Comm_H mov Prev_Comm_H, Temp2 ; Save timestamp as previous commutation -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 anl A, #7Fh ENDIF mov Temp2, A ; Store commutation period in Temp2 (hi byte) @@ -104,7 +104,7 @@ calc_next_comm_startup: subb A, Temp5 mov A, Temp3 subb A, Temp6 ; Calculate the new extended commutation time -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 anl A, #7Fh ENDIF jz calc_next_comm_startup_no_X @@ -352,7 +352,7 @@ calc_new_wait_times: clr A subb A, Temp4 mov Temp2, A -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 clr C rlca Temp1 ; Multiply by 2 rlca Temp2 @@ -552,7 +552,7 @@ setup_zc_scan_timeout: clr C rrca Temp2 rrca Temp1 -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 clr C rrca Temp2 rrca Temp1 @@ -624,7 +624,7 @@ comp_not_startup: ; Too high a value (~>35) causes the RCT4215 630 to run rough on full throttle mov Temp4, #(20 SHL IS_MCU_48MHZ) mov A, Comm_Period4x_H ; Set number of readings higher for lower speeds -IF MCU_TYPE == 0 +IF MCU_TYPE == MCU_BB1 clr C rrc A ENDIF @@ -711,7 +711,7 @@ comp_read_wrong_low_rpm: mov A, Comm_Period4x_H ; Set timeout to ~4x comm period 4x value mov Temp7, #0FFh ; Default to long timeout -IF MCU_TYPE >= 1 +IF MCU_TYPE == MCU_BB2 or MCU_TYPE == MCU_BB51 clr C rlc A jc comp_read_wrong_load_timeout From ae89e70317a034ca3ad198ec0d21cec1dbd1fb83 Mon Sep 17 00:00:00 2001 From: Chris L Date: Tue, 6 Jun 2023 18:52:00 +0200 Subject: [PATCH 4/4] Improve name for app entry code segment #99 --- src/Bluejay.asm | 2 +- src/Modules/Codespace.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bluejay.asm b/src/Bluejay.asm index 8be7d77..5bd8d1c 100644 --- a/src/Bluejay.asm +++ b/src/Bluejay.asm @@ -401,7 +401,7 @@ CSEG AT CSEG_MELODY Eep_Pgm_Beep_Melody: DB 2,58,4,32,52,66,13,0,69,45,13,0,52,66,13,0,78,39,211,0,69,45,208,25,52,25,0 Interrupt_Table_Definition ; SiLabs interrupts -CSEG AT CSEG_AFTER_INTERRUPTS ; Code segment after interrupt vectors +CSEG AT CSEG_APP ; Code segment after interrupt vectors ; Submodule includes $include (Modules\Isrs.asm) diff --git a/src/Modules/Codespace.asm b/src/Modules/Codespace.asm index 172bf39..c06becc 100644 --- a/src/Modules/Codespace.asm +++ b/src/Modules/Codespace.asm @@ -26,7 +26,7 @@ ;**** **** **** **** **** **** **** **** **** **** **** **** **** ; General - CSEG_AFTER_INTERRUPTS EQU 80h + CSEG_APP EQU 80h IF MCU_TYPE == MCU_BB51 ; BB51