DSP2803x_HRCap.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //###########################################################################
  2. //
  3. // FILE: DSP2803x_HRCap.c
  4. //
  5. // TITLE: DSP2803x HRCAP 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. // InitHRCap:
  17. //---------------------------------------------------------------------------
  18. // This function initializes the HRCAP(s) to a known state.
  19. //
  20. void InitHRCap(void)
  21. {
  22. // Initialize HRCAP1, 2...
  23. //tbd...
  24. }
  25. //---------------------------------------------------------------------------
  26. // Example: InitHRCapGpio:
  27. //---------------------------------------------------------------------------
  28. // This function initializes GPIO pins to function as ECAP 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. // For each HRCAP peripheral
  36. // Only one GPIO pin should be enabled for ECAP operation.
  37. // Comment out other unwanted lines.
  38. void InitHRCapGpio()
  39. {
  40. #if DSP28_HRCAP1
  41. InitHRCap1Gpio();
  42. #endif
  43. #if DSP28_HRCAP2
  44. InitHRCap2Gpio();
  45. #endif
  46. }
  47. void InitHRCap1Gpio(void)
  48. {
  49. EALLOW;
  50. /* Enable internal pull-up for the selected pins */
  51. // Pull-ups can be enabled or disabled by the user.
  52. // This will enable the pullups for the specified pins.
  53. // Comment out other unwanted lines.
  54. // GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; // Enable pull-up on GPIO9 (HRCAP1)
  55. GpioCtrlRegs.GPAPUD.bit.GPIO26 = 0; // Enable pull-up on GPIO26 (HRCAP1)
  56. /* Set qualification for selected pins to asynch only */
  57. // This will select asynch (no qualification) for the selected pins.
  58. // Comment out other unwanted lines.
  59. // GpioCtrlRegs.GPAQSEL1.bit.GPIO9 =3; // Asynch to SYSCLKOUT GPIO9 (HRCAP1)
  60. GpioCtrlRegs.GPAQSEL2.bit.GPIO26 = 3; // Asynch to SYSCLKOUT GPIO26 (HRCAP1)
  61. /* Configure HRCAP-1 pins using GPIO regs*/
  62. // This specifies which of the possible GPIO pins will be HRCAP1 functional pins.
  63. // Comment out other unwanted lines.
  64. // GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3; // Configure GPIO9 as HRCAP1
  65. GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 1; // Configure GPIO26 as GRCAP1
  66. EDIS;
  67. }
  68. void InitHRCap2Gpio(void)
  69. {
  70. EALLOW;
  71. /* Enable internal pull-up for the selected pins */
  72. // Pull-ups can be enabled or disabled by the user.
  73. // This will enable the pullups for the specified pins.
  74. // Comment out other unwanted lines.
  75. GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0; // Enable pull-up on GPIO11 (HRCAP2)
  76. // GpioCtrlRegs.GPAPUD.bit.GPIO27 = 0; // Enable pull-up on GPIO27 (HRCAP2)
  77. /* Set qualification for selected pins to asynch only */
  78. // This will select asynch (no qualification) for the selected pins.
  79. // Comment out other unwanted lines.
  80. GpioCtrlRegs.GPAQSEL1.bit.GPIO11 = 3; // Asynch to SYSCLKOUT GPIO11 (HRCAP2)
  81. // GpioCtrlRegs.GPAQSEL2.bit.GPIO27 = 3; // Asynch to SYSCLKOUT GPIO27 (HRCAP2)
  82. /* Configure HRCAP-1 pins using GPIO regs*/
  83. // This specifies which of the possible GPIO pins will be HRCAP1 functional pins.
  84. // Comment out other unwanted lines.
  85. GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 3; // Configure GPIO11 as HRCAP2
  86. // GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 1; // Configure GPIO27 as HRCAP2
  87. EDIS;
  88. }
  89. //===========================================================================
  90. // End of file.
  91. //===========================================================================