A library implementing IEEE 802.15.4 PHY functionality for the MCR20A transceiver. The PHY sublayer provides two services: the PHY data service and the PHY management service interfacing to the PHY sublayer management entity (PLME) service access point (SAP) (known as PLME-SAP). The PHY data service enables the transmission and reception of PHY protocol data units (PSDUs) over the media (radio).

Fork of fsl_phy_mcr20a by Freescale

The Freescale PHY Layer deals with the physical burst which is to be sent and/or received. It performs modulation and demodulation, transmitter and receiver switching, fragmentation, scrambling, interleaving, and error correction coding. The communication to the upper protocol layers is carried out through the Layer 1 Interface.

The PHY Layer is capable of executing the following sequences:

  • I (Idle)
  • R (Receive Sequence conditionally followed by a TxAck)
  • T (Transmit Sequence)
  • C (Standalone CCA)
  • CCCA (Continuous CCA)
  • TR (Transmit/Receive Sequence - transmit unconditionally followed by either an R or RxAck)

In addition to these sequences the PHY Layer also integrates a packet processor which determines whether the packet is MAC-compliant, and if it is, whether it is addressed to the end device. Another feature of the packet processor is Source Address Matching which can be viewed as an extension of packet filtering; however its function is very specific to its intended application (data-polling and indirect queue management by a PAN Coordinator).

Documentation

MCR20A PHY Reference Manual

