云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 基于zigbee协议栈的简单led灯闪烁程序

基于zigbee协议栈的简单led灯闪烁程序

  • 62 次阅读
  • 3 次下载
  • 2026/1/10 2:18:13

/*

* File: MyApp.c

* This project created by -- shawn shinykongcn@gmail.com * based on TI ZStack-1.4.2-1.1.0

* modified HAL/Target/CC2430EB/Config/hal_board_cfg.h \HAL_LCD TURE\to \

* to disable the LCD display. 'Cause LCD display only supported in CC2430DB. * This project is a demo to tell us how a simple ZStack task works. *

* Development environment : IAR Embeded Workbench IDE for 8051 7.20H */

#include \#include \#include \

#include \#include \#include \#include \

#include \

/* HAL */

#include \#include \#include \

#define LED1 P0_4 // (P1_0,P1_1 所接LED也用于网络状态指示,所以程序运行过程中会出现非预期的闪烁) #define LED2 P0_5

#define BLINK_EVT 0x0008 // LED blink event defined by myself

uint8 MyTask_ID;

extern void MyApp_Init( uint8 task_id );

extern UINT16 MyApp_ProcessEvent( uint8 task_id, uint16 events ); extern void CC2430EB_Init(void);

void BlinkLED( void );

void MyApp_Init(uint8 task_id) { MyTask_ID = task_id;

// 端点初始化 P0DIR |= 3<<4; // I/O口 P0_4,5 设置为输出 LED1 = 1; // 初始化关闭LED1,打开LED2 LED2 = 0;

// set blink event.设置闪烁事件 osal_set_event(MyTask_ID,BLINK_EVT); // byte osal_set_event( byte task_id, UINT16 event_flag ) }

UINT16 MyApp_ProcessEvent(uint8 task_id, uint16 events) { if(events == BLINK_EVT) { BlinkLED(); // 反转LED灯状态

// byte osal_start_timerEx( byte taskID, UINT16 event_id, UINT16 timeout_value )

// 启动1000ms定时器,每1000ms即1s反转一次 osal_start_timerEx(MyTask_ID,BLINK_EVT,1000); return (events ^ BLINK_EVT); // 返回未被处理的事件,并清除本次已处理的事件 }

return 0;

}

void BlinkLED( void ) { LED1 = !LED1; LED2 = !LED2; }

void CC2430EB_Init(void) 资源 { }

// ! 逻辑非 ~ 按位取反 ^ 位异或 |位或 // CC2430EB 开发板初始化程序,初始化用户自定义的板载 /*

* File: OSAL_MyApp.c

#include \#include \

#include \#include \

#if defined ( MT_TASK ) #include \#endif

#if !defined( NONWK ) #include \ #include \ #include \#endif

#include \

#include \

extern void MyApp_Init( uint8 task_id );

extern UINT16 MyApp_ProcessEvent( uint8 task_id, uint16 events );

/********************************************************************* * FUNCTIONS

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

/********************************************************************* * @fn osalAddTasks *

* @brief This function adds all the tasks to the task list. * This is where to add new tasks. *

* @param void *

* @return none */

void osalAddTasks( void ) // 向osal添加进程,包括mac,hal,nwk,aps等层的进程和用户应用进程SampleApp

{ // #define OSAL_TASK_PRIORITY_LOW 50 // #define OSAL_TASK_PRIORITY_MED 130 // #define OSAL_TASK_PRIORITY_HIGH 230 // ;优先级,数值越低,优先级越高 /*

This task must be loaded first because Hal_Init() initializes many things that other task_init functions may need. */

osalTaskAdd (Hal_Init, Hal_ProcessEvent, OSAL_TASK_PRIORITY_LOW);

#if defined( ZMAC_F8W )

osalTaskAdd( macTaskInit, macEventLoop, OSAL_TASK_PRIORITY_HIGH ); #endif

#if defined( MT_TASK )

osalTaskAdd( MT_TaskInit, MT_ProcessEvent, OSAL_TASK_PRIORITY_LOW ); #endif

osalTaskAdd( nwk_init, nwk_event_loop, OSAL_TASK_PRIORITY_MED ); osalTaskAdd( APS_Init, APS_event_loop, OSAL_TASK_PRIORITY_LOW );

osalTaskAdd( ZDApp_Init, ZDApp_event_loop, OSAL_TASK_PRIORITY_LOW );

osalTaskAdd( MyApp_Init, MyApp_ProcessEvent, OSAL_TASK_PRIORITY_LOW ); }

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

搜索更多关于: 基于zigbee协议栈的简单led灯闪烁程序 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

/* * File: MyApp.c * This project created by -- shawn shinykongcn@gmail.com * based on TI ZStack-1.4.2-1.1.0 * modified HAL/Target/CC2430EB/Config/hal_board_cfg.h \HAL_LCD TURE\to \ * to disable the LCD display. 'Cause LCD display only supported in CC2430DB. * This project is a demo to tell us how a simple ZStack task works. * * Development env

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com