原创 Chapter 1 802.15.4 MAC/PHY Software Overview

2007-6-4 14:44 2884 2 2 分类: 通信

802.15.4 MAC/PHY Software Overview<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


This chapter describes the 802.15.4 background, and describes Freescale’s 802.15.4 MAC/PHY device types and libraries, parametric details, build environment, source file structure, and hardware setup.


1.1Understanding the 802.15.4 Standard


The 802.15.4 is a standard developed for Wireless Personal Area Networks (WPANs). WPANS convey information over short distances among their participants in the network. They enable small, power efficient, inexpensive solutions to be implemented for a wide range of applications and types of devices. Some key characteristics of an 802.15.4 network are:


    An over the air data rate of 250 kbit/s in the 2.4 GHz band


    16 independent communication channels in the 2.4 GHz band


    Large networks (up to 65534 devices)


    Devices use carrier sense multiple access with collision avoidance (CSMA-CA) to access the medium


    Devices use Energy Detection (ED) for channel selection


    Devices inform the application about the quality of the wireless link - Link Quality Indication (LQI)


The 802.15.4 Standard defines two network topologies in which both topologies use one and only one central device (the PAN coordinator). The PAN coordinator is the principal controller of the network.


    Star Network Topology — In a star network, all communication in the network is either to the PAN coordinator or from the PAN coordinator. That is, communication between non-PAN coordinator devices is not possible.


    Peer-to-Peer Network Topology — In a peer-to-peer network, communication can occur between any two devices in the network as long as they are within range of one another.


 


<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />


Figure 1-1. Peer-to- Peer and Star Network (No PAN Coordinator)


If a device wants to join an 802.15.4 network it will have to associate with a device that is already part of the network. That allows other devices to associate with it. A device can only be associated with one other device but multiple devices can be associated with the same device as shown in Figure 1-1. A device that has other devices associated with it is a coordinator to those devices. A coordinator can provide synchronization services to the devices that are associated with it through the transmission of beacon frames as shown in Figure 1-2. In a star network there will be only one PAN coordinator, but in a peer-to-peer network there can be multiple coordinators plus the PAN coordinator.


 



Figure 1-2. Peer and Star Network (With PAN Coordinator)


A network (both star and peer-to-peer) can operate in either beacon mode or non-beacon mode. In beacon mode, all coordinators within the network transmit synchronization frames (beacon frames) to its associated devices and all data transmissions between the coordinator and its associated devices occur in the active period following the beacon frame as shown in Figure 1-3.


 



Figure 1-3. Beacon Frame Timing


In non-beacon mode data transmissions data transmission can take place at any time. For both non-beacon and beacon networks, the application can choose to transmit data in two ways.


Direct data transfer - Data exchanged between a device and a coordinator in a non-beacon network using direct data transfer takes place as soon as the channel is free using CSMA-CA


Indirect data transfer - Data from a device to a coordinator in a beacon network using indirect data transfer is sent in the CAP as soon as the channel is free using CSMA-CA


Beaconed Tree Mode — A peer-to-peer network operating in beacon mode will experience beacon collision which can result in the possible loss of synchronization. The ZigBee 1.0 specification outlines the Beaconed Tree Mode, which is a synchronized peer-to-peer network topology. An advantage of a Beaconed Tree Mode network is lower power requirements. A Beaconed Tree Mode network node is active for a short duration (the active portion of the superframe) and it enters a low power mode (sleep) during inactive periods of the superframe.The Freescale 802.15.4 software supports Beaconed Tree Mode as described in the 805.15.4 MyWirelessApp User’s Guide (802154MYASUG).


1.2 System Overview


Figure 1-4 shows a block diagram of the system. The application is using the lower layers to implement a wireless application based on the Freescale 802.15.4 software.


 



Figure 1-4. System Block Diagram


The application can theoretically be anything and is entirely up to the user. Some examples are:


•Dedicated MAC application


•ZigBee network layer


•Proprietary stack


The layer below the application as shown in Figure 1-4, is the 802.15.4 MAC (or just MAC). The MAC provides three interfaces to the application.


1.MLME interface - This interface is used for all 802.15.4 MAC commands. For example, the application must use this interface to send the MLME-ASSOCIATE.request primitive and it will also receive the MLME-ASSOCIATE.confirm primitive on this interface. This interface is defined in the 802.15.4 Standard.


2.MCPS interface - This interface is used for all 802.15.4 data related primitives. The application must use this interface in order to send and receive data. This interface is defined in the 802.15.4 Standard.


3.ASP interface - This interface is used for various application support features. For example, the application can request that the hardware must enter a low power mode. This interface is proprietary to Freescale.


As shown in Figure 1-4, the two layers at the bottom are the PHY and the actual radio (including hardware driver). The application does not access the PHY and hardware layer directly.


NOTE


The application must use the three MAC interfaces to implement the desired functionality. Chapter 3, “Interfacing to the 802.15.4 MAC Software” describes the interfaces in complete detail.


 


1.3 802.15.4 MAC/PHY Software Device Types and Libraries


This section describes the suite of Freescale 802.15.4 MAC/PHY software Device Types and their related libraries. The different 802.15.4 MAC/PHY software Device Types offer various degrees of code sizes by reducing functionality. Table 1-1 shows the relationship between each library and any excluded functionality.


NOTE


The code sizes as shown in Table 1-1 are for the HC(S)08 family of MCUs.


Table 1-1. MAC/PHY Software Device Type Functionality



 Device Type


Description


Typical Usage


Mac Library File Name


Code Size


FFD


Full-blown FFD. Contains all 802.15.4 features including security.


PAN Coordinator, Coordinator, Router, or End-device.


Includes Beacon Mode support, GTS, parameter verification and security.


802.15.4_MAC_FFD.Lib


35.4kB


FFDNB


Same as FFD but no beacon capability.


PAN Coordinator, Coordinator, Router, or End-device.


No beacon capability is included, making this Device Type incapable of joining a beacon network. It can transmit/receive beacons for scanning.


Includes security and parameter verification.


802.15.4_MAC_FFDNB.Lib


24.2kB


FFDNBNS


Same as FFD but no beacon and no security capability.


PAN Coordinator, Coordinator, Router, or End-device.


No beacon capability is included, making this Device Type incapable of joining a beacon network. It can transmit/receive beacons for scanning.


Security is not supported.


802.15.4_MAC_FFDNBNS.Lib


19.7kB


FFDNGTS


Same as FFD but no GTS capability.


PAN Coordinator, Coordinator, Router, or End-device.


Lacks the ability to communicate using GTS, but may participate in a Beacon Network.


Includes security.


802.15.4_MAC_FFDNGTS.Lib


31.6kB


RFD


Reduced function device. Contains 802.15.4 RFD features.


Operates as an End-device only and can participate in beacon networks.


Includes security.


802.15.4_MAC_RFD.Lib


26.0kB


RFDNB


Same as RFD but no beacon capability.


Operates as an End-device only, and can not participate in beacon networks.


Includes security


802.15.4_MAC_RFDNB.Lib


21.3kB


RFDNBNS


Same as RFD but no beacon and no security capability.


Can operate as an End-device only, and can not participate in beacon networks.


Security is not supported.


802.15.4_MAC_RFDNBNS.Lib


16.8kB


 


The code size as shown in Table 1-1 is for the complete Freescale 802.15.4 MAC software library. The MAC is available in library format only because it is independent of the hardware platform for the user’s 802.15.4 application.


The PHY is available in source code format because it is dependent on the hardware platform for the user’s 802.15.4 application. For example, if users want to run the Freescale 802.15.4 MAC/PHY software on their own hardware platform, they may need to change the definition of the connections between the HCS08 MCU and the MC1319x. See Section 1.7, “Configuring the 802.15.4 MAC/PHY Software (Users Hardware Platform)” for a detailed description of how to make the Freescale 802.15.4 MAC/PHY software run on the user’s own hardware platform.


For MC1321x platforms, the HCS08 MCU and transceiver are bonded with fixed connections in the SiP, but users may still control items such as antenna control by customizing the PHY driver. See Section 1.7, “Configuring the 802.15.4 MAC/PHY Software (Users Hardware Platform)” for a detailed description of how to make modifications to the Freescale 802.15.4 PHY driver software.


NOTE


The PHY is independent of whether the end user application is a Full Function Device or a Reduce Function Device.


<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />1.3.1   Full Function Device (FFD) Device Type


