F2837xD_ECap.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //###########################################################################
  2. //
  3. // FILE: F2837xD_ECap.c
  4. //
  5. // TITLE: F2837xD eCAP Initialization & Support Functions.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2837xD Support Library v3.05.00.00 $
  9. // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
  10. // $Copyright:
  11. // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
  12. //
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions
  15. // are met:
  16. //
  17. // Redistributions of source code must retain the above copyright
  18. // notice, this list of conditions and the following disclaimer.
  19. //
  20. // Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the
  23. // distribution.
  24. //
  25. // Neither the name of Texas Instruments Incorporated nor the names of
  26. // its contributors may be used to endorse or promote products derived
  27. // from this software without specific prior written permission.
  28. //
  29. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. // $
  41. //###########################################################################
  42. //
  43. // Included Files
  44. //
  45. #include "F2837xD_device.h"
  46. #include "F2837xD_Examples.h"
  47. //
  48. // InitECap - This function initializes the eCAP(s) to a known state.
  49. //
  50. void InitECap(void)
  51. {
  52. // Initialize eCAP1/2/3/4/5/6
  53. //tbd...
  54. }
  55. //
  56. // InitECapGpio - This function initializes GPIO pins to function as ECAP pins
  57. // Each GPIO pin can be configured as a GPIO pin or up to 3
  58. // different peripheral functional pins. By default all pins
  59. // come up as GPIO inputs after reset.
  60. // Caution:
  61. // For each eCAP peripheral
  62. // Only one GPIO pin should be enabled for ECAP operation.
  63. // Comment out other unwanted lines.
  64. //
  65. void InitECapGpio()
  66. {
  67. }
  68. //
  69. // InitECap1Gpio - Initialize ECAP1 GPIOs
  70. //
  71. void InitECap1Gpio(Uint16 pin)
  72. {
  73. EALLOW;
  74. InputXbarRegs.INPUT7SELECT = pin; // Set eCAP1 source to GPIO-pin
  75. EDIS;
  76. }
  77. //
  78. // InitECap2Gpio - Initialize ECAP2 GPIOs
  79. //
  80. void InitECap2Gpio(Uint16 pin)
  81. {
  82. EALLOW;
  83. InputXbarRegs.INPUT8SELECT = pin; // Set eCAP2 source to GPIO-pin
  84. EDIS;
  85. }
  86. //
  87. // InitECap3Gpio - Initialize ECAP3 GPIOs
  88. //
  89. void InitECap3Gpio(Uint16 pin)
  90. {
  91. EALLOW;
  92. InputXbarRegs.INPUT9SELECT = pin; // Set eCAP3 source to GPIO-pin
  93. EDIS;
  94. }
  95. //
  96. // InitECap4Gpio - Initialize ECAP4 GPIOs
  97. //
  98. void InitECap4Gpio(Uint16 pin)
  99. {
  100. EALLOW;
  101. InputXbarRegs.INPUT10SELECT = pin; // Set eCAP4 source to GPIO-pin
  102. EDIS;
  103. }
  104. //
  105. // InitECap5Gpio - Initialize ECAP5 GPIOs
  106. //
  107. void InitECap5Gpio(Uint16 pin)
  108. {
  109. EALLOW;
  110. InputXbarRegs.INPUT11SELECT = pin; // Set eCAP5 source to GPIO-pin
  111. EDIS;
  112. }
  113. //
  114. // InitECap6Gpio - Initialize ECAP6 GPIOs
  115. //
  116. void InitECap6Gpio(Uint16 pin)
  117. {
  118. EALLOW;
  119. InputXbarRegs.INPUT12SELECT = pin; // Set eCAP6 source to GPIO-pin
  120. EDIS;
  121. }
  122. //
  123. // InitAPwm1Gpio - Initialize EPWM1 GPIOs
  124. //
  125. void InitAPwm1Gpio()
  126. {
  127. EALLOW;
  128. OutputXbarRegs.OUTPUT3MUX0TO15CFG.bit.MUX0 = 3; // Select ECAP1.OUT on Mux0
  129. OutputXbarRegs.OUTPUT3MUXENABLE.bit.MUX0 = 1; // Enable MUX0 for ECAP1.OUT
  130. GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 3; // Select OUTPUTXBAR3 on GPIO5
  131. EDIS;
  132. }
  133. //
  134. // End of file
  135. //