Ztack学习笔记(2)-系统初始化分析

一 系统初始化

 1 uint8 osal_init_system( void )
 2 {
 3   // Initialize the Memory Allocation System
 4   osal_mem_init();
 5
 6   // Initialize the message queue
 7   osal_qHead = NULL;
 8
 9   // Initialize the timers
10   osalTimerInit();
11
12   // Initialize the Power Management System
13   osal_pwrmgr_init();
14
15   // Initialize the system tasks.
16   osalInitTasks();
17
18   // Setup efficient search for the first free block of heap.
19   osal_mem_kick();
20
21   return ( SUCCESS );
22 }

二 任务初始化

 1 void osalInitTasks( void )
 2 {
 3   uint8 taskID = 0;
 4
 5   tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
 6   osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
 7
 8   macTaskInit( taskID++ );
 9   nwk_init( taskID++ );
10   Hal_Init( taskID++ );
11 #if defined( MT_TASK )
12   MT_TaskInit( taskID++ );
13 #endif
14   APS_Init( taskID++ );
15 #if defined ( ZIGBEE_FRAGMENTATION )
16   APSF_Init( taskID++ );
17 #endif
18   ZDApp_Init( taskID++ );
19 #if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
20   ZDNwkMgr_Init( taskID++ );
21 #endif
22   SampleApp_Init( taskID );
23 }

3 应用初始化

 1 void SampleApp_Init( uint8 task_id )
 2 {
 3   SampleApp_TaskID = task_id;
 4   SampleApp_NwkState = DEV_INIT;
 5   SampleApp_TransID = 0;
 6
 7   // Device hardware initialization can be added here or in main() (Zmain.c).
 8   // If the hardware is application specific - add it here.
 9   // If the hardware is other parts of the device add it in main().
10
11  #if defined ( BUILD_ALL_DEVICES )
12   // The "Demo" target is setup to have BUILD_ALL_DEVICES and HOLD_AUTO_START
13   // We are looking at a jumper (defined in SampleAppHw.c) to be jumpered
14   // together - if they are - we will start up a coordinator. Otherwise,
15   // the device will start as a router.
16   if ( readCoordinatorJumper() )
17     zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
18   else
19     zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
20 #endif // BUILD_ALL_DEVICES
21
22 #if defined ( HOLD_AUTO_START )
23   // HOLD_AUTO_START is a compile option that will surpress ZDApp
24   //  from starting the device and wait for the application to
25   //  start the device.
26   ZDOInitDevice(0);
27 #endif
28
29   // Setup for the periodic message‘s destination address
30   // Broadcast to everyone
31   SampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;
32   SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
33   SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;
34
35   // Setup for the flash command‘s destination address - Group 1
36   SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;
37   SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
38   SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP;
39
40   // Fill out the endpoint description.
41   SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;
42   SampleApp_epDesc.task_id = &SampleApp_TaskID;
43   SampleApp_epDesc.simpleDesc
44             = (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;
45   SampleApp_epDesc.latencyReq = noLatencyReqs;
46
47   // Register the endpoint description with the AF
48   afRegister( &SampleApp_epDesc );
49
50   // Register for all key events - This app will handle all key events
51   RegisterForKeys( SampleApp_TaskID );
52
53   // By default, all devices start out in Group 1
54   SampleApp_Group.ID = 0x0001;
55   osal_memcpy( SampleApp_Group.name, "Group 1", 7  );
56   aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );
57
58 #if defined ( LCD_SUPPORTED )
59   HalLcdWriteString( "SampleApp", HAL_LCD_LINE_1 );
60 #endif
61 }
时间: 2024-08-24 16:08:07

Ztack学习笔记(2)-系统初始化分析的相关文章

Ztack学习笔记(4)-系统网络分析

//ZDApp.c 1 void ZDApp_Init( uint8 task_id ) 2 { 3 // Save the task ID 4 ZDAppTaskID = task_id; 5 6 // Initialize the ZDO global device short address storage 7 ZDAppNwkAddr.addrMode = Addr16Bit; 8 ZDAppNwkAddr.addr.shortAddr = INVALID_NODE_ADDR;//0xF

C++ Primer 学习笔记_45_STL实践与分析(19)--泛型算法的结构