The Freescale 802.15.4 MAC/PHY software FFD type is an 802.15.4 Standard compliant Full Functional Device that includes all MAC features. It can be used in applications that require both device and coordinator functionality such as ZigBee routers.


Users should compile their application with the 802.15.4_MAC_FFD library to create a device with FFD capabilities.


1.3.2   Full Function Device With No GTS (FFDxxNGTSxx) Device Types


The Freescale 802.15.4 MAC/PHY software FFDxxNGTSxx Device Types are 802.15.4 Standard compliant FFDs that exclude GTS functionality. These can be used in applications that require both device and coordinator functionality such as ZigBee routers. These libraries cannot be used for applications that require GTS data transmissions.


Users should compile their application with the 802.15.4_MAC_FFDxxNGTSxx libraries to create a device with FFDNGTS capabilities.


1.3.3   Full Function Device No Beacon (FFDxxNBxx) Device Types


The Freescale 802.15.4 MAC/PHY software FFDxxNBxx Device Types are 802.15.4 compliant Full Functional Devices that exclude beacon functionality. These can be used in applications that require both device and coordinator functionality such as ZigBee routers. These libraries cannot be used for creating beaconed networks.


Users should compile their application with the 802.15.4_MAC_FFDxxNBxx libraries to create a device with FFDNB capabilities.


1.3.4   Full Function Device No Security (FFDxxNSxx) Device Types


The Freescale 802.15.4 MAC/PHY software FFDxxNSxx Device Types are 802.15.4 compliant Full Functional Devices that exclude security functionality. These can be used in applications that require both device and coordinator functionality such as ZigBee routers. These libraries cannot be used for applications that require encrypted or otherwise secured transactions.


Users should link their application with the 802.15.4_MAC_FFDxxNSxx libraries to create a device with FFDNS capabilities.


1.3.5   Full Function Device Pan Only (FFDPxx) Device Types


The Freescale 802.15.4 MAC/PHY software FFDPxx Device Types are 802.15.4 compliant Full Functional Devices which can be used in applications that require only the coordinator functionality. These libraries cannot be used for applications that require end device capabilities.


Users should link their application with the 802.15.4_MAC_FFDPxx libraries to create a device with FFDP capabilities.


1.3.6   Full Function Device ZigBee Security(FFDxxZSxx) Device Types


The Freescale 802.15.4 MAC/PHY software FFDxxZSxx Device Types are 802.15.4 compliant Full Functional Devices. These can be used in applications that require implementing their own security layer, using the security module provided by the MAC.


Users should link their application with the 802.15.4_MAC_FFDxxZSxx libraries to create a device with FFDZS capabilities.


1.3.7   Reduced Function Device (RFD) Device Type


The Freescale 802.15.4 MAC/PHY software RFD Device Type is an 802.15.4 compliant Reduced Functional Device. It can be used in applications that require only the device functionality.


Users should compile their application with the 802.15.4_MAC_RFD library to create a device with RFD capabilities.


1.3.8   Reduced Function Device No Beacon (RFDxxNBxx) Device Types


The Freescale 802.15.4 MAC/PHY software RFDNB Device Types are 802.15.4 compliant Reduced Functional Device that exclude beacon functionality. These can be used in applications that only require device functionality such as leaf devices (end-devices with no child devices). This library cannot be used for applications that need to participate in beaconed networks.


Users should compile their application with the 802.15.4_MAC_RFDxxNBxx libraries to create a device with RFDNB capabilities.


1.3.9   Reduced Function Device No Security (RFDxxNSxx) Device Types


The Freescale 802.15.4 MAC/PHY software RFDxxNSxx Device Types are 802.15.4 compliant Reduced Functional Devices that exclude security functionality. These can be used in applications that only require device functionality such as leaf devices (end-devices with no child devices). This library cannot be used for applications that require encrypted or otherwise secured transactions.


Users should compile their application with the 802.15.4_MAC_RFDxxNSxx libraries to create a device with RFDNS capabilities.


1.3.10 Reduced Function Device ZigBee Security (RFDxxZSxx) Device Types


The Freescale 802.15.4 MAC/PHY software RFDxxNVxx Device Types are 802.15.4 compliant Reduced Functional Device. These can be used in applications that only require device functionality, such as leaf devices (end-devices with no child devices) and that require implementing their own security layer by using the security module provided in the MAC.


