example_280x_lcd.c
来自「DSP2808例程。TMS320F2808DSP的各个模块的应用例程」· C语言 代码 · 共 202 行
C
202 行
// 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 V1.30 $
// $Release Date: February 10, 2006 $
//###########################################################################
#include "DSP280x_Device.h" // DSP280x Headerfile Include File
#include "DSP280x_Examples.h" // DSP280x Examples Include File
const unsigned char strReadPara[] = {" www.51usb.com "};
// Select the example to compile in. Only one example should be set as 1
// the rest should be set as 0.
// Prototype statements for functions found within this file.
void InitGpio(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();
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP280x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
// Step 5. User specific code:
InitGpio();
LCDInit();
LCDClear();
DispOneByte(0, 0, 0x9);
DispString(0, 0, strReadPara);
for(;;)
{
DispString(0, 0, strReadPara);
DispString(1, 0, strReadPara);
}
}
void InitGpio(void)
{
EALLOW;
// 使能上拉或关闭上拉.
GpioCtrlRegs.GPAPUD.all = 0x0000; // 使能上拉 GPIO0-GPIO31
GpioCtrlRegs.GPBPUD.all = 0x0000; // 使能上拉 enabled GPIO32-GPIO34
//GpioCtrlRegs.GPAPUD.all = 0xFFFF; // Pullup's disabled GPIO0-GPIO31
//GpioCtrlRegs.GPBPUD.all = 0xFFFF; // Pullup's disabled GPIO32-GPIO34
GpioCtrlRegs.GPBPUD.bit.GPIO34 = 0; // Enable pullup on GPIO34
//初始化GPIO00-GPIO11为输出,输出高电平
//GpioDataRegs.GPASET.all = 0x0FFF;
///*
GpioDataRegs.GPASET.bit.GPIO0 = 1;
GpioDataRegs.GPASET.bit.GPIO1 = 1;
GpioDataRegs.GPASET.bit.GPIO2 = 1;
GpioDataRegs.GPASET.bit.GPIO3 = 1;
GpioDataRegs.GPASET.bit.GPIO4 = 1;
GpioDataRegs.GPASET.bit.GPIO5 = 1;
GpioDataRegs.GPASET.bit.GPIO6 = 1;
GpioDataRegs.GPASET.bit.GPIO7 = 1;
GpioDataRegs.GPASET.bit.GPIO8 = 1;
GpioDataRegs.GPASET.bit.GPIO9 = 1;
GpioDataRegs.GPASET.bit.GPIO10 = 1;
GpioDataRegs.GPASET.bit.GPIO11 = 1;
GpioDataRegs.GPASET.bit.GPIO12 = 1;
GpioDataRegs.GPASET.bit.GPIO13 = 1;
GpioDataRegs.GPBSET.bit.GPIO34 = 1;
//*/
//GpioCtrlRegs.GPAMUX1.all = 0xF000;
///*
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // GPIO2 = GPIO2
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; // GPIO3 = GPIO3
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0; // GPIO4 = GPIO4
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 0; // GPIO5 = GPIO5
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // GPIO6 = GPIO6
GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 0; // GPIO7 = GPIO7
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0; // GPIO8 = GPIO8
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0; // GPIO9 = GPIO9
GpioCtrlRegs.GPAMUX1.bit.GPIO10= 0; // GPIO10 = GPIO10
GpioCtrlRegs.GPAMUX1.bit.GPIO11= 0; // GPIO11 = GPIO11
GpioCtrlRegs.GPAMUX1.bit.GPIO12= 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO13= 0;
GpioCtrlRegs.GPBMUX1.bit.GPIO34= 0;
//*/
//GpioCtrlRegs.GPADIR.all = 0x0FFF;
///*
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // GPIO0 = output
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; // GPIO1 = output
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; // GPIO2 = output
GpioCtrlRegs.GPADIR.bit.GPIO3 = 1; // GPIO3 = output
GpioCtrlRegs.GPADIR.bit.GPIO4 = 1; // GPIO4 = output
GpioCtrlRegs.GPADIR.bit.GPIO5 = 1; // GPIO5 = output
GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // GPIO6 = output
GpioCtrlRegs.GPADIR.bit.GPIO7 = 1; // GPIO7 = output
GpioCtrlRegs.GPADIR.bit.GPIO8 = 1; // GPIO8 = output
GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // GPIO9 = output
GpioCtrlRegs.GPADIR.bit.GPIO10= 1; // GPIO10= output
GpioCtrlRegs.GPADIR.bit.GPIO11= 1; // GPIO11= output
GpioCtrlRegs.GPADIR.bit.GPIO12= 1;
GpioCtrlRegs.GPADIR.bit.GPIO13= 1;
GpioCtrlRegs.GPBDIR.bit.GPIO34= 1;
//*/
EDIS;
}
//===========================================================================
// No more.
//===========================================================================
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?