资源描述:
《基于51单片机驱动SI4432无线模块收发C语言程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、基于51单片机驱动SI4432无线模块收发C语言程序#include#include#include#include//----------------------------------RF4432配置口定义---------------------------------------//sbit RF4432_PAC=P2^4; //收发模式切换控制端sbit RF4432_SDO=P3^5; //SPI数据输
2、出sbit RF4432_SDI=P3^4; //SPI数据输入sbit RF4432_SCLK=P3^7; //SPI时钟输入端口sbit RF4432_SEL=P3^3; //SPI片选sbit RF4432_IRQ=P3^2; //SI4432工作状态指示端口sbit KEY=P3^6; //BLT53A上电控制端sbit LED_GREEN=P2^1;sbit P15=P1^5;//-------------------------
3、射频芯片相关定义--------------------------------------------#defineRF4432_TxRxBuf_Len32 //定义RF4432数据包长度char RF4432_TxRxBuf[RF4432_TxRxBuf_Len];unsignedcharPacket[30]={9,20,30,21,15,58,56,69,25,23,12,25,56,22,23,24};//TransmitpacketunsignedcharLength=4;unsigned
4、charData_Buf[10];unsignedcharData_Len;typedefenum_RF_ENUM{ RF_OK = 0x00, //functionresponseparameters RF_ERROR_TIMING = 0x01, RF_ERROR_PARAMETER=0x02, RF_PACKET_RECEIVED =0x03, RF_NO_PACKET = 0x04, RF_CRC_ERROR=0x05,}RF_ENUM;//----------
5、------------------RF4432配置寄存器地址--------------------------------#defineDEVICE_TYPE0x00#defineEVICE_VERSION 0x01 //版本号#defineDEVICE_STATUS 0x02 //设备状态#defineINTERRUPT_STATUS_1 0x03#defineINTERRUPT_STATUS_2 0x04#defineINTERRUPT_ENABLE_10x05#defineINTERRUPT_ENABLE_20x
6、06#defineOPERATING_FUNCTION_CONTROL_1 0x07 //工作模式和功能控制1#defineOPERATING_FUNCTION_CONTROL_20x08 //工作模式和功能控制2#defineCRYSTAL_OSCILLATOR_LOAD_CAPACITANCE 0x09 //晶振负载电容设置#defineMICROCONTROLLER_OUTPUT_CLOCK0x0A#defineGPIO0_CONFIGURATION0x0B //GPIO0功能设置寄存器见英文文档
7、第105页#defineGPIO1_CONFIGURATION 0x0C#defineGPIO2_CONFIGURATION0x0D#defineIO_PORT_CONFIGURATION0x0E#defineADC_CONFIGURATION 0x0F#defineADC_SENSOR_AMPLIFIER_OFFSET 0x10#defineADC_VALUE0x11#defineTEMPERATURE_SENSOR_CONTROL 0x12 //温度传感器校准#defineTEMPERATURE_VALUE_OFFS
8、ET0x13#defineWAKE_UP_TIMER_PERIOD_1 0x14#defineWAKE_UP_TIMER_PERIOD_2 0x15#defineWAKE_UP_TIMER_PERIOD_3 0x16#defineWAKE_UP_TIMER_VALUE_10x