Users should compile their application with the 802.15.4_MAC_RFDxxZSxx libraries to create a device with RFDZS capabilities.


1.4       802.15.4 MAC/PHY Parametric Information


The following list shows the main parametric information for the Freescale 802.15.4 MAC/PHY software. The clock requirements stated here are for an HC(S)08 based MCU.


    When running in beacon mode the MCU must run at a minimum clock frequency of 16 MHz to fulfill the 802.15.4 Standard timing requirement for all 802.15.4 Standard features


    When running in non beacon mode the MCU can also run at a clock frequency of 8 MHz


    Within a period of 64µs, the application must disable the MC1319x/MC1321x interrupts for a maximum duration of 10µs, when running at 16 MHz


    Within a period of 64µs, the application must disable the MC1319x/MC1321x interrupts for a maximum duration of 7µs, when running at 8 MHz


    The frequency of the SPI that connects the HCS08 MCU to the transceiver must be half of the HCS08 clock speed


1.5      802.15.4 MAC/PHY Software Build Environment


Freescale 802.15.4 MAC/PHY applications can be generated using the Freescale BeeKit Wireless Connectivity Toolkit. For more information on how to create wireless applications using BeeKit, see the BeeKit Wireless Connectivity Toolkit User’s Guide (BKWCTKUG).


This section describes the Freescale 802.15.4 MAC/PHY software build environment. The Freescale 802.15.4 MAC/PHY software is built using the IDE CodeWarrior Development Studio for Freescale HC08.


Users should employ the Freescale_802.15.4_MAC_PHY_SW_FOR_STACK_V50.mcp file if development is based on the IDE CodeWarrior Development Studio for Freescale HC08.


1.5.1         Adding User Applications to the Build Environment


This Freescale 802.15.4 MAC/PHY software includes the Freescale 802.15.4 MAC libraries, the Freescale 802.15.4 PHY source code, and CodeWarrior project files (.mcp) only. No application library, code, or documentation is included in this release. Adding a user application directly on top of the build environment is possible, but it requires both in depth knowledge of the 802.15.4 Standard and wireless application experience. Freescale strongly recommends that users base their application development on the Freescale 802.15.4 MAC/PHY My_Wireless_App_demo application example software. This software is described in detail in the Freescale 802.15.4 MyWirelessApp Software User’s Guide (802154MWASUG). Users can download the Freescale 802.15.4 My_Wireless_App_demo application example software and the Freescale 802.15.4 MyWirelessApp Software User’s Guide from the Freescale ZigBee home page at www.freescale.com/zigbee.


1.6       Freescale 802.15.4 MAC/PHY Software Source File Structure


This section describes the source file structure of the Freescale 802.15.4 MAC/PHY software.


The Freescale 802.15.4 MAC/PHY software uses the following file extensions:


Source code*.c *.h


Libraries*.lib


ELF format targets*.elf


S19 record format targets*.s19


Memory maps*.map


NOTE


All targets are drive and main directory independent. The .mcp project file and the MAC/PHY libraries have a version number added to the end of the file name for version tracking.


The Freescale 802.15.4 MAC/PHY software is arranged in the following file structure:


 


|———Application


| |———Configure Configuration header files


| |———Init Application initialization code


| |———Interface 802_15_4.h header file


| |———Source Application source files


| |———UartUtil UART helper functions


|———Bin Empty output directory


|———MacStandalone


| |———Interface MAC interface header files


| |———Mac


| | |———802.15.4_MAC_FFD.Lib library


| | |———802.15.4_MAC_FFDNB.Lib library


| | |———802.15.4_MAC_FFDNBNS.Lib library


| | |———802.15.4_MAC_FFDNGTS.Lib library


| | |———802.15.4_MAC_RFD.Lib library


| | |———802.15.4_MAC_RFDNB.Lib library


| | |———802.15.4_MAC_RFDNBNS.Lib library


| |———Phy


| | |———Interface PHY interface header files


| | |———Isr Interrupt handlers


| | |———Primitives Source code of PHY primitives


|———PLM


| |———Interface Platform interface files


| |———PRM Beestack.prm


| |———Source Source code for drivers


|———SSM


