⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spi.c

📁 TMS320F2808 DSP芯片的接口控制源码
💻 C
字号:
#include "DSP280x_Device.h"     // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File

// Prototype statements for functions found within this file.
interrupt void cpu_timer2_isr(void);
interrupt void cpu_timer0_isr(void);
const	Uint16	LedCode[]={0xC0C0,0xF9F9,0xA4A4,0xB0B0,0x9999,0x9292,0x8282,0xF8F8,0x8080,0x9090,0x8888,0x8383,0xC6C6,0xA1A1,0x8686,0x8E8E,0xFFFF};
const	Uint16	Light[]  ={0xFEFE,0xFDFD,0xFBFB,0xF7F7,0xEFEF,0xDFDF,0xBFBF,0x7F7F };
void   	SendData(Uint16	num,Uint16	data);
Uint16	LedCount = 0;
Uint16	LedCount1 = 0;
void main(void)
{

    InitSysCtrl();

 	InitGpio();  
	InitSpi();
	SetCs(1);
	SetCs(0);

    DINT;

    InitPieCtrl();
   
   IER = 0x0000;
   IFR = 0x0000;

   InitPieVectTable();

   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.TINT2 = &cpu_timer2_isr;
   PieVectTable.TINT0 = &cpu_timer0_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

   InitCpuTimers();   // For this example, only initialize the Cpu Timers

   ConfigCpuTimer(&CpuTimer2, 200, 100000);
   ConfigCpuTimer(&CpuTimer0, 100, 100000);

   IER |= M_INT14;
   IER |= M_INT1;

   PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM

	if(Spib_TxReady() == 1)
	{
		SpibRegs.SPITXBUF = 0XFFFF;
		ClrCs(0);
		SetCs(0);		
	}

	
   	StartCpuTimer2();
   	StartCpuTimer0();
		
   for (; ;);
} 


interrupt void cpu_timer2_isr(void)
{
	if(Spic_TxReady() == 1)
	{
		SpicRegs.SPITXBUF = LedCode[LedCount];
		ClrCs(1);
		SetCs(1);
	}
	LedCount++;
   	if (LedCount>15)   LedCount = 0;
}

interrupt void cpu_timer0_isr(void)
{
	if(Spib_TxReady() == 1)
	{
		SpibRegs.SPITXBUF = Light[LedCount1];
		ClrCs(0);
		SetCs(0);
	}
	LedCount1++;
   	if (LedCount1>7)   LedCount1 = 0;
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
   	
}

//===========================================================================
// No more.
//===========================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -