Contiki 2.5
phy-library.h
1 /*
2  * File: stack/phy/phy-library.h
3  * Description: Interface definition for library functionality.
4  *
5  * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
6  */
7 
8 
9 //---------------------------------------------------------------------------
10 // Definitions
11 //------------
12 
13 /**
14  * @name SIMPLEMAC version defines
15  *@{
16  */
17 
18 
19 /**
20  * @brief Version major number
21  */
22 #define SIMPLEMAC_VERSION_MAJOR 1
23 
24 /**
25  * @brief Version minor number
26  */
27 #define SIMPLEMAC_VERSION_MINOR 0
28 
29 /**
30  * @brief Version patch number
31  */
32 #define SIMPLEMAC_VERSION_PATCH 2
33 
34 /**
35  * @brief Version qualifier
36  */
37 #define SIMPLEMAC_VERSION_QUAL ""
38 
39 #define _SQUOTEME(a) #a
40 #define SQUOTEME(a) _SQUOTEME(a)
41 
42 /**
43  * @brief Version string
44  */
45 #define SIMPLEMAC_VERSION_STRING SQUOTEME(SIMPLEMAC_VERSION_MAJOR) "." SQUOTEME(SIMPLEMAC_VERSION_MINOR) "." SQUOTEME(SIMPLEMAC_VERSION_PATCH) SIMPLEMAC_VERSION_QUAL
46 
47 //@} \\END SIMPLEMAC version defines
48 
49 
50 #define SECURITY_BLOCK_SIZE 16 // bytes
51 #define MIN_RADIO_POWER -43 // dBm
52 #define MAX_RADIO_POWER 3 // dBm
53 
54 #ifndef __PHY_H__
55 enum {
56  ST_RADIO_POWER_MODE_RX_ON,
57  ST_RADIO_POWER_MODE_OFF
58 };
59 typedef u8 RadioPowerMode;
60 
61 //---------------------------------------------------------------------------
62 // Transmit Configuration
63 //-----------------------
64 // The application must declare this structure and initialize each member
65 // variable. radioTransmitConfig must be initialized prior to calling
66 // ST_RadioTransmit() and may be modified only while no transmit operation is
67 // in progress.
68 
69 #define RADIO_CCA_ATTEMPT_MAX_DEFAULT 4
70 #define RADIO_BACKOFF_EXPONENT_MIN_DEFAULT 3
71 #define RADIO_BACKOFF_EXPONENT_MAX_DEFAULT 5
72 
73 typedef struct {
74  boolean waitForAck; // Wait for ACK if ACK request set in FCF.
75  boolean checkCca; // backoff and check CCA before transmit.
76  u8 ccaAttemptMax; // The number of CCA attempts before failure;
77  u8 backoffExponentMin; // Backoff exponent for the initial CCA attempt.
78  u8 backoffExponentMax; // Backoff exponent for the final CCA attempt(s).
79  boolean appendCrc; // Append CRC to transmitted packets.
80 } RadioTransmitConfig;
81 #endif// __PHY_H__
82 
83 #ifndef ST_TYPES_H
84 /**
85  * @name txPowerModes for stSetTxPowerMode and mfglibSetPower
86  */
87 //@{
88 
89 /** @brief The application should call ::stSetTxPowerMode() with the
90  * txPowerMode parameter set to this value to disable all power mode options,
91  * resulting in normal power mode and bi-directional RF transmitter output.
92  */
93 #define ST_TX_POWER_MODE_DEFAULT 0x0000
94 /** @brief The application should call ::stSetTxPowerMode() with the
95  * txPowerMode parameter set to this value to enable boost power mode.
96  */
97 #define ST_TX_POWER_MODE_BOOST 0x0001
98 /** @brief The application should call ::stSetTxPowerMode() with the
99  * txPowerMode parameter set to this value to enable the alternate transmitter
100  * output.
101  */
102 #define ST_TX_POWER_MODE_ALTERNATE 0x0002
103 /** @brief The application should call ::stSetTxPowerMode() with the
104  * txPowerMode parameter set to this value to enable both boost mode and the
105  * alternate transmitter output.
106  */
107 #define ST_TX_POWER_MODE_BOOST_AND_ALTERNATE (ST_TX_POWER_MODE_BOOST \
108  |ST_TX_POWER_MODE_ALTERNATE)
109 #ifndef DOXYGEN_SHOULD_SKIP_THIS
110 // The application does not ever need to call stSetTxPowerMode() with the
111 // txPowerMode parameter set to this value. This value is used internally by
112 // the stack to indicate that the default token configuration has not been
113 // overidden by a prior call to stSetTxPowerMode().
114 #define ST_TX_POWER_MODE_USE_TOKEN 0x8000
115 #endif//DOXYGEN_SHOULD_SKIP_THIS
116 //@} \\END Definitions
117 
118 /**
119  * @brief The maximum 802.15.4 channel number is 26.
120  */
121 #define ST_MAX_802_15_4_CHANNEL_NUMBER 26
122 
123 /**
124  * @brief The minimum 802.15.4 channel number is 11.
125  */
126 #define ST_MIN_802_15_4_CHANNEL_NUMBER 11
127 
128 /**
129  * @brief There are sixteen 802.15.4 channels.
130  */
131 #define ST_NUM_802_15_4_CHANNELS \
132  (ST_MAX_802_15_4_CHANNEL_NUMBER - ST_MIN_802_15_4_CHANNEL_NUMBER + 1)
133 
134 #endif //ST_TYPES_H
135 
136 
137 
138 
139 //---------------------------------------------------------------------------
140 /** @name
141  * Radio power state control APIs
142  *
143  * @brief
144  * These APIs control the overall radio initialization and power state.
145  */
146 //@{
147 
148 /** @brief
149  * This function performs one-time radio initialization and calibration.
150  * This function must be called once after chip reset or wake from deep sleep.
151  * This function will power up the radio while it configures the radio channel.
152  * After the radio is configured and the channel is set the radio will be left
153  * in the state specified by the \c initialRadioPowerMode parameter.
154  * This function calls ST_RadioSetPowerMode(),
155  * ST_RadioEnableAddressFiltering(), ST_RadioEnableAutoAck(),
156  * ST_RadioSetCoordinator(), ST_RadioSetPower(), ST_RadioSetChannel(),
157  * ST_RadioEnablePacketTrace(), and ST_RadioEnableReceiveCrc()
158  * providing the last used argument for each function. If these functions have
159  * not been called before ST_RadioInit() then the default for each is used.
160  * Only the functions listed above can be called before ST_RadioInit().
161  * All other library functions must not be called until after
162  * ST_RadioInit() has been called once after each chip reset or wake from deep
163  * sleep.
164  *
165  * @param
166  * initialRadioPowerMode specifies the state that the function will leave the
167  * radio in after it is configured. This parameter can be either:
168  * ST_RADIO_POWER_MODE_OFF - radio will be powered down.
169  * ST_RADIO_POWER_MODE_RX_ON - radio will be left in the on (receive) state.
170  *
171  * @return ::ST_SUCCESS or a status code indicating the reason for failure.
172  */
173 StStatus ST_RadioInit(RadioPowerMode initialRadioPowerMode);
174 
175 /** @brief
176  * Turns on the radio. The last radio configuration is used.
177  */
178 void ST_RadioWake(void);
179 
180 /** @brief
181  * This function turns off the radio.
182  * Any transmit or receive packets in progress are aborted.
183  * The library may or may not call ST_RadioTransmitCompleteIsrCallback() for an
184  * aborted transmit packet.
185  * ST_RadioWake() must not be called within 250us of having called
186  * ST_RadioSleep().
187  */
188 void ST_RadioSleep(void);
189 
190 //@}//END Radio power state control APIs
191 
192 
193 //---------------------------------------------------------------------------
194 /** @name
195  * Channel APIs
196  *
197  * @brief
198  * These APIs control channel selection and calibration.
199  */
200 //@{
201 
202 /** @brief
203  * Configures the radio to communicate on a 802.15.4 channel.
204  * If ST_RadioInit() has not been called yet, the channel number is recorded
205  * but no calibration takes place. The specified channel will be configured
206  * when ST_RadioInit() is eventually called.
207  * If the radio is asleep this function will wake it to perform channel
208  * calibration and then return it to sleep before exiting.
209  * The first time a channel is selected all radio parameters will be calibrated
210  * for that channel. This full calibration process can take up to 200ms to
211  * complete. The results of some of these calibrations are stored in flash
212  * tokens for use the next time the same channel is selected. Subsequent calls
213  * to ST_RadioSetChannel() requesting the same channel will take less time
214  * because the stored values will be retrieved from the flash tokens and reused.
215  *
216  * @param channel the 802.15.4 channel that the radio will communicate on.
217  *
218  * @return ::ST_SUCCESS or a status code indicating the reason for failure.
219  */
220 StStatus ST_RadioSetChannel(u8 channel);
221 
222 /** @brief
223  * This function gets the 802.15.4 channel that the radio is configured to use.
224  *
225  * @return the 802.15.4 channel that the radio is configured to use.
226  */
227 u8 ST_RadioGetChannel(void);
228 
229 /** @brief
230  * This function is identical to ST_RadioSetChannel() except that it
231  * calibrates all radio parameters regardless of whether calibration is
232  * required.
233  *
234  * NOTE: This function does not need to be called under normal operating
235  * conditions. The library will reuse available stored calibration values
236  * and will perform necessary re-calibration automatically. Calling this
237  * function will cause the library to calibrate all radio parameters and
238  * store the results in flash, overwriting previous stored values. Use of
239  * this function will cause unnecessary flash wear and will take longer to
240  * complete than a call to ST_RadioSetChannel(). This function should only
241  * be called to recover from hardware-related calibration problems, which
242  * should only occur during hardware development.
243  *
244  * @param channel the 802.15.4 channel that the radio will communicate on.
245  *
246  * @return ::ST_SUCCESS or a status code indicating the reason for failure.
247  */
248 StStatus ST_RadioSetChannelAndForceCalibration(u8 channel);
249 
250 /** @brief
251  * This function checks to see if the radio needs calibrating to maintain
252  * expected performance as environmental conditions change.
253  * If this function indicates that the calibration is needed, the application
254  * should call ST_RadioCalibrateCurrentChannel().
255  *
256  * NOTE: This function must not be called while a transmit is in progress.
257  *
258  * @return TRUE if calibration is needed to compensate for temperature changes,
259  * FALSE otherwise.
260  */
261 boolean ST_RadioCheckRadio(void);
262 
263 /** @brief
264  * This function performs necessary recalibration to counteract the effects of
265  * temperature changes since the last calibration. It should be called by the
266  * application when ST_RadioCheckRadio() indicates that calibration is needed.
267  */
268 void ST_RadioCalibrateCurrentChannel(void);
269 
270 //@}//END Channel APIs
271 
272 
273 //---------------------------------------------------------------------------
274 /** @name
275  * Transmit APIs
276  *
277  * @brief
278  * These APIs control the transmission of packets.
279  */
280 //@{
281 
282 /** @brief
283  * This function transmits a packet using the configuration specified in
284  * \c radioTransmitConfig.
285  *
286  * @param *packet A pointer to the packet to be transmitted. The first byte of
287  * \c packet must be set to the number of payload bytes to be transmitted.
288  * If \c radioTransmitConfig.appendCrc is TRUE the length byte must accommodate
289  * the hardware-appended two-byte CRC.
290  * e.g. A packet with a two-byte payload would be represented in memory as:
291  * {0x04, 0x00, 0x01, 0xc0, 0xc1} where 0xc0 and 0xc1 are the CRC bytes.
292  * If \c radioTransmitConfig.checkCca is TRUE this function performs CSMA-CA
293  * backoff(s) and CCA check(s) before transmitting, else it starts the
294  * transmit process immediately.
295  *
296  * @return ::ST_SUCCESS if the transmission process is successfully started.
297  * In this case ST_RadioTransmitCompleteIsrCallback() will eventually be
298  * called to indicate the completion status. If the radio is busy transmitting,
299  * this function returns an error code and
300  * ST_RadioTransmitCompleteIsrCallback() will not be called.
301  */
302 StStatus ST_RadioTransmit(u8* packet);
303 
304 /** @brief
305  * This function is called by the library once after each ST_RadioTransmit()
306  * call that returned successfully. If the ST_RadioTransmit() call returned
307  * an error ST_RadioTransmitCompleteIsrCallback() will not be called.
308  *
309  * NOTE: ST_RadioTransmit() can be called again within the context of this
310  * callback.
311  *
312  * @param status parameter indicates one of the following conditions:
313  * ::ST_SUCCESS - the last byte of the non-ACK-request packet has been
314  * transmitted.
315  * ::ST_PHY_ACK_RECEIVED - the requested ACK was received.
316  * ::ST_MAC_NO_ACK_RECEIVED - the requested ACK was not received in time.
317  * ::ST_PHY_TX_CCA_FAIL - unable to transmit due to lack of clear channel on
318  * all attempts.
319  * ::ST_PHY_TX_UNDERFLOW - DMA underflow occurred while transmitting. Should
320  * never happen.
321  * ::ST_PHY_TX_INCOMPLETE - The PLL synthesizer failed to lock while
322  * transmitting. Should never happen.
323  *
324  * @param sfdSentTime the value of the MAC timer captured when the SFD was sent.
325  *
326  * @param framePending TRUE if the received ACK indicates that data is
327  * pending for this node, FALSE otherwise.
328  */
329 extern void ST_RadioTransmitCompleteIsrCallback(StStatus status,
330  u32 sfdSentTime,
331  boolean framePending);
332 
333 /** @brief
334  * This function sets the Energy Detection Clear Channel Assessment threshold.
335  *
336  * @param threshold the energy level in dBm below which the channel will be
337  * considered clear.
338  */
339 void ST_RadioSetEdCcaThreshold(s8 threshold);
340 
341 /** @brief
342  * This function get the Energy Detection Clear Channel Assessment threshold.
343  *
344  * @return the Energy Detection Clear Channel Assessment threshold in units of
345  * dBm.
346  */
347 s8 ST_RadioGetEdCcaThreshold(void);
348 
349 /** @brief This function enables or disables notification of the SFD sent event
350  * via the ST_RadioSfdSentIsrCallback().
351  *
352  * @param enable TRUE if the notification is to be enabled, FALSE if the
353  * notification is to be disabled.
354  */
355 void ST_RadioEnableSfdSentNotification(boolean enable);
356 
357 /** @brief
358  * This function indicates whether the SFD sent notification via
359  * \c ST_RadioSfdSentIsrCallback() is enabled or disabled.
360  *
361  * @return TRUE if the SFD sent notification is enabled, FALSE otherwise.
362  */
363 boolean ST_RadioSfdSentNotificationEnabled(void);
364 
365 /** @brief
366  * This function is called by the library in response to an SFD sent event if
367  * this notification has been enabled by a call to
368  * \c ST_RadioEnableSfdSentNotification().
369  *
370  * NOTE: This callback is called for ACKs as well as normal packets.
371  *
372  * NOTE: In cases of extreme interrupt latency it is possible that
373  * \c sfdSentTime may contain the SFD time of the last received packet instead
374  * of the time of the last transmitted packet.
375  *
376  * @param sfdSentTime the value of the MAC timer when the SFD was sent in the
377  * last transmitted packet.
378  */
379 void ST_RadioSfdSentIsrCallback(u32 sfdSentTime);
380 
381 /** @brief
382  * This function sets the radio transmit power to a new level within the minimum
383  * and maximum values specified in the datasheet for the specific device.
384  *
385  * NOTE: It is possible for this function to succeed and set the power level to
386  * a value other than that specified in the \c power parameter. The reason for
387  * for this behavior is that not all integer power levels are available at lower
388  * power levels. When a specific power level is not available the next higher
389  * power level is used.
390  *
391  * @return ::ST_SUCCESS if the power level has been changed, or an error
392  * status code if not (e.g. if the requested value is out of range).
393  *
394  * @param power the desired power level in units of dBm.
395  */
396 StStatus ST_RadioSetPower(s8 power);
397 
398 /** @brief
399  * This function gets the radio transmit power level.
400  *
401  * @return the radio transmit power level in units of dBm.
402  */
403 s8 ST_RadioGetPower(void);
404 
405 //@}//END Transmit APIs
406 
407 
408 //---------------------------------------------------------------------------
409 /** @name
410  * Receive APIs
411  *
412  * @brief
413  * These APIs control the reception of packets.
414  */
415 //@{
416 
417 /** @brief
418  * This function is called by the library when a packet has been received.
419  *
420  * @param *packet points to the packet data beginning with the length byte.
421  * The CRC bytes will have been removed from the packet.
422  *
423  * @param ackFramePendingSet TRUE if the library set the Frame Pending bit in
424  * the hardware-generated MAC ACK to this packet, FALSE otherwise.
425  *
426  * @param time The value of the MAC timer when the SFD was received for this
427  * packet.
428  *
429  * @param errors The number of correlator errors in the packet.
430  *
431  * @param rssi The energy detected over the last 8 symbols of the packet in
432  * units of dBm.
433  */
434 extern void ST_RadioReceiveIsrCallback(u8 *packet,
435  boolean ackFramePendingSet,
436  u32 time,
437  u16 errors,
438  s8 rssi);
439 
440 /** @brief
441  * This function enables or disables address filtering on PAN ID, node ID, and
442  * EUI 64.
443  *
444  * NOTE: Address filtering is enabled by default.
445  *
446  * @param enable TRUE to enable address filtering, FALSE otherwise.
447  */
448 void ST_RadioEnableAddressFiltering(boolean enable);
449 
450 /** @brief
451  * This function gets the address filtering status of the device.
452  *
453  * @return TRUE if address filtering is enabled, FALSE otherwise.
454  */
455 boolean ST_RadioAddressFilteringEnabled(void);
456 
457 /** @brief
458  * This function enables or disables automatic transmission of ACKs in response
459  * to received packets which request ACKs.
460  *
461  * NOTE: Address filtering must be enabled for automatic transmission of ACKs to
462  * occur.
463  *
464  * NOTE: Automatic acknowledgement is enabled by default.
465  *
466  * @param enable TRUE to enable automatic acknowledgement transmission, FALSE
467  * otherwise.
468  */
469 void ST_RadioEnableAutoAck(boolean enable);
470 
471 /** @brief
472  * This function gets the automatic acknowledgement status of the device.
473  *
474  * @return TRUE if automatic acknowledgement is enabled, FALSE otherwise.
475  */
476 boolean ST_RadioAutoAckEnabled(void);
477 
478 /** @brief
479  * This function sets the short address of the node.
480  *
481  * @param nodeId the 16-bit address to use for filtering short-addressed
482  * packets when address filtering is enabled.
483  *
484  */
485 void ST_RadioSetNodeId(u16 nodeId);
486 
487 /** @brief
488  * This function gets the short address of the node.
489  *
490  * @return nodeId the 16-bit address to use for filtering short-addressed
491  * packets.
492  */
493 u16 ST_RadioGetNodeId(void);
494 
495 /** @brief
496  * This function sets the PAN id of the node.
497  *
498  * @param panId the 16-bit PAN id to use for filtering packets when address
499  * filtering is enabled.
500  */
501 void ST_RadioSetPanId(u16 panId);
502 
503 /** @brief
504  * This function gets the PAN id of the node.
505  *
506  * @return 16-bit PAN id to use for filtering packets when address
507  * filtering is enabled.
508  */
509 u16 ST_RadioGetPanId(void);
510 
511 /** @brief
512  * This function get the EUI 64 of the node.
513  *
514  * NOTE: The EUI 64 is set via manufacturing tokens (See the Programming and
515  * Serialization Specification for details).
516  *
517  * @return the memory address of the 64-bit EUI address to use for filtering
518  * long-addressed packets when address filtering is enabled.
519  */
520 u8* ST_RadioGetEui64(void);
521 
522 /** @brief
523  * This function is called by the library after the long address fields of a
524  * packet have been received. The library will set the frame pending bit in the
525  * outgoing ACK only if the return value is TRUE. The application must lookup
526  * the \c eui64 in its own data structures and return TRUE if there is data
527  * pending, FALSE otherwise. It is critical that this function complete as
528  * quickly as possible to ensure the frame pending bit can be set before the ACK
529  * is transmitted.
530  *
531  * @return TRUE if the frame pending bit should be set in the outgoing ACK.
532  */
533 boolean ST_RadioDataPendingLongIdIsrCallback(u8* longId);
534 
535 /** @brief
536  * This function is called by the library after the short address fields of a
537  * packet have been received. The library will set the frame pending bit in the
538  * outgoing ACK only if the return value is TRUE. The application must lookup
539  * \c shortId in its own data structures and return TRUE if there is data
540  * pending, FALSE otherwise. It is critical that this function complete as
541  * quickly as possible to ensure the frame pending bit can be set before the ACK
542  * is transmitted.
543  *
544  * @return TRUE if the frame pending bit should be set in the outgoing ACK.
545  */
546 boolean ST_RadioDataPendingShortIdIsrCallback(u16 shortId);
547 
548 /** @brief
549  * This function sets or clears coordinator mode for this node. A
550  * coordinator is able to receive 802.15.4. DATA frames that have no destination
551  * address. A node that is not a coordinator will not receive these packets.
552  *
553  * NOTE: The source PAN id of the DATA frame with no destination address must
554  * still match the node PAN id in order for it to be received by the
555  * coordinator node.
556  *
557  * NOTE: A node is not a coordinator by default.
558  *
559  * @param coordinator TRUE to enable coordinator mode, FALSE to disable
560  * coordinator mode.
561  */
562 void ST_RadioSetCoordinator(boolean coordinator);
563 
564 /** @brief
565  * This function gets the coordinator status of the node.
566  *
567  * @return TRUE if the node is configured as a coordinator, FALSE otherwise.
568  */
569 boolean ST_RadioDeviceIsCoordinator(void);
570 
571 /** @brief
572  * This function enables or disables notification of DMA receive buffer overflow
573  * events via ST_RadioOverflowIsrCallback().
574  *
575  * @param enable TRUE to enable overflow notification, FALSE otherwise.
576  */
577 void ST_RadioEnableOverflowNotification(boolean enable);
578 
579 /** @brief
580  * This function indicates whether the overflow notification via
581  * ST_RadioOverflowIsrCallback() is enabled or disabled.
582  *
583  * @return TRUE if overflow notification is enabled, FALSE otherwise.
584  */
585 boolean ST_RadioOverflowNotificationEnabled(void);
586 
587 /** @brief
588  * This function is called by the library in response to a receive overflow
589  * event if this notification is enabled by a call to
590  * ST_RadioEnableOverflowNotification().
591  */
592 void ST_RadioOverflowIsrCallback(void);
593 
594 /** @brief
595  * This function enables or disables discarding received packets that fail the
596  * Cyclic Redundancy Check.
597  *
598  * NOTE: When this option is enabled the library automatically strips the CRC
599  * bytes off of packets that pass CRC check.
600  *
601  * NOTE: Discarding packets that fail CRC is enabled by default.
602  *
603  * @param enable TRUE to enable discarding packets that fail CRC, FALSE
604  * otherwise.
605  */
606 void ST_RadioEnableReceiveCrc(boolean enable);
607 
608 /** @brief
609  * This function gets the receive CRC configuration of the node.
610  *
611  * @return TRUE if received packets that fail CRC will be discarded, FALSE
612  * otherwise.
613  */
614 boolean ST_RadioReceiveCrcEnabled(void);
615 
616 //@}//END Receive APIs
617 
618 
619 //---------------------------------------------------------------------------
620 /** @name
621  * MAC Timer APIs
622  *
623  * @brief
624  * These APIs expose an interface to the MAC Timer.
625  * The MAC timer is 20-bits long with each LSB tick representing 1us.
626  * The MAC timer rolls over to zero approximately once every second.
627  * The MAC timer is free-running from the time that ST_RadioInit() is called.
628  */
629 //@{
630 
631 /** @brief
632  * This function gets an instantaneous reading of the MAC timer.
633  *
634  * @return the current value of the MAC timer.
635  */
636 u32 ST_RadioGetMacTimer(void);
637 
638 /** @brief
639  * This function enables or disables comparison of the MAC timer against an
640  * application-supplied value and notification via
641  * ST_RadioMacTimerCompareIsrCallback().
642  *
643  * @param enable TRUE to enable MAC timer comparison and notification via a
644  * callback.
645  */
646 void ST_RadioEnableMacTimerCompare(boolean enable);
647 
648 /** @brief
649  * This function indicates whether MAC timer comparison and callback
650  * notification are enabled or disabled.
651  *
652  * @return TRUE if MAC timer comparison and notification are enabled, FALSE
653  * otherwise.
654  */
655 boolean ST_RadioMacTimerCompareEnabled(void);
656 
657 /** @brief
658  * This function sets the value to compare against the MAC timer.
659  *
660  * @param value the value to compare against the MAC timer.
661  */
662 void ST_RadioSetMacTimerCompare(u32 value);
663 
664 /** @brief
665  * This function gets the value to compare against the MAC timer.
666  *
667  * @return the value to compare against the MAC timer.
668  */
669 u32 ST_RadioGetMacTimerCompare(void);
670 
671 /** @brief
672  * This function is called by the library in response to MAC timer comparison
673  * event.
674  */
675 extern void ST_RadioMacTimerCompareIsrCallback(void);
676 //@}//END MAC Timer APIs
677 
678 
679 //---------------------------------------------------------------------------
680 /** @name
681  * Cryptography APIs
682  *
683  * @brief
684  * These APIs provide an interface to the hardware AES coprocessor.
685  */
686 //@{
687 
688 /** @brief
689  * This function sets the key to use during AES encryption.
690  *
691  * @param *key pointer to 128 bits of key data.
692  */
693 void ST_AesSetKey(u8* key);
694 
695 /**
696  * This function gets the key that is used during AES encryption.
697  *
698  * @param *key pointer to memory where 128 bits of key data will be written.
699  */
700 void ST_AesGetKey(u8* key);
701 
702 /** @brief
703  * This function encrypts the 128 bits of plaintext data located at \c block
704  * using the AES coprocessor previously configured by ST_AesSetKey().
705  * The resulting 128 bits of cyphertext are stored at \c block, overwriting
706  * the supplied plaintext.
707  *
708  * @param block pointer to memory containing the plaintext when this function is
709  * called and containing the cyphertext after this function has returned.
710  */
711 void ST_AesEncrypt(u8* block);
712 
713 //@}//END Cryptography APIs
714 
715 
716 //---------------------------------------------------------------------------
717 /** @name
718  * Miscellaneous APIs
719  *
720  * @brief
721  * These APIs control diagnostic and configuration functionality.
722  */
723 //@{
724 
725 /** @brief
726  * This function starts transmission of a carrier wave at the current channel
727  * center frequency. The carrier wave will be transmitted until
728  * ST_RadioStopTransmitTone() is called.
729  *
730  * NOTE: The radio must be idle (not transmitting) before entering this mode.
731  *
732  * NOTE: Other radio APIs must not be called while in this mode.
733  */
734 void ST_RadioStartTransmitTone(void);
735 
736 /** @brief
737  * This function stops transmission of carrier wave started by
738  * ST_RadioStartTransmitTone().
739  */
740 void ST_RadioStopTransmitTone(void);
741 
742 /** @brief
743  * this function starts transmission of a continuous stream of modulated data.
744  * No packet framing is present in this transmission. Random symbols will be
745  * transmitted until ST_RadioStopTransmitStream() is called.
746  *
747  * NOTE: The radio must be idle (not transmitting) before entering this mode.
748  *
749  * NOTE: Other radio APIs must not be called while in this mode.
750  */
751 void ST_RadioStartTransmitStream(void);
752 
753 /** @brief
754  * This function stops transmission of continuous stream of modulated data
755  * started by ST_RadioStartTransmitStream().
756  */
757 void ST_RadioStopTransmitStream(void);
758 
759 /** @brief
760  * This function gets a reading of the average energy detected over the previous
761  * eight symbol periods (128us total).
762  *
763  * @return the energy level detected in units of dBm.
764  */
765 s8 ST_RadioEnergyDetection(void);
766 
767 /** @brief
768  * This function accesses radio hardware to obtain true random numbers.
769  *
770  * @param *rn pointer to memory to hold \c count random numbers.
771  *
772  * @param count the number of 16-bit random numbers to get.
773  */
774 void ST_RadioGetRandomNumbers(u16 *rn, u8 count);
775 
776 /** @brief
777  * This function gets the clear or busy status of the channel.
778  *
779  * @return TRUE if channel is clear, FALSE if channel is busy.
780  */
781 boolean ST_RadioChannelIsClear(void);
782 
783 /** @brief
784  * This function enables or disables Packet Trace output.
785  * Before being enabled, the associated IO pins must be separately
786  * configured to allow for the packet trace peripheral to control the pins.
787  *
788  * NOTE: Packet Trace is on by default.
789  *
790  * @param enable TRUE to enable Packet Trace, FALSE otherwise.
791  */
792 void ST_RadioEnablePacketTrace(boolean enable);
793 
794 /** @brief
795  * This function indicates whether Packet Trace is enabled or not.
796  *
797  * @return TRUE if Packet Trace is enabled, FALSE otherwise.
798  */
799 boolean ST_RadioPacketTraceEnabled(void);
800 
801 /** @brief
802  * This function sets the radio power mode according to the bits
803  * encoded in \c powerMode.
804  *
805  * NOTE: The default power mode is whatever is configured in the PHY_CONFIG
806  * token (normal, bi-directional mode if not explicitly set otherwise.
807  *
808  * NOTE: It is preferable to set this configuration via the PHY_CONFIG token
809  * rather than using this API.
810  *
811  * @param txPowerMode encodes the power mode as follows:
812  * bit 0 set to 0: Normal mode.
813  * bit 0 set to 1: Boost mode.
814  * bit 1 set to 0: Use bi-directional transmit path.
815  * bit 1 set to 1: Use alternate transmit path.
816  *
817  * @return ::ST_SUCCESS always.
818  */
819 StStatus ST_RadioSetPowerMode(u16 txPowerMode);
820 
821 /** @brief
822  * This function gets the radio power mode.
823  *
824  * @return the radio power mode (boost/normal, bi-directional/alternate transmit
825  * path) encoded as bits in a 16-bit word (see ST_RadioSetPowerMode()
826  * documentation for details).
827  */
828 u16 ST_RadioGetPowerMode(void);
829 
830 //@}//END Miscellaneous APIs