📄 mytest.c
字号:
#include "mytest.h"
#include "lpradio.h"
#include "psocgpioint.h"
#ifdef MY_TEST
#define RED_ON nLED2_Data_ADDR &=~nLED2_MASK
#define RED_OFF nLED2_Data_ADDR |=nLED2_MASK
#define GREEN_ON nLED1_Data_ADDR &=~nLED1_MASK
#define GREEN_OFF nLED1_Data_ADDR |=nLED1_MASK
//testing radio/////////////////////////////////////
unsigned char AppBuf[16]={
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
};
void radio_driver_init_test(void)
{
// Initialization, test spi
unsigned char temp;
RED_OFF;
// Initialize radio for:
// CH=96, PN=2, ACK EN, ACK TO=8x, 125kbps, 8DR-64, SOP64,
// PA=7, SOP EN, SOP64, LEN EN, SOPTH=14, TH64=14, TH32=4
RadioInit(0x85, 0x2F); // TX_CFG_ADR, XACT_CFG_ADR
// Configure the Radio
// RadioInit(ACK_EN|END_STATE_RX|ACK_TO_8X, 6|DATCODE_LEN_32|DATMODE_8DR);
RadioSetFrequency(3); // Set the transmit frequency (2400MHz + CHANNEL)
RadioSetThreshold32(0x05); //
RadioSetThreshold64(0x0e); // 0x0E
RadioSetFrameConfig(0xee); //0xEE
temp = RadioGetFrameConfig();
RadioSetSopPnCode(0x04); // Change the PN Code for the Start of Packet
RadioSetPtr(AppBuf);
RadioSetLength(sizeof(AppBuf));
// test block transmit
while(1)
{
RadioBlockingTransmit(250,16);
}
}
void radio_driver_send_test(char data)
{
unsigned char radiostate;
AppBuf[0]= data;
RadioSetPtr(AppBuf);
radiostate = RadioBlockingTransmit(1,16);
}
void radio_driver_receive_poll(void)
{
// test receive
unsigned char radiostate,RxLen;
RadioStartReceive();
while(1)
{
radiostate = RadioGetReceiveState();
if((radiostate & (RADIO_ERROR | RADIO_COMPLETE))==RADIO_COMPLETE)
{
RxLen = RadioEndReceive();
if(RxLen>0 && RxLen != 0xff)
{
if(AppBuf[0])
{
RED_ON;
}
else
{
RED_OFF;
}
}
RadioStartReceive();
}else if(radiostate & RADIO_ERROR)
{
RxLen = RadioEndReceive();
RadioStartReceive();
}
}
}
//end testing////////////////////////////////////////////////
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -