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

📄 app_ex_main.c

📁 CC2430多功能调试程序
💻 C
字号:
/******************************************************************************
Filename:     app_ex_main.c
Target:       cc2430
Revised:      16/12-2005
Revision:     1.0

Description:
    Application example, SmartRF04EB.

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


#include "app_ex.h"
#include "RF04EB.h"
#include "hal.h"
#include "lcd128_64.h"
#include "string.h"
#include "menu.h"


//APPLICATION apps[NBR_OF_APPS];
UINT8 activeApp;
INT8U LanguageSel = 0;
void keyinit(void)
{
	INIT_JOYSTICK();
        IO_DIR_PORT_PIN(0, 1, IO_IN);
	IO_DIR_PORT_PIN(0, 5, IO_IN);
}


/*********************************************************************************
//函数名:INT8U ScanKey(void)
//输入:无
//输出:无
//功能描述:按键扫描
*********************************************************************************/
INT8U ScanKey(void)
{
	INT8U tt;
//	if(KEY_CANCEL == 0)return K_CANCEL;
//	else if(KEY_OK == 0)return K_OK;
//        else
//         {
                tt = halAdcSampleSingle(ADC_REF_AVDD, ADC_14_BIT, ADC_INPUT_JOYSTICK);
                if(tt<0x20)return K_UP;
                else if(tt<0x29)return K_DOWN;
//                else if(tt<0x35)return K_RIGHT;
                else if(tt<0x35)return K_OK;
                else if(tt<0x50)return K_LIFT;
                else return 0xff;
//        }
}

/******************************************************************************
* @fn  main
*
* @brief
*      Main function of application example.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
void main(void)
{
  
  SET_MAIN_CLOCK_SOURCE(CRYSTAL);
  keyinit();
  InitLcd();
  IO_DIR_PORT_PIN(0, 4, IO_OUT);
  P0_4 = 0;
  TurnOnDisp();
  while(1)
  {
    MenuMenuDisp();
  }
}

/******************************************************************************
* @fn  stopApplication
*
* @brief
*     Check for stop application command, Joystick direction left.
*
* Parameters:
*
* @param  void
*
* @return BOOL
*         TRUE    Terminate current application
*         FALSE   No action
*
******************************************************************************/
BOOL stopApplication(void)
{
   return (ScanKey() == K_CANCEL);
}


/******************************************************************************
* @fn  haltApplication
*
* @brief
*     Halts until user stops application.
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
void haltApplication(void)
{
   while(!stopApplication());
}


/******************************************************************************
* @fn  haltApplicationWithLED
*
* @brief
*     Halts until user stops application, toggle LEDs
*
* Parameters:
*
* @param  void
*
* @return void
*
******************************************************************************/
void haltApplicationWithLED(void)
{
   BOOL direction = 0;
   BYTE led_values = 0x01;

   INIT_YLED();

   while(!stopApplication()){
      YLED = !!((led_values & 0x01));

      if(direction == 0)
         (led_values < 0x08) ? (led_values <<= 1):(led_values = 0x08, direction = 1);
      else
         (led_values > 0x01) ? (led_values >>= 1):(led_values = 0x01, direction = 0);

      halWait(40);
   }
}




⌨️ 快捷键说明

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