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.

154 lines
3.3 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 "V"
  26. ; Cc X RC X MC CC MB MA X Ap Ac Bp X X Bc Cp
  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. C_Com EQU 7
  51. ; EQU 6
  52. RTX_PIN EQU 5
  53. ; EQU 4
  54. C_Mux EQU 3
  55. V_Mux EQU 2
  56. B_Mux EQU 1
  57. A_Mux 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 NOT(1 SHL C_Com)
  60. P0_PUSHPULL EQU (1 SHL C_Com)
  61. P0_SKIP EQU 0FFh
  62. ;*********************
  63. ; PORT 1 definitions *
  64. ;*********************
  65. ; EQU 7
  66. A_Pwm EQU 6
  67. A_Com EQU 5
  68. B_Pwm EQU 4
  69. ; EQU 3
  70. ; EQU 2
  71. B_Com EQU 1
  72. C_Pwm EQU 0
  73. P1_DIGITAL EQU (1 SHL A_Pwm) + (1 SHL B_Pwm) + (1 SHL C_Pwm) + (1 SHL A_Com) + (1 SHL B_Com)
  74. P1_INIT EQU 00h
  75. P1_PUSHPULL EQU (1 SHL A_Pwm) + (1 SHL B_Pwm) + (1 SHL C_Pwm) + (1 SHL A_Com) + (1 SHL B_Com)
  76. P1_SKIP EQU 0FFh
  77. ;*********************
  78. ; PORT 2 definitions *
  79. ;*********************
  80. DebugPin EQU 0
  81. P2_DIGITAL EQU (1 SHL DebugPin)
  82. P2_PUSHPULL EQU (1 SHL DebugPin)
  83. P2_SKIP EQU (1 SHL DebugPin)
  84. ;**** **** **** **** ****
  85. ; PWM Phase
  86. ;**** **** **** **** ****
  87. P_A_Pwm EQU P1.A_Pwm
  88. P_A_Com EQU P1.A_Com
  89. P_B_Pwm EQU P1.B_Pwm
  90. P_B_Com EQU P1.B_Com
  91. P_C_Pwm EQU P1.C_Pwm
  92. P_C_Com EQU P0.C_Com
  93. Set_Pwm_Phase_A MACRO
  94. IF DEADTIME == 0
  95. cON P_A_Com
  96. mov P0SKIP, #0FFh
  97. mov P1SKIP, #(NOT (1 SHL A_Pwm))
  98. ELSE
  99. mov P0SKIP, #0FFh
  100. mov P1SKIP, #(NOT ((1 SHL A_Pwm) + (1 SHL A_Com)))
  101. ENDIF
  102. ENDM
  103. Set_Pwm_Phase_B MACRO
  104. IF DEADTIME == 0
  105. cON P_B_Com
  106. mov P0SKIP, #0FFh
  107. mov P1SKIP, #(NOT (1 SHL B_Pwm))
  108. ELSE
  109. mov P0SKIP, #0FFh
  110. mov P1SKIP, #(NOT ((1 SHL B_Pwm) + (1 SHL B_Com)))
  111. ENDIF
  112. ENDM
  113. Set_Pwm_Phase_C MACRO
  114. IF DEADTIME == 0
  115. cON P_C_Com
  116. mov P0SKIP, #0FFh
  117. mov P1SKIP, #(NOT (1 SHL C_Pwm))
  118. ELSE
  119. mov P0SKIP, #(NOT (1 SHL C_Com))
  120. mov P1SKIP, #(NOT (1 SHL C_Pwm))
  121. ENDIF
  122. ENDM
  123. Set_All_Pwm_Phases_Off MACRO
  124. mov P0SKIP, #0FFh
  125. mov P1SKIP, #0FFh
  126. ENDM
  127. ;**** **** **** **** ****
  128. ; Inherit base layout
  129. ;**** **** **** **** ****
  130. $set(CUSTOM_PWM_PHASE)
  131. $include (Base.inc)