/*************************************************************************
** Copyright (C),
**--------------------------文件信息-------------------------------------
** 文 件 名 称:
** 创 建 者:
** 最后修改时期:
** 描 述:
**
**-------------------------历史版本信息----------------------------------
** 文件创建者:
** 版 本:
** 日 期:
** 描 述:
**
**-------------------------当前版本修订----------------------------------
** 文件修改者:
** 日 期:
** 描 述:
**
**************************************************************************/
#include "mrfi_config.h"
uint8_t mrfiRadioState = MRFI_RADIO_STATE_UNKNOWN;
static uint8_t mrfiRndSeed;
static uint16_t sBackoffHelper;
static uint16_t sReplyDelayScalar;
const uint8_t myPaTable[] = {MRFI_PATABLE_VAL};
// Chipcon
// Product = CC1101
// Chip version = A (HW Rev. 0x10)
// Crystal accuracy = 10 ppm
// X-tal frequency = 26 MHz
// RF output power = 10 dBm
// RX filterbandwidth = 101.562500 kHz
// Deviation = 19 kHz
// Datarate = 38.383484 kBaud
// Modulation = (0) 2-FSK
// Manchester enable = (1) Manchester enabled
// RF Frequency = 433.919830 MHz
// Channel spacing = 199.951172 kHz
// Channel number = 0
// Optimization = -
// Sync mode = (3) 30/32 sync word bits detected
// Format of RX/TX data = (0) Normal mode, use FIFOs for RX and TX
// CRC operation = (1) CRC calculation in TX and CRC check in RX enabled
// Forward Error Correction = (0) FEC disabled
// Length configuration = (1) Variable length packets, packet length configured by the first received byte after sync word.
// Packetlength = 16
// Preamble count = (2) 4 bytes
// Append status = 1
// Address check = (0) No address check
// FIFO autoflush = 0
// Device address = 0
// GDO0 signal selection = ( 6) Asserts when sync word has been sent / received, and de-asserts at the end of the packet
// GDO2 signal selection = (41) CHIP_RDY
const MRFI_RF_CONFIG rfSettings = {
0x06, // FSCTRL1 Frequency synthesizer control.
0x00, // FSCTRL0 Frequency synthesizer control.
0x10, // FREQ2 Frequency control word, high byte.
0xB0, // FREQ1 Frequency control word, middle byte.
0x71, // FREQ0 Frequency control word, low byte.
0x55, // SYNC1 Sync Word high byte
0xA0, // SYNC0 Sync Word low byte
0xCA, // MDMCFG4 Modem configuration.
0x83, // MDMCFG3 Modem configuration.
0x8B, // MDMCFG2 Modem configuration.
0x22, // MDMCFG1 Modem configuration.
0xF8, // MDMCFG0 Modem configuration.
0x08, // CHANNR Channel number.
0x34, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
0x56, // FREND1 Front end RX configuration.
0x10, // FREND0 Front end TX configuration.
0x3C, // MCSM1 Main Radio Control State Machine configuration.
0x18, // MCSM0 Main Radio Control State Machine configuration. 0x18
0x16, // FOCCFG Frequency Offset Compensation Configuration.
0x6C, // BSCFG Bit synchronization Configuration.
0x43, // AGCCTRL2 AGC control.
0x40, // AGCCTRL1 AGC control.
0x91, // AGCCTRL0 AGC control.
0xE9, // FSCAL3 Frequency synthesizer calibration.
0x2A, // FSCAL2 Frequency synthesizer calibration.
0x00, // FSCAL1 Frequency synthesizer calibration.
0x1F, // FSCAL0 Frequency synthesizer calibration.
0x59, // FSTEST Frequency synthesizer calibration.
0x88, // TEST2 Various test settings.
0x31, // TEST1 Various test settings.
0x0B, // TEST0 Various test settings.
0x29, // IOCFG2 GDO2 output pin configuration.
0x06, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
0x04, // PKTCTRL1 Packet automation control.
0x04, // PKTCTRL0 Packet automation control.
0x00, // ADDR Device address.
MRFI_PACKET_LEN // PKTLEN Packet length.
};
///////////////////////////////////////////////////////////////////////////
/*************************************************************************
函 数 名:void MrfiWaitRssiValid(void)
功能描述:等待射频模块RSSI值可靠
输入参数: 无
返回参数:无
备 注:
***************************************************************************/
void MrfiWaitRssiValid(void);
/*************************************************************************
函 数 名:void MrfiRxModeOn(void)
功能描述:射频打开接收模式
输入参数: 无
返回参数:无
备 注:
***************************************************************************/
void MrfiRxModeOn(void);
/*************************************************************************
函 数 名:void MrfiRxModeOff(void)
功能描述:射频接收模式关闭
输入参数: 无
返回参数:无
备 注:
***************************************************************************/
void MrfiRxModeOff(void);
/*************************************************************************
函 数 名:uint8_t MrfiCalculateRssi(uint8_t rawValue)
功能描述:射频模块RSSI 值计算
输入参数: rawValue:待计算RSSI值
返回参数:返回计算后RSSI
备 注:
***************************************************************************/
uint8_t MrfiCalculateRssi(uint8_t rawValue);
/*************************************************************************
函 数 名:uint8_t MrfiChipIsBusy(void)
功能描述:射频模块通信是否忙
输入参数: 无
返回参数:返回当前模块是否忙
备 注:
***************************************************************************/
uint8_t MrfiChipIsBusy(void);
/*************************************************************************
函 数 名:uint8_t MrfiStrobe(uint8_t cmd)
功能描述:射频模块写入命令函数
输入参数: cmd:命令参数
返回参数:返回写入命令后返回参数
备 注:
***************************************************************************/
uint8_t MrfiStrobe(uint8_t cmd);
/*************************************************************************
函 数 名:void MrfiDelayUs(uint16_t usec)
功能描述:毫秒延时函数
输入参数: usec:延时参数
返回参数:无
备 注:
***************************************************************************/
void MrfiDelayUs(uint16_t usec)
{
while(usec--)
{
delay_us(1);
}
}
/*************************************************************************
函 数 名:void MrfiSpiPortInit(void)
功能描述:射频模块SPI引脚初始化
输入参数: 无
返回参数:无
备 注:
***************************************************************************/
void MrfiSpiPortInit(void)
{
MRFI_SPI_MOSI_LOW();
MRFI_SPI_MOSI_OUTPUT();
MRFI_SPI_CLK_LOW();
MRFI_SPI_CLK_OUTPUT();
MRFI_SPI_SIMO_LOW();
MRFI_SPI_SIMO_INPUT();
MRFI_SPI_CS_HIGH();
MRFI_SPI_CS_OUTPUT();
}
/*************************************************************************
函 数 名:void MrfiIsrPortInit(void)
功能描述:射频模块中断引脚初始化函数
输入参数: 无
返回参数:无
备 注:
***************************************************************************/
void MrfiIsrPortInit(void)
{
MRFI_GDO0_HIGH();
MRFI_GDO0_INPUT();
MRFI_GDO2_HIGH();
MRFI_GDO2_INPUT();
}
//模块基本操作
/*************************************************************************
函 数 名:static void MrfiSpiClkDelay(uint16_t count)
功能描述:SPI时钟延时函数
输入参数: count:延时参数(系统时钟基数)
返回参数:无
备 注:
***************************************************************************/
//static void MrfiSpiClkDelay(uint16_t count)
//{
// uint16_t i =0x00;
// for(i=0x00;i<count;i++);
//}
/*************************************************************************
函 数 名:static uint8_t MrfiSpiRWByte(uint8_t data)
功能描述:射频模块SPI读写函数
输入�
CC1101 射频433MHZ 驱动程序
5星 · 超过95%的资源 需积分: 49 77 浏览量
2015-07-04
11:06:32
上传
评论
收藏 29KB RAR 举报
xiwangcumt
- 粉丝: 0
- 资源: 5
最新资源
- C语言基础-C语言编程基础之Leetcode编程题解之第30题串联所有单词的子串.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第29题两数相除.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第28题找出字符串中第一个匹配项的下标.zip
- 实验报告模板(1).docx
- C语言基础-C语言编程基础之Leetcode编程题解之第26题删除有序数组中的重复项.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第25题K个一组翻转链表.zip
- hnu计算机系统作业-计算机系统基础课程大作业.zip
- 树莓派app.apk
- C++的基于同态加密技术的匿名电子投票系统源码.zip
- SW建模格式图.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