/***********************************************************************************
Filename: hal_cc2520.c
Description: This file implements the CC2520 Radio HAL.
***********************************************************************************/
/***********************************************************************************
* INCLUDES
*/
#include "hal_cc2520.h"
#include "hal_mcu.h"
/***********************************************************************************
* CONSTANTS AND DEFINES
*/
#define BLOCK_SIZE 255
/***********************************************************************************
* LOCAL FUNCTIONS
*/
static uint8 GotException(uint8 index);
static uint8 waitException(uint8 exc, uint16 timeOut);
static void clearException(uint32 dwMap);
static void CC2520_INS_RD_ARRAY(uint16 count, uint8 *pData);
static uint8 CC2520_INS_MEMCP_COMMON(uint8 instr, uint8 pri, uint16 count, \
uint16 src, uint16 dest);
static uint8 CC2520_SPI_TXRX(uint8 x)
{
CC2520_SPI_TX(x);
CC2520_SPI_WAIT_RXRDY();
return CC2520_SPI_RX();
}
/***********************************************************************************
* @fn GotException
*
* @brief Check if exception is set
*
* @param uint8 index
*
* @return uint8
*/
static uint8 GotException(uint8 index)
{
uint8 exceptions = CC2520_REGRD8(CC2520_EXCFLAG0 + (index >> 3));
if (exceptions & BV(index & 0x07)) {
return TRUE;
} else {
return FALSE;
}
}
/***********************************************************************************
* @fn waitException
*
* @brief Wait for exception
*
* @param uint8 exc
* uint16 timeOut
*
* @return uint8
*/
static uint8 waitException(uint8 exc, uint16 timeOut)
{
while (--timeOut>0) {
if (GotException(exc))
break;
halMcuWaitUs(10);
}
return timeOut>0;
}
/***********************************************************************************
* @fn clearException
*
* @brief Clear exception flag
*
* @param uint32 dwMap
*
* @return none
*/
static void clearException(uint32 dwMap)
{
CC2520_REGWR24(CC2520_EXCFLAG0, ~dwMap);
}
/***********************************************************************************
* @fn CC2520_INS_RD_ARRAY
*
* @brief Read array from CC2520
*
* @param uint16 count -
* uint8 *pData -
*
* @return none
*/
static void CC2520_INS_RD_ARRAY(uint16 count, uint8 *pData)
{
while (count--) {
CC2520_SPI_TX(0x00);
CC2520_SPI_WAIT_RXRDY();
*pData = CC2520_SPI_RX();
pData++;
}
}
/***********************************************************************************
* @fn CC2520_INS_MEMCP_COMMON
*
* @brief memory copy
*
* @param uint8 instr -
* uint8 pri -
* uint16 count -
* uint16 src -
* uint16 dest -
*
* @return uint8 - status byte
*/
static uint8 CC2520_INS_MEMCP_COMMON(uint8 instr, uint8 pri, uint16 count, \
uint16 src, uint16 dest)
{
uint8 s;
CC2520_SPI_BEGIN();
s = CC2520_SPI_TXRX(instr | pri);
CC2520_SPI_TXRX(count);
CC2520_SPI_TXRX((HIBYTE(src) << 4) | HIBYTE(dest));
CC2520_SPI_TXRX(LOBYTE(src));
CC2520_SPI_TXRX(LOBYTE(dest));
CC2520_SPI_END();
return s;
}
/***********************************************************************************
* GLOBAL FUNCTIONS
*/
/***********************************************************************************
* @fn CC2520_INS_WR_ARRAY
*
* @brief Write array to CC2520
*
* @param uint16 count -
* uint8 *pData -
*
* @return none
*/
void CC2520_INS_WR_ARRAY(uint16 count, uint8 *pData)
{
while (count--) {
CC2520_SPI_TX(*pData);
pData++;
CC2520_SPI_WAIT_RXRDY();
}
}
/***********************************************************************************
* @fn CC2520_INS_STROBE
*
* @brief send strobe commane
*
* @param uint8 strobe - strobe command
*
* @return uint8 - status byte
*/
uint8 CC2520_INS_STROBE(uint8 strobe)
{
uint8 s;
CC2520_SPI_BEGIN();
s = CC2520_SPI_TXRX(strobe);
CC2520_SPI_END();
return s;
}
/***********************************************************************************
* @fn CC2520_SNOP
*
* @brief SNOP instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SNOP(void)
{
return CC2520_INS_STROBE(CC2520_INS_SNOP);
}
/***********************************************************************************
* @fn CC2520_SIBUFEX
*
* @brief SIBUFEX instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SIBUFEX(void)
{
return CC2520_INS_STROBE(CC2520_INS_SIBUFEX);
}
/***********************************************************************************
* @fn CC2520_SSAMPLECCA
*
* @brief Sample CCA instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SSAMPLECCA(void)
{
return CC2520_INS_STROBE(CC2520_INS_SSAMPLECCA);
}
/***********************************************************************************
* @fn CC2520_SXOSCON
*
* @brief SXOSCON instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SXOSCON(void)
{
return CC2520_INS_STROBE(CC2520_INS_SXOSCON);
}
/***********************************************************************************
* @fn CC2520_STXCAL
*
* @brief STXCAL instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_STXCAL(void)
{
return CC2520_INS_STROBE(CC2520_INS_STXCAL);
}
/***********************************************************************************
* @fn CC2520_SRXON
*
* @brief SRXON instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SRXON(void)
{
return CC2520_INS_STROBE(CC2520_INS_SRXON);
}
/***********************************************************************************
* @fn CC2520_STXON
*
* @brief STXON instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_STXON(void)
{
return CC2520_INS_STROBE(CC2520_INS_STXON);
}
/***********************************************************************************
* @fn CC2520_STXONCCA
*
* @brief STXONCCA instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_STXONCCA(void)
{
return CC2520_INS_STROBE(CC2520_INS_STXONCCA);
}
/***********************************************************************************
* @fn CC2520_SRFOFF
*
* @brief SRFOFF instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SRFOFF(void)
{
return CC2520_INS_STROBE(CC2520_INS_SRFOFF);
}
/***********************************************************************************
* @fn CC2520_SXOSCOFF
*
* @brief SXOSCOFF instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SXOSCOFF(void)
{
return CC2520_INS_STROBE(CC2520_INS_SXOSCOFF);
}
/***********************************************************************************
* @fn CC2520_SFLUSHRX
*
* @brief SFLUSHRX instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SFLUSHRX(void)
{
return CC2520_INS_STROBE(CC2520_INS_SFLUSHRX);
}
/***********************************************************************************
* @fn CC2520_SFLUSHTX
*
* @brief SFLUSHTX instruction strobe
*
* @param none
*
* @return uint8 - status byte
*/
uint8 CC2520_SFLUSHTX(void)
{
return CC2520_INS_STROBE(CC2520_INS_SFLUSHTX);
}
/*********
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
6709182cc2520peartopeartest.rar (59个子文件)
cc2520点对点测试
ide
light_switch
srf05_ccmsp2618_cc2520
iar
light_switch.ewp 27KB
light_switch.hex 17KB
light_switch.d43 93KB
light_switch.ewd 7KB
light_switch.eww 166B
light_switch.dep 18KB
source
apps
light_switch
light_switch.c 9KB
Components
assembly
assy_ccmsp2618_cc2520em.h 8KB
assy_ccmsp2618_cc2520em.c 4KB
basicrf
basic_rf.c 20KB
basic_rf_security.c 4KB
basic_rf_security.h 3KB
basic_rf.h 5KB
utils
util_menu.h 2KB
util_buffer.h 3KB
util_lcd.c 10KB
util_uart.c 6KB
util.c 5KB
util.h 3KB
util_buffer.c 6KB
util_uart.h 3KB
util_lcd.h 3KB
targets
interface
hal_timer_32k.h 3KB
hal_rf.h 5KB
hal_int.h 4KB
hal_mcu.h 3KB
hal_rf_security.h 3KB
hal_rf_util.h 1KB
hal_joystick.h 3KB
hal_led.h 3KB
hal_assert.h 3KB
hal_lcd.h 4KB
hal_button.h 3KB
hal_uart.h 4KB
hal_digio.h 4KB
srf05_ccmsp2618
hal_button.c 902B
hal_digio.c 12KB
OLED.h 2KB
hal_lcd.c 16KB
OLED.c 28KB
Font.h 0B
hal_board.h 9KB
hal_led.c 4KB
hal_mcu.c 6KB
hal_board.c 4KB
hal_joystick.c 9KB
hal_uart.c 10KB
Font.c 22KB
hal_assert.c 3KB
hal_timer_32k.c 5KB
common
msp430
hal_msp430.h 6KB
hal_defs.h 6KB
hal_types.h 8KB
hal_int.c 4KB
radios
cc2520
hal_cc2520.c 41KB
hal_rf_security.c 7KB
hal_rf.c 17KB
hal_rf_util.c 2KB
hal_cc2520.h 22KB
共 59 条
- 1
资源评论
- 莫扎特的独白2015-04-11下载的东西感觉不错的
- tdrrong2015-01-28可以用了做一般的测试,还行。
- qq_250427972015-04-20很好,很有用,我这次就是用MSP430做基础的
- guozengjun2014-06-20下载了,非常感谢,学习参考
- grf1234822013-12-06非常感谢!学习,参考了!
yuanshen99
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 记录了贪心,动态规划等算法基本思想与设计.zip
- 基于菲阿里基本模型,以及MACD RSI BooL 等技术指标 构建一套基于贪心算法策略的智能投顾模型.zip
- oj算法代码-贪心算法.zip
- 基于yolov8行人检测源码+模型.zip
- 公开整理-地级市-绿色专利申请、授权数据集(2000-2022年).xlsx
- 基于Transformer模型的图像质量评分模型实现源码+详细说明文档.zip
- CST电磁场仿真+线性螺旋电感+建模步骤细节和RLC端口配置+CST高级建模操作
- 大数据库实验的报告材料材料(word文档良心出品).doc
- AIS2024 valid
- 最入门的爬虫代码 python.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功