// TI File $Revision: /main/4 $
// Checkin $Date: September 7, 2005 17:52:52 $
//###########################################################################
//
// FILE: Example_280xGpioSetup.c
//
// TITLE: DSP280x Device GPIO Setup
//
// ASSUMPTIONS:
//
// This program requires the DSP280x header files.
//
// Two different examples are included. Select the example
// to execute before compiling using the #define statements
// found at the top of the code.
//
// As supplied, this project is configured for "boot to SARAM"
// operation. The 280x Boot Mode table is shown below.
// For information on configuring the boot mode of an eZdsp,
// please refer to the documentation included with the eZdsp,
//
// Boot GPIO18 GPIO29 GPIO34
// Mode SPICLKA SCITXDA
// SCITXB
// -------------------------------------
// Flash 1 1 1
// SCI-A 1 1 0
// SPI-A 1 0 1
// I2C-A 1 0 0
// ECAN-A 0 1 1
// SARAM 0 1 0 <- "boot to SARAM"
// OTP 0 0 1
// I/0 0 0 0
//
//
// DESCRIPTION:
//
//
// Configures the 280x GPIO into two different configurations
// This code is verbose to illustrate how the GPIO could be setup.
// In a real application, lines of code can be combined for improved
// code size and efficency.
//
// This example only sets-up the GPIO.. nothing is actually done with
// the pins after setup.
//
// In general:
//
// All pullup resistors are enabled. For ePWMs this may not be desired.
// Input qual for communication ports (eCAN, SPI, SCI, I2C) is asynchronous
// Input qual for Trip pins (TZ) is asynchronous
// Input qual for eCAP and eQEP signals is synch to SYSCLKOUT
// Input qual for some I/O's and interrupts may have a sampling window
//
//
//###########################################################################
// $TI Release: DSP280x C/C++ Header Files V1.70 $
// $Release Date: July 27, 2009 $
//###########################################################################
#include "DSP280x_Device.h" // DSP280x Headerfile Include File
#include "DSP280x_Examples.h" // DSP280x Examples Include File
void Initgpio_out(void);
void Delay(void);
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP280x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP280x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); Skipped for this example
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP280x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP280x_DefaultIsr.c.
// This function is found in DSP280x_PieVect.c.
InitPieVectTable();
Initgpio_out();
while(1)
{
GpioDataRegs.GPATOGGLE.bit.GPIO0=1;
GpioDataRegs.GPATOGGLE.bit.GPIO1=1;
GpioDataRegs.GPATOGGLE.bit.GPIO2=1;
GpioDataRegs.GPATOGGLE.bit.GPIO3=1;
GpioDataRegs.GPATOGGLE.bit.GPIO4=1;
GpioDataRegs.GPATOGGLE.bit.GPIO5=1;
GpioDataRegs.GPATOGGLE.bit.GPIO6=1;
GpioDataRegs.GPATOGGLE.bit.GPIO7=1;
GpioDataRegs.GPATOGGLE.bit.GPIO8=1;
GpioDataRegs.GPATOGGLE.bit.GPIO9=1;
GpioDataRegs.GPATOGGLE.bit.GPIO10=1;
GpioDataRegs.GPATOGGLE.bit.GPIO11=1;
GpioDataRegs.GPATOGGLE.bit.GPIO29=1;
GpioDataRegs.GPATOGGLE.bit.GPIO31=1;
GpioDataRegs.GPBTOGGLE.bit.GPIO32=1;
GpioDataRegs.GPBTOGGLE.bit.GPIO33=1;
GpioDataRegs.GPBTOGGLE.bit.GPIO34=1;
Delay();
}
}
void Initgpio_out(void)
{
EALLOW;
GpioCtrlRegs.GPAPUD.all=0x00000000;
GpioCtrlRegs.GPBPUD.bit.GPIO32=0;
GpioCtrlRegs.GPBPUD.bit.GPIO33=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO0=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO1=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO2=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO3=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO4=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO5=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO6=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO7=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO8=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO9=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO10=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO11=0;
GpioCtrlRegs.GPAMUX2.bit.GPIO29=0;
GpioCtrlRegs.GPAMUX2.bit.GPIO31=0;
GpioCtrlRegs.GPBMUX1.bit.GPIO32=0;
GpioCtrlRegs.GPBMUX1.bit.GPIO33=0;
GpioCtrlRegs.GPBMUX1.bit.GPIO34=0;
GpioCtrlRegs.GPADIR.bit.GPIO0=1;
GpioCtrlRegs.GPADIR.bit.GPIO1=1;
GpioCtrlRegs.GPADIR.bit.GPIO2=1;
GpioCtrlRegs.GPADIR.bit.GPIO3=1;
GpioCtrlRegs.GPADIR.bit.GPIO4=1;
GpioCtrlRegs.GPADIR.bit.GPIO5=1;
GpioCtrlRegs.GPADIR.bit.GPIO6=1;
GpioCtrlRegs.GPADIR.bit.GPIO7=1;
GpioCtrlRegs.GPADIR.bit.GPIO8=1;
GpioCtrlRegs.GPADIR.bit.GPIO9=1;
GpioCtrlRegs.GPADIR.bit.GPIO10=1;
GpioCtrlRegs.GPADIR.bit.GPIO11=1;
GpioCtrlRegs.GPADIR.bit.GPIO29=1;
GpioCtrlRegs.GPADIR.bit.GPIO31=1;
GpioCtrlRegs.GPBDIR.bit.GPIO32=1;
GpioCtrlRegs.GPBDIR.bit.GPIO33=1;
GpioCtrlRegs.GPBDIR.bit.GPIO34=1;
EDIS;
}
void Delay(void)
{
short i;
for(i=0;i<4000;i++){}
}
//===========================================================================
// No more.
//===========================================================================
评论0