Fork from bluejay at github and modified for my custom ESC. I need to modify it because some mistake design on my ESC hardware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

186 lines
3.6 KiB

;**** **** **** **** ****
;
; Bluejay digital ESC firmware for controlling brushless motors in multirotors
;
; Copyright 2020, 2021 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
COM_ACTIVE_HIGH EQU 1 ; Damping inverted
COMPARATOR_PORT EQU 1 ; All comparator (mux) pins must be on the same port
IF DEADTIME == 0
PCA0CPM_POWER EQU PCA0CPM0
PCA0CPL_POWER EQU PCA0CPL0
PCA0CPH_POWER EQU PCA0CPH0
PCA0CPM_DAMP EQU PCA0CPM1
PCA0CPL_DAMP EQU PCA0CPL1
PCA0CPH_DAMP EQU PCA0CPH1
ELSE
PCA0CPM_POWER EQU PCA0CPM0
PCA0CPL_POWER EQU PCA0CPL0
PCA0CPH_POWER EQU PCA0CPH0
PCA0CPM_DAMP EQU PCA0CPM1
PCA0CPL_DAMP EQU PCA0CPL1
PCA0CPH_DAMP EQU PCA0CPH1
ENDIF
;*********************
; 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
RTX_PIN EQU 1
; EQU 0
P0_DIGITAL EQU 0FFh
P0_INIT EQU (1 SHL RTX_PIN)
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 (1 SHL DebugPin)
;**** **** **** **** ****
; PWM Phase
;**** **** **** **** ****
P_A_Pwm EQU P0.A_Pwm
P_A_Com EQU P1.A_Com
P_B_Pwm EQU P0.B_Pwm
P_B_Com EQU P1.B_Com
P_C_Pwm EQU P0.C_Pwm
P_C_Com EQU P1.C_Com
Set_Pwm_Phase_A MACRO
IF DEADTIME == 0
cON P_A_Com
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_Phase_B MACRO
IF DEADTIME == 0
cON P_B_Com
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_Phase_C MACRO
IF DEADTIME == 0
cON P_C_Com
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_All_Pwm_Phases_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)