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.

188 lines
4.6 KiB

  1. ;**** **** **** **** ****
  2. ;
  3. ; Bluejay digital ESC firmware for controlling brushless motors in multirotors
  4. ;
  5. ; Copyright 2020, 2021 Mathias Rasmussen
  6. ; Copyright 2011, 2012 Steffen Skaug
  7. ;
  8. ; This file is part of Bluejay.
  9. ;
  10. ; Bluejay is free software: you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation, either version 3 of the License, or
  13. ; (at your option) any later version.
  14. ;
  15. ; Bluejay is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ; GNU General Public License for more details.
  19. ;
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with Bluejay. If not, see <http://www.gnu.org/licenses/>.
  22. ;
  23. ;**** **** **** **** ****
  24. ;
  25. ; Hardware definition file "W". This is for tristate input style FET driver chips
  26. ; RC MC MB X CC MA X X X Ap Bp Cp X X X X
  27. ;
  28. ;**** **** **** **** ****
  29. PWM_ACTIVE_HIGH EQU 1 ; Pwm non-inverted
  30. COM_ACTIVE_HIGH EQU 1 ; Damping inverted
  31. COMPARATOR_PORT EQU 0 ; All comparator (mux) pins must be on the same port
  32. IF DEADTIME == 0
  33. PCA0CPM_POWER EQU PCA0CPM0
  34. PCA0CPL_POWER EQU PCA0CPL0
  35. PCA0CPH_POWER EQU PCA0CPH0
  36. PCA0CPM_DAMP EQU PCA0CPM1
  37. PCA0CPL_DAMP EQU PCA0CPL1
  38. PCA0CPH_DAMP EQU PCA0CPH1
  39. ELSE
  40. PCA0CPM_POWER EQU PCA0CPM1
  41. PCA0CPL_POWER EQU PCA0CPL1
  42. PCA0CPH_POWER EQU PCA0CPH1
  43. PCA0CPM_DAMP EQU PCA0CPM0
  44. PCA0CPL_DAMP EQU PCA0CPL0
  45. PCA0CPH_DAMP EQU PCA0CPH0
  46. ENDIF
  47. ;*********************
  48. ; PORT 0 definitions *
  49. ;*********************
  50. RTX_PIN EQU 7
  51. C_Mux EQU 6
  52. B_Mux EQU 5
  53. ; EQU 4
  54. V_Mux EQU 3
  55. A_Mux EQU 2
  56. ; EQU 1
  57. ; EQU 0
  58. P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL V_Mux))
  59. P0_INIT EQU 0FFh
  60. P0_PUSHPULL EQU 0
  61. P0_SKIP EQU 0FFh
  62. ;*********************
  63. ; PORT 1 definitions *
  64. ;*********************
  65. ; EQU 7
  66. A_Pwm EQU 6
  67. B_Pwm EQU 5
  68. C_Pwm EQU 4
  69. ; EQU 3
  70. ; EQU 2
  71. ; EQU 1
  72. ; EQU 0
  73. ; pwm outputs start as analog in -> floating
  74. ; this ensures all mosfet drivers start with floating outputs
  75. P1_DIGITAL EQU NOT((1 SHL A_Pwm) + (1 SHL B_Pwm) + (1 SHL C_Pwm))
  76. P1_INIT EQU 00h
  77. P1_PUSHPULL EQU ((1 SHL A_Pwm) + (1 SHL B_Pwm) + (1 SHL C_Pwm))
  78. P1_SKIP EQU 0FFh
  79. A_Pwm_Fet_On MACRO
  80. setb P1.A_Pwm ; set pin to high
  81. orl P1MDIN, #(1 SHL A_Pwm) ; enable pin driver
  82. ENDM
  83. A_Pwm_Fet_Off MACRO
  84. anl P1MDIN, #(NOT(1 SHL A_Pwm)) ; analog in -> pullup, driver and digital in is disable = floating
  85. ENDM
  86. B_Pwm_Fet_On MACRO
  87. setb P1.B_Pwm ; set pin to high
  88. orl P1MDIN, #(1 SHL B_Pwm) ; enable pin driver
  89. ENDM
  90. B_Pwm_Fet_Off MACRO
  91. anl P1MDIN, #(NOT(1 SHL B_Pwm)) ; analog in -> pullup, driver and digital in is disable = floating
  92. ENDM
  93. C_Pwm_Fet_On MACRO
  94. setb P1.C_Pwm ; set pin to high
  95. orl P1MDIN, #(1 SHL C_Pwm) ; enable pin driver
  96. ENDM
  97. C_Pwm_Fet_Off MACRO
  98. anl P1MDIN, #(NOT(1 SHL C_Pwm)) ; analog in -> pullup, driver and digital in is disable = floating
  99. ENDM
  100. All_Pwm_Fets_Off MACRO
  101. 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
  102. ENDM
  103. A_Com_Fet_On MACRO
  104. clr P1.A_Pwm ; set pin to low
  105. orl P1MDIN, #(1 SHL A_Pwm) ; enable pin driver
  106. ENDM
  107. A_Com_Fet_Off MACRO
  108. anl P1MDIN, #(NOT(1 SHL A_Pwm)) ; analog in -> pullup, driver and digital in is disable = floating
  109. ENDM
  110. B_Com_Fet_On MACRO
  111. clr P1.B_Pwm ; set pin to low
  112. orl P1MDIN, #(1 SHL B_Pwm) ; enable pin driver
  113. ENDM
  114. B_Com_Fet_Off MACRO
  115. anl P1MDIN, #(NOT(1 SHL B_Pwm)) ; analog in -> pullup, driver and digital in is disable = floating
  116. ENDM
  117. C_Com_Fet_On MACRO
  118. clr P1.C_Pwm ; set pin to low
  119. orl P1MDIN, #(1 SHL C_Pwm) ; enable pin driver
  120. ENDM
  121. C_Com_Fet_Off MACRO
  122. anl P1MDIN, #(NOT(1 SHL C_Pwm)) ; analog in -> pullup, driver and digital in is disable = floating
  123. ENDM
  124. All_Com_Fets_Off MACRO
  125. 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
  126. ENDM
  127. Set_Pwm_Phase_A MACRO
  128. mov P1SKIP, #(NOT(1 SHL A_Pwm));
  129. orl P1MDIN, #(1 SHL A_Pwm) ; enable pin driver
  130. ENDM
  131. Set_Pwm_Phase_B MACRO
  132. mov P1SKIP, #(NOT(1 SHL B_Pwm));
  133. orl P1MDIN, #(1 SHL B_Pwm) ; enable pin driver
  134. ENDM
  135. Set_Pwm_Phase_C MACRO
  136. mov P1SKIP, #(NOT(1 SHL C_Pwm));
  137. orl P1MDIN, #(1 SHL C_Pwm) ; enable pin driver
  138. ENDM
  139. Set_All_Pwm_Phases_Off MACRO
  140. mov P1SKIP, #P1_SKIP;
  141. ENDM
  142. ;*********************
  143. ; PORT 2 definitions *
  144. ;*********************
  145. DebugPin EQU 0
  146. P2_DIGITAL EQU (1 SHL DebugPin)
  147. P2_PUSHPULL EQU (1 SHL DebugPin)
  148. P2_SKIP EQU (1 SHL DebugPin)
  149. ;**** **** **** **** ****
  150. ; Inherit base layout
  151. ;**** **** **** **** ****
  152. $set(CUSTOM_PWM_PHASE, CUSTOM_FET_TOGGLING)
  153. $include (Base.inc)