00001 /* 00002 * File: stack/phy/phy-library.h 00003 * Description: Interface definition for library functionality. 00004 * 00005 * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. --> 00006 */ 00007 00008 00009 //--------------------------------------------------------------------------- 00010 // Definitions 00011 //------------ 00012 00013 /** 00014 * @name SIMPLEMAC version defines 00015 *@{ 00016 */ 00017 00018 00019 /** 00020 * @brief Version major number 00021 */ 00022 #define SIMPLEMAC_VERSION_MAJOR 1 00023 00024 /** 00025 * @brief Version minor number 00026 */ 00027 #define SIMPLEMAC_VERSION_MINOR 0 00028 00029 /** 00030 * @brief Version patch number 00031 */ 00032 #define SIMPLEMAC_VERSION_PATCH 2 00033 00034 /** 00035 * @brief Version qualifier 00036 */ 00037 #define SIMPLEMAC_VERSION_QUAL "" 00038 00039 #define _SQUOTEME(a) #a 00040 #define SQUOTEME(a) _SQUOTEME(a) 00041 00042 /** 00043 * @brief Version string 00044 */ 00045 #define SIMPLEMAC_VERSION_STRING SQUOTEME(SIMPLEMAC_VERSION_MAJOR) "." SQUOTEME(SIMPLEMAC_VERSION_MINOR) "." SQUOTEME(SIMPLEMAC_VERSION_PATCH) SIMPLEMAC_VERSION_QUAL 00046 00047 //@} \\END SIMPLEMAC version defines 00048 00049 00050 #define SECURITY_BLOCK_SIZE 16 // bytes 00051 #define MIN_RADIO_POWER -43 // dBm 00052 #define MAX_RADIO_POWER 3 // dBm 00053 00054 #ifndef __PHY_H__ 00055 enum { 00056 ST_RADIO_POWER_MODE_RX_ON, 00057 ST_RADIO_POWER_MODE_OFF 00058 }; 00059 typedef u8 RadioPowerMode; 00060 00061 //--------------------------------------------------------------------------- 00062 // Transmit Configuration 00063 //----------------------- 00064 // The application must declare this structure and initialize each member 00065 // variable. radioTransmitConfig must be initialized prior to calling 00066 // ST_RadioTransmit() and may be modified only while no transmit operation is 00067 // in progress. 00068 00069 #define RADIO_CCA_ATTEMPT_MAX_DEFAULT 4 00070 #define RADIO_BACKOFF_EXPONENT_MIN_DEFAULT 3 00071 #define RADIO_BACKOFF_EXPONENT_MAX_DEFAULT 5 00072 00073 typedef struct { 00074 boolean waitForAck; // Wait for ACK if ACK request set in FCF. 00075 boolean checkCca; // backoff and check CCA before transmit. 00076 u8 ccaAttemptMax; // The number of CCA attempts before failure; 00077 u8 backoffExponentMin; // Backoff exponent for the initial CCA attempt. 00078 u8 backoffExponentMax; // Backoff exponent for the final CCA attempt(s). 00079 boolean appendCrc; // Append CRC to transmitted packets. 00080 } RadioTransmitConfig; 00081 #endif// __PHY_H__ 00082 00083 #ifndef ST_TYPES_H 00084 /** 00085 * @name txPowerModes for stSetTxPowerMode and mfglibSetPower 00086 */ 00087 //@{ 00088 00089 /** @brief The application should call ::stSetTxPowerMode() with the 00090 * txPowerMode parameter set to this value to disable all power mode options, 00091 * resulting in normal power mode and bi-directional RF transmitter output. 00092 */ 00093 #define ST_TX_POWER_MODE_DEFAULT 0x0000 00094 /** @brief The application should call ::stSetTxPowerMode() with the 00095 * txPowerMode parameter set to this value to enable boost power mode. 00096 */ 00097 #define ST_TX_POWER_MODE_BOOST 0x0001 00098 /** @brief The application should call ::stSetTxPowerMode() with the 00099 * txPowerMode parameter set to this value to enable the alternate transmitter 00100 * output. 00101 */ 00102 #define ST_TX_POWER_MODE_ALTERNATE 0x0002 00103 /** @brief The application should call ::stSetTxPowerMode() with the 00104 * txPowerMode parameter set to this value to enable both boost mode and the 00105 * alternate transmitter output. 00106 */ 00107 #define ST_TX_POWER_MODE_BOOST_AND_ALTERNATE (ST_TX_POWER_MODE_BOOST \ 00108 |ST_TX_POWER_MODE_ALTERNATE) 00109 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00110 // The application does not ever need to call stSetTxPowerMode() with the 00111 // txPowerMode parameter set to this value. This value is used internally by 00112 // the stack to indicate that the default token configuration has not been 00113 // overidden by a prior call to stSetTxPowerMode(). 00114 #define ST_TX_POWER_MODE_USE_TOKEN 0x8000 00115 #endif//DOXYGEN_SHOULD_SKIP_THIS 00116 //@} \\END Definitions 00117 00118 /** 00119 * @brief The maximum 802.15.4 channel number is 26. 00120 */ 00121 #define ST_MAX_802_15_4_CHANNEL_NUMBER 26 00122 00123 /** 00124 * @brief The minimum 802.15.4 channel number is 11. 00125 */ 00126 #define ST_MIN_802_15_4_CHANNEL_NUMBER 11 00127 00128 /** 00129 * @brief There are sixteen 802.15.4 channels. 00130 */ 00131 #define ST_NUM_802_15_4_CHANNELS \ 00132 (ST_MAX_802_15_4_CHANNEL_NUMBER - ST_MIN_802_15_4_CHANNEL_NUMBER + 1) 00133 00134 #endif //ST_TYPES_H 00135 00136 00137 00138 00139 //--------------------------------------------------------------------------- 00140 /** @name 00141 * Radio power state control APIs 00142 * 00143 * @brief 00144 * These APIs control the overall radio initialization and power state. 00145 */ 00146 //@{ 00147 00148 /** @brief 00149 * This function performs one-time radio initialization and calibration. 00150 * This function must be called once after chip reset or wake from deep sleep. 00151 * This function will power up the radio while it configures the radio channel. 00152 * After the radio is configured and the channel is set the radio will be left 00153 * in the state specified by the \c initialRadioPowerMode parameter. 00154 * This function calls ST_RadioSetPowerMode(), 00155 * ST_RadioEnableAddressFiltering(), ST_RadioEnableAutoAck(), 00156 * ST_RadioSetCoordinator(), ST_RadioSetPower(), ST_RadioSetChannel(), 00157 * ST_RadioEnablePacketTrace(), and ST_RadioEnableReceiveCrc() 00158 * providing the last used argument for each function. If these functions have 00159 * not been called before ST_RadioInit() then the default for each is used. 00160 * Only the functions listed above can be called before ST_RadioInit(). 00161 * All other library functions must not be called until after 00162 * ST_RadioInit() has been called once after each chip reset or wake from deep 00163 * sleep. 00164 * 00165 * @param 00166 * initialRadioPowerMode specifies the state that the function will leave the 00167 * radio in after it is configured. This parameter can be either: 00168 * ST_RADIO_POWER_MODE_OFF - radio will be powered down. 00169 * ST_RADIO_POWER_MODE_RX_ON - radio will be left in the on (receive) state. 00170 * 00171 * @return ::ST_SUCCESS or a status code indicating the reason for failure. 00172 */ 00173 StStatus ST_RadioInit(RadioPowerMode initialRadioPowerMode); 00174 00175 /** @brief 00176 * Turns on the radio. The last radio configuration is used. 00177 */ 00178 void ST_RadioWake(void); 00179 00180 /** @brief 00181 * This function turns off the radio. 00182 * Any transmit or receive packets in progress are aborted. 00183 * The library may or may not call ST_RadioTransmitCompleteIsrCallback() for an 00184 * aborted transmit packet. 00185 * ST_RadioWake() must not be called within 250us of having called 00186 * ST_RadioSleep(). 00187 */ 00188 void ST_RadioSleep(void); 00189 00190 //@}//END Radio power state control APIs 00191 00192 00193 //--------------------------------------------------------------------------- 00194 /** @name 00195 * Channel APIs 00196 * 00197 * @brief 00198 * These APIs control channel selection and calibration. 00199 */ 00200 //@{ 00201 00202 /** @brief 00203 * Configures the radio to communicate on a 802.15.4 channel. 00204 * If ST_RadioInit() has not been called yet, the channel number is recorded 00205 * but no calibration takes place. The specified channel will be configured 00206 * when ST_RadioInit() is eventually called. 00207 * If the radio is asleep this function will wake it to perform channel 00208 * calibration and then return it to sleep before exiting. 00209 * The first time a channel is selected all radio parameters will be calibrated 00210 * for that channel. This full calibration process can take up to 200ms to 00211 * complete. The results of some of these calibrations are stored in flash 00212 * tokens for use the next time the same channel is selected. Subsequent calls 00213 * to ST_RadioSetChannel() requesting the same channel will take less time 00214 * because the stored values will be retrieved from the flash tokens and reused. 00215 * 00216 * @param channel the 802.15.4 channel that the radio will communicate on. 00217 * 00218 * @return ::ST_SUCCESS or a status code indicating the reason for failure. 00219 */ 00220 StStatus ST_RadioSetChannel(u8 channel); 00221 00222 /** @brief 00223 * This function gets the 802.15.4 channel that the radio is configured to use. 00224 * 00225 * @return the 802.15.4 channel that the radio is configured to use. 00226 */ 00227 u8 ST_RadioGetChannel(void); 00228 00229 /** @brief 00230 * This function is identical to ST_RadioSetChannel() except that it 00231 * calibrates all radio parameters regardless of whether calibration is 00232 * required. 00233 * 00234 * NOTE: This function does not need to be called under normal operating 00235 * conditions. The library will reuse available stored calibration values 00236 * and will perform necessary re-calibration automatically. Calling this 00237 * function will cause the library to calibrate all radio parameters and 00238 * store the results in flash, overwriting previous stored values. Use of 00239 * this function will cause unnecessary flash wear and will take longer to 00240 * complete than a call to ST_RadioSetChannel(). This function should only 00241 * be called to recover from hardware-related calibration problems, which 00242 * should only occur during hardware development. 00243 * 00244 * @param channel the 802.15.4 channel that the radio will communicate on. 00245 * 00246 * @return ::ST_SUCCESS or a status code indicating the reason for failure. 00247 */ 00248 StStatus ST_RadioSetChannelAndForceCalibration(u8 channel); 00249 00250 /** @brief 00251 * This function checks to see if the radio needs calibrating to maintain 00252 * expected performance as environmental conditions change. 00253 * If this function indicates that the calibration is needed, the application 00254 * should call ST_RadioCalibrateCurrentChannel(). 00255 * 00256 * NOTE: This function must not be called while a transmit is in progress. 00257 * 00258 * @return TRUE if calibration is needed to compensate for temperature changes, 00259 * FALSE otherwise. 00260 */ 00261 boolean ST_RadioCheckRadio(void); 00262 00263 /** @brief 00264 * This function performs necessary recalibration to counteract the effects of 00265 * temperature changes since the last calibration. It should be called by the 00266 * application when ST_RadioCheckRadio() indicates that calibration is needed. 00267 */ 00268 void ST_RadioCalibrateCurrentChannel(void); 00269 00270 //@}//END Channel APIs 00271 00272 00273 //--------------------------------------------------------------------------- 00274 /** @name 00275 * Transmit APIs 00276 * 00277 * @brief 00278 * These APIs control the transmission of packets. 00279 */ 00280 //@{ 00281 00282 /** @brief 00283 * This function transmits a packet using the configuration specified in 00284 * \c radioTransmitConfig. 00285 * 00286 * @param *packet A pointer to the packet to be transmitted. The first byte of 00287 * \c packet must be set to the number of payload bytes to be transmitted. 00288 * If \c radioTransmitConfig.appendCrc is TRUE the length byte must accommodate 00289 * the hardware-appended two-byte CRC. 00290 * e.g. A packet with a two-byte payload would be represented in memory as: 00291 * {0x04, 0x00, 0x01, 0xc0, 0xc1} where 0xc0 and 0xc1 are the CRC bytes. 00292 * If \c radioTransmitConfig.checkCca is TRUE this function performs CSMA-CA 00293 * backoff(s) and CCA check(s) before transmitting, else it starts the 00294 * transmit process immediately. 00295 * 00296 * @return ::ST_SUCCESS if the transmission process is successfully started. 00297 * In this case ST_RadioTransmitCompleteIsrCallback() will eventually be 00298 * called to indicate the completion status. If the radio is busy transmitting, 00299 * this function returns an error code and 00300 * ST_RadioTransmitCompleteIsrCallback() will not be called. 00301 */ 00302 StStatus ST_RadioTransmit(u8* packet); 00303 00304 /** @brief 00305 * This function is called by the library once after each ST_RadioTransmit() 00306 * call that returned successfully. If the ST_RadioTransmit() call returned 00307 * an error ST_RadioTransmitCompleteIsrCallback() will not be called. 00308 * 00309 * NOTE: ST_RadioTransmit() can be called again within the context of this 00310 * callback. 00311 * 00312 * @param status parameter indicates one of the following conditions: 00313 * ::ST_SUCCESS - the last byte of the non-ACK-request packet has been 00314 * transmitted. 00315 * ::ST_PHY_ACK_RECEIVED - the requested ACK was received. 00316 * ::ST_MAC_NO_ACK_RECEIVED - the requested ACK was not received in time. 00317 * ::ST_PHY_TX_CCA_FAIL - unable to transmit due to lack of clear channel on 00318 * all attempts. 00319 * ::ST_PHY_TX_UNDERFLOW - DMA underflow occurred while transmitting. Should 00320 * never happen. 00321 * ::ST_PHY_TX_INCOMPLETE - The PLL synthesizer failed to lock while 00322 * transmitting. Should never happen. 00323 * 00324 * @param sfdSentTime the value of the MAC timer captured when the SFD was sent. 00325 * 00326 * @param framePending TRUE if the received ACK indicates that data is 00327 * pending for this node, FALSE otherwise. 00328 */ 00329 extern void ST_RadioTransmitCompleteIsrCallback(StStatus status, 00330 u32 sfdSentTime, 00331 boolean framePending); 00332 00333 /** @brief 00334 * This function sets the Energy Detection Clear Channel Assessment threshold. 00335 * 00336 * @param threshold the energy level in dBm below which the channel will be 00337 * considered clear. 00338 */ 00339 void ST_RadioSetEdCcaThreshold(s8 threshold); 00340 00341 /** @brief 00342 * This function get the Energy Detection Clear Channel Assessment threshold. 00343 * 00344 * @return the Energy Detection Clear Channel Assessment threshold in units of 00345 * dBm. 00346 */ 00347 s8 ST_RadioGetEdCcaThreshold(void); 00348 00349 /** @brief This function enables or disables notification of the SFD sent event 00350 * via the ST_RadioSfdSentIsrCallback(). 00351 * 00352 * @param enable TRUE if the notification is to be enabled, FALSE if the 00353 * notification is to be disabled. 00354 */ 00355 void ST_RadioEnableSfdSentNotification(boolean enable); 00356 00357 /** @brief 00358 * This function indicates whether the SFD sent notification via 00359 * \c ST_RadioSfdSentIsrCallback() is enabled or disabled. 00360 * 00361 * @return TRUE if the SFD sent notification is enabled, FALSE otherwise. 00362 */ 00363 boolean ST_RadioSfdSentNotificationEnabled(void); 00364 00365 /** @brief 00366 * This function is called by the library in response to an SFD sent event if 00367 * this notification has been enabled by a call to 00368 * \c ST_RadioEnableSfdSentNotification(). 00369 * 00370 * NOTE: This callback is called for ACKs as well as normal packets. 00371 * 00372 * NOTE: In cases of extreme interrupt latency it is possible that 00373 * \c sfdSentTime may contain the SFD time of the last received packet instead 00374 * of the time of the last transmitted packet. 00375 * 00376 * @param sfdSentTime the value of the MAC timer when the SFD was sent in the 00377 * last transmitted packet. 00378 */ 00379 void ST_RadioSfdSentIsrCallback(u32 sfdSentTime); 00380 00381 /** @brief 00382 * This function sets the radio transmit power to a new level within the minimum 00383 * and maximum values specified in the datasheet for the specific device. 00384 * 00385 * NOTE: It is possible for this function to succeed and set the power level to 00386 * a value other than that specified in the \c power parameter. The reason for 00387 * for this behavior is that not all integer power levels are available at lower 00388 * power levels. When a specific power level is not available the next higher 00389 * power level is used. 00390 * 00391 * @return ::ST_SUCCESS if the power level has been changed, or an error 00392 * status code if not (e.g. if the requested value is out of range). 00393 * 00394 * @param power the desired power level in units of dBm. 00395 */ 00396 StStatus ST_RadioSetPower(s8 power); 00397 00398 /** @brief 00399 * This function gets the radio transmit power level. 00400 * 00401 * @return the radio transmit power level in units of dBm. 00402 */ 00403 s8 ST_RadioGetPower(void); 00404 00405 //@}//END Transmit APIs 00406 00407 00408 //--------------------------------------------------------------------------- 00409 /** @name 00410 * Receive APIs 00411 * 00412 * @brief 00413 * These APIs control the reception of packets. 00414 */ 00415 //@{ 00416 00417 /** @brief 00418 * This function is called by the library when a packet has been received. 00419 * 00420 * @param *packet points to the packet data beginning with the length byte. 00421 * The CRC bytes will have been removed from the packet. 00422 * 00423 * @param ackFramePendingSet TRUE if the library set the Frame Pending bit in 00424 * the hardware-generated MAC ACK to this packet, FALSE otherwise. 00425 * 00426 * @param time The value of the MAC timer when the SFD was received for this 00427 * packet. 00428 * 00429 * @param errors The number of correlator errors in the packet. 00430 * 00431 * @param rssi The energy detected over the last 8 symbols of the packet in 00432 * units of dBm. 00433 */ 00434 extern void ST_RadioReceiveIsrCallback(u8 *packet, 00435 boolean ackFramePendingSet, 00436 u32 time, 00437 u16 errors, 00438 s8 rssi); 00439 00440 /** @brief 00441 * This function enables or disables address filtering on PAN ID, node ID, and 00442 * EUI 64. 00443 * 00444 * NOTE: Address filtering is enabled by default. 00445 * 00446 * @param enable TRUE to enable address filtering, FALSE otherwise. 00447 */ 00448 void ST_RadioEnableAddressFiltering(boolean enable); 00449 00450 /** @brief 00451 * This function gets the address filtering status of the device. 00452 * 00453 * @return TRUE if address filtering is enabled, FALSE otherwise. 00454 */ 00455 boolean ST_RadioAddressFilteringEnabled(void); 00456 00457 /** @brief 00458 * This function enables or disables automatic transmission of ACKs in response 00459 * to received packets which request ACKs. 00460 * 00461 * NOTE: Address filtering must be enabled for automatic transmission of ACKs to 00462 * occur. 00463 * 00464 * NOTE: Automatic acknowledgement is enabled by default. 00465 * 00466 * @param enable TRUE to enable automatic acknowledgement transmission, FALSE 00467 * otherwise. 00468 */ 00469 void ST_RadioEnableAutoAck(boolean enable); 00470 00471 /** @brief 00472 * This function gets the automatic acknowledgement status of the device. 00473 * 00474 * @return TRUE if automatic acknowledgement is enabled, FALSE otherwise. 00475 */ 00476 boolean ST_RadioAutoAckEnabled(void); 00477 00478 /** @brief 00479 * This function sets the short address of the node. 00480 * 00481 * @param nodeId the 16-bit address to use for filtering short-addressed 00482 * packets when address filtering is enabled. 00483 * 00484 */ 00485 void ST_RadioSetNodeId(u16 nodeId); 00486 00487 /** @brief 00488 * This function gets the short address of the node. 00489 * 00490 * @return nodeId the 16-bit address to use for filtering short-addressed 00491 * packets. 00492 */ 00493 u16 ST_RadioGetNodeId(void); 00494 00495 /** @brief 00496 * This function sets the PAN id of the node. 00497 * 00498 * @param panId the 16-bit PAN id to use for filtering packets when address 00499 * filtering is enabled. 00500 */ 00501 void ST_RadioSetPanId(u16 panId); 00502 00503 /** @brief 00504 * This function gets the PAN id of the node. 00505 * 00506 * @return 16-bit PAN id to use for filtering packets when address 00507 * filtering is enabled. 00508 */ 00509 u16 ST_RadioGetPanId(void); 00510 00511 /** @brief 00512 * This function get the EUI 64 of the node. 00513 * 00514 * NOTE: The EUI 64 is set via manufacturing tokens (See the Programming and 00515 * Serialization Specification for details). 00516 * 00517 * @return the memory address of the 64-bit EUI address to use for filtering 00518 * long-addressed packets when address filtering is enabled. 00519 */ 00520 u8* ST_RadioGetEui64(void); 00521 00522 /** @brief 00523 * This function is called by the library after the long address fields of a 00524 * packet have been received. The library will set the frame pending bit in the 00525 * outgoing ACK only if the return value is TRUE. The application must lookup 00526 * the \c eui64 in its own data structures and return TRUE if there is data 00527 * pending, FALSE otherwise. It is critical that this function complete as 00528 * quickly as possible to ensure the frame pending bit can be set before the ACK 00529 * is transmitted. 00530 * 00531 * @return TRUE if the frame pending bit should be set in the outgoing ACK. 00532 */ 00533 boolean ST_RadioDataPendingLongIdIsrCallback(u8* longId); 00534 00535 /** @brief 00536 * This function is called by the library after the short address fields of a 00537 * packet have been received. The library will set the frame pending bit in the 00538 * outgoing ACK only if the return value is TRUE. The application must lookup 00539 * \c shortId in its own data structures and return TRUE if there is data 00540 * pending, FALSE otherwise. It is critical that this function complete as 00541 * quickly as possible to ensure the frame pending bit can be set before the ACK 00542 * is transmitted. 00543 * 00544 * @return TRUE if the frame pending bit should be set in the outgoing ACK. 00545 */ 00546 boolean ST_RadioDataPendingShortIdIsrCallback(u16 shortId); 00547 00548 /** @brief 00549 * This function sets or clears coordinator mode for this node. A 00550 * coordinator is able to receive 802.15.4. DATA frames that have no destination 00551 * address. A node that is not a coordinator will not receive these packets. 00552 * 00553 * NOTE: The source PAN id of the DATA frame with no destination address must 00554 * still match the node PAN id in order for it to be received by the 00555 * coordinator node. 00556 * 00557 * NOTE: A node is not a coordinator by default. 00558 * 00559 * @param coordinator TRUE to enable coordinator mode, FALSE to disable 00560 * coordinator mode. 00561 */ 00562 void ST_RadioSetCoordinator(boolean coordinator); 00563 00564 /** @brief 00565 * This function gets the coordinator status of the node. 00566 * 00567 * @return TRUE if the node is configured as a coordinator, FALSE otherwise. 00568 */ 00569 boolean ST_RadioDeviceIsCoordinator(void); 00570 00571 /** @brief 00572 * This function enables or disables notification of DMA receive buffer overflow 00573 * events via ST_RadioOverflowIsrCallback(). 00574 * 00575 * @param enable TRUE to enable overflow notification, FALSE otherwise. 00576 */ 00577 void ST_RadioEnableOverflowNotification(boolean enable); 00578 00579 /** @brief 00580 * This function indicates whether the overflow notification via 00581 * ST_RadioOverflowIsrCallback() is enabled or disabled. 00582 * 00583 * @return TRUE if overflow notification is enabled, FALSE otherwise. 00584 */ 00585 boolean ST_RadioOverflowNotificationEnabled(void); 00586 00587 /** @brief 00588 * This function is called by the library in response to a receive overflow 00589 * event if this notification is enabled by a call to 00590 * ST_RadioEnableOverflowNotification(). 00591 */ 00592 void ST_RadioOverflowIsrCallback(void); 00593 00594 /** @brief 00595 * This function enables or disables discarding received packets that fail the 00596 * Cyclic Redundancy Check. 00597 * 00598 * NOTE: When this option is enabled the library automatically strips the CRC 00599 * bytes off of packets that pass CRC check. 00600 * 00601 * NOTE: Discarding packets that fail CRC is enabled by default. 00602 * 00603 * @param enable TRUE to enable discarding packets that fail CRC, FALSE 00604 * otherwise. 00605 */ 00606 void ST_RadioEnableReceiveCrc(boolean enable); 00607 00608 /** @brief 00609 * This function gets the receive CRC configuration of the node. 00610 * 00611 * @return TRUE if received packets that fail CRC will be discarded, FALSE 00612 * otherwise. 00613 */ 00614 boolean ST_RadioReceiveCrcEnabled(void); 00615 00616 //@}//END Receive APIs 00617 00618 00619 //--------------------------------------------------------------------------- 00620 /** @name 00621 * MAC Timer APIs 00622 * 00623 * @brief 00624 * These APIs expose an interface to the MAC Timer. 00625 * The MAC timer is 20-bits long with each LSB tick representing 1us. 00626 * The MAC timer rolls over to zero approximately once every second. 00627 * The MAC timer is free-running from the time that ST_RadioInit() is called. 00628 */ 00629 //@{ 00630 00631 /** @brief 00632 * This function gets an instantaneous reading of the MAC timer. 00633 * 00634 * @return the current value of the MAC timer. 00635 */ 00636 u32 ST_RadioGetMacTimer(void); 00637 00638 /** @brief 00639 * This function enables or disables comparison of the MAC timer against an 00640 * application-supplied value and notification via 00641 * ST_RadioMacTimerCompareIsrCallback(). 00642 * 00643 * @param enable TRUE to enable MAC timer comparison and notification via a 00644 * callback. 00645 */ 00646 void ST_RadioEnableMacTimerCompare(boolean enable); 00647 00648 /** @brief 00649 * This function indicates whether MAC timer comparison and callback 00650 * notification are enabled or disabled. 00651 * 00652 * @return TRUE if MAC timer comparison and notification are enabled, FALSE 00653 * otherwise. 00654 */ 00655 boolean ST_RadioMacTimerCompareEnabled(void); 00656 00657 /** @brief 00658 * This function sets the value to compare against the MAC timer. 00659 * 00660 * @param value the value to compare against the MAC timer. 00661 */ 00662 void ST_RadioSetMacTimerCompare(u32 value); 00663 00664 /** @brief 00665 * This function gets the value to compare against the MAC timer. 00666 * 00667 * @return the value to compare against the MAC timer. 00668 */ 00669 u32 ST_RadioGetMacTimerCompare(void); 00670 00671 /** @brief 00672 * This function is called by the library in response to MAC timer comparison 00673 * event. 00674 */ 00675 extern void ST_RadioMacTimerCompareIsrCallback(void); 00676 //@}//END MAC Timer APIs 00677 00678 00679 //--------------------------------------------------------------------------- 00680 /** @name 00681 * Cryptography APIs 00682 * 00683 * @brief 00684 * These APIs provide an interface to the hardware AES coprocessor. 00685 */ 00686 //@{ 00687 00688 /** @brief 00689 * This function sets the key to use during AES encryption. 00690 * 00691 * @param *key pointer to 128 bits of key data. 00692 */ 00693 void ST_AesSetKey(u8* key); 00694 00695 /** 00696 * This function gets the key that is used during AES encryption. 00697 * 00698 * @param *key pointer to memory where 128 bits of key data will be written. 00699 */ 00700 void ST_AesGetKey(u8* key); 00701 00702 /** @brief 00703 * This function encrypts the 128 bits of plaintext data located at \c block 00704 * using the AES coprocessor previously configured by ST_AesSetKey(). 00705 * The resulting 128 bits of cyphertext are stored at \c block, overwriting 00706 * the supplied plaintext. 00707 * 00708 * @param block pointer to memory containing the plaintext when this function is 00709 * called and containing the cyphertext after this function has returned. 00710 */ 00711 void ST_AesEncrypt(u8* block); 00712 00713 //@}//END Cryptography APIs 00714 00715 00716 //--------------------------------------------------------------------------- 00717 /** @name 00718 * Miscellaneous APIs 00719 * 00720 * @brief 00721 * These APIs control diagnostic and configuration functionality. 00722 */ 00723 //@{ 00724 00725 /** @brief 00726 * This function starts transmission of a carrier wave at the current channel 00727 * center frequency. The carrier wave will be transmitted until 00728 * ST_RadioStopTransmitTone() is called. 00729 * 00730 * NOTE: The radio must be idle (not transmitting) before entering this mode. 00731 * 00732 * NOTE: Other radio APIs must not be called while in this mode. 00733 */ 00734 void ST_RadioStartTransmitTone(void); 00735 00736 /** @brief 00737 * This function stops transmission of carrier wave started by 00738 * ST_RadioStartTransmitTone(). 00739 */ 00740 void ST_RadioStopTransmitTone(void); 00741 00742 /** @brief 00743 * this function starts transmission of a continuous stream of modulated data. 00744 * No packet framing is present in this transmission. Random symbols will be 00745 * transmitted until ST_RadioStopTransmitStream() is called. 00746 * 00747 * NOTE: The radio must be idle (not transmitting) before entering this mode. 00748 * 00749 * NOTE: Other radio APIs must not be called while in this mode. 00750 */ 00751 void ST_RadioStartTransmitStream(void); 00752 00753 /** @brief 00754 * This function stops transmission of continuous stream of modulated data 00755 * started by ST_RadioStartTransmitStream(). 00756 */ 00757 void ST_RadioStopTransmitStream(void); 00758 00759 /** @brief 00760 * This function gets a reading of the average energy detected over the previous 00761 * eight symbol periods (128us total). 00762 * 00763 * @return the energy level detected in units of dBm. 00764 */ 00765 s8 ST_RadioEnergyDetection(void); 00766 00767 /** @brief 00768 * This function accesses radio hardware to obtain true random numbers. 00769 * 00770 * @param *rn pointer to memory to hold \c count random numbers. 00771 * 00772 * @param count the number of 16-bit random numbers to get. 00773 */ 00774 void ST_RadioGetRandomNumbers(u16 *rn, u8 count); 00775 00776 /** @brief 00777 * This function gets the clear or busy status of the channel. 00778 * 00779 * @return TRUE if channel is clear, FALSE if channel is busy. 00780 */ 00781 boolean ST_RadioChannelIsClear(void); 00782 00783 /** @brief 00784 * This function enables or disables Packet Trace output. 00785 * Before being enabled, the associated IO pins must be separately 00786 * configured to allow for the packet trace peripheral to control the pins. 00787 * 00788 * NOTE: Packet Trace is on by default. 00789 * 00790 * @param enable TRUE to enable Packet Trace, FALSE otherwise. 00791 */ 00792 void ST_RadioEnablePacketTrace(boolean enable); 00793 00794 /** @brief 00795 * This function indicates whether Packet Trace is enabled or not. 00796 * 00797 * @return TRUE if Packet Trace is enabled, FALSE otherwise. 00798 */ 00799 boolean ST_RadioPacketTraceEnabled(void); 00800 00801 /** @brief 00802 * This function sets the radio power mode according to the bits 00803 * encoded in \c powerMode. 00804 * 00805 * NOTE: The default power mode is whatever is configured in the PHY_CONFIG 00806 * token (normal, bi-directional mode if not explicitly set otherwise. 00807 * 00808 * NOTE: It is preferable to set this configuration via the PHY_CONFIG token 00809 * rather than using this API. 00810 * 00811 * @param txPowerMode encodes the power mode as follows: 00812 * bit 0 set to 0: Normal mode. 00813 * bit 0 set to 1: Boost mode. 00814 * bit 1 set to 0: Use bi-directional transmit path. 00815 * bit 1 set to 1: Use alternate transmit path. 00816 * 00817 * @return ::ST_SUCCESS always. 00818 */ 00819 StStatus ST_RadioSetPowerMode(u16 txPowerMode); 00820 00821 /** @brief 00822 * This function gets the radio power mode. 00823 * 00824 * @return the radio power mode (boost/normal, bi-directional/alternate transmit 00825 * path) encoded as bits in a 16-bit word (see ST_RadioSetPowerMode() 00826 * documentation for details). 00827 */ 00828 u16 ST_RadioGetPowerMode(void); 00829 00830 //@}//END Miscellaneous APIs