Browse Source
chore: Merge pull request #9 from mathiasvr/layouts
chore: Merge pull request #9 from mathiasvr/layouts
Simplify ESC layout configurationmain
Mathias Rasmussen
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 3400 additions and 6791 deletions
-
69Bluejay.asm
-
87Common.inc
-
104Layouts/A.inc
-
104Layouts/B.inc
-
372Layouts/Base.inc
-
155Layouts/C.inc
-
104Layouts/D.inc
-
164Layouts/E.inc
-
104Layouts/F.inc
-
104Layouts/G.inc
-
104Layouts/H.inc
-
106Layouts/I.inc
-
139Layouts/J.inc
-
104Layouts/K.inc
-
104Layouts/L.inc
-
135Layouts/M.inc
-
104Layouts/N.inc
-
114Layouts/O.inc
-
104Layouts/P.inc
-
187Layouts/Q.inc
-
104Layouts/R.inc
-
104Layouts/S.inc
-
104Layouts/T.inc
-
139Layouts/U.inc
-
155Layouts/V.inc
-
189Layouts/W.inc
-
104Layouts/Z.inc
-
4Makefile
-
290targets/A.inc
-
295targets/B.inc
-
297targets/C.inc
-
290targets/D.inc
-
303targets/E.inc
-
290targets/F.inc
-
290targets/G.inc
-
295targets/H.inc
-
289targets/I.inc
-
295targets/J.inc
-
291targets/K.inc
-
289targets/L.inc
-
294targets/M.inc
-
295targets/N.inc
-
291targets/O.inc
-
292targets/P.inc
-
301targets/Q.inc
-
289targets/R.inc
-
294targets/S.inc
-
295targets/T.inc
-
299targets/U.inc
-
301targets/V.inc
-
255targets/W.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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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) |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
|||
|
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
@ -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 <http://www.gnu.org/licenses/>. |
|||
; |
|||
;**** **** **** **** **** |
|||
; |
|||
; 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 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue