1 /*! *********************************************************************************
2 * \defgroup PhyInterface PHY Interface
3 *
4 * 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).
5 * The PHY data service enables the transmission and reception of PHY protocol data units (PSDUs) over the media (radio).
6 * The PHY Layer interfaces to the MAC Layer through function calls and function callbacks.
7 * If the interface primitives are implemented as function calls, the MAC Layer calls the exposed functions (provided by the PHY Layer) to issue commands / requests.
8 *
9 * @{
10 ********************************************************************************** */
11 /*! *********************************************************************************
12 * Copyright (c) 2015, Freescale Semiconductor, Inc.
13 * Copyright 2016-2025 NXP
14 * All rights reserved.
15 *
16 * \file
17 *
18 * SPDX-License-Identifier: BSD-3-Clause
19 ********************************************************************************** */
20 
21 #ifndef _PHY_INTERFACE_H
22 #define _PHY_INTERFACE_H
23 
24 
25 /************************************************************************************
26 *************************************************************************************
27 * Include
28 *************************************************************************************
29 ************************************************************************************/
30 #include <stdbool.h>
31 #include "PhyTypes.h"
32 #include "PhyMessages.h"
33 
34 /************************************************************************************
35 *************************************************************************************
36 * Public macros
37 *************************************************************************************
38 ************************************************************************************/
39 
40 /*! Number of PHY instances (Only for PHYs which support multiple instances) */
41 #ifndef gPhyInstancesCnt_c
42 #define gPhyInstancesCnt_c  1
43 #endif
44 
45 /*! The PHY task stack size (Only for PHYs which use OS task) */
46 #ifndef gPhyTaskStackSize_c
47 #define gPhyTaskStackSize_c 600
48 #endif
49 
50 /*! The PHY task priority (Only for PHYs which use OS task)
51     The PHY Task must have the highest priority! */
52 #ifndef gPhyTaskPriority_c
53 #define gPhyTaskPriority_c  0
54 #endif
55 
56 /*! The following define is used to enable the Automatic Frequency Correction (MKW01 only) */
57 #ifndef gAfcEnabled_d
58 #define gAfcEnabled_d		0
59 #endif
60 
61 /*! Configure the maximum number of PHY timers/events */
62 #ifndef gMaxPhyTimers_c
63 #define gMaxPhyTimers_c                 (8)
64 #endif
65 
66 /*! Configure the HW Auto Dual PAN Mode */
67 #ifndef gHwAutoDualPanMode_c
68 #define gHwAutoDualPanMode_c            (TRUE)
69 #endif
70 
71 /*! This define is used as a start time to signal that a current sequence is handled as soon as possible by the PHY layer.  */
72 #define gPhySeqStartAsap_c              ((phyTime_t)(-1))
73 
74 /*! These defines are used when using OpenThread Vendor Specific IE  */
75 #define IeData_LinkMarginThreshold_c (-102) /* -102 dBm receiver sensitivity from datasheet */
76 #define IeData_Lqi_c                 0x02   /* corelated with IE Data Elements in OT Link metrics */
77 #define IeData_LinkMargin_c          0x04   /* corelated with IE Data Elements in OT Link metrics */
78 #define IeData_Rssi_c                0x08   /* corelated with IE Data Elements in OT Link metrics */
79 #define IeData_MSB_VALID_DATA  0x80000000   /* IE has valid data in data buffer including data lenght in IE Header (first 2 bytes)*/
80 #define IeVendorOuiThreadCompanyId   0xeab89b
81 
82 #define PHY_SEC_KEY_SIZE 16
83 /************************************************************************************
84 *************************************************************************************
85 * Public prototypes
86 *************************************************************************************
87 ************************************************************************************/
88 
89 /************************************************************************************
90 *************************************************************************************
91 * Public type definitions
92 *************************************************************************************
93 ************************************************************************************/
94 #if defined(__ARMCC_VERSION)
95   #pragma push
96   #pragma anon_unions
97 #endif
98 
99 /*! PHY power states. These modes are hardware specific.
100     Some modes may not be available on certain HW platforms. */
101 typedef enum{
102     gPhyPwrIdle_c,
103     gPhyPwrAutodoze_c,
104     gPhyPwrDoze_c,
105     gPhyPwrHibernate_c,
106     gPhyPwrDSM_c,
107     gPhyPwrReset_c
108 }phyPwrMode_t;
109 
110 /*! The PD-DATA.request primitive is generated by the MAC Layer when a MAC data frame (MPDU) is ready to be transferred to the PHY Layer, becoming payload for the PHY frame (PSDU).
111     Upon the reception of this primitive, the PHY Layer will arm either a T or TRxAck sequence, depending on the Acknowledgement Request sub-field bit included in the Frame Control field, which is part of the MHR. */
112 typedef struct pdDataReq_tag
113 {
114     phyTime_t               startTime;  /*!< The absolute start time of the preamble over the air. A value of gPhySeqStartAsap_c to start immediately.  */
115     uint32_t                txDuration; /*!< The computed duration for the Data Request frame. */
116     phySlottedMode_t        slottedTx;
117     phyCCAType_t            CCABeforeTx; /*!< Indicates, whether the CCA is used before this transmission. */
118     phyAckRequired_t        ackRequired; /*!< Indicates, whether the ACK is required for this transmission. */
119     uint8_t                 psduLength;  /*!< The number of octets contained in the PSDU to be transmitted by the PHY Layer, without the last two octets containing the FCS field. */
120     uint8_t                 flags;       /* values from phyTxFlags */
121     uint8_t *               pPsdu;       /*!< A pointer to the set of octets forming the PSDU to be transmitted by the PHY Layer. */
122                                          /* The PSDU has to be right after the request - allocate everything together */
123 } pdDataReq_t;
124 
125 /*! The PD-DATA.confirm primitive reports the result of a request to transfer a data MAC frame (MPDU).
126     The status returned by PD-DATA.confirm can be SUCCESS, indicating that the request to transmit was successful, an error code of BUSY if the PHY Layer
127     was not in the idle state (I sequence) when the PD-DATA.request was issued, or an error code of CHANNEL_BUSY if all CCA sequences indicated that the channel was busy.
128     If the transmission occurred successfully but no valid ACK frame was received (assuming that it was requested), then an error code of NO_ACK is used. */
129 typedef struct pdDataCnf_tag
130 {
131     phyStatus_t             status;
132     uint8_t                 ackLength;
133     phyTime_t               timeStamp;
134     uint8_t                *ackData;    /* The ACK has to be right after the confirmation - allocate everything together */
135 } pdDataCnf_t;
136 
137 /*! The PD-DATA.indication primitive is generated by the PHY Layer when an MPDU is ready to be transferred to the MAC Layer.
138     Besides the PSDU itself, the primitive also returns the LQI value measured during the reception. */
139 typedef struct pdDataInd_tag
140 {
141     phyTime_t               timeStamp;       /*!< The timestamp when the reception started. */
142     uint8_t                 ppduLinkQuality; /*!< Link quality (LQI) value measured during the reception of the PPDU. */
143     int8_t                  ppduRssi;        /*!< RSSI (signal strength indicator)value measured during the reception of the PPDU. */
144     bool_t                  rxAckFp;         /*!< True if the received pachet was acked with frame pending bit set to TRUE. */
145     phyRxAckFpReason_t      rxAckFpReason;   /*!< Ack FP reason */
146     bool_t                  ackedWithSecEnhAck;
147     uint16_t                ackKeyId;
148     uint16_t                psduLength;      /*!< The number of octets contained in the PSDU received by the PHY Layer. */
149     uint32_t                ackFrameCounter;
150     uint8_t *               pPsdu;           /*!< The pointer to the set of octets forming the PSDU received by the PHY Layer. */
151                                              /* The PSDU has to be right after the indication - allocate everything together */
152 } pdDataInd_t;
153 
154 /*! The PD-INDQUEUEINSERT.Request primitive is generated by the MAC Layer when a packet is inserted into the MAC indirect queue.
155     A 16-bit checksum derived from the Destination Address and Destination PAN ID is passed to the PHY Layer.
156     The PHY Layer, both in hardware implementations and emulated in software, must keep a database of checksums, and facilitate writing into it through the use of this primitive. */
157 typedef struct pdIndQueueInsertReq_tag
158 {
159     uint8_t                 index;    /*!< Index into the indirect table */
160     uint16_t                checksum;
161 } pdIndQueueInsertReq_t;
162 
163 /*! Unused! The request is synchronous. */
164 typedef struct pdIndQueueInsertCnf_tag
165 {
166     phyStatus_t             status;
167 } pdIndQueueInsertCnf_t;
168 
169 /*! The PD-INDQUEUEREMOVE.Request primitive is generated by the MAC Layer when a packet is removed from the MAC indirect queue, and the index, at which the packets checksum is stored, gets passed on to the PHY Layer.
170     The PHY Layer, both in hardware implementations and emulated in software, must facilitate erasing entries from its database of checksums through the use of this primitive. */
171 typedef struct pdIndQueueRemoveReq_tag
172 {
173     uint8_t                 index; /*!< Index into the indirect table */
174 } pdIndQueueRemoveReq_t;
175 
176 /*! The PLME-ED.request primitive is generated by the MAC Layer when an ED measurement must be performed by the PHY Layer. */
177 typedef struct plmeEdReq_tag
178 {
179     phyTime_t               startTime;          /*!< Absolute time */
180     uint32_t                measureDurationSym; /*!< Total time in symbols of the measurement, a channel sample takes 8 symbols (128us) and samples are performed continuously until the total time is reached */
181 } plmeEdReq_t;
182 
183 /*! The PLME-CCA.request primitive is generated by the MAC Layer when a CCA operation must be performed, and it is passed to the PHY Layer. */
184 typedef struct plmeCcaReq_tag
185 {
186     phyCCAType_t            ccaType;
187     phyContCCAMode_t        contCcaMode; /*!< Enable continuous CCA mode */
188 } plmeCcaReq_t;
189 
190 /*! The PLME-CCA.confirm primitive is generated by the PHY Layer after the C sequence completes, and returns the response of a previous PLME-CCA.request to the MAC Layer.
191     The status returned can be IDLE if the channel is idle, RX_ON if the transceiver is receiving, or BUSY if there is an ongoing T sequence or the channel assessment process determined that the channel is busy. */
192 typedef struct plmeCcaCnf_tag
193 {
194     phyStatus_t             status;
195 } plmeCcaCnf_t;
196 
197 /*! The PLME-ED.confirm primitive is generated by the PHY Layer after the C sequence completes, and returns the response of a previous PLME-ED.request to the MAC Layer.
198     The status returned can be SUCCESS if the measurement was successful, an error code of TX_ON if there is an ongoing T sequence, or RX_ON if the transceiver is receiving.
199     The PLME-ED.confirm primitive returns the value of the ED measurement. */
200 typedef struct plmeEdCnf_tag
201 {
202     phyStatus_t             status;
203     uint8_t                 energyLevel;      /*!< The ED level for the current channel. If the status is not SUCCESS, the value of this parameter will be ignored. */
204     uint8_t                 energyLeveldB;    /*!< The ED level for the current channel in dBm value. */
205     int8_t                  maxEnergyLeveldB; /*!< The maximum ED level for the current channel in dBm value. This is used if multiple energy samples are requested */
206 } plmeEdCnf_t;
207 
208 /*! The PLME-SET-TRX-STATE.request primitive is generated by the MAC Layer when the transceiver state must be changed by the PHY Layer, which then arms either an I or R sequence.
209     This primitive is also used to cancel any ongoing sequence by setting the state to FORCE_TRX_OFF. If this primitive is issued with an RX_ON or TRX_OFF argument and the PHY is busy transmitting a PPDU, a state change will occur at the end of the transmission.
210     If this primitive is issued with TRX_OFF, and the PHY is in the RX_ON state and has already received a valid SFD, the state change will occur at the end of reception of the PPDU.
211     The slottedTx parameter is used by the PHY Layer during R sequence to determine whether the ensuing transmit acknowledge frame (if any) must be synchronized to a backoff slot boundary. */
212 typedef struct plmeSetTRxStateReq_tag
213 {
214     phyState_t              state;       /*!< The new state in which to configure the transceiver */
215     phySlottedMode_t        slottedMode; /*!< Slotted/non-slotted mode */
216     phyTime_t               startTime;   /*!< Absolute time */
217     uint32_t                rxDuration;  /*!< If the requested state is Rx, then Rx will be enabled for rxDuration symbols. */
218 } plmeSetTRxStateReq_t;
219 
220 /*! PHY Event */
221 typedef struct phyTimeEvent_tag
222 {
223     phyTime_t          timestamp; /*!< Absolute time of the event */
224     phyTimeCallback_t  callback;  /*!< Callback function to handle the event */
225     uint32_t           parameter; /*!< Parameter to be specified to the callback function */
226 }phyTimeEvent_t;
227 
228 /*! The PLME-SET.request primitive is generated by the MAC Layer to modify a PIB attribute in the PHY Layer.
229     This primitive requires the identifier of the PIB attribute to set its value.
230     This request is synchronous. The PIB value will be set inside the call to the PLME SAP. */
231 typedef struct plmeSetReq_tag
232 {
233     phyPibId_t              PibAttribute;
234     uint64_t                PibAttributeValue;
235 } plmeSetReq_t;
236 
237 /*! The PLME-GET.request primitive is generated by the MAC Layer to request information about a PIB attribute in the PHY Layer.
238     This primitive requires the identifier of the PIB attribute to read.
239     This request is synchronous. The PIB value will be available after the call to the PLME SAP. */
240 typedef struct plmeGetReq_tag
241 {
242     phyPibId_t              PibAttribute;
243     uint64_t                PibAttributeValue;
244 } plmeGetReq_t;
245 
246 typedef PACKED_STRUCT deviceAddr_tag
247 {
248     uint8_t addr[8];
249     uint8_t mode;
250     uint16_t panId;
251 } deviceAddr_t;
252 
253 typedef PACKED_STRUCT AckIeData_tag
254 {
255     uint8_t  data[16];
256     uint8_t  extAddr[8];
257     uint16_t shortAddr;
258     uint32_t param; // MSB: =1 if data[16] has valid data including valid Data Length in IE Header Data (first 2 data bytes)
259                     // Rest of the bits holds eventual params (IE Specific)
260 } AckIeData_t;
261 
262 typedef PACKED_STRUCT MacKeyData_tag
263 {
264     uint8_t keyId;
265     uint8_t prevKey[PHY_SEC_KEY_SIZE];
266     uint8_t currKey[PHY_SEC_KEY_SIZE];
267     uint8_t nextKey[PHY_SEC_KEY_SIZE];
268 } MacKeyData_t;
269 
270 typedef PACKED_STRUCT filterAddr_tag
271 {
272     uint8_t  extAddr[8];
273     uint16_t shortAddr;
274     bool_t   block;
275 } filterAddr_t;
276 
277 /*! PHY Management Requests messages */
278 typedef struct macToPlmeMessage_tag
279 {
280     phyMessageId_t            msgType;
281     uint8_t                   ctx_id;
282     union
283     {
284         plmeEdReq_t           edReq;
285         plmeCcaReq_t          ccaReq;
286         plmeSetTRxStateReq_t  setTRxStateReq;
287         plmeSetReq_t          setReq;
288         plmeGetReq_t          getReq;
289 
290         bool_t                SAMState;
291         deviceAddr_t          deviceAddr;
292         filterAddr_t          filterAddr;
293 
294         bool_t                efpEnabled;
295         bool_t                neighbourTblEnabled;
296         uint32_t              cslPeriod;
297         uint32_t              cslSampleTime;
298 
299         AckIeData_t           AckIeData;
300 
301         MacKeyData_t          MacKeyData;
302         uint32_t              MacFrameCounter;
303     } msgData;
304 } macToPlmeMessage_t;
305 
306 /*! PHY Data Requests messages */
307 typedef struct macToPdDataMessage_tag
308 {
309     phyMessageId_t             msgType;
310     uint8_t                    ctx_id;
311     union
312     {
313         pdDataReq_t             dataReq;
314         pdIndQueueInsertReq_t   indQueueInsertReq;
315         pdIndQueueRemoveReq_t   indQueueRemoveReq;
316     } msgData;
317 } macToPdDataMessage_t;
318 
319 /*! PHY Management Confirms/Indications messages */
320 typedef struct plmeToMacMessage_tag
321 {
322     phyMessageId_t             msgType;
323     uint8_t                    ctx_id;
324     uint32_t                   fc;      /* last frame counter used */
325     union
326     {
327         plmeCcaCnf_t            ccaCnf;
328         plmeEdCnf_t             edCnf;
329     } msgData;
330 } plmeToMacMessage_t;
331 
332 /*! PHY Data Confirms/Indications messages */
333 typedef struct pdDataToMacMessage_tag
334 {
335     phyMessageId_t             msgType;
336     uint8_t                    ctx_id;
337     uint32_t                   fc;      /* last frame counter used */
338     union
339     {
340         pdDataCnf_t             dataCnf;
341         pdDataInd_t             dataInd;
342     } msgData;
343 } pdDataToMacMessage_t;
344 
345 /*! Common PHY message header */
346 typedef struct phyMessageHeader_tag
347 {
348     phyMessageId_t             msgType;     /*!< The Id of the PHY message */
349     uint8_t                    ctx_id; /*!< The instance of the upper layer */
350 } phyMessageHeader_t;
351 
352 /*! PHY RX parameter */
353 typedef struct phyRxParams_tag
354 {
355     phyTime_t   timeStamp;  /*!< [symbols] : Rx startTime / DataIndication timestamp */
356     uint8_t     psduLength; /*!< bytes received */
357     uint8_t     linkQuality;/*!< LQI value */
358     int8_t      rssi;       /*!< RSSI value */
359     bool_t      ackedWithSecEnhAck; /*!< Indicates if the rx packet was acked with a security */
360 
361     phyTime_t   startTime;
362     uint32_t    duration;
363 } phyRxParams_t;
364 
365 /*! PHY Channel parameters */
366 typedef struct phyChannelParams_tag
367 {
368     union
369     {
370         phyStatus_t channelStatus;    /*!< Channel busy or idle */
371         uint8_t     energyLeveldB;    /*!< Channel energy level in dBm */
372         int8_t      maxEnergyLeveldB; /*!< MAX Channel energy level in dBm */
373     };
374 } phyChannelParams_t;
375 
376 /*! Passed by the MAC layer to specify that a standalone CCA must be used, or that the ACK is required for the sequence. */
377 typedef struct phyTxParams_tag
378 {
379     pdDataReq_t *dataReq;
380 } phyTxParams_t;
381 
382 typedef struct phyCcaParams_tag
383 {
384     phyMessageId_t msgType;
385     phyCCAType_t ccaParam;
386     phyContCCAMode_t cccaMode;
387     uint32_t edScanDurationSym;
388     phyTimeTimerId_t timer;
389 } phyCcaParams_t;
390 
391 /*! PHY data service callback type */
392 typedef phyStatus_t ( * PD_MAC_SapHandler_t)(pdDataToMacMessage_t * pMsg, instanceId_t instanceId);
393 
394 /*! PHY management service callback type */
395 typedef phyStatus_t ( * PLME_MAC_SapHandler_t)(plmeToMacMessage_t * pMsg, instanceId_t instanceId);
396 
397 typedef void (*phyTxAppCallback)(uint8_t* pTxData);
398 
399 #if defined(__ARMCC_VERSION)
400 #pragma pop
401 #endif
402 
403 #ifdef __cplusplus
404 extern "C" {
405 #endif
406 
407 /************************************************************************************
408 *************************************************************************************
409 * Public memory declarations
410 *************************************************************************************
411 ************************************************************************************/
412 
413 extern uint8_t gPhyTxWuTimeSym;  /*!< TSM TX warmup time in symbols(16us) */
414 extern uint8_t gPhyTxWdTimeSym;  /*!< TSM TX warmdown time in symbols(16us) */
415 extern uint8_t gPhyRxWuTimeSym;  /*!< TSM RX warmup time in symbols(16us) */
416 extern uint8_t gPhyRxWdTimeSym;  /*!< TSM RX warmdown time in symbols(16us) */
417 
418 /************************************************************************************
419 *************************************************************************************
420 * Public functions
421 *************************************************************************************
422 ************************************************************************************/
423 /*! *********************************************************************************
424  * \brief initialize the PHY module
425  *
426  ********************************************************************************** */
427 void Phy_Init( void );
428 
429 /*! *********************************************************************************
430  * \brief get a free PHY ctx and initialize it
431  *
432  ********************************************************************************** */
433 uint8_t PHY_get_ctx();
434 
435 /*! *********************************************************************************
436  * \brief deinitialize a PHY ctx
437  *
438  ********************************************************************************** */
439 void PHY_release_ctx(uint8_t id);
440 
441 /*! *********************************************************************************
442  * \brief deinitialize the PHY module
443  *
444  ********************************************************************************** */
445  void Phy_Deinit( void );
446 
447 /*! *********************************************************************************
448  * \brief Register upper layer callback function to handle the PHY confirms/indications
449  *
450  * \param pPD_MAC_SapHandler    Upper layer callback function for Data messages
451  * \param pPLME_MAC_SapHandler  Upper layer callback function for Management messages
452  * \param instanceId            Instance of the PHY layer
453  *
454  ********************************************************************************** */
455 void Phy_RegisterSapHandlers(PD_MAC_SapHandler_t pPD_MAC_SapHandler, PLME_MAC_SapHandler_t pPLME_MAC_SapHandler, instanceId_t instanceId);
456 
457 /*! *********************************************************************************
458  * \brief This is the entry point for the PHY data service requests
459  *
460  * \param pMsg        Pointer to the request
461  * \param instanceId  Instance of the PHY layer
462  *
463  * \return phyStatus_t
464  *
465  ********************************************************************************** */
466 phyStatus_t MAC_PD_SapHandler(macToPdDataMessage_t * pMsg, instanceId_t phyInstance);
467 
468 /*! *********************************************************************************
469  * \brief This is the entry point for the PHY management service requests
470  *
471  * \param pMsg        Pointer to the request
472  * \param instanceId  Instance of the PHY layer
473  *
474  * \return phyStatus_t
475  *
476  ********************************************************************************** */
477 phyStatus_t MAC_PLME_SapHandler(macToPlmeMessage_t * pMsg, instanceId_t phyInstance);
478 
479 /*! *********************************************************************************
480  * \brief This function will schedule the next event to expire
481  *
482  ********************************************************************************** */
483 void PhyTime_Maintenance ( void );
484 
485 /*! *********************************************************************************
486  * \brief This function will run the callback of the next event scheduled
487  *
488  ********************************************************************************** */
489 void PhyTime_RunCallback ( void );
490 
491 /*! *********************************************************************************
492  * \brief Function to be called from the PHY timer compare match ISR
493  *
494  ********************************************************************************** */
495 void PhyTime_ISR ( void );
496 
497 /*! *********************************************************************************
498  * \brief Initialize the PHY timer module
499  *
500  * \param cb Callback function used to handle a timer compare match event.
501  *           If NULL, the PhyTime_RunCallback() and the PhyTime_Maintenance()
502  *           functions will be called from ISR context
503  *
504  * \return phyTimeStatus_t
505  *
506  ********************************************************************************** */
507 phyTimeStatus_t    PhyTime_TimerInit ( void (*cb)(void) );
508 
509 /*! *********************************************************************************
510  * \brief Deinitialize the PHY timer module
511  *
512  ********************************************************************************** */
513 void PhyTime_TimerDeinit ( void );
514 
515 /*! *********************************************************************************
516  * \brief Return a 64-bit time-stamp in symbols
517  *
518  * \return time-stamp
519  *
520  ********************************************************************************** */
521 phyTime_t          PhyTime_GetTimestamp ( void );
522 
523 /*! *********************************************************************************
524  * \brief This function schedules a timed event.
525  *        The event context is given by the configuration structure.
526  *
527  * \param pEvent Pointer to the event data
528  *
529  * \return Id of the event, or gInvalidTimerId_c if the event cannot be scheduled
530  *
531  ********************************************************************************** */
532 phyTimeTimerId_t   PhyTime_ScheduleEvent( phyTimeEvent_t *pEvent );
533 
534 /*! *********************************************************************************
535  * \brief Cancel a specific scheduled event
536  *
537  * \param timerId The id of the event to schedule
538  *
539  * \return phyTimeStatus_t
540  *
541  ********************************************************************************** */
542 phyTimeStatus_t    PhyTime_CancelEvent  ( phyTimeTimerId_t timerId );
543 
544 /*! *********************************************************************************
545  * \brief Cancel all schedules events which has a specific parameter specified
546  *
547  * \param param Parameter to match the event(s) to be cancel
548  *
549  * \return phyTimeStatus_t
550  *
551  ********************************************************************************** */
552 phyTimeStatus_t    PhyTime_CancelEventsWithParam ( uint32_t param );
553 
554 bool_t PhyTime_can_sleep();
555 
556 /*! *********************************************************************************
557  * \brief Set the low-power state of the PHY
558  *
559  * \param state  The new power state
560  *
561  * \return phyStatus_t
562  *
563  ********************************************************************************** */
564 phyStatus_t        PhyPlmeSetPwrState( uint8_t state );
565 
566 /*! *********************************************************************************
567 * \brief  This function enables the Phy ISR
568 *
569 ********************************************************************************** */
570 void PHY_Enable(void);
571 
572 /*! *********************************************************************************
573 * \brief  This function disables the Phy ISR
574 *
575 ********************************************************************************** */
576 void PHY_Disable(void);
577 
578 /*! *********************************************************************************
579 * \brief  This function enables/disables(cslPeriod = 0) CSL IE inclusion in Enanced ACK
580 *
581 ********************************************************************************** */
582 void PHY_EnableCsl(instanceId_t phyInstance, uint32_t cslPeriod);
583 
584 void PHY_SetEfp(instanceId_t phyInstance, bool_t state);
585 
586 void PHY_SetNbt(instanceId_t phyInstance, bool_t state);
587 
588 /*! *********************************************************************************
589 * \brief  This function sets CSL sample time in PHY in us
590 *
591 ********************************************************************************** */
592 void PHY_SetCslSampleTime(instanceId_t phyInstance, uint32_t cslSampleTimeUs);
593 
594 
595 /*! *********************************************************************************
596 * \brief  Copy data to/from packet ram in a safe manner
597 *
598 ********************************************************************************** */
599 void PHY_MemCpy(uint8_t *dst, volatile uint8_t *src, uint32_t len);
600 
601 void PHY_MemCpyVerify(volatile uint8_t *dst, uint8_t *src, uint32_t len);
602 
603 /*! *********************************************************************************
604 * \brief  Confiure IE data that will be put in an Enhaced ack
605 *
606 * \param[in]  pIeData pointer to IE data
607 * \param[in]  ieDataLen IE data len, if > 0 add entry, if = 0 remove entry
608 * \param[in]  shortAddr short address of the peer device
609 * \param[in]  extAddr extended address of the peer device
610 *
611 ********************************************************************************** */
612 void PHY_ConfigureAckIeData(instanceId_t phyInstance, uint8_t * pIeData, uint32_t ieDataParam, uint16_t shortAddr, uint8_t *extAddr);
613 
614 /*! *********************************************************************************
615 * \brief  Clear IE data array
616 *
617 ********************************************************************************** */
618 void PHY_ClearAckIeData(instanceId_t id);
619 
620 /*! *********************************************************************************
621 * \brief  returns true if XCVR allow sleep, retruns false others ways
622 *
623 ********************************************************************************** */
624 bool PHY_XCVR_AllowLowPower(void);
625 
626 void PHY_allow_sleep();
627 void PHY_disallow_sleep();
628 
629 #ifdef __cplusplus
630 }
631 #endif
632 
633 #endif  /* _PHY_INTERFACE_H */
634 /*! *********************************************************************************
635 * @}
636 ********************************************************************************** */
637