Committer:
andreikovacs
Date:
Tue Aug 18 12:41:42 2015 +0000
Revision:
0:764779eedf2d
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andreikovacs 0:764779eedf2d 1 /*!
andreikovacs 0:764779eedf2d 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
andreikovacs 0:764779eedf2d 3 * All rights reserved.
andreikovacs 0:764779eedf2d 4 *
andreikovacs 0:764779eedf2d 5 * \file MpmInterface.h
andreikovacs 0:764779eedf2d 6 * This is a header file for the Multiple PAN Manager.
andreikovacs 0:764779eedf2d 7 *
andreikovacs 0:764779eedf2d 8 * Redistribution and use in source and binary forms, with or without modification,
andreikovacs 0:764779eedf2d 9 * are permitted provided that the following conditions are met:
andreikovacs 0:764779eedf2d 10 *
andreikovacs 0:764779eedf2d 11 * o Redistributions of source code must retain the above copyright notice, this list
andreikovacs 0:764779eedf2d 12 * of conditions and the following disclaimer.
andreikovacs 0:764779eedf2d 13 *
andreikovacs 0:764779eedf2d 14 * o Redistributions in binary form must reproduce the above copyright notice, this
andreikovacs 0:764779eedf2d 15 * list of conditions and the following disclaimer in the documentation and/or
andreikovacs 0:764779eedf2d 16 * other materials provided with the distribution.
andreikovacs 0:764779eedf2d 17 *
andreikovacs 0:764779eedf2d 18 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
andreikovacs 0:764779eedf2d 19 * contributors may be used to endorse or promote products derived from this
andreikovacs 0:764779eedf2d 20 * software without specific prior written permission.
andreikovacs 0:764779eedf2d 21 *
andreikovacs 0:764779eedf2d 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
andreikovacs 0:764779eedf2d 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
andreikovacs 0:764779eedf2d 24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
andreikovacs 0:764779eedf2d 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
andreikovacs 0:764779eedf2d 26 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
andreikovacs 0:764779eedf2d 27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
andreikovacs 0:764779eedf2d 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
andreikovacs 0:764779eedf2d 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
andreikovacs 0:764779eedf2d 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
andreikovacs 0:764779eedf2d 31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
andreikovacs 0:764779eedf2d 32 */
andreikovacs 0:764779eedf2d 33
andreikovacs 0:764779eedf2d 34 #ifndef __MPM_H__
andreikovacs 0:764779eedf2d 35 #define __MPM_H__
andreikovacs 0:764779eedf2d 36
andreikovacs 0:764779eedf2d 37 /************************************************************************************
andreikovacs 0:764779eedf2d 38 *************************************************************************************
andreikovacs 0:764779eedf2d 39 * Include
andreikovacs 0:764779eedf2d 40 *************************************************************************************
andreikovacs 0:764779eedf2d 41 ************************************************************************************/
andreikovacs 0:764779eedf2d 42
andreikovacs 0:764779eedf2d 43 #include "EmbeddedTypes.h"
andreikovacs 0:764779eedf2d 44 //#include "fsl_os_abstraction.h"
andreikovacs 0:764779eedf2d 45 #include "PhyInterface.h"
andreikovacs 0:764779eedf2d 46
andreikovacs 0:764779eedf2d 47 /************************************************************************************
andreikovacs 0:764779eedf2d 48 *************************************************************************************
andreikovacs 0:764779eedf2d 49 * Public macros
andreikovacs 0:764779eedf2d 50 *************************************************************************************
andreikovacs 0:764779eedf2d 51 ************************************************************************************/
andreikovacs 0:764779eedf2d 52
andreikovacs 0:764779eedf2d 53 /* The maximun number of MAC instances that can be registered.
andreikovacs 0:764779eedf2d 54 * If set to 0, the MPM is disabled!
andreikovacs 0:764779eedf2d 55 */
andreikovacs 0:764779eedf2d 56 #if !defined(gMpmMaxPANs_c)
andreikovacs 0:764779eedf2d 57 #define gMpmMaxPANs_c 1
andreikovacs 0:764779eedf2d 58 #endif
andreikovacs 0:764779eedf2d 59
andreikovacs 0:764779eedf2d 60 #define gMpmIncluded_d (gMpmMaxPANs_c > 1)
andreikovacs 0:764779eedf2d 61
andreikovacs 0:764779eedf2d 62 #define gMpmPhyPanRegSets_c (2)
andreikovacs 0:764779eedf2d 63 #define gMpmUseDifferentTxPwrLevel_c (0)
andreikovacs 0:764779eedf2d 64 #define gMpmAcquireIsBlocking_d (0)
andreikovacs 0:764779eedf2d 65 #define gMpmInvalidRegSet_c (gMpmPhyPanRegSets_c)
andreikovacs 0:764779eedf2d 66
andreikovacs 0:764779eedf2d 67 /* Dual Pan Dwell settings
andreikovacs 0:764779eedf2d 68 +-----------------+---------------------+
andreikovacs 0:764779eedf2d 69 | PRESCALER | RANGE |
andreikovacs 0:764779eedf2d 70 | bits [1:0] | bits [7:2] |
andreikovacs 0:764779eedf2d 71 +------+----------+---------------------+
andreikovacs 0:764779eedf2d 72 |value | timebase | min - max |
andreikovacs 0:764779eedf2d 73 +------+----------+---------------------+
andreikovacs 0:764779eedf2d 74 | 00 | 0.5 ms | 0.5 - 32 ms |
andreikovacs 0:764779eedf2d 75 | 01 | 2.5 ms | 2.5 - 160 ms |
andreikovacs 0:764779eedf2d 76 | 10 | 10 ms | 10 - 640 ms |
andreikovacs 0:764779eedf2d 77 | 11 | 50 ms | 50 - 3.2 seconds |
andreikovacs 0:764779eedf2d 78 +------+----------+---------------------+
andreikovacs 0:764779eedf2d 79 */
andreikovacs 0:764779eedf2d 80
andreikovacs 0:764779eedf2d 81 /* Dwell Time prescaller (0 to 3) */
andreikovacs 0:764779eedf2d 82 #define mDefaultDualPanDwellPrescaller_c (0x00) // 0,5 ms
andreikovacs 0:764779eedf2d 83 #define mDualPanDwellPrescallerMask_c (0x03)
andreikovacs 0:764779eedf2d 84 #define mDualPanDwellPrescallerShift_c (0)
andreikovacs 0:764779eedf2d 85
andreikovacs 0:764779eedf2d 86 /* Dwell Time value (0 to 63) */
andreikovacs 0:764779eedf2d 87 #define mDefaultDualPanDwellTime_c (0x06)
andreikovacs 0:764779eedf2d 88 #define mDualPanDwellTimeMask_c (0xFC)
andreikovacs 0:764779eedf2d 89 #define mDualPanDwellTimeShift_c (2)
andreikovacs 0:764779eedf2d 90
andreikovacs 0:764779eedf2d 91
andreikovacs 0:764779eedf2d 92 #if (gMpmMaxPANs_c > gMpmPhyPanRegSets_c)
andreikovacs 0:764779eedf2d 93 #error The number of PANs exceeds the number of HW registry sets! This feature is not supported yet.
andreikovacs 0:764779eedf2d 94 #endif
andreikovacs 0:764779eedf2d 95
andreikovacs 0:764779eedf2d 96 /* MPM flags */
andreikovacs 0:764779eedf2d 97 #define gMpmFlagPanCoord_c (1 << 0)
andreikovacs 0:764779eedf2d 98 #define gMpmFlagPromiscuous_c (1 << 1)
andreikovacs 0:764779eedf2d 99 #define gMpmFlagRxOnWhenIdle_c (1 << 2)
andreikovacs 0:764779eedf2d 100
andreikovacs 0:764779eedf2d 101 /************************************************************************************
andreikovacs 0:764779eedf2d 102 *************************************************************************************
andreikovacs 0:764779eedf2d 103 * Public type definitions
andreikovacs 0:764779eedf2d 104 *************************************************************************************
andreikovacs 0:764779eedf2d 105 ************************************************************************************/
andreikovacs 0:764779eedf2d 106
andreikovacs 0:764779eedf2d 107 typedef PACKED_STRUCT mpmConfig_tag{
andreikovacs 0:764779eedf2d 108 bool_t autoMode;
andreikovacs 0:764779eedf2d 109 uint8_t dwellTime;
andreikovacs 0:764779eedf2d 110 uint8_t activeMAC;
andreikovacs 0:764779eedf2d 111 }mpmConfig_t;
andreikovacs 0:764779eedf2d 112
andreikovacs 0:764779eedf2d 113 typedef union panFlags_tag{
andreikovacs 0:764779eedf2d 114 uint16_t all;
andreikovacs 0:764779eedf2d 115 struct{
andreikovacs 0:764779eedf2d 116 uint16_t panCoordinator: 1;
andreikovacs 0:764779eedf2d 117 uint16_t promiscuous: 1;
andreikovacs 0:764779eedf2d 118 uint16_t rxOnWhenIdle: 1;
andreikovacs 0:764779eedf2d 119 uint16_t reserved: 13;
andreikovacs 0:764779eedf2d 120 };
andreikovacs 0:764779eedf2d 121 }panFlags_t;
andreikovacs 0:764779eedf2d 122
andreikovacs 0:764779eedf2d 123 typedef struct panInfo_tag{
andreikovacs 0:764779eedf2d 124 uint8_t flags;
andreikovacs 0:764779eedf2d 125 uint8_t macInstance;
andreikovacs 0:764779eedf2d 126 uint8_t phyRegSet;
andreikovacs 0:764779eedf2d 127 int8_t locked;
andreikovacs 0:764779eedf2d 128 #if (gMpmMaxPANs_c > gMpmPhyPanRegSets_c)
andreikovacs 0:764779eedf2d 129 uint64_t longAddr;
andreikovacs 0:764779eedf2d 130 uint16_t shortAddr;
andreikovacs 0:764779eedf2d 131 uint16_t panId;
andreikovacs 0:764779eedf2d 132 uint8_t channel;
andreikovacs 0:764779eedf2d 133 #endif
andreikovacs 0:764779eedf2d 134 #if gMpmUseDifferentTxPwrLevel_c
andreikovacs 0:764779eedf2d 135 uint8_t pwrLevel;
andreikovacs 0:764779eedf2d 136 #endif
andreikovacs 0:764779eedf2d 137 }panInfo_t;
andreikovacs 0:764779eedf2d 138
andreikovacs 0:764779eedf2d 139 #ifdef __cplusplus
andreikovacs 0:764779eedf2d 140 extern "C" {
andreikovacs 0:764779eedf2d 141 #endif
andreikovacs 0:764779eedf2d 142
andreikovacs 0:764779eedf2d 143 /************************************************************************************
andreikovacs 0:764779eedf2d 144 *************************************************************************************
andreikovacs 0:764779eedf2d 145 * Public memory declarations
andreikovacs 0:764779eedf2d 146 *************************************************************************************
andreikovacs 0:764779eedf2d 147 ************************************************************************************/
andreikovacs 0:764779eedf2d 148
andreikovacs 0:764779eedf2d 149 /************************************************************************************
andreikovacs 0:764779eedf2d 150 *************************************************************************************
andreikovacs 0:764779eedf2d 151 * Public functions
andreikovacs 0:764779eedf2d 152 *************************************************************************************
andreikovacs 0:764779eedf2d 153 ************************************************************************************/
andreikovacs 0:764779eedf2d 154 #if gMpmIncluded_d
andreikovacs 0:764779eedf2d 155
andreikovacs 0:764779eedf2d 156 void MPM_Init( void );
andreikovacs 0:764779eedf2d 157 void MPM_SetConfig( mpmConfig_t *pCfg );
andreikovacs 0:764779eedf2d 158 void MPM_GetConfig( mpmConfig_t *pCfg );
andreikovacs 0:764779eedf2d 159
andreikovacs 0:764779eedf2d 160 int32_t MPM_GetPanIndex( instanceId_t macInstance );
andreikovacs 0:764779eedf2d 161 uint32_t MPM_GetRegSet(uint8_t panIdx);
andreikovacs 0:764779eedf2d 162 uint32_t MPM_GetMacInstanceFromRegSet(uint32_t regSet);
andreikovacs 0:764779eedf2d 163 #define MPM_isPanActive( panIdx ) (MPM_GetRegSet(panIdx) != gMpmInvalidRegSet_c)
andreikovacs 0:764779eedf2d 164
andreikovacs 0:764779eedf2d 165 phyStatus_t MPM_PrepareForTx( instanceId_t macInstance );
andreikovacs 0:764779eedf2d 166 phyStatus_t MPM_PrepareForRx( instanceId_t macInstance );
andreikovacs 0:764779eedf2d 167 phyStatus_t MPM_GetPIB(phyPibId_t pibId, void *pValue, uint8_t panIdx);
andreikovacs 0:764779eedf2d 168 phyStatus_t MPM_SetPIB(phyPibId_t pibId, void *pValue, uint8_t panIdx);
andreikovacs 0:764779eedf2d 169
andreikovacs 0:764779eedf2d 170 #else /* #if gMpmIncluded_d */
andreikovacs 0:764779eedf2d 171
andreikovacs 0:764779eedf2d 172 #define MPM_Init()
andreikovacs 0:764779eedf2d 173 #define MPM_SetConfig( prescaller, dwellTime )
andreikovacs 0:764779eedf2d 174
andreikovacs 0:764779eedf2d 175 #define MPM_GetPanIndex( macInstance ) 0
andreikovacs 0:764779eedf2d 176 #define MPM_GetRegSet( panIdx ) 0
andreikovacs 0:764779eedf2d 177 #define MPM_GetMacInstanceFromRegSet( regSet ) 0
andreikovacs 0:764779eedf2d 178 #define MPM_isPanActive( panIdx ) 1
andreikovacs 0:764779eedf2d 179
andreikovacs 0:764779eedf2d 180 #define MPM_PrepareForTx( macInstance ) gPhySuccess_c
andreikovacs 0:764779eedf2d 181 #define MPM_PrepareForRx( macInstance ) gPhySuccess_c
andreikovacs 0:764779eedf2d 182 #define MPM_GetPIB( pibId, pibValue, panIdx ) gPhySuccess_c
andreikovacs 0:764779eedf2d 183 #define MPM_SetPIB( pibId, pibValue, panIdx ) gPhySuccess_c
andreikovacs 0:764779eedf2d 184
andreikovacs 0:764779eedf2d 185 #endif /* #if gMpmIncluded_d */
andreikovacs 0:764779eedf2d 186
andreikovacs 0:764779eedf2d 187 phyStatus_t MPM_AcquirePAN( instanceId_t macInstance );
andreikovacs 0:764779eedf2d 188 phyStatus_t MPM_ReleasePAN( instanceId_t macInstance );
andreikovacs 0:764779eedf2d 189
andreikovacs 0:764779eedf2d 190 #ifdef __cplusplus
andreikovacs 0:764779eedf2d 191 }
andreikovacs 0:764779eedf2d 192 #endif
andreikovacs 0:764779eedf2d 193
andreikovacs 0:764779eedf2d 194 #endif /*__MPM_H__ */