1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //###########################################################################
- //
- // FILE: DSP2803x_EQep.c
- //
- // TITLE: DSP2803x eQEP Initialization & Support Functions.
- //
- //###########################################################################
- // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V130 $
- // $Release Date: May 8, 2015 $
- // $Copyright: Copyright (C) 2009-2015 Texas Instruments Incorporated -
- // http://www.ti.com/ ALL RIGHTS RESERVED $
- //###########################################################################
- #include "DSP2803x_Device.h" // DSP2803x Headerfile Include File
- #include "DSP2803x_Examples.h" // DSP2803x Examples Include File
- //---------------------------------------------------------------------------
- // InitEQep:
- //---------------------------------------------------------------------------
- // This function initializes the eQEP(s) to a known state.
- //
- void InitEQep(void)
- {
- // Initialize eQEP1
- //tbd...
- }
- //---------------------------------------------------------------------------
- // Example: InitEQepGpio:
- //---------------------------------------------------------------------------
- // This function initializes GPIO pins to function as eQEP pins
- //
- // Each GPIO pin can be configured as a GPIO pin or up to 3 different
- // peripheral functional pins. By default all pins come up as GPIO
- // inputs after reset.
- //
- // Caution:
- // For each eQEP peripheral
- // Only one GPIO pin should be enabled for EQEPxA operation.
- // Only one GPIO pin should be enabled for EQEPxB operation.
- // Only one GPIO pin should be enabled for EQEPxS operation.
- // Only one GPIO pin should be enabled for EQEPxI operation.
- // Comment out other unwanted lines.
- void InitEQepGpio()
- {
- #if DSP28_EQEP1
- InitEQep1Gpio();
- #endif // endif DSP28_EQEP1
- }
- #if DSP28_EQEP1
- void InitEQep1Gpio(void)
- {
- EALLOW;
- /* Enable internal pull-up for the selected pins */
- // Pull-ups can be enabled or disabled by the user.
- // This will enable the pullups for the specified pins.
- // Comment out other unwanted lines.
- GpioCtrlRegs.GPAPUD.bit.GPIO20 = 0; // Enable pull-up on GPIO20 (EQEP1A)
- GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0; // Enable pull-up on GPIO21 (EQEP1B)
- GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0; // Enable pull-up on GPIO22 (EQEP1S)
- GpioCtrlRegs.GPAPUD.bit.GPIO23 = 0; // Enable pull-up on GPIO23 (EQEP1I)
- // Inputs are synchronized to SYSCLKOUT by default.
- // Comment out other unwanted lines.
- GpioCtrlRegs.GPAQSEL2.bit.GPIO20 = 0; // Sync to SYSCLKOUT GPIO20 (EQEP1A)
- GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 0; // Sync to SYSCLKOUT GPIO21 (EQEP1B)
- GpioCtrlRegs.GPAQSEL2.bit.GPIO22 = 0; // Sync to SYSCLKOUT GPIO22 (EQEP1S)
- GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0; // Sync to SYSCLKOUT GPIO23 (EQEP1I)
- /* Configure eQEP-1 pins using GPIO regs*/
- // This specifies which of the possible GPIO pins will be eQEP1 functional pins.
- // Comment out other unwanted lines.
- GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1; // Configure GPIO20 as EQEP1A
- GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 1; // Configure GPIO21 as EQEP1B
- GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 1; // Configure GPIO22 as EQEP1S
- GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 1; // Configure GPIO23 as EQEP1I
- EDIS;
- }
- #endif // if DSP28_EQEP1
- //===========================================================================
- // End of file.
- //===========================================================================
|