DSP2803x_Comp.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //###########################################################################
  2. //
  3. // FILE: DSP2803x_Comp.c
  4. //
  5. // TITLE: DSP2803x Comparator Initialization & Support Functions.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V130 $
  9. // $Release Date: May 8, 2015 $
  10. // $Copyright: Copyright (C) 2009-2015 Texas Instruments Incorporated -
  11. // http://www.ti.com/ ALL RIGHTS RESERVED $
  12. //###########################################################################
  13. #include "DSP2803x_Device.h" // DSP2803x Headerfile Include File
  14. #include "DSP2803x_Examples.h" // DSP2803x Examples Include File
  15. //---------------------------------------------------------------------------
  16. // InitComp:
  17. //---------------------------------------------------------------------------
  18. // This function initializes the Comp to a known state.
  19. //
  20. void InitComp(void)
  21. {
  22. // Initialize Comp:
  23. //tbd...
  24. }
  25. //---------------------------------------------------------------------------
  26. // Example: InitCompGpio:
  27. //---------------------------------------------------------------------------
  28. // This function initializes GPIO pins to function as Comp pins
  29. //
  30. // Each GPIO pin can be configured as a GPIO pin or up to 3 different
  31. // peripheral functional pins. By default all pins come up as GPIO
  32. // inputs after reset.
  33. //
  34. // Caution:
  35. // Only one GPIO pin should be enabled for each operation.
  36. // Only one GPIO pin shoudl be enabled for each operation.
  37. // Comment out other unwanted lines.
  38. void InitCompGpio()
  39. {
  40. InitComp1Gpio();
  41. #if DSP28_COMP2
  42. InitComp2Gpio();
  43. #endif
  44. #if DSP28_COMP3
  45. InitComp3Gpio();
  46. #endif
  47. }
  48. void InitComp1Gpio()
  49. {
  50. EALLOW;
  51. /* Disable internal pull-up for the selected output pins
  52. to reduce power consumption */
  53. // Pull-ups can be enabled or disabled disabled by the user.
  54. // Comment out other unwanted lines.
  55. GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // Disable pull-up for GPIO1 (CMP1OUT)
  56. // GpioCtrlRegs.GPAPUD.bit.GPIO20 = 1; // Disable pull-up for GPIO20 (CMP1OUT)
  57. // GpioCtrlRegs.GPBPUD.bit.GPIO42 = 1; // Disable pull-up for GPIO42 (CMP1OUT)
  58. /* Configure Comp pins using GPIO regs*/
  59. // This specifies which of the possible GPIO pins will be Comp functional pins.
  60. // Comment out other unwanted lines.
  61. GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 3; // Configure GPIO1 for CMP1OUT operation
  62. // GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 3; // Configure GPIO20 for CMP1OUT operation
  63. // GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 3; // Configure GPIO42 for CMP1OUT operation
  64. GpioCtrlRegs.AIOMUX1.bit.AIO2 = 2; // Configure AIO2 for CMP1A (analog input) operation
  65. GpioCtrlRegs.AIOMUX1.bit.AIO10 = 2; // Configure AIO10 for CMP1B (analog input) operation
  66. EDIS;
  67. }
  68. #if DSP28_COMP2
  69. void InitComp2Gpio()
  70. {
  71. EALLOW;
  72. /* Disable internal pull-up for the selected output pins
  73. to reduce power consumption */
  74. // Pull-ups can be enabled or disabled disabled by the user.
  75. // Comment out other unwanted lines.
  76. GpioCtrlRegs.GPAPUD.bit.GPIO3 = 1; // Disable pull-up for GPIO3 (CMP2OUT)
  77. GpioCtrlRegs.GPAPUD.bit.GPIO21 = 1; // Disable pull-up for GPIO21 (CMP2OUT)
  78. // GpioCtrlRegs.GPBPUD.bit.GPIO34 = 1; // Disable pull-up for GPIO34 (CMP2OUT)
  79. // GpioCtrlRegs.GPBPUD.bit.GPIO43 = 1; // Disable pull-up for GPIO43 (CMP2OUT)
  80. /* Configure Comp pins using GPIO regs*/
  81. // This specifies which of the possible GPIO pins will be Comp functional pins.
  82. // Comment out other unwanted lines.
  83. GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 3; // Configure GPIO3 for CMP2OUT operation
  84. GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 3; // Configure GPIO21 for CMP2OUT operation
  85. // GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 1; // Configure GPIO34 for CMP2OUT operation
  86. // GpioCtrlRegs.GPBMUX1.bit.GPIO43 = 3; // Configure GPIO43 for CMP2OUT operation
  87. GpioCtrlRegs.AIOMUX1.bit.AIO4 = 2; // Configure AIO4 for CMP2A (analog input) operation
  88. GpioCtrlRegs.AIOMUX1.bit.AIO12 = 2; // Configure AIO12 for CMP2B (analog input) operation
  89. EDIS;
  90. }
  91. #endif //end DSP28_COMP2
  92. #if DSP28_COMP3
  93. void InitComp3Gpio()
  94. {
  95. EALLOW;
  96. /* Disable internal pull-up for the selected output pins
  97. to reduce power consumption */
  98. // Pull-ups can be enabled or disabled disabled by the user.
  99. // Comment out other unwanted lines.
  100. GpioCtrlRegs.GPBPUD.bit.GPIO34 = 1; // Disable pull-up for GPIO34 (CMP3OUT)
  101. /* Configure Comp pins using GPIO regs*/
  102. // This specifies which of the possible GPIO pins will be Comp functional pins.
  103. // Comment out other unwanted lines.
  104. GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 3; // Configure GPIO34 for CMP3OUT operation
  105. GpioCtrlRegs.AIOMUX1.bit.AIO6 = 2; // Configure AIO6 for CMP3A (analog input) operation
  106. GpioCtrlRegs.AIOMUX1.bit.AIO14 = 2; // Configure AIO14 for CMP3B (analog input) operation
  107. EDIS;
  108. }
  109. #endif //end DSP28_COMP3
  110. //===========================================================================
  111. // End of file.
  112. //===========================================================================