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.

155 lines
3.3 KiB

  1. ;**** **** **** **** ****
  2. ;
  3. ; Bluejay digital ESC firmware for controlling brushless motors in multirotors
  4. ;
  5. ; Copyright 2020 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. COMPWM_ACTIVE_HIGH EQU 1 ; Damping inverted
  31. ; Note: currently all comparator pins (Comp_ and Mux_) must be on the same port
  32. COMP_PORT EQU 0
  33. ;*********************
  34. ; PORT 0 definitions *
  35. ;*********************
  36. C_com EQU 7 ;o
  37. ; EQU 6 ;i
  38. Rcp_In EQU 5 ;i
  39. ; EQU 4 ;i
  40. C_Mux EQU 3 ;i
  41. Comp_Com EQU 2 ;i
  42. B_Mux EQU 1 ;i
  43. A_Mux EQU 0 ;i
  44. P0_DIGITAL EQU NOT((1 SHL A_Mux) + (1 SHL B_Mux) + (1 SHL C_Mux) + (1 SHL Comp_Com))
  45. P0_INIT EQU NOT(1 SHL C_com)
  46. P0_PUSHPULL EQU (1 SHL C_com)
  47. P0_SKIP EQU 0FFh
  48. IF FETON_DELAY == 0
  49. PCA0_POWER_MODULE EQU PCA0CPM0
  50. PCA0_POWER_L EQU PCA0CPL0
  51. PCA0_POWER_H EQU PCA0CPH0
  52. PCA0_DAMP_MODULE EQU PCA0CPM1
  53. PCA0_DAMP_L EQU PCA0CPL1
  54. PCA0_DAMP_H EQU PCA0CPH1
  55. ELSE
  56. PCA0_POWER_MODULE EQU PCA0CPM1
  57. PCA0_POWER_L EQU PCA0CPL1
  58. PCA0_POWER_H EQU PCA0CPH1
  59. PCA0_DAMP_MODULE EQU PCA0CPM0
  60. PCA0_DAMP_L EQU PCA0CPL0
  61. PCA0_DAMP_H EQU PCA0CPH0
  62. ENDIF
  63. ;*********************
  64. ; PORT 1 definitions *
  65. ;*********************
  66. ; EQU 7 ;i
  67. A_pwm EQU 6 ;i
  68. A_com EQU 5 ;i
  69. B_pwm EQU 4 ;o
  70. ; EQU 3 ;o
  71. ; EQU 2 ;o
  72. B_com EQU 1 ;o
  73. C_pwm EQU 0 ;o
  74. P_ApwmFET EQU P1.A_pwm
  75. P_AcomFET EQU P1.A_com
  76. P_BpwmFET EQU P1.B_pwm
  77. P_BcomFET EQU P1.B_com
  78. P_CpwmFET EQU P1.C_pwm
  79. P_CcomFET EQU P0.C_com
  80. P1_DIGITAL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) + (1 SHL B_com)
  81. P1_INIT EQU 00h
  82. P1_PUSHPULL EQU (1 SHL A_pwm) + (1 SHL B_pwm) + (1 SHL C_pwm) + (1 SHL A_com) + (1 SHL B_com)
  83. P1_SKIP EQU 0FFh
  84. Set_Pwm_A MACRO
  85. IF FETON_DELAY == 0
  86. cON P_AcomFET
  87. mov P0SKIP, #0FFh
  88. mov P1SKIP, #(NOT (1 SHL A_pwm))
  89. ELSE
  90. mov P0SKIP, #0FFh
  91. mov P1SKIP, #(NOT ((1 SHL A_pwm) + (1 SHL A_com)))
  92. ENDIF
  93. ENDM
  94. Set_Pwm_B MACRO
  95. IF FETON_DELAY == 0
  96. cON P_BcomFET
  97. mov P0SKIP, #0FFh
  98. mov P1SKIP, #(NOT (1 SHL B_pwm))
  99. ELSE
  100. mov P0SKIP, #0FFh
  101. mov P1SKIP, #(NOT ((1 SHL B_pwm) + (1 SHL B_com)))
  102. ENDIF
  103. ENDM
  104. Set_Pwm_C MACRO
  105. IF FETON_DELAY == 0
  106. cON P_CcomFET
  107. mov P0SKIP, #0FFh
  108. mov P1SKIP, #(NOT (1 SHL C_pwm))
  109. ELSE
  110. mov P0SKIP, #(NOT (1 SHL C_com))
  111. mov P1SKIP, #(NOT (1 SHL C_pwm))
  112. ENDIF
  113. ENDM
  114. Set_Pwms_Off MACRO
  115. mov P0SKIP, #0FFh
  116. mov P1SKIP, #0FFh
  117. ENDM
  118. ;*********************
  119. ; PORT 2 definitions *
  120. ;*********************
  121. DebugPin EQU 0 ;o
  122. P2_DIGITAL EQU (1 SHL DebugPin)
  123. P2_PUSHPULL EQU (1 SHL DebugPin)
  124. P2_SKIP EQU 0FFh
  125. ;**** **** **** **** ****
  126. ; Inherit base layout
  127. ;**** **** **** **** ****
  128. $set(CUSTOM_PWM_PHASE)
  129. $include (Base.inc)