sy.c
来自「rs485、八位扫描显示、按键、数字编码器」· C语言 代码 · 共 51 行
C
51 行
#include<reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit spi_spe=P3^3;
sbit spi_dat=P3^0;
sbit spi_clk=P3^1;
main()
{
uint temp;
uchar num;
while(1)
{
for(temp=0x200;temp>0;temp--)
{;}
temp=0xa50e;
spi_spe=0;
_nop_();
_nop_();
spi_clk=0;
_nop_();
_nop_();
spi_dat=0;
for(num=16;num>0;num--)
{
if(temp&0x8000 )
spi_dat=1;
else spi_dat=0;
_nop_();
_nop_();
_nop_();
_nop_();
spi_clk=1;
_nop_();
_nop_();
_nop_();
_nop_();
spi_clk=0;
_nop_();
_nop_();
_nop_();
_nop_();
temp<<=1;
}
_nop_();
_nop_();
spi_spe=1;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?