| |———TS Task scheduler source code


| |———ZTC ZigBee test client source code


|———mcp CodeWarrior project file


 


 


1.7     Configuring the 802.15.4 MAC/PHY Software (Users Hardware Platform)


This section describes how to redefine the HCS08 clock speed and how to change the interconnection between the HCS08 MCU and the MC1319x. This enables users to run their 802.15.4 application on their own hardware platform.


1.7.1         Redefining the HCS08 Clock Speed


By properly configuring the Freescale 802.15.4 MAC/PHY software, it is possible to run the HSC08 MCU at various clock speeds. Freescale recommends adding a compiler define “Type_XXXX”, where XXXX corresponds to the selected MAC library, when the MAC/PHY libraries are linked with the application software. That is to specify “Type_FFD” for MAC FFD library, “Type_RFD” for MAC RFD library, etc. The MAC libraries were also built using this #define to enable the functionality required for a specific Device Type.


However, the system clock is not directly controlled by the libraries but by the application. In the Freescale 802.15.4 example application My_Wireless_App_demo, the system clock is controlled from the files in the sys directory. Freescale recommends copying and reusing the files from these examples.


The “Type_XXXX” define selects a minimum system bus frequency in the AppToPlatformConfig.h header file in the interface directory for each Device Type. The application can choose to use a higher system bus frequency, but Freescale recommends to not use a lower one. If users want to use a higher frequency than necessary, they need to define one of the following settings on their project:


#define SYSTEM_CLOCK_16MHZ


#define SYSTEM_CLOCK_16_78MHZ


The above defines are used in the NV_Data.c file to setup the correct system bus frequency.


NOTE


Some MCU serial port baud rates are only available at certain system clock frequencies.


1.7.2   Changing the Interconnection Between the HCS08 MCU and the MC1319x


The PHY is provided with standard interconnections. There is one each for the Freescale 13192-SARD and 13192-EVB evaluation boards and one for the AXIOM AXM-0308, HCS08 development board. If users require a different interconnection for their own hardware platform, the PHY files must be changed. For this reason the PHY library is delivered as source code.


NOTE


The MC1321x SiP contains fixed internal interconnection between its internal HCS08 MCU and the transceiver. Therefore, no changes can be made for this mapping. The NCB and SRB use the MC1321x, so this section is not applicable to those boards.


In the MacPhy.h header file, a set of macros is defined which are used directly by the PHY layer for antenna control and other functions. In addition to the macros used directly by the PHY layer, the GPIO ports on the MCU must be set correctly. The port settings are controlled by an additional set of macros which are configured in the PortConfig.h file. The PHY function PHY_HW_Setup() uses these macros to set up the ports. Therefore, PHY_HW_Setup() must be called before calling the InitializePhy() function.


The macros in the PortConfig.h file can easily be changed for a new hardware configuration. All macros use the following definitions which must be redefined if other port and pin mappings are used. In the following example code, the settings are for the Freescale 13192-SARD and 13192-EVB evaluation boards.


 


// Define HW pin mapping


  #define gMC1319xAttnPort     PTBD


  #define gMC1319xRxTxPort     PTBD


  #define gMC1319xResetPort    PTBD


 


  #define gMC1319xAttnMask_c   (1<<2)


  #define gMC1319xRxTxMask_c   (1<<3)


  #define gMC1319xResetMask_c  (1<<1)


 


  #define gMC1319xGPIO1Port    PTBD


  #define gMC1319xGPIO2Port    PTBD


  #define gMC1319xAntSwPort    PTBD


 


  #define gMC1319xGPIO1Mask_c  (1<<4)


  #define gMC1319xGPIO2Mask_c  (1<<5)


  #define gMC1319xAntSwMask_c  (1<<6)


 


  #define gMC1319xSpiTxD1Mask_c  (1<<0)


  #define gMC1319xSpiRxD1Mask_c  (1<<1)


  #define gMC1319xSpiSsMask_c    (1<<2)


  #define gMC1319xSpiMisoMask_c  (1<<3)


  #define gMC1319xSpiMosiMask_c  (1<<4)


  #define gMC1319xSpiSpsckMask_c (1<<5)


 

文章评论0条评论)

登录后参与讨论
我要评论
0
2
关闭 站长推荐上一条 /2 下一条