不知道我的这个程序为啥不对,只能控制哪个灯亮,不可以输出数字
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
//宏定义//
#define LED1_ON GpioDataRegs.GPBSET.bit.GPIO58=1;
#define LED1_OFF GpioDataRegs.GPBCLEAR.bit.GPIO58=1;
//变量定义//
unsigned char msg[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
Uint16 number=0;
//函数声明//
void Spi_Init_Led(void);
void Spi_Init(void);
void Spi_Init_FIFO(void);
void Spi_mixt(Uint16 ch);
void Spi_Init_Led(void)
{
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO58=0;
GpioDataRegs.GPBSET.bit.GPIO58=1;
GpioCtrlRegs.GPBMUX2.bit.GPIO58=0;
GpioCtrlRegs.GPBDIR.bit.GPIO58=1;
EDIS;
LED1_OFF;
}
void Sellect_bit(Uint16 i)
{
switch(i)
{
case 1:
LED1_ON;
break;
default:
break;
}
}
void delay(Uint32 t)
{
Uint32 i=0;
for(i=0;i<t;i++)
{}
}
void Spi_Init(void)
{
SpiaRegs.SPICCR.all=0x004F;
SpiaRegs.SPICTL.all=0x0006;
SpiaRegs.SPIBRR=0x007F;
SpiaRegs.SPICCR.all=0x00DF;
SpiaRegs.SPIPRI.bit.FREE=1;
}
void Spi_Init_FIFO(void)
{
SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0x204f;
SpiaRegs.SPIFFCT.all=0x0;
}
void Spi_mixt(Uint16 ch)
{
SpiaRegs.SPITXBUF=ch;
}
void main()
{
InitSysCtrl();
InitPieCtrl();
InitPieVectTable();
IER=0x0000;
IFR=0x0000;
DINT;
Spi_Init_Led();
Spi_Init();
Spi_Init_FIFO();
for(;;)
{
Sellect_bit(1);
Spi_mixt(msg[number]);
delay(30000);
number++;
if(number>9)
number=0;
}
}
|