Timac Study Notes 1

Source: Internet
Author: User

Timac is the introduction of TI company based on the IEEE 802.15.4 Communication protocol stack, the compiler environment for IAR, the use of IAR clib Library, Clib Library provides a lightweight C library, it does not support embedded C + +. Applicable to RF4CE protocol and Zigbee-pro products.

Currently learning the MAC layer protocol version is 1.5.0.

Why do you learn Timac? In the development of ZigBee-based projects, encountered a number of problems on the ground, and then in depth, found that the card in the lower-level package of the library, timac than zstack lower levels of openness, in order to better understand the wireless transmission of some of the details of the problem, will go to see Timac protocol.

Characteristics

1. Multi-platform support, cc2538,2530,2531 wireless mcus,cc2520 transceiver,

2. Support for star topology, point-to-point, bit-to-multipoint

3. Support synchronous beacon and asynchronous non-beacon mode. The current zstack is not supported for synchronous beacon networks.

4. Support network security, no copyright and license fees

Application areas

1. Wireless point-to-point and point-to-multipoint transmission environments

2. Battery-powered equipment, need to support ACK and retransmission of the environment, low-rate wireless transmission requirements (<100kbps)

Learning steps

1. First from the TIMAC to bring the document look, first general browsing once, later encountered related functions, can remember where to find on it.

802.14.4 MAC api.pdf all in three parts

1.1 documentation purposes, references and related abbreviations

1.2 API overview, divided into internal interface mechanism, data interface and management interface, common constants and structure

1.3 The following functions are used to introduce the relevant interfaces, initialize interfaces, data interfaces, management interfaces, extension interfaces, callback interfaces, and some common usage scenarios. Each part of the interface according to the introduction, general constants and structure, function interface in detail described, well-organized, clear level, reference value is very high.

2. See Timac provided routines

The catalog is located in D:\Texas Instruments\timac 1.5.0\projects\mac\sample\cc2530\iar project, and the project name is MSA_CC2530.EWW. This project has four configurations, as shown in:

The CC2350 routines of the TIMAC provide two different size program configurations, which are divided into bank (maximum available 256K flash) and non-banked (maximum usable 64K flash). Provides both safe and normal data transfer modes, For normal and secure. Program default configuration: Normal, meaning is normal transmission, non-banked configuration, a total of 4 different configuration options, meaning and so on.

The IEEE 802.15.4 specification defines 16 channels within the 2.4G frequency range, numbering from 11 to 26.

Let's start by analyzing the overall structure of the instance program.

From the task array (see), there are only three tasks running in the whole system, one is MAC layer, one application layer MSA, and one hardware abstraction layer HAL.

The MAC layer event processing must have been sealed off, where is the seal? The code must not be found, search Lib file, found the following several suspicious files.

Obviously, from the name point of view, the MAC layer of the relevant operation function is sealed here, four kinds of library, on the project configuration inside the four kinds of situations, corresponding to the. From the time of size and compile generation, the security transfer requires more Mac libraries than the normal transmission of Mac, banked mode is larger than the non-banked library, the reason is obvious, there is no need to explain. Where is the path to the library file referenced in the IAR? From the option for Node->linker->extra options, it should be to include the path of the reference library, but the default configuration is not included, is it less? Or is it contained somewhere else? This is not a point to understand.

or return to the program itself, Timac inside the routines, provides a basic protocol and function interface for testing and verifying the IEEE 802.15.4 MAC layer related operations. Ability to demonstrate device role creation, join/build networks, connect and disconnect, send and receive data, and beacon support.

The sample program consists of 4 parts, main, initialization, system event handling, and callback function processing.

When compiling errors, you need to modify the number of virtual registers used by the IAR, and change the original value to 8 to compile the pass.

The macro configuration differences of four different engineering configurations are given, which makes it easy to control the code later.

Project configuration
Normal Secure Normal-banked Normal-secure
Default macro Configuration

Cc2530eb
Power_saving
Hal_aes=false
Hal_dma=false
Hal_flash=false
Non_banked
Feature_enhanced_beacon
Feature_green_power

Cc2530eb
Power_saving
Feature_mac_security

Hal_flash=false

Non_banked

Feature_enhanced_beacon
Feature_green_power

Cc2530eb
Power_saving
Hal_aes=false
Hal_dma=false
Hal_flash=false


