89LV51.C
#include <reg51.h>
#include <intrins.h>
#include "api.h"
/*
*This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTYT;
*
*uart:9600BPS
苏州天铱电子免费代码公布
*****************
* 官方网址: http://www.tianyi-dz.com
* 官方论坛: http://www.tianyi-dz.com/bbs
****************
***TY Tech**
***bai chun yu **
***qq:472230383 328997835 **
***Email:baichunyu1232000@163.com **
****************
*/
/***************************************************/
#define uchar unsigned char
#define TX_ADR_WIDTH 5 // 5 bytes TX(RX) address width
#define TX_PLOAD_WIDTH 20 // 20 bytes TX payload
uchar const TX_ADDRESS[TX_ADR_WIDTH] = {0x34,0x43,0x10,0x10,0x01}; // Define a static TX address
uchar rx_buf[TX_PLOAD_WIDTH];
uchar tx_buf[TX_PLOAD_WIDTH];
uchar flag;
/**************************************************/
sbit CE = P1^0;
sbit CSN= P1^1;
sbit SCK= P1^2;
sbit MOSI= P1^3;
sbit MISO= P1^4;
sbit IRQ = P1^5;
/**************************************************/
uchar bdata sta;
sbit RX_DR=sta^6;
sbit TX_DS=sta^5;
sbit MAX_RT=sta^4;
/**************************************************/
/**************************************************
Function: init_io();
Description:
flash led one time,chip enable(ready to TX or RX Mode),
Spi disable,Spi clock line init high
/**************************************************/
#define KEY 0xaa
void init_io(void)
{
P0=KEY; // led light
CE=0; // chip enable
CSN=1; // Spi disable
SCK=0; // Spi clock line init high
P0=0xff; // led close
}
/**************************************************/
/**************************************************
Function: Inituart();
Description:
set uart working mode
/**************************************************/
void Inituart(void)
{
TMOD = 0x20; //timer1 working mode 1
TL1 = 0xfd; //f7=9600 for 16mhz Fosc,and ...
TH1 = 0xfd; //...fd=19200 for 11.0592mhz Fosc
SCON = 0xd8; //uart mode 3,ren==1
PCON = 0x80; //smod=0
TR1 = 1; //start timer1
}
第 1 页
PDF 文件使用 "pdfFactory Pro" 试用版本创建 www.fineprint.com.cn
评论1
最新资源