?? key_spi.txt
字號(hào):
#include "LPC2294.h"
#include "config.h"
#include "stdio.h"
#define BEEP 1<<24
#define LEDS3 0x07<<28
#define HC595_CS 1<<7
#define KEY0 1<<16
#define KEY1 1<<17
#define KEY2 1<<18
#define KEY3 1<<19
void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
void MSPI_Init(void)
{
PINSEL0=(PINSEL0&(~(0x3F<<8)))|(0x15<<8);
SPCCR=0x52;
SPCR=(0<<3)|(1<<4)|(1<<5)|(0<<6)|(0<<7);
}
uint8 MSPI_SendData(uint8 data)
{
IO0CLR=HC595_CS;
SPI_SPDR=data;
while(0==(SPI_SPSR&0x80));
IO0SET=HC595_CS;
return(SPI_SPDR);
}
uint8 DISP_TAB[19]={
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,
0x88,0x83,0xC6,0xA1,0x86,0x8E,
0xC7,0x8C,0xC6};
int main(void)
{
uint8 i=0;
IO0DIR&=~(KEY0);
IO0DIR|=HC595_CS;
MSPI_Init();
while(1)
{
if((IO0PIN&KEY0)==0)
{
MSPI_SendData(DISP_TAB[1]);
}
else
{
DelayNS(10);
MSPI_SendData(DISP_TAB[0]);
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -