crystal_oscillator.c
来自「CC2420+PIC单片机基础实验代码、CC2420无线收发实验代码」· C语言 代码 · 共 66 行
C
66 行
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON HARDWARE ABSTRACTION LIBRARY FOR THE CC2420 *
* *** + + *** CC2420 crystal oscillator stabilization *
* *** +++ *** *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* The Chipcon Hardware Abstraction Library is a collection of functions, macros and constants, which *
* can be used to ease access to the hardware on the CC2420 and the target microcontroller. *
* *
* This file contains a function that ensures that the CC2420 crystal oscillator is stable. *
* *
* EXAMPLE OF USAGE: *
* // Turn the crystal oscillator on and wait for it to become stable *
* DISBALE_GLOBAL_INT(); *
* FASTSPI_STROBE(CC2420_SXOSCON); *
* ENABLE_GLOBAL_INT(); *
* halRfWaitForCrystalOscillator(); *
*******************************************************************************************************
* Compiler: AVR-GCC *
* Target platform: CC2420DB, CC2420 + any MCU with very few modifications required *
*******************************************************************************************************
* Revision history: *
* $Log: hal_rf_wait_for_crystal_oscillator.c,v $
* Revision 1.3 2004/03/30 14:59:35 mbr
* Release for web
*
*
*
*******************************************************************************************************/
#include <include.h>
//-------------------------------------------------------------------------------------------------------
// void rfWaitForCrystalOscillator(void)
//
// DESCRIPTION:
// Waits for the crystal oscillator to become stable. The flag is polled via the SPI status byte.
//
// Note that this function will lock up if the SXOSCON command strobe has not been given before the
// function call. Also note that global interrupts will always be enabled when this function
// returns.
//-------------------------------------------------------------------------------------------------------
void halRfWaitForCrystalOscillator(void) {
BYTE spiStatusByte;
// Poll the SPI status byte until the crystal oscillator is stable
do {
DISABLE_GLOBAL_INT();
FASTSPI_UPD_STATUS(spiStatusByte);
ENABLE_GLOBAL_INT();
} while (!(spiStatusByte & (BM(CC2420_XOSC16M_STABLE))));
} // halRfWaitForCrystalOscillator
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?