【文件属性】:
文件名称:SI4432 CODE
文件大小:5KB
文件格式:ZIP
更新时间:2015-10-01 02:33:59
SI4432
#ifndef _SI4432_TX_H
#define _SI4432_TX_H
#include //包含型号头文件
//#include //包含"位"操作头文件
/******************数据类型宏定义******************/
#define uchar unsigned char
#define uint unsigned int
//***********************************Si4432接口定义*******************************************
#define Si4432_SDN DDRD|=(1<<2) //输出1 关闭输入引脚
#define Si4432_nSEL DDRD|=(1<<4) //输出1 SPI片选
#define Si4432_SCLK DDRD|=(1<<7) //输出1 SPI时钟
#define Si4432_SDI DDRD|=(1<<5) //输出1 从SPI数据输入脚
#define Si4432_SDO PIND & (1<<6) //输入0 从SPI数据输出脚
#define Si4432_nIRQ PIND & (1<<3) //输入0 中断输出引脚
#define Hign_Si4432_SDN PORTD |= (1 << 2)
#define Low_Si4432_SDN PORTD &= ~(1 << 2)
#define Hign_Si4432_nSEL PORTD |= (1 << 4)
#define Low_Si4432_nSEL PORTD &= ~(1 << 4)
#define Hign_Si4432_SCLK PORTD |= (1 << 7)
#define Low_Si4432_SCLK PORTD &= ~(1 << 7)
#define Hign_Si4432_SDI PORTD |= (1 << 5)
#define Low_Si4432_SDI PORTD &= ~(1 << 5)
#define Read_Si4432_SDO PIND &(1 << 6)
#define Read_Si4432_nIRQ PIND &(1 << 3)
//***************************************Si4432寄存器指令*******************************************************
#define READ_REG 0x00 //读寄存器指令
#define WRITE_REG 0x80 //写寄存器指令
#define TX1_RX0 SPI_RW_Reg(WRITE_REG + 0x0e, 0x01) //发射状态的天线开关定义
#define TX0_RX1 SPI_RW_Reg(WRITE_REG + 0x0e, 0x02) //接收状态的天线开关定义
#define TX0_RX0 SPI_RW_Reg(WRITE_REG + 0x0e, 0x00) //非发射,接收状态的天线开关定义
#define TxBuf_Len 10
#define RxBuf_Len 10 //定义RF4432数据包长度
void SPI_Init(void);
uchar SPI_Byte(uchar data);
uchar SPI_RW_Reg(uchar addr, uchar data);
void SPI_Read_Buf(uchar addr, uchar *data, uchar number);
void SPI_Write_Buf(uchar addr, uchar *data, uchar number);
void Si4432_init(void);
uchar RF4432_RSSI(void);
uchar RF4432_RxPacket(void);
void SetRX_Mode(void);
void SetTX_Mode(uchar *Tx_Buf);
//void SI4432RxTx(void);
#endif
【文件预览】:
SI4432_TX.c
Si4432_TX.H