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

📄 clockmodes.c

📁 ti-Chipcon CC2430 zigbee Soc应用开发源码实例。包括rf,powermodes,clockmodes底层驱动源码。有了这些实例,包括误码率测试等。对你更好的理解和应用这颗芯片
💻 C
字号:
/******************************************************************************
*                                                                             *
*        **********                                                           *
*       ************                                                          *
*      ***        ***                                                         *
*     ***    ++    ***                                                        *
*     ***   +  +   ***                      CHIPCON                           *
*     ***   +                                                                 *
*     ***   +  +   ***                                                        *
*     ***    ++    ***                                                        *
*      ***        ***                                                         *
*       ************                                                          *
*        **********                                                           *
*                                                                             *
*******************************************************************************

Filename:     clockmodes.c
Target:       cc2430
Author:       EFU
Revised:      30/5-2007
Revision:     1.2

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

******************************************************************************/

/******************************************************************************
 * INCLUDES
 */
#include "app_ex.h"

/******************************************************************************
 * CONSTANTS
 */

/******************************************************************************
 * TYPEDEFS
 */

/******************************************************************************
 * GLOBAL VARIABLES
 */

/******************************************************************************
 * LOCAL VARIABLES
 */

/******************************************************************************
 * LOCAL FUNCTIONS
 */
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();

   initLcd();

   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 LED
   uint16 timeOut = 0xFFFF;
   while(timeOut--);

   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;
   char *menuText[] = {(char*)" RC 16 MHz", (char*)" Crystal 32 MHz"};


   initClockmodes();

   while((state = lcdMenu(menuText,2)) != ABORT_MENU)
   {
      if(state == 0)
      {
         // Turning on RC oscillator and waiting for HFRC stable
         SET_MAIN_CLOCK_SOURCE(RC);
         lcdUpdate((char*)"Internal 16 MHz",(char*)"RC Osc.");
      }
      else if(state == 1)
      {
         //Turning on Crystal oscillator and waiting for it to become stable
         SET_MAIN_CLOCK_SOURCE(CRYSTAL);
         lcdUpdate((char*)"External 32 MHZ",(char*)"X-stal Osc.");
      }

      while(!stopApplication())
      {
         blinkLeds();
      }

   }
}


/******************************************************************************
* @fn  clockmodes_init
*
* @brief
*      Initializes the clock modes application example.
*
* Parameters:
*
* @param  APPLICATION *a
*         Main application
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void clockmodes_init(APPLICATION *a)
{
   a->menuText = (char*)"Clock Modes";
   a->description = (char*)"";
   a->main_func = clockmodes_main;
}
#endif

⌨️ 快捷键说明

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