ZigBee Series Learning Note II (Engineering document Analysis)

Source: Internet
Author: User

The following is reproduced content, because learning ZigBee, a little to tidy up a bit, I hope the author do not blame.

First, download zstack-cc2530.2.5.1a URL http://download.csdn.net/detail/thanksgining/8328925

After download:

Second, installation zstack-cc2530.2.5.1a

After installation:

Components: As the name implies, this is a library file, which puts some zdo,driver,hal,zcl and other library code

Documents: This needless to say that we all know is to put TI development documents, you can read these documents one by one, you are familiar with the protocol stack. A lot of it is a must-read API that tells the protocol stack

Projects: This file folder is the TI protocol stack example program, each example program is in the form of a project to us, learn these examples of the program one or two, basic you can do things

Tools: This file is a program that puts TI's example programs on some host computer, as a tool to use

Components folder

As stated above, there are some library things, HAL is the hardware level of some driver and so on. Mac, Zmac is the MAC layer protocol interface, MT is the API we use almost all can be found here examples. Osal This is the TI's Zstack protocol stack operating system, is event-driven, stack is some zdo and zcl and so on.

Third, open Samleapp.eww project, path: projects\zstack\samples\sampleapp\cc2530db

1, enter the main function, file path: Zmain under the ZMAIN.C

int main (void)

{

/* * Turn off interrupts off all interrupts, in fact is the total interrupt is off * #define Ints_all 0xFF * Final Call EA = 0; */

Osal_int_disable (Ints_all);

/* * Initialization for board related stuff such as LEDs * Initialize system clock, LEDs */

Hal_board_init ();

/* * Make sure supply voltage are high enough to run * check the chip voltage is normal */

Zmain_vdd_check (); Initialize board I/O Initboard (ob_cold);

/* * Initialze HAL Drivers * Initialize ADC, DMA, AES, LED, LCD, KEY * UART, SPI and so on have been initialized in this function, but not implemented * hardware related initialization */

Haldriverinit ();

/* * Initialize NV System * Initialize Flash, memory */

Osal_nv_init (NULL);

/* * Initialize the Mac * Initialize the MAC layer */

Zmacinit ();

/* * Determine the Extended address * Determine IEEE 64-bit addresses */

Zmain_ext_addr ();

#if defined zcl_key_establish//Not defined

Initialize the Certicom certificate information.

Zmain_cert_init ();

#endif

/* * Initialize basic NV Items * Initialize non-volatile variable */

Zginit ();

#ifndef NONWK

Since the AF isn ' t a task, call it ' s initialization routine

Afinit ();

#endif

/* * Initialize the operating system * Initialize OS */

Osal_init_system ();

/* * Allow interrupts all interrupts, in fact, the total interrupt is open * #define INTS_ALL 0xFF * Final Call EA = 1; */

Osal_int_enable (Ints_all);

/* Final Board Initialization * Initialize key * #define OB_READY 2 */

Initboard (Ob_ready);

/* Display information about this device * Print the device information on the LCD

Zmain_dev_info ();

/* Display the device info on the LCD */

#ifdef lcd_supported//Not defined

Zmain_lcd_init ();

#endif

#ifdef WDT_IN_PM1//Not defined

/* If WDT is used, this is a good place to enable it. */

Watchdogenable (WDTIMX);

#endif

/* * No return from the here * operating system, will not return after entry */

Osal_start_system ();

return 0; Shouldn ' t get here.

}//main ()

For an on-chip system, there must be a power supply, crystal/clock, memory and other components, all of our protocol stack must initialize these. As can be seen from the main function, it does initialize the voltage, clock, memory, network, IEEE, System, non-volatile variables and other initialization, which are mainly based on the specific hardware platform. The Zstack protocol stack uses a multi-tasking mechanism and uses polling to perform these tasks. After calling Osal_start_system to start the system, the system begins to poll indefinitely to perform each task. Before we look at how to poll all the tasks after the system starts, let's take a look at the system initialization function Osal_init_system

Uint8 Osal_init_system (void)

{

/* * Initialize the memory Allocation System * Initialize RAM allocation */

Osal_mem_init ();

/* * * * Initialize the message queue * Initialize messages queuing */

/*typedef void * osal_msg_q_t; * osal_msg_q_t Osal_qhead;

/*osal_qhead is a void pointer that can point to any type */

Osal_qhead = NULL;

/* * Initialize the timers * function has only one statement: Osal_systemclock = 0; * While the static uint32 Osal_systemclock; * Initialize timed timing variable to 0 */

Osaltimerinit ();

/* * Initialize the Power Management System * To initialize the supply management * *

Osal_pwrmgr_init ();

/* * Initialize the system tasks. * Initialize System Tasks */

Osalinittasks ();

/* * Setup efficient search for the first free block of heap. * Set a valid search for the first heap of free blocks */

Osal_mem_kick ();

return (SUCCESS);

}

The initialization of the system is mainly from the operating system level to do the corresponding initialization, such as memory management, power management, Message Queuing and other initialization. The timer initialization is due to the fact that the Zstack-osal system uses timed capture task events. This is primarily the System task initialization function Osalinittask (), which initializes all tasks for the entire system.

ZigBee Series Learning Note II (Engineering document Analysis)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.