hal_rf_set_channel.c
来自「zigbee子节点源代码」· C语言 代码 · 共 31 行
C
31 行
#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 + =
减小字号Ctrl + -
显示快捷键?