📄 example_28xgpio.c
字号:
#include "DSP28_Device.h"
#include "DSP28_Globalprototypes.h"
/*---- Flash API include file -------------------------------------------------*/
#include "Flash281x_API_Library.h"
// Prototype statements for functions found within this file.
// interrupt void ISRTimer2(void);
void delay_loop(void);
void Gpio_select(void);
unsigned int var1 = 0;
unsigned int var2 = 0;
unsigned int var3 = 0;
unsigned int var4 = 0;
unsigned int var5 = 0;
void main(void)
{
InitSysCtrl();
// Disable and clear all CPU interrupts:
DINT;
IER = 0x0000;
IFR = 0x0000;
// Initialize Pie Control Registers To Default State:
InitPieCtrl();
InitPieVectTable();
// Run GPIO test
var1= 0x0000; // sets GPIO Muxs as I/Os
var2= 0xFFFF; // sets GPIO DIR as outputs
var3= 0x0000; // sets the Input qualifier values
Gpio_select();
// Toggle I/Os using DATA register for ever
while(1)
{
// GpioDataRegs.GPADAT.all =0xAAAA;
// GpioDataRegs.GPBDAT.all =0xAAAA;
// GpioDataRegs.GPDDAT.all =0x0022;
// GpioDataRegs.GPEDAT.all =0x0002;
GpioDataRegs.GPFDAT.all =0x0000;
// GpioDataRegs.GPGDAT.all =0x0020;
delay_loop();
// GpioDataRegs.GPADAT.all =0x5555;
// GpioDataRegs.GPBDAT.all =0x5555;
// GpioDataRegs.GPDDAT.all =0x0041; // Four I/Os only
// GpioDataRegs.GPEDAT.all =0x0005; // ThreeI/Os only
GpioDataRegs.GPFDAT.all =0x4000;
// GpioDataRegs.GPGDAT.all =0x0010; // Two I/Os only
delay_loop();
}
}
void delay_loop()
{
unsigned int i;
unsigned int j;
for (i = 0; i < 5000; i++) {for (j = 0; j < 2000; j++);}
}
void Gpio_select(void)
{
EALLOW;
//GpioMuxRegs.GPAMUX.all=var1;
//GpioMuxRegs.GPBMUX.all=var1;
//GpioMuxRegs.GPDMUX.all=var1;
GpioMuxRegs.GPFMUX.all=0x0000;
//GpioMuxRegs.GPEMUX.all=var1;
//GpioMuxRegs.GPGMUX.all=var1;
//GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as output
//GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as output
//GpioMuxRegs.GPDDIR.all=var2;
//GpioMuxRegs.GPEDIR.all=var2;
GpioMuxRegs.GPFDIR.all=0x4000;
//GpioMuxRegs.GPGDIR.all=var2;
//GpioMuxRegs.GPAQUAL.all=var3; // Set GPIO input qualifier values
//GpioMuxRegs.GPBQUAL.all=var3;
//GpioMuxRegs.GPDQUAL.all=var3;
//GpioMuxRegs.GPEQUAL.all=var3;
EDIS;
}
//===========================================================================
// No more.
//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -