The Freescale MCR20A Simple Media Access Controller (MCR20A SMAC) is a simple ANSI C based codebase available as sample source code. The MCR20A SMAC is used for developing proprietary RF transceiver applications using Freescale’s MCR20A 2.4 GHz transceiver
Fork of fsl_smac by
The MCR20A SMAC is a small codebase that provides simple communication and test applications based on drivers, (802.15.4 compliant) PHY, and framework utilities available as source code. This environment is useful for hardware and RF debug, hardware standards certification, and developing proprietary applications. The MCR20A SMAC is provided as part of the Example Application Demos available for MCR20A and also as a standalone set of files.
SMAC features include:
- Compact footprint.
- Very low power, proprietary, bidirectional RF communication link.
- The MCR20A radio allows packet filtering by hardware by checking the preamble and the synchronization word, which reduces software overhead and memory footprint.
- Broadcast communication.
- Unicast communication — MCR20A SMAC includes a Node Address 16-bit field. This allows SMAC to perform unicast transmissions. To change the address of a node, modify this constant: gNodeAddress_c inside the SMAC_Config.h file, or call SMACSetShortSrcAddress(uint16_t nwShortAddress). The address is set to 0xBEAD by default. Some of the Demo Applications allow the user to change this address at runtime.
- Change of current PAN. The SMAC packet uses a short 802.15.4 compliant header with a hard-coded configuration for frame control which allows the user to switch between PANs. The PAN address has also 16 bits (gDefaultPanID_c). This address can be modified by changing the default value from SMAC_Config.h file or by calling SMACSetPanID(uint16_t nwShortPanID.
- There are no blocking functions within the MCR20A SMAC.
- Easy-to-use sample applications included.
- Light-weight, custom LBT algorithm.
- Light-weight, custom, AA mechanism which is transparent to the user after enabling the feature.
- Encryption using Advanced Encryption Standard in Cipher Block Chaining mode with configurable initial vector and key.
- Configurable number of retries and backoff interval.
- Inter-layer communication using SAPs.
- The MCR20A SMAC also filters packets that have correct addressing information (pass address filtering) but are not in the expected format (short addressing, no security, data frame).
Documentation
SMAC_Interface.h@0:401ba973869e, 2015-08-18 (annotated)
- Committer:
- andreikovacs
- Date:
- Tue Aug 18 12:48:33 2015 +0000
- Revision:
- 0:401ba973869e
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andreikovacs | 0:401ba973869e | 1 | /************************************************************************************************** |
andreikovacs | 0:401ba973869e | 2 | * SMAC Interface header file |
andreikovacs | 0:401ba973869e | 3 | * |
andreikovacs | 0:401ba973869e | 4 | * Freescale Semiconductor Inc. |
andreikovacs | 0:401ba973869e | 5 | * (c) Copyright 2004-2014 Freescale Semiconductor, Inc. |
andreikovacs | 0:401ba973869e | 6 | * ALL RIGHTS RESERVED. |
andreikovacs | 0:401ba973869e | 7 | * |
andreikovacs | 0:401ba973869e | 8 | *************************************************************************************************** |
andreikovacs | 0:401ba973869e | 9 | * |
andreikovacs | 0:401ba973869e | 10 | * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR |
andreikovacs | 0:401ba973869e | 11 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
andreikovacs | 0:401ba973869e | 12 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
andreikovacs | 0:401ba973869e | 13 | * IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
andreikovacs | 0:401ba973869e | 14 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
andreikovacs | 0:401ba973869e | 15 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
andreikovacs | 0:401ba973869e | 16 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
andreikovacs | 0:401ba973869e | 17 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
andreikovacs | 0:401ba973869e | 18 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
andreikovacs | 0:401ba973869e | 19 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
andreikovacs | 0:401ba973869e | 20 | * THE POSSIBILITY OF SUCH DAMAGE. |
andreikovacs | 0:401ba973869e | 21 | * |
andreikovacs | 0:401ba973869e | 22 | ***********************************************************************************************//*! |
andreikovacs | 0:401ba973869e | 23 | **************************************************************************************************/ |
andreikovacs | 0:401ba973869e | 24 | |
andreikovacs | 0:401ba973869e | 25 | #ifndef SMAC_INTERFACE_H_ |
andreikovacs | 0:401ba973869e | 26 | #define SMAC_INTERFACE_H_ |
andreikovacs | 0:401ba973869e | 27 | |
andreikovacs | 0:401ba973869e | 28 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 29 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 30 | * Includes |
andreikovacs | 0:401ba973869e | 31 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 32 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 33 | #include "EmbeddedTypes.h" |
andreikovacs | 0:401ba973869e | 34 | #include "PhyTypes.h" |
andreikovacs | 0:401ba973869e | 35 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 36 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 37 | * Interface macro definitions |
andreikovacs | 0:401ba973869e | 38 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 39 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 40 | |
andreikovacs | 0:401ba973869e | 41 | #define gSmacHeaderBytes_c ( sizeof(smacHeader_t) ) |
andreikovacs | 0:401ba973869e | 42 | #define gMaxSmacSDULength_c (gMaxPHYPacketSize_c -(sizeof(smacHeader_t) + 2) ) |
andreikovacs | 0:401ba973869e | 43 | #define gMinSmacSDULength_c (0) |
andreikovacs | 0:401ba973869e | 44 | |
andreikovacs | 0:401ba973869e | 45 | #define gBroadcastAddress_c (0xFFFF) |
andreikovacs | 0:401ba973869e | 46 | #define gSmacDefaultFrameCtrl (0x8841) |
andreikovacs | 0:401ba973869e | 47 | #define gSmacDefaultSeqNo (0xAB) |
andreikovacs | 0:401ba973869e | 48 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 49 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 50 | * Public memory declarations |
andreikovacs | 0:401ba973869e | 51 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 52 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 53 | // extern bool_t smacStandalone; |
andreikovacs | 0:401ba973869e | 54 | extern uint8_t gTotalChannels; |
andreikovacs | 0:401ba973869e | 55 | |
andreikovacs | 0:401ba973869e | 56 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 57 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 58 | * Interface Type definitions |
andreikovacs | 0:401ba973869e | 59 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 60 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 61 | |
andreikovacs | 0:401ba973869e | 62 | typedef enum smacMessageDefs_tag |
andreikovacs | 0:401ba973869e | 63 | { |
andreikovacs | 0:401ba973869e | 64 | gMcpsDataReq_c, |
andreikovacs | 0:401ba973869e | 65 | gMcpsDataCnf_c, |
andreikovacs | 0:401ba973869e | 66 | gMcpsDataInd_c, |
andreikovacs | 0:401ba973869e | 67 | |
andreikovacs | 0:401ba973869e | 68 | gMcpsIndQueueInsertReq_c, |
andreikovacs | 0:401ba973869e | 69 | gMcpsIndQueueInsertCnf_c, |
andreikovacs | 0:401ba973869e | 70 | gMcpsIndQueueRemoveReq_c, |
andreikovacs | 0:401ba973869e | 71 | |
andreikovacs | 0:401ba973869e | 72 | gMlmeCcaReq_c, |
andreikovacs | 0:401ba973869e | 73 | gMlmeCcaCnf_c, |
andreikovacs | 0:401ba973869e | 74 | |
andreikovacs | 0:401ba973869e | 75 | gMlmeEdReq_c, |
andreikovacs | 0:401ba973869e | 76 | gMlmeEdCnf_c, |
andreikovacs | 0:401ba973869e | 77 | |
andreikovacs | 0:401ba973869e | 78 | gMlmeSetTRxStateReq_c, |
andreikovacs | 0:401ba973869e | 79 | gMlmeSetTRxStateCnf_c, |
andreikovacs | 0:401ba973869e | 80 | |
andreikovacs | 0:401ba973869e | 81 | gMlmeSetReq_c, |
andreikovacs | 0:401ba973869e | 82 | gMlmeSetCnf_c, |
andreikovacs | 0:401ba973869e | 83 | |
andreikovacs | 0:401ba973869e | 84 | gMlmeGetReq_c, |
andreikovacs | 0:401ba973869e | 85 | gMlmeGetCnf_c, |
andreikovacs | 0:401ba973869e | 86 | |
andreikovacs | 0:401ba973869e | 87 | gMlmeTimeoutInd_c, |
andreikovacs | 0:401ba973869e | 88 | |
andreikovacs | 0:401ba973869e | 89 | gMlme_StartEventInd_c, |
andreikovacs | 0:401ba973869e | 90 | gMlme_SyncLossInd_c, |
andreikovacs | 0:401ba973869e | 91 | gMlme_RxSfdDetectInd_c, |
andreikovacs | 0:401ba973869e | 92 | gMlme_FilterFailInd_c, |
andreikovacs | 0:401ba973869e | 93 | gMlme_UnexpectedRadioResetInd_c, |
andreikovacs | 0:401ba973869e | 94 | }smacMessageDefs_t; |
andreikovacs | 0:401ba973869e | 95 | |
andreikovacs | 0:401ba973869e | 96 | typedef uint64_t smacTime_t; |
andreikovacs | 0:401ba973869e | 97 | |
andreikovacs | 0:401ba973869e | 98 | typedef struct smacPdu_tag |
andreikovacs | 0:401ba973869e | 99 | { |
andreikovacs | 0:401ba973869e | 100 | uint8_t smacPdu[1]; |
andreikovacs | 0:401ba973869e | 101 | }smacPdu_t; |
andreikovacs | 0:401ba973869e | 102 | |
andreikovacs | 0:401ba973869e | 103 | typedef PACKED_STRUCT smacHeader_tag |
andreikovacs | 0:401ba973869e | 104 | { |
andreikovacs | 0:401ba973869e | 105 | uint16_t frameControl; |
andreikovacs | 0:401ba973869e | 106 | uint8_t seqNo; |
andreikovacs | 0:401ba973869e | 107 | uint16_t panId; |
andreikovacs | 0:401ba973869e | 108 | uint16_t destAddr; |
andreikovacs | 0:401ba973869e | 109 | uint16_t srcAddr; |
andreikovacs | 0:401ba973869e | 110 | }smacHeader_t; |
andreikovacs | 0:401ba973869e | 111 | |
andreikovacs | 0:401ba973869e | 112 | typedef struct txPacket_tag |
andreikovacs | 0:401ba973869e | 113 | { |
andreikovacs | 0:401ba973869e | 114 | uint8_t u8DataLength; |
andreikovacs | 0:401ba973869e | 115 | smacHeader_t smacHeader; |
andreikovacs | 0:401ba973869e | 116 | smacPdu_t smacPdu; |
andreikovacs | 0:401ba973869e | 117 | }txPacket_t; |
andreikovacs | 0:401ba973869e | 118 | |
andreikovacs | 0:401ba973869e | 119 | typedef struct txContextConfig_tag |
andreikovacs | 0:401ba973869e | 120 | { |
andreikovacs | 0:401ba973869e | 121 | bool_t ccaBeforeTx; |
andreikovacs | 0:401ba973869e | 122 | bool_t autoAck; |
andreikovacs | 0:401ba973869e | 123 | uint8_t retryCountCCAFail; |
andreikovacs | 0:401ba973869e | 124 | uint8_t retryCountAckFail; |
andreikovacs | 0:401ba973869e | 125 | }txContextConfig_t; |
andreikovacs | 0:401ba973869e | 126 | |
andreikovacs | 0:401ba973869e | 127 | typedef enum rxStatus_tag |
andreikovacs | 0:401ba973869e | 128 | { |
andreikovacs | 0:401ba973869e | 129 | rxInitStatus, |
andreikovacs | 0:401ba973869e | 130 | rxProcessingReceptionStatus_c, |
andreikovacs | 0:401ba973869e | 131 | rxSuccessStatus_c, |
andreikovacs | 0:401ba973869e | 132 | rxTimeOutStatus_c, |
andreikovacs | 0:401ba973869e | 133 | rxAbortedStatus_c, |
andreikovacs | 0:401ba973869e | 134 | rxMaxStatus_c |
andreikovacs | 0:401ba973869e | 135 | } rxStatus_t; |
andreikovacs | 0:401ba973869e | 136 | |
andreikovacs | 0:401ba973869e | 137 | typedef struct rxPacket_tag |
andreikovacs | 0:401ba973869e | 138 | { |
andreikovacs | 0:401ba973869e | 139 | uint8_t u8MaxDataLength; |
andreikovacs | 0:401ba973869e | 140 | rxStatus_t rxStatus; |
andreikovacs | 0:401ba973869e | 141 | uint8_t u8DataLength; |
andreikovacs | 0:401ba973869e | 142 | smacHeader_t smacHeader; |
andreikovacs | 0:401ba973869e | 143 | smacPdu_t smacPdu; |
andreikovacs | 0:401ba973869e | 144 | }rxPacket_t; |
andreikovacs | 0:401ba973869e | 145 | |
andreikovacs | 0:401ba973869e | 146 | typedef enum txStatus_tag |
andreikovacs | 0:401ba973869e | 147 | { |
andreikovacs | 0:401ba973869e | 148 | txSuccessStatus_c, |
andreikovacs | 0:401ba973869e | 149 | txFailureStatus_c, |
andreikovacs | 0:401ba973869e | 150 | txMaxStatus_c |
andreikovacs | 0:401ba973869e | 151 | } txStatus_t; |
andreikovacs | 0:401ba973869e | 152 | |
andreikovacs | 0:401ba973869e | 153 | typedef enum smacErrors_tag |
andreikovacs | 0:401ba973869e | 154 | { |
andreikovacs | 0:401ba973869e | 155 | gErrorNoError_c = 0, |
andreikovacs | 0:401ba973869e | 156 | gErrorBusy_c, |
andreikovacs | 0:401ba973869e | 157 | gErrorChannelBusy_c, |
andreikovacs | 0:401ba973869e | 158 | gErrorNoAck_c, |
andreikovacs | 0:401ba973869e | 159 | gErrorOutOfRange_c, |
andreikovacs | 0:401ba973869e | 160 | gErrorNoResourcesAvailable_c, |
andreikovacs | 0:401ba973869e | 161 | gErrorNoValidCondition_c, |
andreikovacs | 0:401ba973869e | 162 | gErrorCorrupted_c, |
andreikovacs | 0:401ba973869e | 163 | gErrorMaxError_c |
andreikovacs | 0:401ba973869e | 164 | } smacErrors_t; |
andreikovacs | 0:401ba973869e | 165 | |
andreikovacs | 0:401ba973869e | 166 | #if defined (gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 167 | |
andreikovacs | 0:401ba973869e | 168 | typedef enum smacRFModes_tag |
andreikovacs | 0:401ba973869e | 169 | { |
andreikovacs | 0:401ba973869e | 170 | gRFMode1_c = gPhyMode1_c, |
andreikovacs | 0:401ba973869e | 171 | gRFMode2_c = gPhyMode2_c, |
andreikovacs | 0:401ba973869e | 172 | gRFMode3_c = gPhyMode3_c, |
andreikovacs | 0:401ba973869e | 173 | gRFMode4_c = gPhyMode4_c, |
andreikovacs | 0:401ba973869e | 174 | gRFMode5_c = gPhyMode1ARIB_c, /*ARIB mode 1*/ |
andreikovacs | 0:401ba973869e | 175 | gRFMode6_c = gPhyMode2ARIB_c, /*ARIB mode 2*/ |
andreikovacs | 0:401ba973869e | 176 | gRFMaxMode_c |
andreikovacs | 0:401ba973869e | 177 | } smacRFModes_t; |
andreikovacs | 0:401ba973869e | 178 | |
andreikovacs | 0:401ba973869e | 179 | typedef enum smacFrequencyBands_tag |
andreikovacs | 0:401ba973869e | 180 | { |
andreikovacs | 0:401ba973869e | 181 | gSMAC_863_870MHz_c = gFreq863__870MHz_c, /* 863-870 (Europe) */ |
andreikovacs | 0:401ba973869e | 182 | gSMAC_902_928MHz_c = gFreq902__928MHz_c, /* 902-928 (US) */ |
andreikovacs | 0:401ba973869e | 183 | gSMAC_920_928MHz_c = gFreq920__928MHz_c, /* 920-928 (Japan) */ |
andreikovacs | 0:401ba973869e | 184 | gSMAC_169_400__169_475MHz_c = gFreq169_400__169_475MHz_c /* 169-475 */ |
andreikovacs | 0:401ba973869e | 185 | }smacFrequencyBands_t; |
andreikovacs | 0:401ba973869e | 186 | |
andreikovacs | 0:401ba973869e | 187 | #endif |
andreikovacs | 0:401ba973869e | 188 | typedef struct smacPacket_tag |
andreikovacs | 0:401ba973869e | 189 | { |
andreikovacs | 0:401ba973869e | 190 | uint8_t u8SyncWordSize; |
andreikovacs | 0:401ba973869e | 191 | uint8_t *u8SyncWordValue; |
andreikovacs | 0:401ba973869e | 192 | uint16_t u16PreambleLength; |
andreikovacs | 0:401ba973869e | 193 | }smacPacket_t; |
andreikovacs | 0:401ba973869e | 194 | |
andreikovacs | 0:401ba973869e | 195 | typedef enum scanModes_tag |
andreikovacs | 0:401ba973869e | 196 | { |
andreikovacs | 0:401ba973869e | 197 | gScanModeCCA_c = 0, |
andreikovacs | 0:401ba973869e | 198 | gScanModeED_c, |
andreikovacs | 0:401ba973869e | 199 | gMaxScanMode_c |
andreikovacs | 0:401ba973869e | 200 | } scanModes_t; |
andreikovacs | 0:401ba973869e | 201 | |
andreikovacs | 0:401ba973869e | 202 | #if defined (gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 203 | |
andreikovacs | 0:401ba973869e | 204 | typedef struct packetConfig_tag |
andreikovacs | 0:401ba973869e | 205 | { |
andreikovacs | 0:401ba973869e | 206 | uint16_t u16PreambleSize; |
andreikovacs | 0:401ba973869e | 207 | uint8_t u8SyncWordSize; |
andreikovacs | 0:401ba973869e | 208 | uint8_t *pu8SyncWord; |
andreikovacs | 0:401ba973869e | 209 | } packetConfig_t; |
andreikovacs | 0:401ba973869e | 210 | |
andreikovacs | 0:401ba973869e | 211 | #endif |
andreikovacs | 0:401ba973869e | 212 | |
andreikovacs | 0:401ba973869e | 213 | /*@CMA, Connectivity Test_Start*/ |
andreikovacs | 0:401ba973869e | 214 | typedef enum channels_tag |
andreikovacs | 0:401ba973869e | 215 | { |
andreikovacs | 0:401ba973869e | 216 | #include "SMAC_Channels.h" |
andreikovacs | 0:401ba973869e | 217 | } channels_t; |
andreikovacs | 0:401ba973869e | 218 | |
andreikovacs | 0:401ba973869e | 219 | typedef enum smacTestMode_tag |
andreikovacs | 0:401ba973869e | 220 | { |
andreikovacs | 0:401ba973869e | 221 | gTestModeForceIdle_c = 0, |
andreikovacs | 0:401ba973869e | 222 | gTestModeContinuousTxModulated_c, |
andreikovacs | 0:401ba973869e | 223 | gTestModeContinuousTxUnmodulated_c, |
andreikovacs | 0:401ba973869e | 224 | gTestModePRBS9_c, |
andreikovacs | 0:401ba973869e | 225 | gTestModeContinuousRxBER_c, |
andreikovacs | 0:401ba973869e | 226 | gMaxTestMode_c |
andreikovacs | 0:401ba973869e | 227 | } smacTestMode_t; |
andreikovacs | 0:401ba973869e | 228 | |
andreikovacs | 0:401ba973869e | 229 | typedef struct smacDataCnf_tag |
andreikovacs | 0:401ba973869e | 230 | { |
andreikovacs | 0:401ba973869e | 231 | smacErrors_t status; |
andreikovacs | 0:401ba973869e | 232 | } smacDataCnf_t; |
andreikovacs | 0:401ba973869e | 233 | |
andreikovacs | 0:401ba973869e | 234 | typedef struct smacDataInd_tag |
andreikovacs | 0:401ba973869e | 235 | { |
andreikovacs | 0:401ba973869e | 236 | //phyTimeTimestamp_t timeStamp; |
andreikovacs | 0:401ba973869e | 237 | uint8_t ppduLinkQuality; |
andreikovacs | 0:401ba973869e | 238 | uint8_t u8LastRxRssi; |
andreikovacs | 0:401ba973869e | 239 | rxPacket_t * pRxPacket; |
andreikovacs | 0:401ba973869e | 240 | } smacDataInd_t; |
andreikovacs | 0:401ba973869e | 241 | |
andreikovacs | 0:401ba973869e | 242 | typedef struct smacEdReq_tag |
andreikovacs | 0:401ba973869e | 243 | { |
andreikovacs | 0:401ba973869e | 244 | channels_t scanChannel; |
andreikovacs | 0:401ba973869e | 245 | smacTime_t startTime; // absolute |
andreikovacs | 0:401ba973869e | 246 | } smacEdReq_t; |
andreikovacs | 0:401ba973869e | 247 | |
andreikovacs | 0:401ba973869e | 248 | typedef struct smacCcaReq_tag |
andreikovacs | 0:401ba973869e | 249 | { |
andreikovacs | 0:401ba973869e | 250 | scanModes_t ccaType; |
andreikovacs | 0:401ba973869e | 251 | } smacCcaReq_t; |
andreikovacs | 0:401ba973869e | 252 | |
andreikovacs | 0:401ba973869e | 253 | typedef struct smacCcaCnf_tag |
andreikovacs | 0:401ba973869e | 254 | { |
andreikovacs | 0:401ba973869e | 255 | smacErrors_t status; |
andreikovacs | 0:401ba973869e | 256 | } smacCcaCnf_t; |
andreikovacs | 0:401ba973869e | 257 | |
andreikovacs | 0:401ba973869e | 258 | typedef struct smacEdCnf_tag |
andreikovacs | 0:401ba973869e | 259 | { |
andreikovacs | 0:401ba973869e | 260 | smacErrors_t status; |
andreikovacs | 0:401ba973869e | 261 | uint8_t energyLevel; |
andreikovacs | 0:401ba973869e | 262 | uint8_t energyLeveldB; |
andreikovacs | 0:401ba973869e | 263 | channels_t scannedChannel; |
andreikovacs | 0:401ba973869e | 264 | } smacEdCnf_t; |
andreikovacs | 0:401ba973869e | 265 | |
andreikovacs | 0:401ba973869e | 266 | typedef struct smacToAppMlmeMessage_tag |
andreikovacs | 0:401ba973869e | 267 | { |
andreikovacs | 0:401ba973869e | 268 | smacMessageDefs_t msgType; |
andreikovacs | 0:401ba973869e | 269 | uint8_t appInstanceId; |
andreikovacs | 0:401ba973869e | 270 | union |
andreikovacs | 0:401ba973869e | 271 | { |
andreikovacs | 0:401ba973869e | 272 | smacCcaCnf_t ccaCnf; |
andreikovacs | 0:401ba973869e | 273 | smacEdCnf_t edCnf; |
andreikovacs | 0:401ba973869e | 274 | }msgData; |
andreikovacs | 0:401ba973869e | 275 | } smacToAppMlmeMessage_t; |
andreikovacs | 0:401ba973869e | 276 | |
andreikovacs | 0:401ba973869e | 277 | typedef struct smacToAppDataMessage_tag |
andreikovacs | 0:401ba973869e | 278 | { |
andreikovacs | 0:401ba973869e | 279 | smacMessageDefs_t msgType; |
andreikovacs | 0:401ba973869e | 280 | uint8_t appInstanceId; |
andreikovacs | 0:401ba973869e | 281 | union |
andreikovacs | 0:401ba973869e | 282 | { |
andreikovacs | 0:401ba973869e | 283 | smacDataCnf_t dataCnf; |
andreikovacs | 0:401ba973869e | 284 | smacDataInd_t dataInd; |
andreikovacs | 0:401ba973869e | 285 | }msgData; |
andreikovacs | 0:401ba973869e | 286 | } smacToAppDataMessage_t; |
andreikovacs | 0:401ba973869e | 287 | |
andreikovacs | 0:401ba973869e | 288 | typedef smacErrors_t ( * SMAC_APP_MCPS_SapHandler_t)(smacToAppDataMessage_t * pMsg, instanceId_t instanceId); |
andreikovacs | 0:401ba973869e | 289 | |
andreikovacs | 0:401ba973869e | 290 | typedef smacErrors_t ( * SMAC_APP_MLME_SapHandler_t)(smacToAppMlmeMessage_t * pMsg, instanceId_t instanceId); |
andreikovacs | 0:401ba973869e | 291 | |
andreikovacs | 0:401ba973869e | 292 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 293 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 294 | * External Prototypes |
andreikovacs | 0:401ba973869e | 295 | ************************************************************************************* |
andreikovacs | 0:401ba973869e | 296 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 297 | extern void InitSmac(void); |
andreikovacs | 0:401ba973869e | 298 | |
andreikovacs | 0:401ba973869e | 299 | /*********************************************************************************** |
andreikovacs | 0:401ba973869e | 300 | * Smac_RegisterSapHandlers |
andreikovacs | 0:401ba973869e | 301 | * This function registers the data and management components callbacks to the application |
andreikovacs | 0:401ba973869e | 302 | * After calling this function and providing two function pointers, SMAC will call |
andreikovacs | 0:401ba973869e | 303 | * one of these two, for each async request, based on request type (data or management) |
andreikovacs | 0:401ba973869e | 304 | * |
andreikovacs | 0:401ba973869e | 305 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 306 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 307 | * |
andreikovacs | 0:401ba973869e | 308 | * Return value: |
andreikovacs | 0:401ba973869e | 309 | * None |
andreikovacs | 0:401ba973869e | 310 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 311 | extern void Smac_RegisterSapHandlers(SMAC_APP_MCPS_SapHandler_t pSMAC_APP_MCPS_SapHandler, |
andreikovacs | 0:401ba973869e | 312 | SMAC_APP_MLME_SapHandler_t pSMAC_APP_MLME_SapHandler, |
andreikovacs | 0:401ba973869e | 313 | instanceId_t smacInstanceId); |
andreikovacs | 0:401ba973869e | 314 | |
andreikovacs | 0:401ba973869e | 315 | /*********************************************************************************** |
andreikovacs | 0:401ba973869e | 316 | * App to Smac SAP HANDLERS |
andreikovacs | 0:401ba973869e | 317 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 318 | //smacErrors_t AppToSmac_Data_SapHandler(AppToSmacDataMessage_t* pMsg, uint8_t MACInstance); |
andreikovacs | 0:401ba973869e | 319 | //smacErrors_t AppToSmac_Mlme_SapHandler(AppToSmacMlmeMessage_t* pMsg, uint8_t MACInstance); |
andreikovacs | 0:401ba973869e | 320 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 321 | |
andreikovacs | 0:401ba973869e | 322 | /******************************** SMAC Data primitives *****************************/ |
andreikovacs | 0:401ba973869e | 323 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 324 | |
andreikovacs | 0:401ba973869e | 325 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 326 | * MCPSDataRequest |
andreikovacs | 0:401ba973869e | 327 | * |
andreikovacs | 0:401ba973869e | 328 | * This data primitive is used to send an over the air packet. This is an asyncronous |
andreikovacs | 0:401ba973869e | 329 | * function, it means it ask SMAC to transmit one OTA packet, but when the function |
andreikovacs | 0:401ba973869e | 330 | * returns it is not sent already. |
andreikovacs | 0:401ba973869e | 331 | * |
andreikovacs | 0:401ba973869e | 332 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 333 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 334 | * |
andreikovacs | 0:401ba973869e | 335 | * Return value: |
andreikovacs | 0:401ba973869e | 336 | * gErrorNoError_c: Everything is ok and the transmission will be performed. |
andreikovacs | 0:401ba973869e | 337 | * gErrorOutOfRange_c: One of the members in the pTxMessage structure is out of |
andreikovacs | 0:401ba973869e | 338 | * range (no valid bufer size or data buffer pointer is NULL) |
andreikovacs | 0:401ba973869e | 339 | * gErrorNoResourcesAvailable_c: the radio is performing another action. |
andreikovacs | 0:401ba973869e | 340 | * gErrorNoValidCondition_c: The SMAC has not been initialized |
andreikovacs | 0:401ba973869e | 341 | * |
andreikovacs | 0:401ba973869e | 342 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 343 | extern smacErrors_t MCPSDataRequest(txPacket_t *psTxPacket); |
andreikovacs | 0:401ba973869e | 344 | |
andreikovacs | 0:401ba973869e | 345 | |
andreikovacs | 0:401ba973869e | 346 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 347 | * MLMEConfigureTxContext |
andreikovacs | 0:401ba973869e | 348 | * |
andreikovacs | 0:401ba973869e | 349 | * This management primitive sets up the transmission conditions used by MCPSDataRequest |
andreikovacs | 0:401ba973869e | 350 | * |
andreikovacs | 0:401ba973869e | 351 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 352 | * SMAC is initialized |
andreikovacs | 0:401ba973869e | 353 | * |
andreikovacs | 0:401ba973869e | 354 | * Return value: |
andreikovacs | 0:401ba973869e | 355 | * gErrorNoError_c: Everything is set accordingly. |
andreikovacs | 0:401ba973869e | 356 | * gErrorOutOfRange_c: More than gMaxRetriesAllowed_c are required |
andreikovacs | 0:401ba973869e | 357 | * gErrorNoValidCondition_c: Retries are required but neither Ack nor CCA are requested |
andreikovacs | 0:401ba973869e | 358 | * |
andreikovacs | 0:401ba973869e | 359 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 360 | extern smacErrors_t MLMEConfigureTxContext(txContextConfig_t* pTxConfig); |
andreikovacs | 0:401ba973869e | 361 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 362 | * MLMERXEnableRequest |
andreikovacs | 0:401ba973869e | 363 | * |
andreikovacs | 0:401ba973869e | 364 | * Function used to place the radio into receive mode |
andreikovacs | 0:401ba973869e | 365 | * |
andreikovacs | 0:401ba973869e | 366 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 367 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 368 | * |
andreikovacs | 0:401ba973869e | 369 | * Arguments: |
andreikovacs | 0:401ba973869e | 370 | * |
andreikovacs | 0:401ba973869e | 371 | * rxPacket_t *gsRxPacket: Pointer to the structure where the reception results will be stored. |
andreikovacs | 0:401ba973869e | 372 | * smacTime_t stTimeout: 64-bit timeout value, absolute time in symbols |
andreikovacs | 0:401ba973869e | 373 | * |
andreikovacs | 0:401ba973869e | 374 | * Return Value: |
andreikovacs | 0:401ba973869e | 375 | * gErrorNoError_c: Everything is ok and the reception will be performed. |
andreikovacs | 0:401ba973869e | 376 | * gErrorOutOfRange_c: One of the members in the pRxMessage structure is out of range (no valid bufer size or data buffer pointer is NULL). |
andreikovacs | 0:401ba973869e | 377 | * gErrorBusy_c: the radio is performing another action. |
andreikovacs | 0:401ba973869e | 378 | * gErrorNoValidCondition_c: The SMAC has not been initialized. |
andreikovacs | 0:401ba973869e | 379 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 380 | extern smacErrors_t MLMERXEnableRequest(rxPacket_t *gsRxPacket, smacTime_t stTimeout); |
andreikovacs | 0:401ba973869e | 381 | |
andreikovacs | 0:401ba973869e | 382 | |
andreikovacs | 0:401ba973869e | 383 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 384 | * MLMERXDisableRequest |
andreikovacs | 0:401ba973869e | 385 | * |
andreikovacs | 0:401ba973869e | 386 | * Returns the radio to idle mode from receive mode. |
andreikovacs | 0:401ba973869e | 387 | * |
andreikovacs | 0:401ba973869e | 388 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 389 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 390 | * |
andreikovacs | 0:401ba973869e | 391 | * Arguments: |
andreikovacs | 0:401ba973869e | 392 | * None |
andreikovacs | 0:401ba973869e | 393 | * |
andreikovacs | 0:401ba973869e | 394 | * Return Value: |
andreikovacs | 0:401ba973869e | 395 | * gErrorNoValidCondition_c If the Radio is not in Rx state. |
andreikovacs | 0:401ba973869e | 396 | * gErrorNoError_c When the message was aborted or disabled. |
andreikovacs | 0:401ba973869e | 397 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 398 | extern smacErrors_t MLMERXDisableRequest(void); |
andreikovacs | 0:401ba973869e | 399 | |
andreikovacs | 0:401ba973869e | 400 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 401 | * MLMELinkQuality |
andreikovacs | 0:401ba973869e | 402 | * |
andreikovacs | 0:401ba973869e | 403 | * This function returns an integer value that is the link quality from the last received |
andreikovacs | 0:401ba973869e | 404 | * packet of the form: dBm = (-Link Quality/2). |
andreikovacs | 0:401ba973869e | 405 | * |
andreikovacs | 0:401ba973869e | 406 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 407 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 408 | * |
andreikovacs | 0:401ba973869e | 409 | * Arguments: |
andreikovacs | 0:401ba973869e | 410 | * None |
andreikovacs | 0:401ba973869e | 411 | * |
andreikovacs | 0:401ba973869e | 412 | * Return Value: |
andreikovacs | 0:401ba973869e | 413 | * uint8_t: 8 bit value representing the link quality value in dBm. |
andreikovacs | 0:401ba973869e | 414 | * Returns the result in smacLastDataRxParams.linkQuality. |
andreikovacs | 0:401ba973869e | 415 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 416 | extern uint8_t MLMELinkQuality(void); |
andreikovacs | 0:401ba973869e | 417 | |
andreikovacs | 0:401ba973869e | 418 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 419 | * MLMESetInterPacketRxDelay |
andreikovacs | 0:401ba973869e | 420 | * |
andreikovacs | 0:401ba973869e | 421 | * This sets the inter packet delay for the packet handler |
andreikovacs | 0:401ba973869e | 422 | * |
andreikovacs | 0:401ba973869e | 423 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 424 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 425 | * |
andreikovacs | 0:401ba973869e | 426 | * Arguments: |
andreikovacs | 0:401ba973869e | 427 | * uint8_t u8InterPacketRxDelay: interpacket delay in ms |
andreikovacs | 0:401ba973869e | 428 | * |
andreikovacs | 0:401ba973869e | 429 | * Return Value: |
andreikovacs | 0:401ba973869e | 430 | * gErrorNoValidCondition_c If the Radio is not in Rx state. |
andreikovacs | 0:401ba973869e | 431 | * gErrorNoError_c When the message was aborted or disabled. |
andreikovacs | 0:401ba973869e | 432 | * |
andreikovacs | 0:401ba973869e | 433 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 434 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 435 | extern smacErrors_t MLMESetInterPacketRxDelay(uint8_t u8InterPacketRxDelay); |
andreikovacs | 0:401ba973869e | 436 | #endif |
andreikovacs | 0:401ba973869e | 437 | |
andreikovacs | 0:401ba973869e | 438 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 439 | /******************************** SMAC Radio primitives ****************************/ |
andreikovacs | 0:401ba973869e | 440 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 441 | |
andreikovacs | 0:401ba973869e | 442 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 443 | * MLMESetChannelRequest |
andreikovacs | 0:401ba973869e | 444 | * |
andreikovacs | 0:401ba973869e | 445 | * This sets the frequency on which the radio will transmit or receive on. |
andreikovacs | 0:401ba973869e | 446 | * |
andreikovacs | 0:401ba973869e | 447 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 448 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 449 | * |
andreikovacs | 0:401ba973869e | 450 | * Arguments: |
andreikovacs | 0:401ba973869e | 451 | * channels_t newChannel: channel to be set |
andreikovacs | 0:401ba973869e | 452 | * |
andreikovacs | 0:401ba973869e | 453 | * Return Value: |
andreikovacs | 0:401ba973869e | 454 | * gErrorNoError_c: The channel set has been performed |
andreikovacs | 0:401ba973869e | 455 | * gErrorOutOfRange_c : channel requested is not valid |
andreikovacs | 0:401ba973869e | 456 | * gErrorBusy_c: when SMAC is busy in other radio activity as transmitting or receiving data. Or performing a channel scan. |
andreikovacs | 0:401ba973869e | 457 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 458 | extern smacErrors_t MLMESetChannelRequest (channels_t newChannel); |
andreikovacs | 0:401ba973869e | 459 | |
andreikovacs | 0:401ba973869e | 460 | #ifdef gIncludeCalibrationOption |
andreikovacs | 0:401ba973869e | 461 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 462 | * MLMESetAdditionalRFOffset |
andreikovacs | 0:401ba973869e | 463 | * |
andreikovacs | 0:401ba973869e | 464 | * This sets the frequency offset in respect to the current channel. Used for calibration. |
andreikovacs | 0:401ba973869e | 465 | * |
andreikovacs | 0:401ba973869e | 466 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 467 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 468 | * |
andreikovacs | 0:401ba973869e | 469 | * Arguments: |
andreikovacs | 0:401ba973869e | 470 | * uint32_t additionalRFOffset: offset used in frequency Calculation |
andreikovacs | 0:401ba973869e | 471 | * |
andreikovacs | 0:401ba973869e | 472 | * Return Value: |
andreikovacs | 0:401ba973869e | 473 | * gErrorNoError_c: The PIB is set |
andreikovacs | 0:401ba973869e | 474 | * gErrorNoValidCondition_c: SMAC is not initialized |
andreikovacs | 0:401ba973869e | 475 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 476 | extern smacErrors_t MLMESetAdditionalRFOffset (uint32_t additionalRFOffset); |
andreikovacs | 0:401ba973869e | 477 | |
andreikovacs | 0:401ba973869e | 478 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 479 | * MLMEGetAdditionalRFOffset |
andreikovacs | 0:401ba973869e | 480 | * |
andreikovacs | 0:401ba973869e | 481 | * This gets the frequency offset in respect to the current channel. Used for calibration. |
andreikovacs | 0:401ba973869e | 482 | * |
andreikovacs | 0:401ba973869e | 483 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 484 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 485 | * |
andreikovacs | 0:401ba973869e | 486 | * Arguments: |
andreikovacs | 0:401ba973869e | 487 | * None |
andreikovacs | 0:401ba973869e | 488 | * |
andreikovacs | 0:401ba973869e | 489 | * Return Value: |
andreikovacs | 0:401ba973869e | 490 | * calibration offset |
andreikovacs | 0:401ba973869e | 491 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 492 | extern uint32_t MLMEGetAdditionalRFOffset( void ); |
andreikovacs | 0:401ba973869e | 493 | |
andreikovacs | 0:401ba973869e | 494 | #endif |
andreikovacs | 0:401ba973869e | 495 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 496 | * MLMEGetChannelRequest |
andreikovacs | 0:401ba973869e | 497 | * |
andreikovacs | 0:401ba973869e | 498 | * This function returns the current channel, if an error is detected it returns gChannelOutOfRange_c. |
andreikovacs | 0:401ba973869e | 499 | * |
andreikovacs | 0:401ba973869e | 500 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 501 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 502 | * |
andreikovacs | 0:401ba973869e | 503 | * Arguments: |
andreikovacs | 0:401ba973869e | 504 | * None |
andreikovacs | 0:401ba973869e | 505 | * |
andreikovacs | 0:401ba973869e | 506 | * Return Value: |
andreikovacs | 0:401ba973869e | 507 | * channels_t (uint8_t): The current RF channel. |
andreikovacs | 0:401ba973869e | 508 | * gChannelOutOfRange_c: If current channel could not be detected |
andreikovacs | 0:401ba973869e | 509 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 510 | extern channels_t MLMEGetChannelRequest(void); |
andreikovacs | 0:401ba973869e | 511 | |
andreikovacs | 0:401ba973869e | 512 | |
andreikovacs | 0:401ba973869e | 513 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 514 | * MLMERssi |
andreikovacs | 0:401ba973869e | 515 | * |
andreikovacs | 0:401ba973869e | 516 | * This call starts an energy detect (ED) cycle and returns the energy value (-power/2) |
andreikovacs | 0:401ba973869e | 517 | * via the returned argument. For example, if the Energy Detect returns 80 then the |
andreikovacs | 0:401ba973869e | 518 | * interpreted value is -80/2 or -40 dBm |
andreikovacs | 0:401ba973869e | 519 | * |
andreikovacs | 0:401ba973869e | 520 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 521 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 522 | * |
andreikovacs | 0:401ba973869e | 523 | * Arguments: |
andreikovacs | 0:401ba973869e | 524 | * None |
andreikovacs | 0:401ba973869e | 525 | * |
andreikovacs | 0:401ba973869e | 526 | * Return Value: |
andreikovacs | 0:401ba973869e | 527 | * uint8_t: An unsigned 8-bit value representing the energy on the current channel. |
andreikovacs | 0:401ba973869e | 528 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 529 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 530 | extern uint8_t MLMERssi(void); |
andreikovacs | 0:401ba973869e | 531 | #endif |
andreikovacs | 0:401ba973869e | 532 | |
andreikovacs | 0:401ba973869e | 533 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 534 | * MLMESetCCADuration |
andreikovacs | 0:401ba973869e | 535 | * |
andreikovacs | 0:401ba973869e | 536 | * This call sets the amount of time necessary to perform CCA or ED |
andreikovacs | 0:401ba973869e | 537 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 538 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 539 | * |
andreikovacs | 0:401ba973869e | 540 | * Arguments: |
andreikovacs | 0:401ba973869e | 541 | * uint64_t usCCADuration: duration in microseconds |
andreikovacs | 0:401ba973869e | 542 | * |
andreikovacs | 0:401ba973869e | 543 | * Return Value: |
andreikovacs | 0:401ba973869e | 544 | * gErrorNoError_c in case of success, error code otherwise. |
andreikovacs | 0:401ba973869e | 545 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 546 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 547 | extern smacErrors_t MLMESetCCADuration(uint64_t usCCADuration ); |
andreikovacs | 0:401ba973869e | 548 | #endif |
andreikovacs | 0:401ba973869e | 549 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 550 | * MLMEPacketConfig |
andreikovacs | 0:401ba973869e | 551 | * |
andreikovacs | 0:401ba973869e | 552 | * This function sets the following parameters for OTA packets in radio�s registers: |
andreikovacs | 0:401ba973869e | 553 | * Preamble size, synchronization word size, and synchronization word value. |
andreikovacs | 0:401ba973869e | 554 | * |
andreikovacs | 0:401ba973869e | 555 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 556 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 557 | * |
andreikovacs | 0:401ba973869e | 558 | * Arguments: |
andreikovacs | 0:401ba973869e | 559 | * packetConfig_t *pPacketCfg |
andreikovacs | 0:401ba973869e | 560 | * |
andreikovacs | 0:401ba973869e | 561 | * Return Value: |
andreikovacs | 0:401ba973869e | 562 | * gErrorBusy_c: when SMAC is busy in other radio activity as transmitting or receiving data. |
andreikovacs | 0:401ba973869e | 563 | * Or performing a channel scan. |
andreikovacs | 0:401ba973869e | 564 | * gErrorNoError_c: the packet has been configured |
andreikovacs | 0:401ba973869e | 565 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 566 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 567 | extern smacErrors_t MLMEPacketConfig(packetConfig_t *pPacketCfg); |
andreikovacs | 0:401ba973869e | 568 | #endif |
andreikovacs | 0:401ba973869e | 569 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 570 | * MLMERadioInit |
andreikovacs | 0:401ba973869e | 571 | * |
andreikovacs | 0:401ba973869e | 572 | * This function initializes the Radio parameters. |
andreikovacs | 0:401ba973869e | 573 | * |
andreikovacs | 0:401ba973869e | 574 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 575 | * None |
andreikovacs | 0:401ba973869e | 576 | * |
andreikovacs | 0:401ba973869e | 577 | * Arguments: |
andreikovacs | 0:401ba973869e | 578 | * None |
andreikovacs | 0:401ba973869e | 579 | * |
andreikovacs | 0:401ba973869e | 580 | * Return Value: |
andreikovacs | 0:401ba973869e | 581 | * gErrorNoError_c: the Radio initialization has been done successfully |
andreikovacs | 0:401ba973869e | 582 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 583 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 584 | extern smacErrors_t MLMERadioInit(void); |
andreikovacs | 0:401ba973869e | 585 | #endif |
andreikovacs | 0:401ba973869e | 586 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 587 | * MLMEPhySoftReset |
andreikovacs | 0:401ba973869e | 588 | * |
andreikovacs | 0:401ba973869e | 589 | * This function performs a software reset on the radio, PHY and SMAC state machines. |
andreikovacs | 0:401ba973869e | 590 | * |
andreikovacs | 0:401ba973869e | 591 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 592 | * None |
andreikovacs | 0:401ba973869e | 593 | * |
andreikovacs | 0:401ba973869e | 594 | * Arguments: |
andreikovacs | 0:401ba973869e | 595 | * None |
andreikovacs | 0:401ba973869e | 596 | * |
andreikovacs | 0:401ba973869e | 597 | * Return Value: |
andreikovacs | 0:401ba973869e | 598 | * gErrorNoError_c: If the action is performed. |
andreikovacs | 0:401ba973869e | 599 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 600 | #ifdef __cplusplus |
andreikovacs | 0:401ba973869e | 601 | extern "C" { |
andreikovacs | 0:401ba973869e | 602 | #endif |
andreikovacs | 0:401ba973869e | 603 | smacErrors_t MLMEPhySoftReset(void); |
andreikovacs | 0:401ba973869e | 604 | |
andreikovacs | 0:401ba973869e | 605 | #ifdef __cplusplus |
andreikovacs | 0:401ba973869e | 606 | } //extern "C" |
andreikovacs | 0:401ba973869e | 607 | #endif |
andreikovacs | 0:401ba973869e | 608 | |
andreikovacs | 0:401ba973869e | 609 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 610 | * MLMEPAOutputAdjust |
andreikovacs | 0:401ba973869e | 611 | * |
andreikovacs | 0:401ba973869e | 612 | * |
andreikovacs | 0:401ba973869e | 613 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 614 | extern smacErrors_t MLMEPAOutputAdjust(uint8_t u8PaValue); |
andreikovacs | 0:401ba973869e | 615 | |
andreikovacs | 0:401ba973869e | 616 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 617 | * MLMESetPreambleLength |
andreikovacs | 0:401ba973869e | 618 | * |
andreikovacs | 0:401ba973869e | 619 | * |
andreikovacs | 0:401ba973869e | 620 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 621 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 622 | extern smacErrors_t MLMESetPreambleLength(uint16_t u16preambleLength); |
andreikovacs | 0:401ba973869e | 623 | #endif |
andreikovacs | 0:401ba973869e | 624 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 625 | * MLMESetSyncWordValue |
andreikovacs | 0:401ba973869e | 626 | * |
andreikovacs | 0:401ba973869e | 627 | * |
andreikovacs | 0:401ba973869e | 628 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 629 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 630 | extern smacErrors_t MLMESetSyncWordValue(uint8_t *u8syncWordValue); |
andreikovacs | 0:401ba973869e | 631 | #endif |
andreikovacs | 0:401ba973869e | 632 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 633 | * MLMESetSyncWordSize |
andreikovacs | 0:401ba973869e | 634 | * |
andreikovacs | 0:401ba973869e | 635 | * |
andreikovacs | 0:401ba973869e | 636 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 637 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 638 | extern smacErrors_t MLMESetSyncWordSize(uint8_t u8syncWordSize); |
andreikovacs | 0:401ba973869e | 639 | #endif |
andreikovacs | 0:401ba973869e | 640 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 641 | * MLMESetFreqBand |
andreikovacs | 0:401ba973869e | 642 | * |
andreikovacs | 0:401ba973869e | 643 | * |
andreikovacs | 0:401ba973869e | 644 | * |
andreikovacs | 0:401ba973869e | 645 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 646 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 647 | extern smacErrors_t MLMESetFreqBand(smacFrequencyBands_t freqBand, smacRFModes_t phyMode); |
andreikovacs | 0:401ba973869e | 648 | #endif |
andreikovacs | 0:401ba973869e | 649 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 650 | * MLMESetPhyMode |
andreikovacs | 0:401ba973869e | 651 | * |
andreikovacs | 0:401ba973869e | 652 | * |
andreikovacs | 0:401ba973869e | 653 | * |
andreikovacs | 0:401ba973869e | 654 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 655 | #if defined(gPHY_802_15_4g_d) |
andreikovacs | 0:401ba973869e | 656 | extern smacErrors_t MLMESetPhyMode(smacRFModes_t phyMode); |
andreikovacs | 0:401ba973869e | 657 | #endif |
andreikovacs | 0:401ba973869e | 658 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 659 | /***************************** SMAC Management primitives **************************/ |
andreikovacs | 0:401ba973869e | 660 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 661 | |
andreikovacs | 0:401ba973869e | 662 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 663 | * MLMEScanRequest |
andreikovacs | 0:401ba973869e | 664 | * |
andreikovacs | 0:401ba973869e | 665 | * This function scans the channel passed as parameter using CCA or ED mode |
andreikovacs | 0:401ba973869e | 666 | * returns the RSSI in that channel. |
andreikovacs | 0:401ba973869e | 667 | * |
andreikovacs | 0:401ba973869e | 668 | * Interface assumptions: |
andreikovacs | 0:401ba973869e | 669 | * The SMAC and radio driver have been initialized and are ready to be used. |
andreikovacs | 0:401ba973869e | 670 | * |
andreikovacs | 0:401ba973869e | 671 | * Arguments: |
andreikovacs | 0:401ba973869e | 672 | * channels_t u8ChannelToScan: channel to scan |
andreikovacs | 0:401ba973869e | 673 | * uint8_t *u8ChannelScanResult: to return the RSSI value |
andreikovacs | 0:401ba973869e | 674 | * |
andreikovacs | 0:401ba973869e | 675 | * Return Value: |
andreikovacs | 0:401ba973869e | 676 | * gErrorNoError_c: If the action was performed correctly. |
andreikovacs | 0:401ba973869e | 677 | * gErrorBusy_c: If SMAC is busy. |
andreikovacs | 0:401ba973869e | 678 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 679 | extern smacErrors_t MLMEScanRequest(channels_t u8ChannelToScan); |
andreikovacs | 0:401ba973869e | 680 | |
andreikovacs | 0:401ba973869e | 681 | /*@CMA, Conn Test Added*/ |
andreikovacs | 0:401ba973869e | 682 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 683 | * MLMECcaRequest |
andreikovacs | 0:401ba973869e | 684 | * |
andreikovacs | 0:401ba973869e | 685 | * This function performs Clear Channel Assessment on the active channel |
andreikovacs | 0:401ba973869e | 686 | * |
andreikovacs | 0:401ba973869e | 687 | * Return value: |
andreikovacs | 0:401ba973869e | 688 | * gErrorNoError_c: SMAC will perform Cca |
andreikovacs | 0:401ba973869e | 689 | * gErrorBusy_c: SMAC is busy |
andreikovacs | 0:401ba973869e | 690 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 691 | extern smacErrors_t MLMECcaRequest(void); |
andreikovacs | 0:401ba973869e | 692 | |
andreikovacs | 0:401ba973869e | 693 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 694 | * MLMETXDisableRequest |
andreikovacs | 0:401ba973869e | 695 | * |
andreikovacs | 0:401ba973869e | 696 | * Returns the radio to idle mode from Tx mode. |
andreikovacs | 0:401ba973869e | 697 | * |
andreikovacs | 0:401ba973869e | 698 | ************************************************************************************/ |
andreikovacs | 0:401ba973869e | 699 | extern void MLMETXDisableRequest(void); |
andreikovacs | 0:401ba973869e | 700 | |
andreikovacs | 0:401ba973869e | 701 | /*********************************************************************************** |
andreikovacs | 0:401ba973869e | 702 | ******************************** SMAC MCU primitives ******************************* |
andreikovacs | 0:401ba973869e | 703 | ***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 704 | |
andreikovacs | 0:401ba973869e | 705 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 706 | *SMAC auxiliary functions |
andreikovacs | 0:401ba973869e | 707 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 708 | |
andreikovacs | 0:401ba973869e | 709 | /************************************************************************************ |
andreikovacs | 0:401ba973869e | 710 | *SMACFillHeader |
andreikovacs | 0:401ba973869e | 711 | *This is a replacement for the u8DestAddress in the txPacket_t structure |
andreikovacs | 0:401ba973869e | 712 | *To set the destination address simply call this function with a pointer to |
andreikovacs | 0:401ba973869e | 713 | *txPacket->smacHeader and a uint16_t variable resembling the address. |
andreikovacs | 0:401ba973869e | 714 | *Also, to change the default source address and panID, modify gDefaultPanID_c and |
andreikovacs | 0:401ba973869e | 715 | *gNodeAddress_c from SMAC_Config.h or call SMACSetShortSrcAddress and SMACSetPanID. |
andreikovacs | 0:401ba973869e | 716 | *************************************************************************************/ |
andreikovacs | 0:401ba973869e | 717 | extern void SMACFillHeader(smacHeader_t* pSmacHeader, uint16_t destAddr); |
andreikovacs | 0:401ba973869e | 718 | |
andreikovacs | 0:401ba973869e | 719 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 720 | extern smacErrors_t SMACSetShortSrcAddress(uint16_t nwShortAddress); |
andreikovacs | 0:401ba973869e | 721 | |
andreikovacs | 0:401ba973869e | 722 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 723 | extern smacErrors_t SMACSetPanID(uint16_t nwShortPanID); |
andreikovacs | 0:401ba973869e | 724 | |
andreikovacs | 0:401ba973869e | 725 | /***********************************************************************************/ |
andreikovacs | 0:401ba973869e | 726 | |
andreikovacs | 0:401ba973869e | 727 | |
andreikovacs | 0:401ba973869e | 728 | |
andreikovacs | 0:401ba973869e | 729 | #endif /* SMAC_INTERFACE_H_ */ |