NXP / fsl_phy_mcr20a

Fork of fsl_phy_mcr20a by Freescale

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PhyInterface.h Source File

PhyInterface.h

Go to the documentation of this file.
00001 /*!
00002 * Copyright (c) 2015, Freescale Semiconductor, Inc.
00003 * All rights reserved.
00004 *
00005 * \file PhyInterface.h
00006 *
00007 * Redistribution and use in source and binary forms, with or without modification,
00008 * are permitted provided that the following conditions are met:
00009 *
00010 * o Redistributions of source code must retain the above copyright notice, this list
00011 *   of conditions and the following disclaimer.
00012 *
00013 * o Redistributions in binary form must reproduce the above copyright notice, this
00014 *   list of conditions and the following disclaimer in the documentation and/or
00015 *   other materials provided with the distribution.
00016 *
00017 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
00018 *   contributors may be used to endorse or promote products derived from this
00019 *   software without specific prior written permission.
00020 *
00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00022 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00025 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00028 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 */
00032 
00033 #ifndef _PHY_INTERFACE_H
00034 #define _PHY_INTERFACE_H
00035 
00036 
00037 /************************************************************************************
00038 *************************************************************************************
00039 * Include
00040 *************************************************************************************
00041 ************************************************************************************/
00042 
00043 #include "PhyTypes.h "
00044 //#include "Messaging.h"
00045 #include "PhyConfig.h "
00046 
00047 /************************************************************************************
00048 *************************************************************************************
00049 * Public macros
00050 *************************************************************************************
00051 ************************************************************************************/
00052 
00053 /* Constants */
00054 #ifndef gMaxPhyTimers_c
00055 #define gMaxPhyTimers_c                 (5)
00056 #endif
00057 
00058 #ifdef gPHY_802_15_4g_d
00059 #define gPhySeqStartAsap_c              (0xFFFFFFFFFFFFFFFF)
00060 #else
00061 #define gPhySeqStartAsap_c              (0xFFFFFFFF)
00062 #endif
00063 
00064 /* XCVR active/idle power modes */
00065 #define gPhyDefaultActivePwrMode_c gPhyPwrAutodoze_c /* Do not change! */
00066 #define gPhyDefaultIdlePwrMode_c   gPhyPwrAutodoze_c
00067 
00068 /************************************************************************************
00069 *************************************************************************************
00070 * Public prototypes
00071 *************************************************************************************
00072 ************************************************************************************/
00073 
00074 /************************************************************************************
00075 *************************************************************************************
00076 * Public type definitions
00077 *************************************************************************************
00078 ************************************************************************************/
00079 
00080 typedef enum
00081 {
00082 #include "PhyMessages.h "
00083 }phyMessageId_t;
00084 
00085 typedef enum{
00086     gPhyPwrIdle_c,
00087     gPhyPwrAutodoze_c,
00088     gPhyPwrDoze_c,
00089     gPhyPwrHibernate_c,
00090     gPhyPwrReset_c
00091 }phyPwrMode_t;
00092 
00093 typedef  struct pdDataReq_tag
00094 { 
00095     phyTime_t               startTime;  // absolute  
00096     uint32_t                txDuration; // relative
00097     phySlottedMode_t        slottedTx;
00098     phyCCAType_t            CCABeforeTx;
00099     phyAckRequired_t        ackRequired;
00100     uint8_t                 psduLength;
00101 #ifdef gPHY_802_15_4g_d 
00102     phyPHR_t                phyHeader;
00103     uint8_t                 macDataIndex;
00104     uint8_t                 fillFifoBlockLength;    
00105 #endif  // gPHY_802_15_4g_d 
00106     uint8_t *               pPsdu; 
00107 } pdDataReq_t;
00108 
00109 typedef  struct pdDataCnf_tag
00110 {
00111     phyStatus_t             status;
00112 } pdDataCnf_t;
00113 
00114 typedef  struct pdDataInd_tag
00115 {
00116     phyTimeTimestamp_t      timeStamp;
00117     uint8_t                 ppduLinkQuality;
00118     uint8_t                 psduLength;
00119     uint8_t *               pPsdu;
00120 #ifdef gPHY_802_15_4g_d 
00121     uint32_t                crcValue;
00122     bool_t                  crcValid;
00123 #endif
00124 } pdDataInd_t;
00125 
00126 typedef  struct pdIndQueueInsertReq_tag
00127 {
00128     uint8_t                 index;
00129     uint16_t                checksum;
00130 } pdIndQueueInsertReq_t;
00131 
00132 typedef  struct pdIndQueueInsertCnf_tag
00133 {
00134     phyStatus_t             status;
00135 } pdIndQueueInsertCnf_t;
00136 
00137 typedef  struct pdIndQueueRemoveReq_tag
00138 {
00139     uint8_t                 index;
00140 } pdIndQueueRemoveReq_t;
00141 
00142 typedef  struct plmeEdReq_tag
00143 {
00144     phyTime_t               startTime;  // absolute
00145 } plmeEdReq_t;
00146 
00147 typedef  struct plmeCcaReq_tag
00148 {
00149     phyCCAType_t            ccaType;
00150     phyContCCAMode_t        contCcaMode;
00151 } plmeCcaReq_t;
00152 
00153 typedef  struct plmeCcaCnf_tag
00154 {
00155     phyStatus_t             status;
00156 } plmeCcaCnf_t;
00157 
00158 typedef  struct plmeEdCnf_tag
00159 {
00160     phyStatus_t             status;
00161     uint8_t                 energyLevel;
00162     uint8_t                 energyLeveldB;
00163 } plmeEdCnf_t;
00164 
00165 typedef  struct plmeSetTRxStateReq_tag
00166 {
00167     phyState_t              state;
00168     phySlottedMode_t        slottedMode;
00169     phyTime_t               startTime;   // absolute
00170     uint32_t                rxDuration;  // relative
00171 } plmeSetTRxStateReq_t;
00172 
00173 typedef struct phyTimeEvent_tag
00174 {
00175     phyTimeTimestamp_t timestamp; // absolute
00176     phyTimeCallback_t  callback;
00177     uint32_t           parameter;
00178 }phyTimeEvent_t;
00179 
00180 typedef  struct plmeSetTRxStateCnf_tag
00181 {
00182     phyStatus_t             status;
00183 } plmeSetTRxStateCnf_t;
00184 
00185 typedef  struct plmeSetReq_tag
00186 {
00187     phyPibId_t              PibAttribute;
00188     uint64_t                PibAttributeValue;
00189 } plmeSetReq_t;
00190 
00191 typedef  struct plmeSetCnf_tag
00192 {
00193     phyStatus_t             status;
00194     phyPibId_t              PibAttribute;
00195 } plmeSetCnf_t;
00196 
00197 typedef  struct plmeGetReq_tag
00198 {
00199     phyPibId_t              PibAttribute;
00200     uint64_t *              pPibAttributeValue;
00201 } plmeGetReq_t;
00202 
00203 typedef  struct plmeGetCnf_tag
00204 {
00205     phyStatus_t             status;
00206     phyPibId_t              PibAttribute;
00207     uint64_t                PibAttributeValue;
00208 } plmeGetCnf_t;
00209 
00210 typedef  struct macToPlmeMessage_tag
00211 {
00212     phyMessageId_t             msgType;
00213     uint8_t                    macInstance;
00214     union
00215     {
00216         plmeEdReq_t                edReq;
00217         plmeCcaReq_t               ccaReq;
00218         plmeSetTRxStateReq_t       setTRxStateReq;
00219         plmeSetReq_t               setReq;
00220         plmeGetReq_t               getReq;
00221     }msgData;
00222 } macToPlmeMessage_t;
00223 
00224 typedef  struct macToPdDataMessage_tag
00225 {
00226     phyMessageId_t             msgType;
00227     uint8_t                    macInstance;
00228     union
00229     {
00230         pdDataReq_t             dataReq;
00231         pdIndQueueInsertReq_t   indQueueInsertReq;
00232         pdIndQueueRemoveReq_t   indQueueRemoveReq;
00233     }msgData;
00234 } macToPdDataMessage_t;
00235 
00236 typedef  struct plmeToMacMessage_tag
00237 {
00238     phyMessageId_t             msgType;
00239     uint8_t                    macInstance;
00240     union
00241     {
00242         plmeCcaCnf_t            ccaCnf;
00243         plmeEdCnf_t             edCnf;
00244         plmeSetTRxStateCnf_t    setTRxStateCnf;
00245         plmeSetCnf_t            setCnf;
00246         plmeGetCnf_t            getCnf;
00247     }msgData;
00248 } plmeToMacMessage_t;
00249 
00250 typedef  struct pdDataToMacMessage_tag
00251 {
00252     phyMessageId_t             msgType;
00253     uint8_t                    macInstance;
00254     union
00255     {
00256         pdDataCnf_t             dataCnf;
00257         pdDataInd_t             dataInd;
00258         pdIndQueueInsertCnf_t   indQueueInsertCnf;
00259     }msgData;
00260 } pdDataToMacMessage_t;
00261 
00262 typedef  struct phyMessageHeader_tag
00263 {
00264     phyMessageId_t             msgType;
00265     uint8_t                    macInstance;
00266 } phyMessageHeader_t;
00267 
00268 typedef struct phyRxParams_tag {
00269     phyTime_t   timeStamp;
00270     uint8_t     psduLength;
00271     uint8_t     linkQuality;
00272 #ifdef gPHY_802_15_4g_d     
00273     uint8_t     headerLength; 
00274     uint8_t     macDataIndex;
00275     uint8_t     unfillFifoBlockLength;  
00276     phyPHR_t    phyHeader;
00277 #else
00278     phySlottedMode_t phyRxMode;
00279     pdDataToMacMessage_t *pRxData;
00280 #endif  // gPHY_802_15_4g_d  
00281 } phyRxParams_t;
00282 
00283 typedef struct phyChannelParams_tag {
00284     union{
00285         phyStatus_t channelStatus;
00286         uint8_t     energyLeveldB;
00287     };
00288 #ifdef gPHY_802_15_4g_d
00289     uint8_t     ccaThreshold;
00290     uint8_t     ccaParam;
00291 #endif   // gPHY_802_15_4g_d    
00292 } phyChannelParams_t;
00293 
00294 typedef struct phyTxParams_tag {
00295   uint8_t           numOfCca;
00296   phyAckRequired_t  ackRequired;
00297 } phyTxParams_t;
00298 
00299 typedef phyStatus_t ( * PD_MAC_SapHandler_t)(pdDataToMacMessage_t * pMsg, instanceId_t instanceId);
00300 
00301 typedef phyStatus_t ( * PLME_MAC_SapHandler_t)(plmeToMacMessage_t * pMsg, instanceId_t instanceId);
00302 
00303 #ifdef __cplusplus
00304 extern "C" {
00305 #endif 
00306 
00307 /************************************************************************************
00308 *************************************************************************************
00309 * Public memory declarations
00310 *************************************************************************************
00311 ************************************************************************************/
00312 extern const uint8_t gPhyIndirectQueueSize_c;
00313 
00314 /************************************************************************************
00315 *************************************************************************************
00316 * Public functions
00317 *************************************************************************************
00318 ************************************************************************************/
00319 
00320 void Phy_Init( void );
00321 
00322 instanceId_t BindToPHY( instanceId_t macInstance );
00323 
00324 // SAPs
00325 void Phy_RegisterSapHandlers(PD_MAC_SapHandler_t pPD_MAC_SapHandler, PLME_MAC_SapHandler_t pPLME_MAC_SapHandler, instanceId_t instanceId);
00326 
00327 phyStatus_t MAC_PD_SapHandler(macToPdDataMessage_t * pMsg, instanceId_t phyInstance);
00328 
00329 phyStatus_t MAC_PLME_SapHandler(macToPlmeMessage_t * pMsg, instanceId_t phyInstance);
00330 
00331 // PHY Time
00332 void PhyTime_Maintenance ( void );
00333 
00334 void PhyTime_RunCallback ( void );
00335 
00336 void PhyTime_ISR         ( void );
00337 
00338 phyTimeStatus_t PhyTime_TimerInit ( void (*cb)(void) );
00339 
00340 phyTimeTimestamp_t PhyTime_GetTimestamp ( void );
00341 
00342 phyTimeTimerId_t   PhyTime_ScheduleEvent( phyTimeEvent_t *pEvent );
00343 
00344 phyTimeStatus_t    PhyTime_CancelEvent  ( phyTimeTimerId_t timerId );
00345 
00346 phyTimeStatus_t    PhyTime_CancelEventsWithParam ( uint32_t param );
00347 
00348 #ifdef __cplusplus
00349 }
00350 #endif 
00351     
00352 #endif  /* _PHY_INTERFACE_H */