Feature_enhanced_beacon
Feature_green_power

Cc2530eb
Power_saving
Feature_mac_security


Hal_flash=false


Feature_enhanced_beacon
Feature_green_power

In the event handler function of the MSA, the various packets received are processed uniformly by a pointer of type maccbackevent_t. How did this happen? Originally, maccbackevent_t is a variable pointer of an enumeration type whose prototype is defined as follows:

typedef union{maceventhdr_t HDR;           macmlmeassociateind_t Associateind; /*Mac_mlme_associate_ind*/macmlmeassociatecnf_t associatecnf; /*mac_mlme_associate_cnf*/macmlmedisassociateind_t Disassociateind; /*Mac_mlme_disassociate_ind*/macmlmedisassociatecnf_t disassociatecnf; /*mac_mlme_disassociate_cnf*/macmlmebeaconnotifyind_t Beaconnotifyind; /*Mac_mlme_beacon_notify_ind*/macmlmeorphanind_t Orphanind; /*Mac_mlme_orphan_ind*/macmlmescancnf_t scancnf; /*mac_mlme_scan_cnf*/macmlmestartcnf_t startcnf; /*mac_mlme_start_cnf*/macmlmesynclossind_t Synclossind; /*Mac_mlme_sync_loss_ind*/macmlmepollcnf_t pollcnf; /*mac_mlme_poll_cnf*/macmlmepollind_t Pollind; /*Mac_mlme_poll_ind*/macmlmecommstatusind_t Commstatusind; /*Mac_mlme_comm_status_ind*/macmcpsdatacnf_t datacnf; /*mac_mcps_data_cnf*/macmcpsdataind_t Dataind; /*Mac_mcps_data_ind*/macmcpspurgecnf_t purgecnf; /*mac_mcps_purge_cnf*/} maccbackevent_t;

From the name, you should be able to see what the clues. For each command, almost all have an ind and CNF. wherein, IND should be refers to the issue of this command, and for the CNF for the MAC layer to complete this command to the application layer confirmation, simple to understand, Ind is the order to send out, CNF is the bottom of the command after the completion of the application layer of the confirmation information or the underlying data received to the application layer of information, (Corrected the understanding that the IND and CNF are actually notifications of events sent to the application layer based on the commands received by the MAC layer, except that the receiving command is different from the source.) The CNF-type event notification is a local Mac receiving a request from a local application, which is then fed back to the local application tier, and the IND type event notification is the local Mac receiving a request sent by the foreign MAC layer, and then feedback to the local application layer, well, that's the difference between them, right? ^_^. As an example to establish a connection:

Mac layer of the SYS_EVENT_MSG callback event processing a total of 16, just exactly enough two bytes of 16 bits, one more state information will not be. In addition to sys_event_msg, there are rotation request event msa_poll_event for terminal devices, data sending event msa_send_event.

In the call to send data function msa_mcpsdatareq, there is a directmsg parameter, from the name, can probably guess what it means, send the message directly. According to the following code, when this parameter is true, the coordinator sends the data directly to the terminal, Instead of caching the data, wait for the terminal to send poll to request the data. As a coordinator, when the MAC layer is idle, its receiver should always remain open, as a terminal device, the MAC layer receiver settings depend on msa_isdirectmsg, if it is true, You need to remain open when the MAC layer receiver is idle.

The Mac_cbackevent function, which is a callback function of the MAC layer, is used to pass events that occur on the MAC layer to the application layer, where the osal message space should be allocated, the MAC layer message is copied to the Osal message structure, and then passed to the application layer. Because this callback function may be called frequently in the context of a task or interrupt, it needs to be designed to be reentrant. At the beginning of the function, in order to unify the length information of different messages, take a message length array

At the beginning of the function, use the

To assign different message lengths based on the different event types, this is a good practice to learn to record.

From the use of the instructions, for the same project, after the program starts, its behavior depends on the external keys, before any physical action, there will only be a flashing light behavior.

For the coordinator, there are beacon enable and non-beacon enable two modes, for terminal equipment, there is a direct transmission mode and indirect transmission mode, so they have 22 combinations between them have 4 network conditions. As the following table:

Well, we'll learn here today, and tomorrow we will continue to drill down into each code execution process to learn the various design ideas and processes of the TIMAC layer, laying the foundation for future development.

Timac Study Notes 1

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.