?? nrf401收發程序1.txt
字號:
nRF401無線收發串口中斷服務程序
/*------------------------------------
nRF401無線收發串口中斷服務程序
------------------------------------*/
void sioproc() interrupt SIO_VECTOR using 1
{
unsigned char i;
unsigned int crc;
if (RI) {//接收中斷
RI = 0;
if (!nRFTXEN && SioBuffers.RXCount) {//每次接收20個數據
i = SBUF;
SioBuffers.RXCount --;
SioBuffers.RXBuffers[19 - SioBuffers.RXCount] = i;
switch(SioBuffers.RXCount) {
case 19:
if (i != 0x55) SioBuffers.RXCount = 20;
break;
case 18:
if (i != 0xaa) SioBuffers.RXCount = 20;
break;
case 0:
crc = 0;
for (i = 1; i <= 8; i ++) {
crc = crc16r(GetRXBuffWord(i + i), crc);
}
if (crc != GetRXBuffWord(18))
SioBuffers.RXCount = 20;
else {
nRFTXEN = 1;//發送
for (i = 0; i < 20; i ++) {
SioBuffers.TXBuffers = SioBuffers.RXBuffers;
}
SioBuffers.TXMAXCount = TX_MAXCount;
SioBuffers.TXCount = TX_Count + 32;
TI = 1;//接收結束立即轉為發送
}
break;
}
}
}
if (TI) {//發送中斷
TI = 0;
if (nRFTXEN && SioBuffers.TXCount) {
SioBuffers.TXCount --;
if (SioBuffers.TXCount > 19) {
SBUF = 0x00;
}
else {
SBUF = SioBuffers.TXBuffers[19 - SioBuffers.TXCount];
}
if (SioBuffers.TXCount == 0) {
if (SioBuffers.TXMAXCount) {
SioBuffers.TXMAXCount --;
SioBuffers.TXCount = TX_Count;
}
else {
nRFTXEN = 0;//發送結束立即轉為接收
SioBuffers.RXCount = 20;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -