📄 hal_rf_set_channel.c
字号:
#include "include.h"
//-------------------------------------------------------------------------------------------------------
// void halRfSetChannel(UINT8 Channel)
//
// DESCRIPTION:
// Programs CC2420 for a given IEEE 802.15.4 channel.
// Note that SRXON, STXON or STXONCCA must be run for the new channel selection to take full effect.
//
// PARAMETERS:
// UINT8 channel
// The channel number (11-26)
//-------------------------------------------------------------------------------------------------------
void halRfSetChannel(UINT8 channel) {
UINT16 f;
// Derive frequency programming from the given channel number
f = (UINT16) (channel - 11); // Subtract the base channel
f = f + (f << 2); // Multiply with 5, which is the channel spacing
f = f + 357 + 0x4000; // 357 is 2405-2048, 0x4000 is LOCK_THR = 1
// Write it to the CC2420
DISABLE_GLOBAL_INT();
FASTSPI_SETREG(CC2420_FSCTRL, f);
ENABLE_GLOBAL_INT();
} // rfSetChannel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -