DSP2803x_EQep.c 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //###########################################################################
  2. //
  3. // FILE: DSP2803x_EQep.c
  4. //
  5. // TITLE: DSP2803x eQEP 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. // InitEQep:
  17. //---------------------------------------------------------------------------
  18. // This function initializes the eQEP(s) to a known state.
  19. //
  20. void InitEQep(void)
  21. {
  22. // Initialize eQEP1
  23. //tbd...
  24. }
  25. //---------------------------------------------------------------------------
  26. // Example: InitEQepGpio:
  27. //---------------------------------------------------------------------------
  28. // This function initializes GPIO pins to function as eQEP 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 eQEP peripheral
  36. // Only one GPIO pin should be enabled for EQEPxA operation.
  37. // Only one GPIO pin should be enabled for EQEPxB operation.
  38. // Only one GPIO pin should be enabled for EQEPxS operation.
  39. // Only one GPIO pin should be enabled for EQEPxI operation.
  40. // Comment out other unwanted lines.
  41. void InitEQepGpio()
  42. {
  43. #if DSP28_EQEP1
  44. InitEQep1Gpio();
  45. #endif // endif DSP28_EQEP1
  46. }
  47. #if DSP28_EQEP1
  48. void InitEQep1Gpio(void)
  49. {
  50. EALLOW;
  51. /* Enable internal pull-up for the selected pins */
  52. // Pull-ups can be enabled or disabled by the user.
  53. // This will enable the pullups for the specified pins.
  54. // Comment out other unwanted lines.
  55. GpioCtrlRegs.GPAPUD.bit.GPIO20 = 0; // Enable pull-up on GPIO20 (EQEP1A)
  56. GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0; // Enable pull-up on GPIO21 (EQEP1B)
  57. GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0; // Enable pull-up on GPIO22 (EQEP1S)
  58. GpioCtrlRegs.GPAPUD.bit.GPIO23 = 0; // Enable pull-up on GPIO23 (EQEP1I)
  59. // Inputs are synchronized to SYSCLKOUT by default.
  60. // Comment out other unwanted lines.
  61. GpioCtrlRegs.GPAQSEL2.bit.GPIO20 = 0; // Sync to SYSCLKOUT GPIO20 (EQEP1A)
  62. GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 0; // Sync to SYSCLKOUT GPIO21 (EQEP1B)
  63. GpioCtrlRegs.GPAQSEL2.bit.GPIO22 = 0; // Sync to SYSCLKOUT GPIO22 (EQEP1S)
  64. GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0; // Sync to SYSCLKOUT GPIO23 (EQEP1I)
  65. /* Configure eQEP-1 pins using GPIO regs*/
  66. // This specifies which of the possible GPIO pins will be eQEP1 functional pins.
  67. // Comment out other unwanted lines.
  68. GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1; // Configure GPIO20 as EQEP1A
  69. GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 1; // Configure GPIO21 as EQEP1B
  70. GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 1; // Configure GPIO22 as EQEP1S
  71. GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 1; // Configure GPIO23 as EQEP1I
  72. EDIS;
  73. }
  74. #endif // if DSP28_EQEP1
  75. //===========================================================================
  76. // End of file.
  77. //===========================================================================