⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clockmodes.c

📁 基于cc2430的无限通信实例
💻 C
字号:
/******************************************************************************
Filename:     clockmodes.c
Target:       cc2430
Revised:      16/12-2005
Revision:     1.0

Description:
    This application shows how to switch between the main clock sources.
    The green LED toggles according to clock speed.

******************************************************************************/
#include <string.h>
#include "RF04EB.h"
#include "app_ex.h"
#include "menu.h"
#include "lcd128_64.h"
#include "hal.h"

// Prototypes
void blinkLeds(void);
void initClockmodes(void);
void clockmodes_main(void);


/******************************************************************************
* @fn  initClockmodes
*
* @brief
*      Initializes components for the clock mode application example.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/

void initClockmodes(void)
{
   DISABLE_ALL_INTERRUPTS();

   SLEEP &= ~0x04;
   halWait(1);

   P1SEL &= ~0x01; // may have been set by another app
   INIT_GLED();
}


/******************************************************************************
* @fn  blinkLeds
*
* @brief
*      Toggle LEDs according to clock speed.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
void blinkLeds(void)
{
   static BYTE counter = 0;
   //Blinking LEDs.
   UINT16 timeOut = 0xFFFF;
   while(timeOut--){
      asm("NOP");
   }

   counter++;

   GLED ^= 1;
} //ends blink LEDs


/******************************************************************************
* @fn  clockmodes_main
*
* @brief
*      Main function, switches between RCosc and Xosc.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void clockmodes_main(void){
#else
void main(void){
#endif
    BYTE state = 0;

    TopDisp = 7;
    if(LanguageSel == 1)
    {
        strcpy((char*)MenuItem[0] ,"1:RC      16M ");
        strcpy((char*)MenuItem[1] ,"2:CRYSTAL 32M ");
    }
    else
    {
        strcpy((char*)MenuItem[0] ,"1:RC  16M     ");
        strcpy((char*)MenuItem[1] ,"2:晶体 32M    ");
    }
    FirstItem = 0;
    NowItem = 0;

    initClockmodes();
    state = DrawMenu(MenuItem , 2 );
    switch(state)
    {
        case 0:
	{
	    SET_MAIN_CLOCK_SOURCE(RC);
            while (!HIGH_FREQUENCY_RC_OSC_STABLE);
        }break;
	case 1:
	{
	    SET_MAIN_CLOCK_SOURCE(CRYSTAL);
            while (!XOSC_STABLE);
	}break;
        case 0xff:
	{
            blinkLeds();
            return ;
        }break;
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -