AVR的SPI驅(qū)動(dòng)74HC595測(cè)試程序
#includeavr/io.h>
#define uchar unsigned char
#define uint unsigned int
#define lat_on PORTB|=0x10
#define lat_off PORTB=0xe0
void spi_init(void)
{
SPCR=0x70;
SPSR=0X01;
}
void spi_send(uchar dd)
{
SPDR=dd;
while(0==(SPSR0X80));
}
int main(void)
{
DDRB=0xff;
PORTB=0XFF;
spi_init();
lat_off;
spi_send(0x92);
spi_send(0x24);
lat_on;
while(1);
}
評(píng)論