diff --git a/Bluejay.asm b/Bluejay.asm index 5c3a362..35d82a3 100644 --- a/Bluejay.asm +++ b/Bluejay.asm @@ -61,29 +61,35 @@ $NOMOD51 ; ;**** **** **** **** **** ; List of enumerated supported ESCs -A_ EQU 1 ; X X RC X MC MB MA CC X X Cc Cp Bc Bp Ac Ap -B_ EQU 2 ; X X RC X MC MB MA CC X X Ap Ac Bp Bc Cp Cc -C_ EQU 3 ; Ac Ap MC MB MA CC X RC X X X X Cc Cp Bc Bp -D_ EQU 4 ; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap Com fets inverted -E_ EQU 5 ; L1 L0 RC X MC MB MA CC X L2 Cc Cp Bc Bp Ac Ap A with LEDs -F_ EQU 6 ; X X RC X MA MB MC CC X X Cc Cp Bc Bp Ac Ap -G_ EQU 7 ; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap Like D, but non-inverted com fets -H_ EQU 8 ; RC X X X MA MB CC MC X Ap Bp Cp X Ac Bc Cc -I_ EQU 9 ; X X RC X MC MB MA CC X X Ac Bc Cc Ap Bp Cp -J_ EQU 10 ; L2 L1 L0 RC CC MB MC MA X X Cc Bc Ac Cp Bp Ap LEDs -K_ EQU 11 ; X X MC X MB CC MA RC X X Ap Bp Cp Cc Bc Ac Com fets inverted -L_ EQU 12 ; X X RC X CC MA MB MC X X Ac Bc Cc Ap Bp Cp -M_ EQU 13 ; MA MC CC MB RC L0 X X X Cc Bc Ac Cp Bp Ap X LED -N_ EQU 14 ; X X RC X MC MB MA CC X X Cp Cc Bp Bc Ap Ac -O_ EQU 15 ; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap Like D, but low side pwm -P_ EQU 16 ; X X RC MA CC MB MC X X Cc Bc Ac Cp Bp Ap X -Q_ EQU 17 ; Cp Bp Ap L1 L0 X RC X X MA MB MC CC Cc Bc Ac LEDs -R_ EQU 18 ; X X RC X MC MB MA CC X X Ac Bc Cc Ap Bp Cp -S_ EQU 19 ; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap Like O, but com fets inverted -T_ EQU 20 ; RC X MA X MB CC MC X X X Cp Bp Ap Ac Bc Cc -U_ EQU 21 ; MA MC CC MB RC L0 L1 L2 X Cc Bc Ac Cp Bp Ap X Like M, but with 3 LEDs -V_ EQU 22 ; Cc X RC X MC CC MB MA X Ap Ac Bp X X Bc Cp -W_ EQU 23 ; RC MC MB X CC MA X X X Ap Bp Cp X X X X Tristate gate driver + ; PORT 0 PORT 1 + ; P0 P1 P2 P3 P4 P5 P6 P7 P0 P1 P2 P3 P4 P5 P6 P7 + ; ----------------------- ----------------------- +A_ EQU 1 ; Vn Am Bm Cm __ RX __ __ Ap Ac Bp Bc Cp Cc __ __ +B_ EQU 2 ; Vn Am Bm Cm __ RX __ __ Cc Cp Bc Bp Ac Ap __ __ +C_ EQU 3 ; RX __ Vn Am Bm Cm Ap Ac Bp Bc Cp Cc __ __ __ __ +D_ EQU 4 ; Bm Cm Am Vn __ RX __ __ Ap Ac Bp Bc Cp Cc __ __ Com fets inverted +E_ EQU 5 ; Vn Am Bm Cm __ RX L0 L1 Ap Ac Bp Bc Cp Cc L2 __ A with LEDs +F_ EQU 6 ; Vn Cm Bm Am __ RX __ __ Ap Ac Bp Bc Cp Cc __ __ +G_ EQU 7 ; Bm Cm Am Vn __ RX __ __ Ap Ac Bp Bc Cp Cc __ __ Like D, but non-inverted com fets +H_ EQU 8 ; Cm Vn Bm Am __ __ __ RX Cc Bc Ac __ Cp Bp Ap __ +I_ EQU 9 ; Vn Am Bm Cm __ RX __ __ Cp Bp Ap Cc Bc Ac __ __ +J_ EQU 10 ; Am Cm Bm Vn RX L0 L1 L2 Ap Bp Cp Ac Bc Cc __ __ LEDs +K_ EQU 11 ; RX Am Vn Bm __ Cm __ __ Ac Bc Cc Cp Bp Ap __ __ Com fets inverted +L_ EQU 12 ; Cm Bm Am Vn __ RX __ __ Cp Bp Ap Cc Bc Ac __ __ Like I with different mux pins +M_ EQU 13 ; __ __ L0 RX Bm Vn Cm Am __ Ap Bp Cp Ac Bc Cc __ LED +N_ EQU 14 ; Vn Am Bm Cm __ RX __ __ Ac Ap Bc Bp Cc Cp __ __ Like B, with A and C fets swapped +O_ EQU 15 ; Bm Cm Am Vn __ RX __ __ Ap Ac Bp Bc Cp Cc __ __ Like D, but low side pwm +P_ EQU 16 ; __ Cm Bm Vn Am RX __ __ __ Ap Bp Cp Ac Bc Cc __ Like M, without LEDs and different mux +Q_ EQU 17 ; __ RX __ L0 L1 Ap Bp Cp Ac Bc Cc Vn Cm Bm Am __ LEDs +R_ EQU 18 ; Vn Am Bm Cm __ RX __ __ Cp Bp Ap Cc Bc Ac __ __ Like L, with different mux pins +S_ EQU 19 ; Bm Cm Am Vn __ RX __ __ Ap Ac Bp Bc Cp Cc __ __ Like O, but com fets inverted +T_ EQU 20 ; __ Cm Vn Bm __ Am __ RX Cc Bc Ac Ap Bp Cp __ __ +U_ EQU 21 ; L2 L1 L0 RX Bm Vn Cm Am __ Ap Bp Cp Ac Bc Cc __ Like M, but with 3 LEDs +V_ EQU 22 ; Am Bm Vn Cm __ RX __ Cc Cp Bc __ __ Bp Ac Ap __ +W_ EQU 23 ; __ __ Am Vn __ Bm Cm RX __ __ __ __ Cp Bp Ap __ Tristate gate driver +X_ EQU 24 +Y_ EQU 25 +Z_ EQU 26 ; Bm Cm Am Vn __ RX __ __ Ac Ap Bc Bp Cc Cp __ __ Pwm fets inverted ;**** **** **** **** **** ; Select the port mapping to use (or unselect all for use with external batch compile file) @@ -1133,19 +1139,19 @@ ENDIF ; Set power pwm auto-reload registers IF PWM_BITS_H != 0 - mov PCA0_POWER_L, Power_Pwm_Reg_L - mov PCA0_POWER_H, Power_Pwm_Reg_H + Set_Power_Pwm_Reg_L Power_Pwm_Reg_L + Set_Power_Pwm_Reg_H Power_Pwm_Reg_H ELSE - mov PCA0_POWER_H, Power_Pwm_Reg_L + Set_Power_Pwm_Reg_H Power_Pwm_Reg_L ENDIF IF FETON_DELAY != 0 ; Set damp pwm auto-reload registers IF PWM_BITS_H != 0 - mov PCA0_DAMP_L, Damp_Pwm_Reg_L - mov PCA0_DAMP_H, Damp_Pwm_Reg_H + Set_Damp_Pwm_Reg_L Damp_Pwm_Reg_L + Set_Damp_Pwm_Reg_H Damp_Pwm_Reg_H ELSE - mov PCA0_DAMP_H, Damp_Pwm_Reg_L + Set_Damp_Pwm_Reg_H Damp_Pwm_Reg_L ENDIF ENDIF @@ -3509,6 +3515,11 @@ pgm_start: mov P1, #P1_INIT mov P1SKIP, #P1_SKIP mov P2MDOUT, #P2_PUSHPULL +IF MCU_48MHZ == 1 + ; Not available on BB1 + mov P2MDIN, #P2_DIGITAL + mov P2SKIP, #P2_SKIP +ENDIF Initialize_Xbar ; Initialize the XBAR and related functionality call switch_power_off ; Switch power off again, after initializing ports diff --git a/Common.inc b/Common.inc index 8e21f5d..1430639 100644 --- a/Common.inc +++ b/Common.inc @@ -42,51 +42,64 @@ ENDIF ;**** **** **** **** **** ; ESC selection statements IF ESCNO == A_ -$include (targets/A.inc) ; Select pinout A +$include (Layouts/A.inc) ; Select pinout A ELSEIF ESCNO == B_ -$include (targets/B.inc) ; Select pinout B +$include (Layouts/B.inc) ; Select pinout B ELSEIF ESCNO == C_ -$include (targets/C.inc) ; Select pinout C +$include (Layouts/C.inc) ; Select pinout C ELSEIF ESCNO == D_ -$include (targets/D.inc) ; Select pinout D +$include (Layouts/D.inc) ; Select pinout D ELSEIF ESCNO == E_ -$include (targets/E.inc) ; Select pinout E +$include (Layouts/E.inc) ; Select pinout E ELSEIF ESCNO == F_ -$include (targets/F.inc) ; Select pinout F +$include (Layouts/F.inc) ; Select pinout F ELSEIF ESCNO == G_ -$include (targets/G.inc) ; Select pinout G +$include (Layouts/G.inc) ; Select pinout G ELSEIF ESCNO == H_ -$include (targets/H.inc) ; Select pinout H +$include (Layouts/H.inc) ; Select pinout H ELSEIF ESCNO == I_ -$include (targets/I.inc) ; Select pinout I +$include (Layouts/I.inc) ; Select pinout I ELSEIF ESCNO == J_ -$include (targets/J.inc) ; Select pinout J +$include (Layouts/J.inc) ; Select pinout J ELSEIF ESCNO == K_ -$include (targets/K.inc) ; Select pinout K +$include (Layouts/K.inc) ; Select pinout K ELSEIF ESCNO == L_ -$include (targets/L.inc) ; Select pinout L +$include (Layouts/L.inc) ; Select pinout L ELSEIF ESCNO == M_ -$include (targets/M.inc) ; Select pinout M +$include (Layouts/M.inc) ; Select pinout M ELSEIF ESCNO == N_ -$include (targets/N.inc) ; Select pinout N +$include (Layouts/N.inc) ; Select pinout N ELSEIF ESCNO == O_ -$include (targets/O.inc) ; Select pinout O +$include (Layouts/O.inc) ; Select pinout O ELSEIF ESCNO == P_ -$include (targets/P.inc) ; Select pinout P +$include (Layouts/P.inc) ; Select pinout P ELSEIF ESCNO == Q_ -$include (targets/Q.inc) ; Select pinout Q +$include (Layouts/Q.inc) ; Select pinout Q ELSEIF ESCNO == R_ -$include (targets/R.inc) ; Select pinout R +$include (Layouts/R.inc) ; Select pinout R ELSEIF ESCNO == S_ -$include (targets/S.inc) ; Select pinout S +$include (Layouts/S.inc) ; Select pinout S ELSEIF ESCNO == T_ -$include (targets/T.inc) ; Select pinout T +$include (Layouts/T.inc) ; Select pinout T ELSEIF ESCNO == U_ -$include (targets/U.inc) ; Select pinout U +$include (Layouts/U.inc) ; Select pinout U ELSEIF ESCNO == V_ -$include (targets/V.inc) ; Select pinout V +$include (Layouts/V.inc) ; Select pinout V ELSEIF ESCNO == W_ -$include (targets/W.inc) ; Select pinout W +$include (Layouts/W.inc) ; Select pinout W +;ELSEIF ESCNO == X_ +;$include (Layouts/X.inc) ; Select pinout X +;ELSEIF ESCNO == Y_ +;$include (Layouts/Y.inc) ; Select pinout Y +ELSEIF ESCNO == Z_ +$include (Layouts/Z.inc) ; Select pinout Z +ENDIF + +SIGNATURE_001 EQU 0E8h ; Device signature +IF MCU_48MHZ == 0 +SIGNATURE_002 EQU 0B1h +ELSE +SIGNATURE_002 EQU 0B2h ENDIF ;**** **** **** **** **** @@ -146,34 +159,20 @@ Initialize_PCA MACRO mov PCA0PWM, #(80h + PWM_BITS_H) ;; Enable PCA auto-reload registers and set pwm cycle length (8-11 bits) IF PWM_CENTERED == 1 - mov PCA0CENT, #03h ;; Center aligned pwm + mov PCA0CENT, #07h ;; Center aligned pwm ELSE mov PCA0CENT, #00h ;; Edge aligned pwm ENDIF ENDM -Enable_Power_Pwm_Module MACRO -IF FETON_DELAY == 0 - mov PCA0_POWER_MODULE, #4Ah ;; Enable comparator of module, enable match, set pwm mode -ELSE - mov PCA0_POWER_MODULE, #42h ;; Enable comparator of module, set pwm mode -ENDIF -ENDM - -Enable_Damp_Pwm_Module MACRO -IF FETON_DELAY == 0 - mov PCA0_DAMP_MODULE, #00h ;; Disable -ELSE - mov PCA0_DAMP_MODULE, #42h ;; Enable comparator of module, set pwm mode -ENDIF -ENDM - Clear_COVF_Interrupt MACRO anl PCA0PWM, #0DFh ENDM + Enable_COVF_Interrupt MACRO orl PCA0PWM, #40h ENDM + Disable_COVF_Interrupt MACRO anl PCA0PWM, #0BFh ENDM @@ -182,9 +181,11 @@ ENDM Clear_CCF_Interrupt MACRO anl PCA0CN0, #0FEh ENDM + Enable_CCF_Interrupt MACRO orl PCA0CPM0,#01h ENDM + Disable_CCF_Interrupt MACRO anl PCA0CPM0,#0FEh ENDM @@ -225,3 +226,9 @@ Set_MCU_Clk_48MHz MACRO setb Flag_Clock_At_48MHz ENDM + +Set_RPM_Out MACRO +ENDM + +Clear_RPM_Out MACRO +ENDM diff --git a/Layouts/A.inc b/Layouts/A.inc new file mode 100644 index 0000000..410430f --- /dev/null +++ b/Layouts/A.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "A" +; X X RC X MC MB MA CC X X Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +B_Mux EQU 2 +A_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_com EQU 5 +C_pwm EQU 4 +B_com EQU 3 +B_pwm EQU 2 +A_com EQU 1 +A_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/B.inc b/Layouts/B.inc new file mode 100644 index 0000000..9bf06d3 --- /dev/null +++ b/Layouts/B.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "B". Equals "A", but with A and C fets swapped and pwm and com fets swapped +; X X RC X MC MB MA CC X X Ap Ac Bp Bc Cp Cc +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +B_Mux EQU 2 +A_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +A_pwm EQU 5 +A_com EQU 4 +B_pwm EQU 3 +B_com EQU 2 +C_pwm EQU 1 +C_com EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/Base.inc b/Layouts/Base.inc new file mode 100644 index 0000000..64bf781 --- /dev/null +++ b/Layouts/Base.inc @@ -0,0 +1,372 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Base layout +; +; The inheriting layout should +; - Specify PWM_ACTIVE_HIGH, COMPWM_ACTIVE_HIGH and COMPARATOR_PORT +; - Set CUSTOM_* flags to override default implementation +; +;**** **** **** **** **** + + +;**** **** **** **** **** +; Bootloader definitions +;**** **** **** **** **** +; Note: The RTX pin must be on port 0 because we use the IT01CF register for interrupts +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 Rcp_In ; RTX pin + + +;**** **** **** **** **** +; PWM pin routing and polarity setup +;**** **** **** **** **** +$if NOT CUSTOM_PWM_SETUP + +Initialize_Xbar MACRO + mov XBR2, #40h ;; Xbar enabled + mov XBR1, #02h ;; CEX0 and CEX1 routed to pins +ENDM + +Set_Pwm_Polarity MACRO +IF PCA0CPM_POWER == 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 + +$endif + + +;**** **** **** **** **** +; PWM channels and updating +;**** **** **** **** **** +$if NOT CUSTOM_PWM_UPDATE + +Enable_Power_Pwm_Module MACRO +IF FETON_DELAY == 0 + mov PCA0CPM_POWER, #4Ah ;; Enable comparator of module, enable match, set pwm mode +ELSE + mov PCA0CPM_POWER, #42h ;; Enable comparator of module, set pwm mode +ENDIF +ENDM + +Enable_Damp_Pwm_Module MACRO +IF FETON_DELAY == 0 + mov PCA0CPM_DAMP, #00h ;; Disable +ELSE + mov PCA0CPM_DAMP, #42h ;; Enable comparator of module, set pwm mode +ENDIF +ENDM + +Set_Power_Pwm_Reg_L MACRO value + mov PCA0CPL_POWER, value +ENDM + +Set_Power_Pwm_Reg_H MACRO value + mov PCA0CPH_POWER, value +ENDM + +Set_Damp_Pwm_Reg_L MACRO value + mov PCA0CPL_DAMP, value +ENDM + +Set_Damp_Pwm_Reg_H MACRO value + mov PCA0CPH_DAMP, value +ENDM + +$endif + + +;**** **** **** **** **** +; Comparator setup and phase change +;**** **** **** **** **** +IF COMPARATOR_PORT == 0 +CMP_CN0 EQU CMP0CN0 +CMP_MD EQU CMP0MD +CMP_MX EQU CMP0MX +ELSE +CMP_CN0 EQU CMP1CN0 +CMP_MD EQU CMP1MD +CMP_MX EQU CMP1MX +ENDIF + +$if NOT CUSTOM_COMP_SETUP + +Initialize_Comparator MACRO + mov CMP_CN0, #80h ;; Comparator enabled, no hysteresis + mov CMP_MD, #00h ;; Comparator response time 100ns +ENDM + +$endif + +Read_Comp_Out MACRO + mov A, CMP_CN0 ;; Read comparator output +ENDM + +; Set comparator multiplexer to phase A +Set_Comp_Phase_A MACRO + mov CMP_MX, #((A_Mux SHL 4) + V_Mux) +ENDM + +; Set comparator multiplexer to phase B +Set_Comp_Phase_B MACRO + mov CMP_MX, #((B_Mux SHL 4) + V_Mux) +ENDM + +; Set comparator multiplexer to phase C +Set_Comp_Phase_C MACRO + mov CMP_MX, #((C_Mux SHL 4) + V_Mux) +ENDM + + +; Toggle FETs 'on' and 'off' +IF PWM_ACTIVE_HIGH == 1 ; PWM FET active high +pON LIT 'setb' +pOFF LIT 'clr' +ELSE ; PWM FET active low +pON LIT 'clr' +pOFF LIT 'setb' +ENDIF + +IF COMPWM_ACTIVE_HIGH == 1 ; COM FET active high +cON LIT 'setb' +cOFF LIT 'clr' +ELSE ; COM FET active low +cON LIT 'clr' +cOFF LIT 'setb' +ENDIF + + +;**** **** **** **** **** +; PWM phase change +;**** **** **** **** **** +$if NOT CUSTOM_PWM_PHASE + +; All pwm and complementary pwm pins must be on port 1 to use the base code below +P_ApwmFET EQU P1.A_pwm +P_AcomFET EQU P1.A_com +P_BpwmFET EQU P1.B_pwm +P_BcomFET EQU P1.B_com +P_CpwmFET EQU P1.C_pwm +P_CcomFET EQU P1.C_com + +Set_Pwm_A MACRO +IF FETON_DELAY == 0 + cON P_AcomFET + mov P1SKIP, #(NOT (1 SHL A_pwm)) +ELSE + mov P1SKIP, #(NOT ((1 SHL A_pwm) + (1 SHL A_com))) +ENDIF +ENDM + +Set_Pwm_B MACRO +IF FETON_DELAY == 0 + cON P_BcomFET + mov P1SKIP, #(NOT (1 SHL B_pwm)) +ELSE + mov P1SKIP, #(NOT ((1 SHL B_pwm) + (1 SHL B_com))) +ENDIF +ENDM + +Set_Pwm_C MACRO +IF FETON_DELAY == 0 + cON P_CcomFET + mov P1SKIP, #(NOT (1 SHL C_pwm)) +ELSE + mov P1SKIP, #(NOT ((1 SHL C_pwm) + (1 SHL C_com))) +ENDIF +ENDM + +Set_Pwms_Off MACRO + mov P1SKIP, #0FFh +ENDM + +$endif + + +;**** **** **** **** **** +; Toggling FETs on/off +;**** **** **** **** **** +$if NOT CUSTOM_FET_TOGGLING + +ApwmFET_on MACRO + pON P_ApwmFET +IF FETON_DELAY == 0 + cON P_AcomFET +ENDIF +ENDM + +ApwmFET_off MACRO +IF FETON_DELAY != 0 + pOFF P_ApwmFET +ELSE + cOFF P_AcomFET +ENDIF +ENDM + +BpwmFET_on MACRO + pON P_BpwmFET +IF FETON_DELAY == 0 + cON P_BcomFET +ENDIF +ENDM + +BpwmFET_off MACRO +IF FETON_DELAY != 0 + pOFF P_BpwmFET +ELSE + cOFF P_BcomFET +ENDIF +ENDM + +CpwmFET_on MACRO + pON P_CpwmFET +IF FETON_DELAY == 0 + cON P_CcomFET +ENDIF +ENDM + +CpwmFET_off MACRO +IF FETON_DELAY != 0 + pOFF P_CpwmFET +ELSE + cOFF P_CcomFET +ENDIF +ENDM + +All_pwmFETs_Off MACRO + ApwmFET_off + BpwmFET_off + CpwmFET_off +ENDM + + +AcomFET_on MACRO +IF FETON_DELAY == 0 + pOFF P_ApwmFET +ENDIF + cON P_AcomFET +ENDM + +AcomFET_off MACRO + cOFF P_AcomFET +ENDM + +BcomFET_on MACRO +IF FETON_DELAY == 0 + pOFF P_BpwmFET +ENDIF + cON P_BcomFET +ENDM + +BcomFET_off MACRO + cOFF P_BcomFET +ENDM + +CcomFET_on MACRO +IF FETON_DELAY == 0 + pOFF P_CpwmFET +ENDIF + cON P_CcomFET +ENDM + +CcomFET_off MACRO + cOFF P_CcomFET +ENDM + +All_comFETs_Off MACRO + AcomFET_off + BcomFET_off + CcomFET_off +ENDM + +$endif + + +;**** **** **** **** **** +; ADC and temperature measurement +;**** **** **** **** **** +TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) +TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC + +Initialize_Adc MACRO + mov REF0CN, #0Ch ;; Set vdd (3.3V) as reference. Enable temp sensor and bias +IF MCU_48MHZ == 0 + mov ADC0CF, #59h ;; ADC clock 2MHz, PGA gain 1 +ELSE + mov ADC0CF, #0B9h ;; ADC clock 2MHz, PGA gain 1 +ENDIF + mov ADC0MX, #10h ;; Select temp sensor input + mov ADC0CN0, #80h ;; ADC enabled + mov ADC0CN1, #01h ;; Common mode buffer enabled +ENDM + +Start_Adc MACRO + mov ADC0CN0, #90h ;; ADC start +ENDM + +Read_Adc_Result MACRO + mov Temp1, ADC0L + mov Temp2, ADC0H +ENDM + +Stop_Adc MACRO +ENDM + + +;**** **** **** **** **** +; LEDs +;**** **** **** **** **** +$if NOT CUSTOM_LED + +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 + +$endif diff --git a/Layouts/C.inc b/Layouts/C.inc new file mode 100644 index 0000000..d464ee7 --- /dev/null +++ b/Layouts/C.inc @@ -0,0 +1,155 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "C" +; Ac Ap MC MB MA CC X RC X X X X Cc Cp Bc Bp +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +A_com EQU 7 +A_pwm EQU 6 +C_Mux EQU 5 +B_Mux EQU 4 +A_Mux EQU 3 +V_Mux EQU 2 +; EQU 1 +Rcp_In EQU 0 + + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU NOT((1 SHL A_pwm) + (1 SHL A_com)) +P0_PUSHPULL EQU (1 SHL A_pwm) + (1 SHL A_com) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +; EQU 5 +; EQU 4 +C_com EQU 3 +C_pwm EQU 2 +B_com EQU 1 +B_pwm EQU 0 + + +P1_DIGITAL EQU (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL B_com) + (1 SHL C_com) +P1_INIT EQU 00h +P1_PUSHPULL EQU (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL B_com) + (1 SHL C_com) +P1_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; PWM Phase +;**** **** **** **** **** +P_ApwmFET EQU P0.A_pwm +P_AcomFET EQU P0.A_com +P_BpwmFET EQU P1.B_pwm +P_BcomFET EQU P1.B_com +P_CpwmFET EQU P1.C_pwm +P_CcomFET EQU P1.C_com + +Set_Pwm_A MACRO +IF FETON_DELAY == 0 + cON P_AcomFET + mov P0SKIP, #(NOT (1 SHL A_pwm)) + mov P1SKIP, #0FFh +ELSE + mov P0SKIP, #(NOT ((1 SHL A_pwm) + (1 SHL A_com))) + mov P1SKIP, #0FFh +ENDIF +ENDM + +Set_Pwm_B MACRO +IF FETON_DELAY == 0 + cON P_BcomFET + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT (1 SHL B_pwm)) +ELSE + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT ((1 SHL B_pwm) + (1 SHL B_com))) +ENDIF +ENDM + +Set_Pwm_C MACRO +IF FETON_DELAY == 0 + cON P_CcomFET + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT (1 SHL C_pwm)) +ELSE + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT ((1 SHL C_pwm) + (1 SHL C_com))) +ENDIF +ENDM + +Set_Pwms_Off MACRO + mov P0SKIP, #0FFh + mov P1SKIP, #0FFh +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_PWM_PHASE) +$include (Base.inc) diff --git a/Layouts/D.inc b/Layouts/D.inc new file mode 100644 index 0000000..0725874 --- /dev/null +++ b/Layouts/D.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "D". Com fets are active low for H/L_N driver and EN_N/PWM driver. A with different comp +; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 0 ; Damping non-inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +C_Mux EQU 1 +B_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_com EQU 5 +C_pwm EQU 4 +B_com EQU 3 +B_pwm EQU 2 +A_com EQU 1 +A_pwm EQU 0 + + +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_INIT EQU (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com) +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/E.inc b/Layouts/E.inc new file mode 100644 index 0000000..6a3947f --- /dev/null +++ b/Layouts/E.inc @@ -0,0 +1,164 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "E". Equals "A", but with LED control. And with HIP2103/4 driver initialization +; L1 L0 RC X MC MB MA CC X L2 Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +LED_1 EQU 7 +LED_0 EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +B_Mux EQU 2 +A_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU NOT((1 SHL LED_0) + (1 SHL LED_1)) +P0_PUSHPULL EQU (1 SHL LED_0) + (1 SHL LED_1) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +LED_2 EQU 6 +C_com EQU 5 +C_pwm EQU 4 +B_com EQU 3 +B_pwm EQU 2 +A_com EQU 1 +A_pwm EQU 0 + + +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) + (1 SHL LED_2) +P1_INIT EQU 00h +P1_PUSHPULL 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) + (1 SHL LED_2) +P1_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; ESC specific +;**** **** **** **** **** +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 PCA0CPM_POWER == 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 + + +;**** **** **** **** **** +; LED configuration +;**** **** **** **** **** +Set_LED_0 MACRO + setb P0.LED_0 +ENDM + +Clear_LED_0 MACRO + clr P0.LED_0 +ENDM + +Set_LED_1 MACRO + setb P0.LED_1 +ENDM + +Clear_LED_1 MACRO + clr P0.LED_1 +ENDM + +Set_LED_2 MACRO + setb P1.LED_2 +ENDM + +Clear_LED_2 MACRO + clr P1.LED_2 +ENDM + +Set_LED_3 MACRO +ENDM + +Clear_LED_3 MACRO +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_PWM_SETUP, CUSTOM_LED) +$include (Base.inc) diff --git a/Layouts/F.inc b/Layouts/F.inc new file mode 100644 index 0000000..2ff2ca6 --- /dev/null +++ b/Layouts/F.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "F". Equals "A", but with A_Mux and C_Mux swapped +; X X RC X MA MB MC CC X X Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +A_Mux EQU 3 +B_Mux EQU 2 +C_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_com EQU 5 +C_pwm EQU 4 +B_com EQU 3 +B_pwm EQU 2 +A_com EQU 1 +A_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/G.inc b/Layouts/G.inc new file mode 100644 index 0000000..0a1cc5b --- /dev/null +++ b/Layouts/G.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "G". A with different comp ordering +; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +C_Mux EQU 1 +B_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_com EQU 5 +C_pwm EQU 4 +B_com EQU 3 +B_pwm EQU 2 +A_com EQU 1 +A_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/H.inc b/Layouts/H.inc new file mode 100644 index 0000000..0b99b68 --- /dev/null +++ b/Layouts/H.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "H". +; RC X X X MA MB CC MC X Ap Bp Cp X Ac Bc Cc +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +Rcp_In EQU 7 +; EQU 6 +; EQU 5 +; EQU 4 +A_Mux EQU 3 +B_Mux EQU 2 +V_Mux EQU 1 +C_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +A_pwm EQU 6 +B_pwm EQU 5 +C_pwm EQU 4 +; EQU 3 +A_com EQU 2 +B_com EQU 1 +C_com EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/I.inc b/Layouts/I.inc new file mode 100644 index 0000000..3ff7fff --- /dev/null +++ b/Layouts/I.inc @@ -0,0 +1,106 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "I" +; X X RC X MC MB MA CC X X Ac Bc Cc Ap Bp Cp +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +B_Mux EQU 2 +A_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +A_com EQU 5 +B_com EQU 4 +C_com EQU 3 +A_pwm EQU 2 +B_pwm EQU 1 +C_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/J.inc b/Layouts/J.inc new file mode 100644 index 0000000..5e704f8 --- /dev/null +++ b/Layouts/J.inc @@ -0,0 +1,139 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "J" +; L2 L1 L0 RC CC MB MC MA X X Cc Bc Ac Cp Bp Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +LED_2 EQU 7 +LED_1 EQU 6 +LED_0 EQU 5 +Rcp_In EQU 4 +V_Mux EQU 3 +B_Mux EQU 2 +C_Mux EQU 1 +A_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU (1 SHL LED_0) + (1 SHL LED_1) + (1 SHL LED_2) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_com EQU 5 +B_com EQU 4 +A_com EQU 3 +C_pwm EQU 2 +B_pwm EQU 1 +A_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; LED configuration +;**** **** **** **** **** +Set_LED_0 MACRO + clr P0.LED_0 +ENDM + +Clear_LED_0 MACRO + setb P0.LED_0 +ENDM + +Set_LED_1 MACRO + clr P0.LED_1 +ENDM + +Clear_LED_1 MACRO + setb P0.LED_1 +ENDM + +Set_LED_2 MACRO + clr P0.LED_2 +ENDM + +Clear_LED_2 MACRO + setb P0.LED_2 +ENDM + +Set_LED_3 MACRO +ENDM + +Clear_LED_3 MACRO +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_LED) +$include (Base.inc) diff --git a/Layouts/K.inc b/Layouts/K.inc new file mode 100644 index 0000000..1532b2c --- /dev/null +++ b/Layouts/K.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "K". Com fets are active low for H/L_N driver and EN_N/PWM driver +; X X MC X MB CC MA RC X X Ap Bp Cp Cc Bc Ac Com fets inverted +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 0 ; Damping non-inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +C_Mux EQU 5 +; EQU 4 +B_Mux EQU 3 +V_Mux EQU 2 +A_Mux EQU 1 +Rcp_In EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +A_pwm EQU 5 +B_pwm EQU 4 +C_pwm EQU 3 +C_com EQU 2 +B_com EQU 1 +A_com EQU 0 + + +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_INIT EQU (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com) +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/L.inc b/Layouts/L.inc new file mode 100644 index 0000000..650ad78 --- /dev/null +++ b/Layouts/L.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "L". I with different comp ordering +; X X RC X CC MA MB MC X X Ac Bc Cc Ap Bp Cp +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +B_Mux EQU 1 +C_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +A_com EQU 5 +B_com EQU 4 +C_com EQU 3 +A_pwm EQU 2 +B_pwm EQU 1 +C_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/M.inc b/Layouts/M.inc new file mode 100644 index 0000000..46eb85e --- /dev/null +++ b/Layouts/M.inc @@ -0,0 +1,135 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "M". +; MA MC CC MB RC L0 X X X Cc Bc Ac Cp Bp Ap X +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +A_Mux EQU 7 +C_Mux EQU 6 +V_Mux EQU 5 +B_Mux EQU 4 +Rcp_In EQU 3 +LED_0 EQU 2 +; EQU 1 +; EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU NOT(1 SHL LED_0) +P0_PUSHPULL EQU (1 SHL LED_0) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +C_com EQU 6 +B_com EQU 5 +A_com EQU 4 +C_pwm EQU 3 +B_pwm EQU 2 +A_pwm EQU 1 +; EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; LED configuration +;**** **** **** **** **** +Set_LED_0 MACRO + setb P0.LED_0 +ENDM + +Clear_LED_0 MACRO + clr P0.LED_0 +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 + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_LED) +$include (Base.inc) diff --git a/Layouts/N.inc b/Layouts/N.inc new file mode 100644 index 0000000..3a0aa5b --- /dev/null +++ b/Layouts/N.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "N". B with A and C fets swapped +; X X RC X MC MB MA CC X X Cp Cc Bp Bc Ap Ac +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +B_Mux EQU 2 +A_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_pwm EQU 5 +C_com EQU 4 +B_pwm EQU 3 +B_com EQU 2 +A_pwm EQU 1 +A_com EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/O.inc b/Layouts/O.inc new file mode 100644 index 0000000..9a0597d --- /dev/null +++ b/Layouts/O.inc @@ -0,0 +1,114 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "O". Com fets are active low for H/L_N driver and EN_N/PWM driver. Low side pwm and 1S flag set +; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 0 ; Damping non-inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +C_Mux EQU 1 +B_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_com EQU 5 +C_pwm EQU 4 +B_com EQU 3 +B_pwm EQU 2 +A_com EQU 1 +A_pwm EQU 0 + + +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_INIT EQU (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com) +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Comparator setup +;**** **** **** **** **** +Initialize_Comparator MACRO + mov CMP_CN0, #80h ;; Comparator enabled, no hysteresis + mov CMP_MD, #40h ;; Comparator response time 100ns, Output polarity inverted +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_COMP_SETUP) +$include (Base.inc) diff --git a/Layouts/P.inc b/Layouts/P.inc new file mode 100644 index 0000000..86cf601 --- /dev/null +++ b/Layouts/P.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "P". M with different comp and no LEDs +; X X RC MA CC MB MC X X Cc Bc Ac Cp Bp Ap X +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +A_Mux EQU 4 +V_Mux EQU 3 +B_Mux EQU 2 +C_Mux EQU 1 +; EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +C_com EQU 6 +B_com EQU 5 +A_com EQU 4 +C_pwm EQU 3 +B_pwm EQU 2 +A_pwm EQU 1 +; EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/Q.inc b/Layouts/Q.inc new file mode 100644 index 0000000..20a7ecb --- /dev/null +++ b/Layouts/Q.inc @@ -0,0 +1,187 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "Q" +; Cp Bp Ap L1 L0 X RC X X MA MB MC CC Cc Bc Ac +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 1 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +C_pwm EQU 7 +B_pwm EQU 6 +A_pwm EQU 5 +LED_1 EQU 4 +LED_0 EQU 3 +; EQU 2 +Rcp_In EQU 1 +; EQU 0 + + +P0_DIGITAL EQU 0FFh +P0_INIT EQU (1 SHL Rcp_In) +P0_PUSHPULL EQU (1 SHL LED_0) + (1 SHL LED_1) + (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +A_Mux EQU 6 +B_Mux EQU 5 +C_Mux EQU 4 +V_Mux EQU 3 +C_com EQU 2 +B_com EQU 1 +A_com EQU 0 + + +P1_DIGITAL EQU (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com) +P1_INIT EQU 00h +P1_PUSHPULL EQU (1 SHL A_com) + (1 SHL B_com) + (1 SHL C_com) +P1_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; PWM Phase +;**** **** **** **** **** +P_ApwmFET EQU P0.A_pwm +P_AcomFET EQU P1.A_com +P_BpwmFET EQU P0.B_pwm +P_BcomFET EQU P1.B_com +P_CpwmFET EQU P0.C_pwm +P_CcomFET EQU P1.C_com + +Set_Pwm_A MACRO +IF FETON_DELAY == 0 + cON P_AcomFET + mov P0SKIP, #(NOT (1 SHL A_pwm)) + mov P1SKIP, #0FFh +ELSE + mov P0SKIP, #(NOT (1 SHL A_pwm)) + mov P1SKIP, #(NOT (1 SHL A_com)) +ENDIF +ENDM + +Set_Pwm_B MACRO +IF FETON_DELAY == 0 + cON P_BcomFET + mov P0SKIP, #(NOT (1 SHL B_pwm)) + mov P1SKIP, #0FFh +ELSE + mov P0SKIP, #(NOT (1 SHL B_pwm)) + mov P1SKIP, #(NOT (1 SHL B_com)) +ENDIF +ENDM + +Set_Pwm_C MACRO +IF FETON_DELAY == 0 + cON P_CcomFET + mov P0SKIP, #(NOT (1 SHL C_pwm)) + mov P1SKIP, #0FFh +ELSE + mov P0SKIP, #(NOT (1 SHL C_pwm)) + mov P1SKIP, #(NOT (1 SHL C_com)) +ENDIF +ENDM + +Set_Pwms_Off MACRO + mov P0SKIP, #0FFh + mov P1SKIP, #0FFh +ENDM + + +;**** **** **** **** **** +; LED configuration +;**** **** **** **** **** +Set_LED_0 MACRO + setb P0.LED_0 +ENDM + +Clear_LED_0 MACRO + clr P0.LED_0 +ENDM + +Set_LED_1 MACRO + setb P0.LED_1 +ENDM + +Clear_LED_1 MACRO + clr P0.LED_1 +ENDM + +Set_LED_2 MACRO +ENDM + +Clear_LED_2 MACRO +ENDM + +Set_LED_3 MACRO +ENDM + +Clear_LED_3 MACRO +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_PWM_PHASE, CUSTOM_LED) +$include (Base.inc) diff --git a/Layouts/R.inc b/Layouts/R.inc new file mode 100644 index 0000000..bdafb15 --- /dev/null +++ b/Layouts/R.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "R". L with different comp +; X X RC X MC MB MA CC X X Ac Bc Cc Ap Bp Cp +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +B_Mux EQU 2 +A_Mux EQU 1 +V_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +A_com EQU 5 +B_com EQU 4 +C_com EQU 3 +A_pwm EQU 2 +B_pwm EQU 1 +C_pwm EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/S.inc b/Layouts/S.inc new file mode 100644 index 0000000..da79c10 --- /dev/null +++ b/Layouts/S.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "S". like "O" but Com fets are active high, Pwm fets are active low. N with different comp +; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +C_Mux EQU 1 +B_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_pwm EQU 5 +C_com EQU 4 +B_pwm EQU 3 +B_com EQU 2 +A_pwm EQU 1 +A_com EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/T.inc b/Layouts/T.inc new file mode 100644 index 0000000..821aa70 --- /dev/null +++ b/Layouts/T.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "T". +; RC X MA X MB CC MC X X X Cp Bp Ap Ac Bc Cc +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +Rcp_In EQU 7 +; EQU 6 +A_Mux EQU 5 +; EQU 4 +B_Mux EQU 3 +V_Mux EQU 2 +C_Mux EQU 1 +; EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_pwm EQU 5 +B_pwm EQU 4 +A_pwm EQU 3 +A_com EQU 2 +B_com EQU 1 +C_com EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Layouts/U.inc b/Layouts/U.inc new file mode 100644 index 0000000..d83a192 --- /dev/null +++ b/Layouts/U.inc @@ -0,0 +1,139 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "U". Like M, but with 3 LEDs +; MA MC CC MB RC L0 L1 L2 X Cc Bc Ac Cp Bp Ap X +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 + +;********************* +; PORT 0 definitions * +;********************* +A_Mux EQU 7 +C_Mux EQU 6 +V_Mux EQU 5 +B_Mux EQU 4 +Rcp_In EQU 3 +LED_0 EQU 2 +LED_1 EQU 1 +LED_2 EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU (1 SHL LED_0) + (1 SHL LED_1) + (1 SHL LED_2) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +C_com EQU 6 +B_com EQU 5 +A_com EQU 4 +C_pwm EQU 3 +B_pwm EQU 2 +A_pwm EQU 1 +; EQU 0 + + +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_INIT EQU 00h +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; LED configuration +;**** **** **** **** **** +Set_LED_0 MACRO + clr P0.LED_0 +ENDM + +Clear_LED_0 MACRO + setb P0.LED_0 +ENDM + +Set_LED_1 MACRO + clr P0.LED_1 +ENDM + +Clear_LED_1 MACRO + setb P0.LED_1 +ENDM + +Set_LED_2 MACRO + clr P0.LED_2 +ENDM + +Clear_LED_2 MACRO + setb P0.LED_2 +ENDM + +Set_LED_3 MACRO +ENDM + +Clear_LED_3 MACRO +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_LED) +$include (Base.inc) diff --git a/Layouts/V.inc b/Layouts/V.inc new file mode 100644 index 0000000..5dce934 --- /dev/null +++ b/Layouts/V.inc @@ -0,0 +1,155 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "V" +; Cc X RC X MC CC MB MA X Ap Ac Bp X X Bc Cp +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +C_com EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +C_Mux EQU 3 +V_Mux EQU 2 +B_Mux EQU 1 +A_Mux EQU 0 + + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU NOT(1 SHL C_com) +P0_PUSHPULL EQU (1 SHL C_com) +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +A_pwm EQU 6 +A_com EQU 5 +B_pwm EQU 4 +; EQU 3 +; EQU 2 +B_com EQU 1 +C_pwm EQU 0 + + +P1_DIGITAL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) + (1 SHL B_com) +P1_INIT EQU 00h +P1_PUSHPULL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) + (1 SHL B_com) +P1_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; PWM Phase +;**** **** **** **** **** +P_ApwmFET EQU P1.A_pwm +P_AcomFET EQU P1.A_com +P_BpwmFET EQU P1.B_pwm +P_BcomFET EQU P1.B_com +P_CpwmFET EQU P1.C_pwm +P_CcomFET EQU P0.C_com + +Set_Pwm_A MACRO +IF FETON_DELAY == 0 + cON P_AcomFET + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT (1 SHL A_pwm)) +ELSE + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT ((1 SHL A_pwm) + (1 SHL A_com))) +ENDIF +ENDM + +Set_Pwm_B MACRO +IF FETON_DELAY == 0 + cON P_BcomFET + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT (1 SHL B_pwm)) +ELSE + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT ((1 SHL B_pwm) + (1 SHL B_com))) +ENDIF +ENDM + +Set_Pwm_C MACRO +IF FETON_DELAY == 0 + cON P_CcomFET + mov P0SKIP, #0FFh + mov P1SKIP, #(NOT (1 SHL C_pwm)) +ELSE + mov P0SKIP, #(NOT (1 SHL C_com)) + mov P1SKIP, #(NOT (1 SHL C_pwm)) +ENDIF +ENDM + +Set_Pwms_Off MACRO + mov P0SKIP, #0FFh + mov P1SKIP, #0FFh +ENDM + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_PWM_PHASE) +$include (Base.inc) diff --git a/Layouts/W.inc b/Layouts/W.inc new file mode 100644 index 0000000..d8b50e4 --- /dev/null +++ b/Layouts/W.inc @@ -0,0 +1,189 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "W". This is for tristate input style FET driver chips +; RC MC MB X CC MA X X X Ap Bp Cp X X X X +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +Rcp_In EQU 7 +C_Mux EQU 6 +B_Mux EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +; EQU 1 +; EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +A_pwm EQU 6 +B_pwm EQU 5 +C_pwm EQU 4 +; EQU 3 +; EQU 2 +; EQU 1 +; EQU 0 + + +; pwm outputs start as analog in -> floating +; 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_INIT EQU 00h +P1_PUSHPULL EQU ((1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm)) +P1_SKIP EQU 0FFh + + +ApwmFET_on MACRO + setb P1.A_pwm ; set pin to high + orl P1MDIN, #(1 SHL A_pwm) ; enable pin driver +ENDM + +ApwmFET_off MACRO + anl P1MDIN, #(NOT(1 SHL A_pwm)) ; analog in -> pullup, driver and digital in is disable = floating +ENDM + +BpwmFET_on MACRO + setb P1.B_pwm ; set pin to high + orl P1MDIN, #(1 SHL B_pwm) ; enable pin driver +ENDM + +BpwmFET_off MACRO + anl P1MDIN, #(NOT(1 SHL B_pwm)) ; analog in -> pullup, driver and digital in is disable = floating +ENDM + +CpwmFET_on MACRO + setb P1.C_pwm ; set pin to high + orl P1MDIN, #(1 SHL C_pwm) ; enable pin driver +ENDM + +CpwmFET_off MACRO + anl P1MDIN, #(NOT(1 SHL C_pwm)) ; analog in -> pullup, driver and digital in is disable = floating +ENDM + +All_pwmFETs_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 + clr P1.A_pwm ; set pin to low + orl P1MDIN, #(1 SHL A_pwm) ; enable pin driver +ENDM + +AcomFET_off MACRO + anl P1MDIN, #(NOT(1 SHL A_pwm)) ; analog in -> pullup, driver and digital in is disable = floating +ENDM + +BcomFET_on MACRO + clr P1.B_pwm ; set pin to low + orl P1MDIN, #(1 SHL B_pwm) ; enable pin driver +ENDM + +BcomFET_off MACRO + anl P1MDIN, #(NOT(1 SHL B_pwm)) ; analog in -> pullup, driver and digital in is disable = floating +ENDM + +CcomFET_on MACRO + clr P1.C_pwm ; set pin to low + orl P1MDIN, #(1 SHL C_pwm) ; enable pin driver +ENDM + +CcomFET_off MACRO + anl P1MDIN, #(NOT(1 SHL C_pwm)) ; analog in -> pullup, driver and digital in is disable = floating +ENDM + +All_comFETs_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 + +Set_Pwm_A MACRO + mov P1SKIP, #(NOT(1 SHL A_pwm)); + orl P1MDIN, #(1 SHL A_pwm) ; enable pin driver +ENDM + +Set_Pwm_B MACRO + mov P1SKIP, #(NOT(1 SHL B_pwm)); + orl P1MDIN, #(1 SHL B_pwm) ; enable pin driver +ENDM + +Set_Pwm_C MACRO + mov P1SKIP, #(NOT(1 SHL C_pwm)); + orl P1MDIN, #(1 SHL C_pwm) ; enable pin driver +ENDM + +Set_Pwms_Off MACRO + mov P1SKIP, #P1_SKIP; +ENDM + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$set(CUSTOM_PWM_PHASE, CUSTOM_FET_TOGGLING) +$include (Base.inc) diff --git a/Layouts/Z.inc b/Layouts/Z.inc new file mode 100644 index 0000000..452a87f --- /dev/null +++ b/Layouts/Z.inc @@ -0,0 +1,104 @@ +;**** **** **** **** **** +; +; Bluejay digital ESC firmware for controlling brushless motors in multirotors +; +; Copyright 2020 Mathias Rasmussen +; Copyright 2011, 2012 Steffen Skaug +; +; 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 . +; +;**** **** **** **** **** +; +; Hardware definition file "Z". N different comp and pwm active low +; X X RC X CC MA MC MB X X Cp Cc Bp Bc Ap Ac +; +;**** **** **** **** **** + +PWM_ACTIVE_HIGH EQU 0 ; Pwm inverted +COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted + +; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port +COMPARATOR_PORT EQU 0 + +IF FETON_DELAY == 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 PCA0CPM1 + PCA0CPL_POWER EQU PCA0CPL1 + PCA0CPH_POWER EQU PCA0CPH1 + + PCA0CPM_DAMP EQU PCA0CPM0 + PCA0CPL_DAMP EQU PCA0CPL0 + PCA0CPH_DAMP EQU PCA0CPH0 +ENDIF + +;********************* +; PORT 0 definitions * +;********************* +; EQU 7 +; EQU 6 +Rcp_In EQU 5 +; EQU 4 +V_Mux EQU 3 +A_Mux EQU 2 +C_Mux EQU 1 +B_Mux EQU 0 + +P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux)) +P0_INIT EQU 0FFh +P0_PUSHPULL EQU 0 +P0_SKIP EQU 0FFh + + +;********************* +; PORT 1 definitions * +;********************* +; EQU 7 +; EQU 6 +C_pwm EQU 5 +C_com EQU 4 +B_pwm EQU 3 +B_com EQU 2 +A_pwm EQU 1 +A_com EQU 0 + + +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_INIT EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) +P1_PUSHPULL 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_SKIP EQU 0FFh + + +;********************* +; PORT 2 definitions * +;********************* +DebugPin EQU 0 + +P2_DIGITAL EQU (1 SHL DebugPin) +P2_PUSHPULL EQU (1 SHL DebugPin) +P2_SKIP EQU 0FFh + + +;**** **** **** **** **** +; Inherit base layout +;**** **** **** **** **** +$include (Base.inc) diff --git a/Makefile b/Makefile index 80c5fd8..0b1c9a6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION ?= v0.10 # Target parameters -LAYOUTS = A B C D E F G H I J K L M N O P Q R S T U V W +LAYOUTS = A B C D E F G H I J K L M N O P Q R S T U V W Z MCUS = H L DEADTIMES = 0 5 10 15 20 25 30 40 50 70 90 PWM_FREQS = 24 48 96 @@ -36,7 +36,7 @@ LX51_FLAGS = # Source files ASM_SRC = Bluejay.asm -ASM_INC = $(LAYOUTS:%=targets/%.inc) Common.inc BLHeliBootLoad.inc Silabs/SI_EFM8BB1_Defs.inc Silabs/SI_EFM8BB2_Defs.inc +ASM_INC = $(LAYOUTS:%=Layouts/%.inc) Layouts/Base.inc Common.inc BLHeliBootLoad.inc Silabs/SI_EFM8BB1_Defs.inc Silabs/SI_EFM8BB2_Defs.inc # Check that wine/simplicity studio is available EXECUTABLES = $(AX51_BIN) $(LX51_BIN) $(OX51_BIN) diff --git a/targets/A.inc b/targets/A.inc deleted file mode 100644 index 07f512b..0000000 --- a/targets/A.inc +++ /dev/null @@ -1,290 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "A" -; X X RC X MC MB MA CC X X Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Mux_B EQU 2 ;i -Mux_A EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CcomFET EQU 5 ;o -CpwmFET EQU 4 ;o -BcomFET EQU 3 ;o -BpwmFET EQU 2 ;o -AcomFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/B.inc b/targets/B.inc deleted file mode 100644 index c56445c..0000000 --- a/targets/B.inc +++ /dev/null @@ -1,295 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "B". Equals "A", but with A and C fets swapped and pwm and com fets swapped -; X X RC X MC MB MA CC X X Ap Ac Bp Bc Cp Cc -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Mux_B EQU 2 ;i -Mux_A EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -ApwmFET EQU 5 ;o -AcomFET EQU 4 ;o -BpwmFET EQU 3 ;o -BcomFET EQU 2 ;o -CpwmFET EQU 1 ;o -CcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #1Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #37h -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/C.inc b/targets/C.inc deleted file mode 100644 index c182ded..0000000 --- a/targets/C.inc +++ /dev/null @@ -1,297 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "C" -; Ac Ap MC MB MA CC X RC X X X X Cc Cp Bc Bp -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 0 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -AcomFET EQU 7 ;o -ApwmFET EQU 6 ;o -Mux_C EQU 5 ;i -Mux_B EQU 4 ;i -Mux_A EQU 3 ;i -Comp_Com EQU 2 ;i -; EQU 1 ;i -Rcp_In EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU NOT((1 SHL ApwmFET)+(1 SHL AcomFET)) -P0_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL AcomFET) -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -; EQU 5 ;i -; EQU 4 ;i -CcomFET EQU 3 ;o -CpwmFET EQU 2 ;o -BcomFET EQU 1 ;o -BpwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 0Fh - -ApwmFET_on MACRO - setb P0.ApwmFET -IF FETON_DELAY == 0 - setb P0.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P0.ApwmFET -ELSE - clr P0.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P0.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P0.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P0.ApwmFET -ENDIF - setb P0.AcomFET -ENDM -AcomFET_off MACRO - clr P0.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P0.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P0.AcomFET - mov P0SKIP, #0BFh - mov P1SKIP, #0Fh -ELSE - mov P0SKIP, #03Fh - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P0SKIP, #0FFh - mov P1SKIP, #0Eh -ELSE - mov P0SKIP, #0FFh - mov P1SKIP, #0Ch -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P0SKIP, #0FFh - mov P1SKIP, #0Bh -ELSE - mov P0SKIP, #0FFh - mov P1SKIP, #03h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P0SKIP, #0FFh - mov P1SKIP, #0Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #32h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #42h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #52h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/D.inc b/targets/D.inc deleted file mode 100644 index fcb7c9e..0000000 --- a/targets/D.inc +++ /dev/null @@ -1,290 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "D". Com fets are active low for H/L_N driver and EN_N/PWM driver -; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_A EQU 2 ;i -Mux_C EQU 1 ;i -Mux_B EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #00h ; Damping noninverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CcomFET EQU 5 ;o -CpwmFET EQU 4 ;o -BcomFET EQU 3 ;o -BpwmFET EQU 2 ;o -AcomFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU (1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - clr P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - setb P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - clr P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - setb P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - clr P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - setb P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - setb P1.AcomFET - setb P1.BcomFET - setb P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - clr P1.AcomFET -ENDM -AcomFET_off MACRO - setb P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - clr P1.BcomFET -ENDM -BcomFET_off MACRO - setb P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - clr P1.CcomFET -ENDM -CcomFET_off MACRO - setb P1.CcomFET -ENDM -All_comFETs_Off MACRO - setb P1.AcomFET - setb P1.BcomFET - setb P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - clr P1.AcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - clr P1.BcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - clr P1.CcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #03h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/E.inc b/targets/E.inc deleted file mode 100644 index 5d2e78d..0000000 --- a/targets/E.inc +++ /dev/null @@ -1,303 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "E". Equals "A", but with LED control. And with HIP2103/4 driver initialization -; L1 L0 RC X MC MB MA CC X L2 Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -LED_1 EQU 7 ;o -LED_0 EQU 6 ;o -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Mux_B EQU 2 ;i -Mux_A EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU NOT((1 SHL LED_0)+(1 SHL LED_1)) -P0_PUSHPULL EQU (1 SHL LED_0)+(1 SHL LED_1) -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -LED_2 EQU 6 ;o -CcomFET EQU 5 ;o -CpwmFET EQU 4 ;o -BcomFET EQU 3 ;o -BpwmFET EQU 2 ;o -AcomFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET)+(1 SHL LED_2) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET)+(1 SHL LED_2) -P1_SKIP EQU 7Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #7Eh -ELSE - mov P1SKIP, #7Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #7Bh -ELSE - mov P1SKIP, #73h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #6Fh -ELSE - mov P1SKIP, #4Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Comparator MACRO - mov CMP0CN0, #80h ; Comparator enabled, no hysteresis - mov CMP0MD, #00h ; Comparator response time 100ns -ENDM -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -ENDM -Set_LED_0 MACRO - setb P0.LED_0 -ENDM -Clear_LED_0 MACRO - clr P0.LED_0 -ENDM -Set_LED_1 MACRO - setb P0.LED_1 -ENDM -Clear_LED_1 MACRO - clr P0.LED_1 -ENDM -Set_LED_2 MACRO - setb P1.LED_2 -ENDM -Clear_LED_2 MACRO - clr P1.LED_2 -ENDM -Set_LED_3 MACRO -ENDM -Clear_LED_3 MACRO -ENDM diff --git a/targets/F.inc b/targets/F.inc deleted file mode 100644 index b1f3180..0000000 --- a/targets/F.inc +++ /dev/null @@ -1,290 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "F". Equals "A", but with Mux_A and Mux_C swapped -; X X RC X MA MB MC CC X X Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_A EQU 3 ;i -Mux_B EQU 2 ;i -Mux_C EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CcomFET EQU 5 ;o -CpwmFET EQU 4 ;o -BcomFET EQU 3 ;o -BpwmFET EQU 2 ;o -AcomFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/G.inc b/targets/G.inc deleted file mode 100644 index 2f0c435..0000000 --- a/targets/G.inc +++ /dev/null @@ -1,290 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "G" -; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_A EQU 2 ;i -Mux_C EQU 1 ;i -Mux_B EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CcomFET EQU 5 ;o -CpwmFET EQU 4 ;o -BcomFET EQU 3 ;o -BpwmFET EQU 2 ;o -AcomFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #03h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/H.inc b/targets/H.inc deleted file mode 100644 index 3dd73f9..0000000 --- a/targets/H.inc +++ /dev/null @@ -1,295 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "H". -; RC X X X MA MB CC MC X Ap Bp Cp X Ac Bc Cc -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -Rcp_In EQU 7 ;i -; EQU 6 ;i -; EQU 5 ;i -; EQU 4 ;i -Mux_A EQU 3 ;i -Mux_B EQU 2 ;i -Comp_Com EQU 1 ;i -Mux_C EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -ApwmFET EQU 6 ;o -BpwmFET EQU 5 ;o -CpwmFET EQU 4 ;o -; EQU 3 ;i -AcomFET EQU 2 ;o -BcomFET EQU 1 ;o -CcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 7Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Fh -ELSE - mov P1SKIP, #3Bh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #5Fh -ELSE - mov P1SKIP, #5Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #6Fh -ELSE - mov P1SKIP, #6Eh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #31h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #21h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #01h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/I.inc b/targets/I.inc deleted file mode 100644 index 846fa3b..0000000 --- a/targets/I.inc +++ /dev/null @@ -1,289 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "I" -; X X RC X MC MB MA CC X X Ac Bc Cc Ap Bp Cp -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Mux_B EQU 2 ;i -Mux_A EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -AcomFET EQU 5 ;o -BcomFET EQU 4 ;o -CcomFET EQU 3 ;o -ApwmFET EQU 2 ;o -BpwmFET EQU 1 ;o -CpwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #1Bh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #2Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #36h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/J.inc b/targets/J.inc deleted file mode 100644 index bee43d5..0000000 --- a/targets/J.inc +++ /dev/null @@ -1,295 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "J" -; L2 L1 L0 RC CC MB MC MA X X Cc Bc Ac Cp Bp Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 4 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -LED_2 EQU 7 ;o -LED_1 EQU 6 ;o -LED_0 EQU 5 ;o -Rcp_In EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_B EQU 2 ;i -Mux_C EQU 1 ;i -Mux_A EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU (1 SHL LED_0)+(1 SHL LED_1)+(1 SHL LED_2) -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CcomFET EQU 5 ;o -BcomFET EQU 4 ;o -AcomFET EQU 3 ;o -CpwmFET EQU 2 ;o -BpwmFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #36h -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #2Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #1Bh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #03h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -ENDM -Set_LED_0 MACRO - clr P0.LED_0 -ENDM -Clear_LED_0 MACRO - setb P0.LED_0 -ENDM -Set_LED_1 MACRO - clr P0.LED_1 -ENDM -Clear_LED_1 MACRO - setb P0.LED_1 -ENDM -Set_LED_2 MACRO - clr P0.LED_2 -ENDM -Clear_LED_2 MACRO - setb P0.LED_2 -ENDM -Set_LED_3 MACRO -ENDM -Clear_LED_3 MACRO -ENDM diff --git a/targets/K.inc b/targets/K.inc deleted file mode 100644 index d5dd1ac..0000000 --- a/targets/K.inc +++ /dev/null @@ -1,291 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "K". Com fets are active low for H/L_N driver and EN_N/PWM driver -; X X MC X MB CC MA RC X X Ap Bp Cp Cc Bc Ac Com fets inverted -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 0 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Mux_C EQU 5 ;i -; EQU 4 ;i -Mux_B EQU 3 ;i -Comp_Com EQU 2 ;i -Mux_A EQU 1 ;i -Rcp_In EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #00h ; Damping noninverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -ApwmFET EQU 5 ;o -BpwmFET EQU 4 ;o -CpwmFET EQU 3 ;o -CcomFET EQU 2 ;o -BcomFET EQU 1 ;o -AcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU (1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - clr P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - setb P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - clr P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - setb P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - clr P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - setb P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - setb P1.AcomFET - setb P1.BcomFET - setb P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - clr P1.AcomFET -ENDM -AcomFET_off MACRO - setb P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - clr P1.BcomFET -ENDM -BcomFET_off MACRO - setb P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - clr P1.CcomFET -ENDM -CcomFET_off MACRO - setb P1.CcomFET -ENDM -All_comFETs_Off MACRO - setb P1.AcomFET - setb P1.BcomFET - setb P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - clr P1.AcomFET - mov P1SKIP, #1Fh -ELSE - mov P1SKIP, #1Eh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - clr P1.BcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #2Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - clr P1.CcomFET - mov P1SKIP, #37h -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #12h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #32h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #52h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/L.inc b/targets/L.inc deleted file mode 100644 index 94432bb..0000000 --- a/targets/L.inc +++ /dev/null @@ -1,289 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "L" -; X X RC X CC MA MB MC X X Ac Bc Cc Ap Bp Cp -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_A EQU 2 ;i -Mux_B EQU 1 ;i -Mux_C EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -AcomFET EQU 5 ;o -BcomFET EQU 4 ;o -CcomFET EQU 3 ;o -ApwmFET EQU 2 ;o -BpwmFET EQU 1 ;o -CpwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #1Bh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #2Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #36h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #03h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/M.inc b/targets/M.inc deleted file mode 100644 index a012602..0000000 --- a/targets/M.inc +++ /dev/null @@ -1,294 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "M". -; MA MC CC MB RC L0 X X X Cc Bc Ac Cp Bp Ap X -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 3 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -Mux_A EQU 7 ;i -Mux_C EQU 6 ;i -Comp_Com EQU 5 ;i -Mux_B EQU 4 ;i -Rcp_In EQU 3 ;i -LED_0 EQU 2 ;i -; EQU 1 ;i -; EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU NOT(1 SHL LED_0) -P0_PUSHPULL EQU (1 SHL LED_0) -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -CcomFET EQU 6 ;o -BcomFET EQU 5 ;o -AcomFET EQU 4 ;o -CpwmFET EQU 3 ;i -BpwmFET EQU 2 ;o -ApwmFET EQU 1 ;o -; EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 7Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #7Dh -ELSE - mov P1SKIP, #6Dh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #7Bh -ELSE - mov P1SKIP, #5Bh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #77h -ELSE - mov P1SKIP, #37h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #75h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #45h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #65h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -ENDM -Set_LED_0 MACRO - setb P0.LED_0 -ENDM -Clear_LED_0 MACRO - clr P0.LED_0 -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 diff --git a/targets/N.inc b/targets/N.inc deleted file mode 100644 index 6c80255..0000000 --- a/targets/N.inc +++ /dev/null @@ -1,295 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "N" -; X X RC X MC MB MA CC X X Cp Cc Bp Bc Ap Ac -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Mux_B EQU 2 ;i -Mux_A EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CpwmFET EQU 5 ;o -CcomFET EQU 4 ;o -BpwmFET EQU 3 ;o -BcomFET EQU 2 ;o -ApwmFET EQU 1 ;o -AcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #37h -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #1Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/O.inc b/targets/O.inc deleted file mode 100644 index e29a78a..0000000 --- a/targets/O.inc +++ /dev/null @@ -1,291 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "O". Com fets are active low for H/L_N driver and EN_N/PWM driver. Low side pwm and 1S flag set -; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_A EQU 2 ;i -Mux_C EQU 1 ;i -Mux_B EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #00h ; Damping noninverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CcomFET EQU 5 ;o -CpwmFET EQU 4 ;o -BcomFET EQU 3 ;o -BpwmFET EQU 2 ;o -AcomFET EQU 1 ;o -ApwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU (1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - clr P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - setb P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - clr P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - setb P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - clr P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - setb P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - setb P1.AcomFET - setb P1.BcomFET - setb P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - clr P1.AcomFET -ENDM -AcomFET_off MACRO - setb P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - clr P1.BcomFET -ENDM -BcomFET_off MACRO - setb P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - clr P1.CcomFET -ENDM -CcomFET_off MACRO - setb P1.CcomFET -ENDM -All_comFETs_Off MACRO - setb P1.AcomFET - setb P1.BcomFET - setb P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - clr P1.AcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - clr P1.BcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - clr P1.CcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #03h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output - cpl A -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/P.inc b/targets/P.inc deleted file mode 100644 index 6502e19..0000000 --- a/targets/P.inc +++ /dev/null @@ -1,292 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "P". -; X X RC MA CC MB MC X X Cc Bc Ac Cp Bp Ap X -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -Mux_A EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_B EQU 2 ;i -Mux_C EQU 1 ;i -; EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -CcomFET EQU 6 ;o -BcomFET EQU 5 ;o -AcomFET EQU 4 ;o -CpwmFET EQU 3 ;i -BpwmFET EQU 2 ;o -ApwmFET EQU 1 ;o -; EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 7Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #7Dh -ELSE - mov P1SKIP, #6Dh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #7Bh -ELSE - mov P1SKIP, #5Bh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #77h -ELSE - mov P1SKIP, #37h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #43h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/Q.inc b/targets/Q.inc deleted file mode 100644 index 5340f5c..0000000 --- a/targets/Q.inc +++ /dev/null @@ -1,301 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "Q" -; Cp Bp Ap L1 L0 X RC X X MA MB MC CC Cc Bc Ac -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 1 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -CpwmFET EQU 7 ;o -BpwmFET EQU 6 ;o -ApwmFET EQU 5 ;o -LED_1 EQU 4 ;i -LED_0 EQU 3 ;i -; EQU 2 ;i -Rcp_In EQU 1 ;i -; EQU 0 ;i - -P0_DIGITAL EQU 0FFh -P0_INIT EQU (1 SHL Rcp_In) -P0_PUSHPULL EQU (1 SHL LED_0)+(1 SHL LED_1)+(1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET) -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -Mux_A EQU 6 ;i -Mux_B EQU 5 ;i -Mux_C EQU 4 ;i -Comp_Com EQU 3 ;o -CcomFET EQU 2 ;o -BcomFET EQU 1 ;o -AcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 07h - -ApwmFET_on MACRO - setb P0.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P0.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P0.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P0.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P0.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P0.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P0.ApwmFET - clr P0.BpwmFET - clr P0.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P0.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P0.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P0.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P0SKIP, #0DFh - mov P1SKIP, #07h -ELSE - mov P0SKIP, #0DFh - mov P1SKIP, #06h -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P0SKIP, #0BFh - mov P1SKIP, #07h -ELSE - mov P0SKIP, #0BFh - mov P1SKIP, #05h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P0SKIP, #07Fh - mov P1SKIP, #07h -ELSE - mov P0SKIP, #07Fh - mov P1SKIP, #03h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P0SKIP, #0FFh - mov P1SKIP, #07h -ENDM - -Set_Comp_Phase_A MACRO - mov CMP1MX, #63h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP1MX, #53h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP1MX, #43h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP1CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 CMP1CN0, #80h ; Comparator enabled, no hysteresis - mov CMP1MD, #00h ; Comparator response time 100ns -ENDM -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -ENDM -Set_LED_0 MACRO - setb P0.LED_0 -ENDM -Clear_LED_0 MACRO - clr P0.LED_0 -ENDM -Set_LED_1 MACRO - setb P0.LED_1 -ENDM -Clear_LED_1 MACRO - clr P0.LED_1 -ENDM -Set_LED_2 MACRO -ENDM -Clear_LED_2 MACRO -ENDM -Set_LED_3 MACRO -ENDM -Clear_LED_3 MACRO -ENDM diff --git a/targets/R.inc b/targets/R.inc deleted file mode 100644 index 7efd605..0000000 --- a/targets/R.inc +++ /dev/null @@ -1,289 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "R". -; X X RC X MC MB MA CC X X Ac Bc Cc Ap Bp Cp -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Mux_B EQU 2 ;i -Mux_A EQU 1 ;i -Comp_Com EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -AcomFET EQU 5 ;o -BcomFET EQU 4 ;o -CcomFET EQU 3 ;o -ApwmFET EQU 2 ;o -BpwmFET EQU 1 ;o -CpwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Bh -ELSE - mov P1SKIP, #1Bh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #2Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #3Eh -ELSE - mov P1SKIP, #36h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #10h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #20h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #30h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/S.inc b/targets/S.inc deleted file mode 100644 index 9b2f514..0000000 --- a/targets/S.inc +++ /dev/null @@ -1,294 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "S". like "O" but Com fets are active high, Pwm fets are active low -; X X RC X CC MA MC MB X X Cc Cp Bc Bp Ac Ap -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_A EQU 2 ;i -Mux_C EQU 1 ;i -Mux_B EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CpwmFET EQU 5 ;o -CcomFET EQU 4 ;o -BpwmFET EQU 3 ;o -BcomFET EQU 2 ;o -ApwmFET EQU 1 ;o -AcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU (0 SHL AcomFET)+(0 SHL BcomFET)+(0 SHL CcomFET) -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #3Dh -ELSE - mov P1SKIP, #3Ch -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #37h -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #1Fh -ELSE - mov P1SKIP, #0Fh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #23h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #03h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #13h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/T.inc b/targets/T.inc deleted file mode 100644 index 617a58e..0000000 --- a/targets/T.inc +++ /dev/null @@ -1,295 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "T". -; RC X MA X MB CC MC X X X Cp Bp Ap Ac Bc Cc -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -Rcp_In EQU 7 ;i -; EQU 6 ;i -Mux_A EQU 5 ;i -; EQU 4 ;i -Mux_B EQU 3 ;i -Comp_Com EQU 2 ;i -Mux_C EQU 1 ;i -; EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -; EQU 6 ;i -CpwmFET EQU 5 ;o -BpwmFET EQU 4 ;o -ApwmFET EQU 3 ;o -AcomFET EQU 2 ;o -BcomFET EQU 1 ;o -CcomFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 3Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #37h -ELSE - mov P1SKIP, #33h -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #2Fh -ELSE - mov P1SKIP, #2Dh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #1Fh -ELSE - mov P1SKIP, #1Eh -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #3Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #52h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #32h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #12h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/U.inc b/targets/U.inc deleted file mode 100644 index b86f96a..0000000 --- a/targets/U.inc +++ /dev/null @@ -1,299 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "U". -; MA MC CC MB RC L0 L1 L2 X Cc Bc Ac Cp Bp Ap X -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 3 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -Mux_A EQU 7 ;i -Mux_C EQU 6 ;i -Comp_Com EQU 5 ;i -Mux_B EQU 4 ;i -Rcp_In EQU 3 ;i -LED_0 EQU 2 ;i -LED_1 EQU 1 ;i -LED_2 EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU (1 SHL LED_0)+(1 SHL LED_1)+(1 SHL LED_2) -P0_SKIP EQU 0FFh - -Set_Pwm_Polarity MACRO - mov PCA0POL, #02h ; Damping inverted, pwm noninverted -ENDM - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ENDIF - - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -CcomFET EQU 6 ;o -BcomFET EQU 5 ;o -AcomFET EQU 4 ;o -CpwmFET EQU 3 ;i -BpwmFET EQU 2 ;o -ApwmFET EQU 1 ;o -; EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET)+(1 SHL CcomFET) -P1_SKIP EQU 7Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P1.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P1.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P1.CcomFET -ENDM -CcomFET_off MACRO - clr P1.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P1.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P1SKIP, #7Dh -ELSE - mov P1SKIP, #6Dh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P1SKIP, #7Bh -ELSE - mov P1SKIP, #5Bh -ENDIF -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P1.CcomFET - mov P1SKIP, #77h -ELSE - mov P1SKIP, #37h -ENDIF -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #75h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #45h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #65h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -ENDM -Set_LED_0 MACRO - clr P0.LED_0 -ENDM -Clear_LED_0 MACRO - setb P0.LED_0 -ENDM -Set_LED_1 MACRO - clr P0.LED_1 -ENDM -Clear_LED_1 MACRO - setb P0.LED_1 -ENDM -Set_LED_2 MACRO - clr P0.LED_2 -ENDM -Clear_LED_2 MACRO - setb P0.LED_2 -ENDM -Set_LED_3 MACRO -ENDM -Clear_LED_3 MACRO -ENDM - diff --git a/targets/V.inc b/targets/V.inc deleted file mode 100644 index 54ddf71..0000000 --- a/targets/V.inc +++ /dev/null @@ -1,301 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "V" -; Cc X RC X MC CC MB MA X Ap Ac Bp X X Bc Cp -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 5 ; RTX pin - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - -;********************* -; PORT 0 definitions * -;********************* -CcomFET EQU 7 ;o -; EQU 6 ;i -Rcp_In EQU 5 ;i -; EQU 4 ;i -Mux_C EQU 3 ;i -Comp_Com EQU 2 ;i -Mux_B EQU 1 ;i -Mux_A EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU NOT(1 SHL CcomFET) -P0_PUSHPULL EQU (1 SHL CcomFET) -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -ApwmFET EQU 6 ;i -AcomFET EQU 5 ;i -BpwmFET EQU 4 ;o -; EQU 3 ;o -; EQU 2 ;o -BcomFET EQU 1 ;o -CpwmFET EQU 0 ;o - -P1_DIGITAL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET) -P1_INIT EQU 00h -P1_PUSHPULL EQU (1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)+(1 SHL AcomFET)+(1 SHL BcomFET) -P1_SKIP EQU 7Fh - -ApwmFET_on MACRO - setb P1.ApwmFET -IF FETON_DELAY == 0 - setb P1.AcomFET -ENDIF -ENDM -ApwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET -ELSE - clr P1.AcomFET -ENDIF -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET -IF FETON_DELAY == 0 - setb P1.BcomFET -ENDIF -ENDM -BpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.BpwmFET -ELSE - clr P1.BcomFET -ENDIF -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET -IF FETON_DELAY == 0 - setb P0.CcomFET -ENDIF -ENDM -CpwmFET_off MACRO -IF FETON_DELAY != 0 - clr P1.CpwmFET -ELSE - clr P0.CcomFET -ENDIF -ENDM -All_pwmFETs_Off MACRO -IF FETON_DELAY != 0 - clr P1.ApwmFET - clr P1.BpwmFET - clr P1.CpwmFET -ELSE - clr P1.AcomFET - clr P1.BcomFET - clr P0.CcomFET -ENDIF -ENDM - -AcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.ApwmFET -ENDIF - setb P1.AcomFET -ENDM -AcomFET_off MACRO - clr P1.AcomFET -ENDM -BcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.BpwmFET -ENDIF - setb P1.BcomFET -ENDM -BcomFET_off MACRO - clr P1.BcomFET -ENDM -CcomFET_on MACRO -IF FETON_DELAY == 0 - clr P1.CpwmFET -ENDIF - setb P0.CcomFET -ENDM -CcomFET_off MACRO - clr P0.CcomFET -ENDM -All_comFETs_Off MACRO - clr P1.AcomFET - clr P1.BcomFET - clr P0.CcomFET -ENDM - -Set_Pwm_A MACRO -IF FETON_DELAY == 0 - setb P1.AcomFET - mov P0SKIP, #0FFh - mov P1SKIP, #3Fh -ELSE - mov P0SKIP, #0FFh - mov P1SKIP, #1Fh -ENDIF -ENDM -Set_Pwm_B MACRO -IF FETON_DELAY == 0 - setb P1.BcomFET - mov P0SKIP, #0FFh - mov P1SKIP, #6Fh -ELSE - mov P0SKIP, #0FFh - mov P1SKIP, #6Dh -endif -ENDM -Set_Pwm_C MACRO -IF FETON_DELAY == 0 - setb P0.CcomFET - mov P0SKIP, #0FFh - mov P1SKIP, #7Fh -ELSE - mov P0SKIP, #7Fh - mov P1SKIP, #7Eh -endif -ENDM -Set_Pwms_Off MACRO - mov P0SKIP, #0FFh - mov P1SKIP, #7Fh -ENDM - -Set_Comp_Phase_A MACRO - mov CMP0MX, #02h ; Set comparator multiplexer to phase A -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #12h ; Set comparator multiplexer to phase B -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #32h ; Set comparator multiplexer to phase C -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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 diff --git a/targets/W.inc b/targets/W.inc deleted file mode 100644 index ba44f98..0000000 --- a/targets/W.inc +++ /dev/null @@ -1,255 +0,0 @@ -;**** **** **** **** **** -; -; Bluejay digital ESC firmware for controlling brushless motors in multirotors -; -; Copyright 2020 Mathias Rasmussen -; Copyright 2011, 2012 Steffen Skaug -; -; 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 . -; -;**** **** **** **** **** -; -; Hardware definition file "W". This is for tristate input style FET driver chips -; RC MC MB X CC MA X X X Ap Bp Cp X X X X -; -;**** **** **** **** **** - -TEMP_LIMIT EQU 49 ; Temperature measurement ADC value for which main motor power is limited at 80degC (low byte, assuming high byte is 1) -TEMP_LIMIT_STEP EQU 9 ; Temperature measurement ADC value increment for another 10degC - -;**** **** **** **** **** -; 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 - -SIGNATURE_001 EQU 0E8h ; Device signature -IF MCU_48MHZ == 0 -SIGNATURE_002 EQU 0B1h -ELSE -SIGNATURE_002 EQU 0B2h -ENDIF - - -;********************* -; PORT 0 definitions * -;********************* -Rcp_In EQU 7 ;i -Mux_C EQU 6 ;i -Mux_B EQU 5 ;i -; EQU 4 ;i -Comp_Com EQU 3 ;i -Mux_A EQU 2 ;i -; EQU 1 ;i -; EQU 0 ;i - -P0_DIGITAL EQU NOT((1 SHL Mux_A)+(1 SHL Mux_B)+(1 SHL Mux_C)+(1 SHL Comp_Com)) -P0_INIT EQU 0FFh -P0_PUSHPULL EQU 0 -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 - -IF FETON_DELAY == 0 - PCA0_POWER_MODULE EQU PCA0CPM0 - PCA0_POWER_L EQU PCA0CPL0 - PCA0_POWER_H EQU PCA0CPH0 - - PCA0_DAMP_MODULE EQU PCA0CPM1 - PCA0_DAMP_L EQU PCA0CPL1 - PCA0_DAMP_H EQU PCA0CPH1 -ELSE - PCA0_POWER_MODULE EQU PCA0CPM1 - PCA0_POWER_L EQU PCA0CPL1 - PCA0_POWER_H EQU PCA0CPH1 - - PCA0_DAMP_MODULE EQU PCA0CPM0 - PCA0_DAMP_L EQU PCA0CPL0 - PCA0_DAMP_H EQU PCA0CPH0 -ENDIF - - -;********************* -; PORT 1 definitions * -;********************* -; EQU 7 ;i -ApwmFET EQU 6 ;o -BpwmFET EQU 5 ;o -CpwmFET EQU 4 ;o -; EQU 3 ;i -; EQU 2 ;i -; EQU 1 ;i -; EQU 0 ;i -; pwm outputs start as analog in -> floating -; this ensures all mosfet drivers start with floating outputs -P1_DIGITAL EQU NOT((1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)) -P1_INIT EQU 00h -P1_PUSHPULL EQU ((1 SHL ApwmFET)+(1 SHL BpwmFET)+(1 SHL CpwmFET)) -; -P1_SKIP EQU 0FFh - - -ApwmFET_on MACRO - setb P1.ApwmFET ; set pin to high - orl P1MDIN, #(1 SHL ApwmFET) ; enable pin driver -ENDM -ApwmFET_off MACRO - anl P1MDIN, #(NOT(1 SHL ApwmFET)) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -BpwmFET_on MACRO - setb P1.BpwmFET ; set pin to high - orl P1MDIN, #(1 SHL BpwmFET) ; enable pin driver -ENDM -BpwmFET_off MACRO - anl P1MDIN, #(NOT(1 SHL BpwmFET)) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -CpwmFET_on MACRO - setb P1.CpwmFET ; set pin to high - orl P1MDIN, #(1 SHL CpwmFET) ; enable pin driver -ENDM -CpwmFET_off MACRO - anl P1MDIN, #(NOT(1 SHL CpwmFET)) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -All_pwmFETs_Off MACRO - anl P1MDIN, #(NOT((1 SHL ApwmFET) + (1 SHL BpwmFET) + (1 SHL CpwmFET))) ; analog in -> pullup, driver and digital in is disable = floating -ENDM - -AcomFET_on MACRO - clr P1.ApwmFET ; set pin to low - orl P1MDIN, #(1 SHL ApwmFET) ; enable pin driver -ENDM -AcomFET_off MACRO - anl P1MDIN, #(NOT(1 SHL ApwmFET)) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -BcomFET_on MACRO - clr P1.BpwmFET ; set pin to low - orl P1MDIN, #(1 SHL BpwmFET) ; enable pin driver -ENDM -BcomFET_off MACRO - anl P1MDIN, #(NOT(1 SHL BpwmFET)) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -CcomFET_on MACRO - clr P1.CpwmFET ; set pin to low - orl P1MDIN, #(1 SHL CpwmFET) ; enable pin driver -ENDM -CcomFET_off MACRO - anl P1MDIN, #(NOT(1 SHL CpwmFET)) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -All_comFETs_Off MACRO - anl P1MDIN, #(NOT((1 SHL ApwmFET) + (1 SHL BpwmFET) + (1 SHL CpwmFET))) ; analog in -> pullup, driver and digital in is disable = floating -ENDM -Set_Pwm_A MACRO - mov P1SKIP, #(NOT(1 SHL ApwmFET)); - orl P1MDIN, #(1 SHL ApwmFET) ; enable pin driver -ENDM -Set_Pwm_B MACRO - mov P1SKIP, #(NOT(1 SHL BpwmFET)); - orl P1MDIN, #(1 SHL BpwmFET) ; enable pin driver -ENDM -Set_Pwm_C MACRO - mov P1SKIP, #(NOT(1 SHL CpwmFET)); - orl P1MDIN, #(1 SHL CpwmFET) ; enable pin driver -ENDM -Set_Pwms_Off MACRO - mov P1SKIP, #P1_SKIP; -ENDM - - - -Set_Comp_Phase_A MACRO - mov CMP0MX, #((Mux_A) SHL 4)+((Comp_Com) SHL 0); -ENDM -Set_Comp_Phase_B MACRO - mov CMP0MX, #((Mux_B) SHL 4)+((Comp_Com) SHL 0); -ENDM -Set_Comp_Phase_C MACRO - mov CMP0MX, #((Mux_C) SHL 4)+((Comp_Com) SHL 0); -ENDM -Read_Comp_Out MACRO - mov A, CMP0CN0 ; Read comparator output -ENDM - - - -;********************* -; PORT 2 definitions * -;********************* -DebugPin EQU 0 ;o - -P2_PUSHPULL EQU (1 SHL DebugPin) - - -;********************** -; 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 -Initialize_Adc MACRO - mov REF0CN, #0Ch ; Set vdd (3.3V) as reference. Enable temp sensor and bias -IF MCU_48MHZ == 0 - mov ADC0CF, #59h ; ADC clock 2MHz, PGA gain 1 -ELSE - mov ADC0CF, #0B9h ; ADC clock 2MHz, PGA gain 1 -ENDIF - mov ADC0MX, #10h ; Select temp sensor input - mov ADC0CN0, #80h ; ADC enabled - mov ADC0CN1, #01h ; Common mode buffer enabled -ENDM -Start_Adc MACRO - mov ADC0CN0, #90h ; ADC start -ENDM -Read_Adc_Result MACRO - mov Temp1, ADC0L - mov Temp2, ADC0H -ENDM -Stop_Adc MACRO -ENDM -Set_RPM_Out MACRO -ENDM -Clear_RPM_Out MACRO -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