STL实践与分析 --泛型算法的结构 引言: 正如全部的容器都建立在一致的设计模式上一样,算法也具有共同的设计基础. 算法最主要的性质是须要使用的迭代器种类.全部算法都指定了它的每一个迭代器形參可使用的迭代器类型.比方,假设形參必须为随机訪问迭代器则可提供vector或 deque类型的迭代器,或者提供指向数组的指针.而其它容器的迭代器不能用在这类算法上. C++还提供了另外两种算法模式:一种模式由算法所带的形參定义;还有一种模式则通过两种函数命名和重载的规范定义. 一.算法的形參模式 大多数的

Java学习笔记二:初始化(一)

1.对象初始化 在使用 new 初始化对象时,系统通常使用默认的构造函数,这个构造函数没有返回值,格式为: public class InitializeTest { private int a; // 默认构造函数 public InitializeTest() { } // 自定义构造函数 public InitializeTest(int a) { this.a = a; } } 虽然在使用 new 创建实例时,返回了这个对象的引用,但是这个与没有返回值的void方法不同 //void方法

C++ Primer 学习笔记_46_STL实践与分析(20)--容器特有的算法

STL实践与分析 --容器特有的算法 与其它顺序容器所支持的操作相比,标准库为list容器定义了更精细的操作集合,使它不必仅仅依赖于泛型操作.当中非常大的一个原因就是list容器不是依照内存中的顺序进行布局的,不支持随即訪问,这样,在list容器上就不能使用随即訪问迭代器的算法,如sort等:还有其它的一些算法如:merge.remove.reverse和unique,尽管能够用在list上,但却付出了高昂的性能代价.因此标准库结合list的内部结构,编写出了更快算法: list容器特有的操作

Symfony2 学习笔记之系统路由

mfony2 学习笔记之系统路由 漂亮的URL绝对是一个严肃的web应用程序必须做到的,这种方式使index.php?article_id=57这类的丑陋URL被隐藏,由更受欢迎的像 /read/intro-to-symfony 来替代. 拥有灵活性更为重要,如果你要改变一个页面的URL,比如从/blog 到 /new 怎么办?有多少链接需要你找出来并更新呢? 如果你使用Symfony的router,这种改变将变得很简单. Symfony2 router让你定义更具创造力的URL,你可以map你

Castle ActiveRecord学习笔记三:初始化配置

在使用Castle ActiveRecord的时候,需要两种方式来进行初始化,一种就是通过配置文件,另外一种就是将初始配置进行硬编码,写到程序中来. 当然,一般来说,利用配置文件来进行将会大大简化后期维护,我们首先在程序中添加一个App.config的配置文件,记住,一定要将这个配置文件的生成操作设置为"嵌入的资源"才行.否则会提示如学习笔记二中所出现的问题. 具体的配置如下: <?xml version="1.0" encoding="utf-8&

Ztack学习笔记(3)-系统启动分析

一 系统启动 //OSAL.cvoid osal_start_system( void ) { #if !defined ( ZBIT ) && !defined ( UBIT ) for(;;) // Forever Loop #endif { osal_run_system(); } } 二 操作系统运行 //OSAL.cvoid osal_run_system( void ) { uint8 idx = 0; osalTimeUpdate(); Hal_ProcessPoll();/

Hadoop学习笔记—20.网站日志分析项目案例(三)统计分析

网站日志分析项目案例(一)项目介绍:http://www.cnblogs.com/edisonchou/p/4449082.html 网站日志分析项目案例(二)数据清洗:http://www.cnblogs.com/edisonchou/p/4458219.html 网站日志分析项目案例(三)统计分析:当前页面 一.借助Hive进行统计 1.1 准备工作:建立分区表 为了能够借助Hive进行统计分析,首先我们需要将清洗后的数据存入Hive中,那么我们需要先建立一张表.这里我们选择分区表,以日期作

Java学习笔记二:初始化(二)

这里主要学习初始化,分为: 1.变量初始化 2.构造函数初始化 3.数组初始化 4.继承初始化   1.变量初始化 成员初始化分为两种: (1)成员变量初始化 在定义成员变量时,如果没有给变量赋于初始值,系统会给出一个默认值. 这里有两种选择:要么使用系统的默认初始值,要么自己定义初始值. 系统给出的默认输出值为: boolean false char [ ] byte 0 short 0 int 0 long 0 float 0.0 double 0.0 refenece null char初