| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /****************************************************************************** |
| 2 | |||
| 3 | MRF24WB0M Driver Set/Get param messages |
||
| 4 | Module for Microchip TCP/IP Stack |
||
| 5 | -Provides access to MRF24WB0M WiFi controller |
||
| 6 | -Reference: MRF24WB0M Data sheet, IEEE 802.11 Standard |
||
| 7 | |||
| 8 | ******************************************************************************* |
||
| 9 | FileName: WFParamMsg.c |
||
| 10 | Dependencies: TCP/IP Stack header files |
||
| 11 | Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 12 | Compiler: Microchip C32 v1.10b or higher |
||
| 13 | Microchip C30 v3.22 or higher |
||
| 14 | Microchip C18 v3.34 or higher |
||
| 15 | Company: Microchip Technology, Inc. |
||
| 16 | |||
| 17 | Software License Agreement |
||
| 18 | |||
| 19 | Copyright (C) 2002-2010 Microchip Technology Inc. All rights reserved. |
||
| 20 | |||
| 21 | Microchip licenses to you the right to use, modify, copy, and distribute: |
||
| 22 | (i) the Software when embedded on a Microchip microcontroller or digital |
||
| 23 | signal controller product ("Device") which is integrated into |
||
| 24 | Licensee's product; or |
||
| 25 | (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 26 | ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device used in |
||
| 27 | conjunction with a Microchip ethernet controller for the sole purpose |
||
| 28 | of interfacing with the ethernet controller. |
||
| 29 | |||
| 30 | You should refer to the license agreement accompanying this Software for |
||
| 31 | additional information regarding your rights and obligations. |
||
| 32 | |||
| 33 | THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY |
||
| 34 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
| 35 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
||
| 36 | NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR ANY INCIDENTAL, |
||
| 37 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST |
||
| 38 | OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS BY |
||
| 39 | THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS |
||
| 40 | FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON |
||
| 41 | THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR |
||
| 42 | OTHERWISE. |
||
| 43 | |||
| 44 | |||
| 45 | Author Date Comment |
||
| 46 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 47 | KH 27 Jan 2010 Created for MRF24WB0M |
||
| 48 | ******************************************************************************/ |
||
| 49 | |||
| 50 | /* |
||
| 51 | ********************************************************************************************************* |
||
| 52 | * INCLUDES |
||
| 53 | ********************************************************************************************************* |
||
| 54 | */ |
||
| 55 | |||
| 56 | #include "TCPIP Stack/WFMac.h" |
||
| 57 | #if defined(WF_CS_TRIS) |
||
| 58 | |||
| 59 | |||
| 60 | /* |
||
| 61 | ********************************************************************************************************* |
||
| 62 | * DEFINES |
||
| 63 | ********************************************************************************************************* |
||
| 64 | */ |
||
| 65 | |||
| 66 | /* used for assertions */ |
||
| 67 | #ifdef WF_DEBUG |
||
| 68 | #define WF_MODULE_NUMBER WF_MODULE_WF_PARAM_MSG |
||
| 69 | #endif |
||
| 70 | |||
| 71 | #define MSG_PARAM_START_DATA_INDEX (6) |
||
| 72 | #define MULTICAST_ADDRESS (6) |
||
| 73 | #define ADDRESS_FILTER_DEACTIVATE (0) |
||
| 74 | |||
| 75 | #define ENABLE_MRF24WB0M (1) |
||
| 76 | |||
| 77 | |||
| 78 | /******************************************************************************* |
||
| 79 | Function: |
||
| 80 | void WFEnableMRF24WB0MMode(void) |
||
| 81 | |||
| 82 | Summary: |
||
| 83 | Must be called to configure the MRF24WB0M for operations. |
||
| 84 | |||
| 85 | Description: |
||
| 86 | |||
| 87 | Precondition: |
||
| 88 | MACInit must be called first. |
||
| 89 | |||
| 90 | Parameters: |
||
| 91 | None. |
||
| 92 | |||
| 93 | Returns: |
||
| 94 | None. |
||
| 95 | |||
| 96 | Remarks: |
||
| 97 | None. |
||
| 98 | *****************************************************************************/ |
||
| 99 | void WFEnableMRF24WB0MMode(void) |
||
| 100 | { |
||
| 101 | UINT8 buf[1] = {ENABLE_MRF24WB0M}; |
||
| 102 | |||
| 103 | SendSetParamMsg(PARAM_MRF24WB0M, buf, sizeof(buf)); |
||
| 104 | } |
||
| 105 | |||
| 106 | /******************************************************************************* |
||
| 107 | Function: |
||
| 108 | void WFGetMRF24WB0MVersion(UINT8 *p_version) |
||
| 109 | |||
| 110 | Summary: |
||
| 111 | Retrieves the MRF24WB0M version from the device. |
||
| 112 | |||
| 113 | Description: |
||
| 114 | |||
| 115 | Precondition: |
||
| 116 | MACInit must be called first. |
||
| 117 | |||
| 118 | Parameters: |
||
| 119 | p_version -- pointer to location to store version number. |
||
| 120 | |||
| 121 | Returns: |
||
| 122 | None. |
||
| 123 | |||
| 124 | Remarks: |
||
| 125 | None. |
||
| 126 | *****************************************************************************/ |
||
| 127 | void WFGetMRF24WB0MVersion(UINT8 *p_version) |
||
| 128 | { |
||
| 129 | SendGetParamMsg(PARAM_MRF24WB0M, p_version, 1); |
||
| 130 | } |
||
| 131 | |||
| 132 | /******************************************************************************* |
||
| 133 | Function: |
||
| 134 | void WF_GetDeviceInfo(tWFDeviceInfo *p_deviceInfo) |
||
| 135 | |||
| 136 | Summary: |
||
| 137 | Retrieves WF device information |
||
| 138 | |||
| 139 | Description: |
||
| 140 | |||
| 141 | Precondition: |
||
| 142 | MACInit must be called first. |
||
| 143 | |||
| 144 | Parameters: |
||
| 145 | p_deviceInfo -- pointer where device info will be written |
||
| 146 | |||
| 147 | Returns: |
||
| 148 | None. |
||
| 149 | |||
| 150 | Remarks: |
||
| 151 | None. |
||
| 152 | *****************************************************************************/ |
||
| 153 | void WF_GetDeviceInfo(tWFDeviceInfo *p_deviceInfo) |
||
| 154 | { |
||
| 155 | UINT8 msgData[2]; |
||
| 156 | |||
| 157 | SendGetParamMsg(PARAM_SYSTEM_VERSION, msgData, sizeof(msgData)); |
||
| 158 | |||
| 159 | p_deviceInfo->deviceType = MRF24WB0M_DEVICE; |
||
| 160 | p_deviceInfo->romVersion = msgData[0]; |
||
| 161 | p_deviceInfo->patchVersion = msgData[1]; |
||
| 162 | } |
||
| 163 | |||
| 164 | /******************************************************************************* |
||
| 165 | Function: |
||
| 166 | void WF_SetMacAddress(UINT8 *p_mac) |
||
| 167 | |||
| 168 | Summary: |
||
| 169 | Uses a different MAC address for the MRF24WB0M |
||
| 170 | |||
| 171 | Description: |
||
| 172 | Directs the MRF24WB0M to use the input MAC address instead of its |
||
| 173 | factory-default MAC address. This function does not overwrite the factory |
||
| 174 | default, which is in FLASH memory it simply tells the MRF24WB0M to use a |
||
| 175 | different MAC. |
||
| 176 | |||
| 177 | Precondition: |
||
| 178 | MACInit must be called first. Cannot be called when the MRF24WB0M is in a |
||
| 179 | connected state. |
||
| 180 | |||
| 181 | Parameters: |
||
| 182 | p_mac -- pointer to 6-byte MAC that will be sent to MRF24WB0M |
||
| 183 | |||
| 184 | Returns: |
||
| 185 | None. |
||
| 186 | |||
| 187 | Remarks: |
||
| 188 | None. |
||
| 189 | *****************************************************************************/ |
||
| 190 | void WF_SetMacAddress(UINT8 *p_mac) |
||
| 191 | { |
||
| 192 | SendSetParamMsg(PARAM_MAC_ADDRESS, p_mac, WF_MAC_ADDRESS_LENGTH); |
||
| 193 | } |
||
| 194 | |||
| 195 | /******************************************************************************* |
||
| 196 | Function: |
||
| 197 | void WF_GetMacAddress(UINT8 *p_mac) |
||
| 198 | |||
| 199 | Summary: |
||
| 200 | Retrieves the MRF24WB0M MAC address |
||
| 201 | |||
| 202 | Description: |
||
| 203 | |||
| 204 | Precondition: |
||
| 205 | MACInit must be called first. |
||
| 206 | |||
| 207 | Parameters: |
||
| 208 | p_mac -- pointer where mac will be written (must point to a 6-byte buffer) |
||
| 209 | |||
| 210 | Returns: |
||
| 211 | None. |
||
| 212 | |||
| 213 | Remarks: |
||
| 214 | None. |
||
| 215 | *****************************************************************************/ |
||
| 216 | void WF_GetMacAddress(UINT8 *p_mac) |
||
| 217 | { |
||
| 218 | SendGetParamMsg(PARAM_MAC_ADDRESS, p_mac, WF_MAC_ADDRESS_LENGTH); |
||
| 219 | } |
||
| 220 | |||
| 221 | #if defined(WF_USE_MULTICAST_FUNCTIONS) |
||
| 222 | /******************************************************************************* |
||
| 223 | Function: |
||
| 224 | void WF_SetMultiCastFilter(UINT8 multicastFilterId, |
||
| 225 | UINT8 multicastAddress[6]) |
||
| 226 | |||
| 227 | Summary: |
||
| 228 | Sets a multicast address filter using one of the two multicast filters. |
||
| 229 | |||
| 230 | Description: |
||
| 231 | This function allows the application to configure up to two Multicast |
||
| 232 | Address Filters on the MRF24WB0M. If two active multicast filters are set |
||
| 233 | up they are ORd together the MRF24WB0M will receive and pass to the Host |
||
| 234 | CPU received packets from either multicast address. |
||
| 235 | The allowable values for the multicast filter are: |
||
| 236 | * WF_MULTICAST_FILTER_1 |
||
| 237 | * WF_MULTICAST_FILTER_2 |
||
| 238 | |||
| 239 | By default, both Multicast Filters are inactive. |
||
| 240 | |||
| 241 | Precondition: |
||
| 242 | MACInit must be called first. |
||
| 243 | |||
| 244 | Parameters: |
||
| 245 | multicastFilterId -- WF_MULTICAST_FILTER_1 or WF_MULTICAST_FILTER_2 |
||
| 246 | multicastAddress -- 6-byte address (all 0xFF will inactivate the filter) |
||
| 247 | |||
| 248 | Returns: |
||
| 249 | None. |
||
| 250 | |||
| 251 | Remarks: |
||
| 252 | None. |
||
| 253 | *****************************************************************************/ |
||
| 254 | void WF_SetMultiCastFilter(UINT8 multicastFilterId, |
||
| 255 | UINT8 multicastAddress[6]) |
||
| 256 | { |
||
| 257 | int i; |
||
| 258 | BOOL deactivateFlag = TRUE; |
||
| 259 | UINT8 msgData[8]; |
||
| 260 | |||
| 261 | WF_ASSERT( (multicastFilterId == WF_MULTICAST_FILTER_1) || (multicastFilterId == WF_MULTICAST_FILTER_2) ); |
||
| 262 | |||
| 263 | /* check if all 6 bytes of the address are 0xff, implying that the caller wants to deactivate */ |
||
| 264 | /* the multicast filter. */ |
||
| 265 | for (i = 0; i < 6; ++i) |
||
| 266 | { |
||
| 267 | /* if any byte is not 0xff then a presume a valid multicast address */ |
||
| 268 | if (multicastAddress[i] != 0xff) |
||
| 269 | { |
||
| 270 | deactivateFlag = FALSE; |
||
| 271 | break; |
||
| 272 | } |
||
| 273 | } |
||
| 274 | |||
| 275 | msgData[0] = multicastFilterId; /* Address Compare Register number to use */ |
||
| 276 | if (deactivateFlag) |
||
| 277 | { |
||
| 278 | msgData[1] = ADDRESS_FILTER_DEACTIVATE; |
||
| 279 | } |
||
| 280 | else |
||
| 281 | { |
||
| 282 | msgData[1] = MULTICAST_ADDRESS; /* type of address being used in the filter */ |
||
| 283 | } |
||
| 284 | memcpy(&msgData[2], (void *)multicastAddress, WF_MAC_ADDRESS_LENGTH); |
||
| 285 | |||
| 286 | SendSetParamMsg(PARAM_COMPARE_ADDRESS, msgData, sizeof(msgData) ); |
||
| 287 | } |
||
| 288 | |||
| 289 | /******************************************************************************* |
||
| 290 | Function: |
||
| 291 | void WF_GetMultiCastFilter(UINT8 multicastFilterId, |
||
| 292 | UINT8 multicastAddress[6]) |
||
| 293 | |||
| 294 | Summary: |
||
| 295 | Gets a multicast address filter from one of the two multicast filters. |
||
| 296 | |||
| 297 | Description: |
||
| 298 | Gets the current state of the specified Multicast Filter. |
||
| 299 | |||
| 300 | Normally would call SendGetParamMsg, but this GetParam returns all 6 address |
||
| 301 | filters + 2 more bytes for a total of 48 bytes plus header. So, doing this |
||
| 302 | msg manually to not require a large stack allocation to hold all the data. |
||
| 303 | |||
| 304 | Exact format of returned message is: |
||
| 305 | [0] -- always mgmt response (2) |
||
| 306 | [1] -- always WF_GET_PARAM_SUBTYPE (16) |
||
| 307 | [2] -- result (1 if successful) |
||
| 308 | [3] -- mac state (not used) |
||
| 309 | [4] -- data length (length of response data starting at index 6) |
||
| 310 | [5] -- not used |
||
| 311 | [6-11] -- Compare Address 0 address |
||
| 312 | [12] -- Compare Address 0 group |
||
| 313 | [13] -- Compare Address 0 type |
||
| 314 | [14-19] -- Compare Address 1 address |
||
| 315 | [20] -- Compare Address 1 group |
||
| 316 | [21] -- Compare Address 1 type |
||
| 317 | [22-27] -- Compare Address 2 address |
||
| 318 | [28] -- Compare Address 2 group |
||
| 319 | [29] -- Compare Address 2 type |
||
| 320 | [30-35] -- Compare Address 3 address |
||
| 321 | [36] -- Compare Address 3 group |
||
| 322 | [37] -- Compare Address 3 type |
||
| 323 | [38-43] -- Compare Address 4 address |
||
| 324 | [44] -- Compare Address 4 group |
||
| 325 | [45] -- Compare Address 4 type |
||
| 326 | [46-51] -- Compare Address 5 address |
||
| 327 | [52] -- Compare Address 5 group |
||
| 328 | [53] -- Compare Address 5 type |
||
| 329 | |||
| 330 | Precondition: |
||
| 331 | MACInit must be called first. |
||
| 332 | |||
| 333 | Parameters: |
||
| 334 | multicastFilterId -- WF_MULTICAST_FILTER_1 or WF_MULTICAST_FILTER_2 |
||
| 335 | multicastAddress -- 6-byte address |
||
| 336 | |||
| 337 | Returns: |
||
| 338 | None. |
||
| 339 | |||
| 340 | Remarks: |
||
| 341 | None. |
||
| 342 | *****************************************************************************/ |
||
| 343 | void WF_GetMultiCastFilter(UINT8 multicastFilterId, |
||
| 344 | UINT8 multicastAddress[6]) |
||
| 345 | { |
||
| 346 | UINT8 hdr[4]; |
||
| 347 | UINT8 paramData[8]; |
||
| 348 | UINT8 startIndex; |
||
| 349 | |||
| 350 | WF_ASSERT( (multicastFilterId == WF_MULTICAST_FILTER_1) || (multicastFilterId == WF_MULTICAST_FILTER_2) ); |
||
| 351 | |||
| 352 | |||
| 353 | hdr[0] = WF_MGMT_REQUEST_TYPE; |
||
| 354 | hdr[1] = WF_GET_PARAM_SUBTYPE; |
||
| 355 | hdr[2] = 0x00; /* MS 8 bits of param Id, always 0 */ |
||
| 356 | hdr[3] = PARAM_COMPARE_ADDRESS; /* LS 8 bits of param ID */ |
||
| 357 | |||
| 358 | SendMgmtMsg(hdr, /* header */ |
||
| 359 | sizeof(hdr), /* size of header */ |
||
| 360 | NULL, /* no data */ |
||
| 361 | 0); /* no data */ |
||
| 362 | |||
| 363 | if (multicastFilterId == WF_MULTICAST_FILTER_1) |
||
| 364 | { |
||
| 365 | startIndex = 38; /* index of first byte of index 4 address filter */ |
||
| 366 | } |
||
| 367 | else |
||
| 368 | { |
||
| 369 | startIndex = 46; /* index of first byte of index 5 address filter */ |
||
| 370 | } |
||
| 371 | |||
| 372 | WaitForMgmtResponseAndReadData(WF_GET_PARAM_SUBTYPE, /* expected subtype */ |
||
| 373 | sizeof(paramData), /* num data bytes to read */ |
||
| 374 | startIndex, /* starting at this index */ |
||
| 375 | paramData); /* write the response data here */ |
||
| 376 | |||
| 377 | |||
| 378 | memcpy((void *)multicastAddress, (void *)¶mData[0], 6); |
||
| 379 | } |
||
| 380 | |||
| 381 | #endif /* WF_USE_MULTICAST_FUNCTIONS */ |
||
| 382 | |||
| 383 | /******************************************************************************* |
||
| 384 | Function: |
||
| 385 | void WF_SetTxDataConfirm(UINT8 state) |
||
| 386 | |||
| 387 | Summary: |
||
| 388 | Enables or disables Tx data confirmation management messages. |
||
| 389 | |||
| 390 | Description: |
||
| 391 | Enables or disables the MRF24WB0M Tx data confirm mgmt message. Data |
||
| 392 | confirms should always be disabled. |
||
| 393 | |||
| 394 | Precondition: |
||
| 395 | MACInit must be called first. |
||
| 396 | |||
| 397 | Parameters: |
||
| 398 | state -- WF_DISABLED or WF_ENABLED |
||
| 399 | |||
| 400 | Returns: |
||
| 401 | None. |
||
| 402 | |||
| 403 | Remarks: |
||
| 404 | None. |
||
| 405 | *****************************************************************************/ |
||
| 406 | void WF_SetTxDataConfirm(UINT8 state) |
||
| 407 | { |
||
| 408 | SendSetParamMsg(PARAM_CONFIRM_DATA_TX_REQ, &state, 1); |
||
| 409 | } |
||
| 410 | |||
| 411 | /******************************************************************************* |
||
| 412 | Function: |
||
| 413 | void WF_GetTxDataConfirm(UINT8 *p_txDataConfirm) |
||
| 414 | |||
| 415 | Summary: |
||
| 416 | Retrives the current state of Tx data confirmation management messages. |
||
| 417 | |||
| 418 | Description: |
||
| 419 | |||
| 420 | Precondition: |
||
| 421 | MACInit must be called first. |
||
| 422 | |||
| 423 | Parameters: |
||
| 424 | p_txDataConfirm -- pointer to location where Tx data confirmation state is |
||
| 425 | |||
| 426 | Returns: |
||
| 427 | None. |
||
| 428 | |||
| 429 | Remarks: |
||
| 430 | None. |
||
| 431 | *****************************************************************************/ |
||
| 432 | void WF_GetTxDataConfirm(UINT8 *p_txDataConfirm) |
||
| 433 | { |
||
| 434 | SendGetParamMsg(PARAM_CONFIRM_DATA_TX_REQ, p_txDataConfirm, 1); |
||
| 435 | } |
||
| 436 | |||
| 437 | /******************************************************************************* |
||
| 438 | Function: |
||
| 439 | void WF_SetRegionalDomain(UINT8 regionalDomain) |
||
| 440 | |||
| 441 | Summary: |
||
| 442 | Enables or disables the MRF24WB0M Regional Domain. |
||
| 443 | |||
| 444 | Description: |
||
| 445 | Sets the regional domain on the MRF24WB0M. Note that this function does not |
||
| 446 | overwrite the factory-set regional domain in FLASH. By default the |
||
| 447 | MRF24WB0M will use the factory-set regional domain. It is invalid to call |
||
| 448 | this function while in a connected state. |
||
| 449 | |||
| 450 | Valid values for the regional domain are: |
||
| 451 | * WF_DOMAIN_FCC |
||
| 452 | * WF_DOMAIN_IC |
||
| 453 | * WF_DOMAIN_ETSI |
||
| 454 | * WF_DOMAIN_SPAIN |
||
| 455 | * WF_DOMAIN_FRANCE |
||
| 456 | * WF_DOMAIN_JAPAN_A |
||
| 457 | * WF_DOMAIN_JAPAN_B |
||
| 458 | |||
| 459 | Precondition: |
||
| 460 | MACInit must be called first. This function must not be called while in a |
||
| 461 | connected state. |
||
| 462 | |||
| 463 | Parameters: |
||
| 464 | regionalDomain -- value to set the regional domain to |
||
| 465 | |||
| 466 | Returns: |
||
| 467 | None. |
||
| 468 | |||
| 469 | Remarks: |
||
| 470 | None. |
||
| 471 | *****************************************************************************/ |
||
| 472 | void WF_SetRegionalDomain(UINT8 regionalDomain) |
||
| 473 | { |
||
| 474 | SendSetParamMsg(PARAM_REGIONAL_DOMAIN, ®ionalDomain, 1); |
||
| 475 | } |
||
| 476 | |||
| 477 | /******************************************************************************* |
||
| 478 | Function: |
||
| 479 | void WF_GetRegionalDomain(UINT8 *p_regionalDomain) |
||
| 480 | |||
| 481 | Summary: |
||
| 482 | Retrieves the MRF24WB0M Regional domain |
||
| 483 | |||
| 484 | Description: |
||
| 485 | Gets the regional domain on the MRF24WB0M. Allowable values are: |
||
| 486 | * WF_DOMAIN_FCC |
||
| 487 | * WF_DOMAIN_IC |
||
| 488 | * WF_DOMAIN_ETSI |
||
| 489 | * WF_DOMAIN_SPAIN |
||
| 490 | * WF_DOMAIN_FRANCE |
||
| 491 | * WF_DOMAIN_JAPAN_A |
||
| 492 | * WF_DOMAIN_JAPAN_B |
||
| 493 | |||
| 494 | Precondition: |
||
| 495 | MACInit must be called first. |
||
| 496 | |||
| 497 | Parameters: |
||
| 498 | p_regionalDomain -- pointer where the regional domain value will be written |
||
| 499 | |||
| 500 | Returns: |
||
| 501 | None. |
||
| 502 | |||
| 503 | Remarks: |
||
| 504 | None. |
||
| 505 | *****************************************************************************/ |
||
| 506 | void WF_GetRegionalDomain(UINT8 *p_regionalDomain) |
||
| 507 | { |
||
| 508 | SendGetParamMsg(PARAM_REGIONAL_DOMAIN, p_regionalDomain, 1); |
||
| 509 | } |
||
| 510 | |||
| 511 | /******************************************************************************* |
||
| 512 | Function: |
||
| 513 | void WF_SetRtsThreshold(UINT16 rtsThreshold) |
||
| 514 | |||
| 515 | Summary: |
||
| 516 | Sets the RTS Threshold. |
||
| 517 | |||
| 518 | Description: |
||
| 519 | Sets the RTS/CTS packet size threshold for when RTS/CTS frame will be sent. |
||
| 520 | The default is 2347 bytes the maximum for 802.11. It is recommended that |
||
| 521 | the user leave the default at 2347 until they understand the performance and |
||
| 522 | power ramifications of setting it smaller. Valid values are from 0 to |
||
| 523 | WF_RTS_THRESHOLD_MAX (2347). |
||
| 524 | |||
| 525 | Precondition: |
||
| 526 | MACInit must be called first. |
||
| 527 | |||
| 528 | Parameters: |
||
| 529 | rtsThreshold -- value of the packet size threshold |
||
| 530 | |||
| 531 | Returns: |
||
| 532 | None. |
||
| 533 | |||
| 534 | Remarks: |
||
| 535 | None. |
||
| 536 | *****************************************************************************/ |
||
| 537 | void WF_SetRtsThreshold(UINT16 rtsThreshold) |
||
| 538 | { |
||
| 539 | WF_ASSERT(rtsThreshold <= WF_RTS_THRESHOLD_MAX); |
||
| 540 | |||
| 541 | /* correct endianness before sending message */ |
||
| 542 | rtsThreshold = HSTOWFS(rtsThreshold); |
||
| 543 | |||
| 544 | SendSetParamMsg(PARAM_RTS_THRESHOLD, (UINT8 *)&rtsThreshold, sizeof(rtsThreshold)); |
||
| 545 | } |
||
| 546 | |||
| 547 | /******************************************************************************* |
||
| 548 | Function: |
||
| 549 | void WF_GetRtsThreshold(UINT16 *p_rtsThreshold) |
||
| 550 | |||
| 551 | Summary: |
||
| 552 | Gets the RTS Threshold |
||
| 553 | |||
| 554 | Description: |
||
| 555 | Gets the RTS/CTS packet size threshold. |
||
| 556 | |||
| 557 | Precondition: |
||
| 558 | MACInit must be called first. |
||
| 559 | |||
| 560 | Parameters: |
||
| 561 | p_rtsThreshold -- Pointer to where RTS threshold is written |
||
| 562 | |||
| 563 | Returns: |
||
| 564 | None. |
||
| 565 | |||
| 566 | Remarks: |
||
| 567 | None. |
||
| 568 | *****************************************************************************/ |
||
| 569 | void WF_GetRtsThreshold(UINT16 *p_rtsThreshold) |
||
| 570 | { |
||
| 571 | SendGetParamMsg(PARAM_RTS_THRESHOLD, (UINT8 *)p_rtsThreshold, sizeof(UINT16)); |
||
| 572 | |||
| 573 | /* correct endianness before sending message */ |
||
| 574 | *p_rtsThreshold = HSTOWFS(*p_rtsThreshold); |
||
| 575 | } |
||
| 576 | |||
| 577 | /******************************************************************************* |
||
| 578 | Function: |
||
| 579 | void WF_GetMacStats(tWFMacStats *p_macStats) |
||
| 580 | |||
| 581 | Summary: |
||
| 582 | Gets MAC statistics. |
||
| 583 | |||
| 584 | Description: |
||
| 585 | |||
| 586 | Precondition: |
||
| 587 | MACInit must be called first. |
||
| 588 | |||
| 589 | Parameters: |
||
| 590 | p_macStats -- pointer to where MAC statistics are written |
||
| 591 | |||
| 592 | Returns: |
||
| 593 | None. |
||
| 594 | |||
| 595 | Remarks: |
||
| 596 | None. |
||
| 597 | *****************************************************************************/ |
||
| 598 | void WF_GetMacStats(tWFMacStats *p_macStats) |
||
| 599 | { |
||
| 600 | UINT32 *p_value; |
||
| 601 | UINT8 numElements; |
||
| 602 | UINT8 i; |
||
| 603 | |||
| 604 | SendGetParamMsg(PARAM_STAT_COUNTERS, (UINT8 *)p_macStats, sizeof(tWFMacStats)); |
||
| 605 | |||
| 606 | /* calculate number of 32-bit counters in the stats structure and point to first element */ |
||
| 607 | numElements = sizeof(tWFMacStats) / sizeof(UINT32); |
||
| 608 | p_value = (UINT32 *)p_macStats; |
||
| 609 | |||
| 610 | /* correct endianness on all counters in structure */ |
||
| 611 | for (i = 0; i < numElements; ++i) |
||
| 612 | { |
||
| 613 | *p_value = WFTOHL(*p_value); |
||
| 614 | ++p_value; |
||
| 615 | } |
||
| 616 | } |
||
| 617 | |||
| 618 | /******************************************************************************* |
||
| 619 | Function: |
||
| 620 | void SendSetParamMsg(UINT8 paramType, |
||
| 621 | UINT8 *p_paramData, |
||
| 622 | UINT8 paramDataLength) |
||
| 623 | |||
| 624 | Summary: |
||
| 625 | Sends a SetParam Mgmt request to MRF24WB0M and waits for response. |
||
| 626 | |||
| 627 | Description: |
||
| 628 | Index Set Param Request |
||
| 629 | ----- ----------------- |
||
| 630 | |||
| 631 | 1 subtype (always 0x10 signifying a Set Param Msg) |
||
| 632 | 2 param ID [msb] (MS byte of parameter ID being requested, e.g. |
||
| 633 | PARAM_SYSTEM_VERSION) |
||
| 634 | 3 param ID [lsb] (LS byte of parameter ID being requested. e.g. |
||
| 635 | PARAM_SYSTEM_VERSION) |
||
| 636 | 4 payload[0] first byte of param data |
||
| 637 | N payload[n] Nth byte of payload data |
||
| 638 | |||
| 639 | Index Set Param Response |
||
| 640 | ------ ------------------ |
||
| 641 | |||
| 642 | 1 subtype (always 0x10 signifying a Param Response Msg |
||
| 643 | 2 result (1 if successful -- any other value indicates failure |
||
| 644 | 3 mac state (not used) |
||
| 645 | |||
| 646 | Precondition: |
||
| 647 | MACInit must be called first. |
||
| 648 | |||
| 649 | Parameters: |
||
| 650 | paramType -- Parameter type associated with the SetParam msg. |
||
| 651 | p_paramData -- pointer to parameter data |
||
| 652 | paramDataLength -- number of bytes pointed to by p_paramData |
||
| 653 | |||
| 654 | Returns: |
||
| 655 | None. |
||
| 656 | |||
| 657 | Remarks: |
||
| 658 | None. |
||
| 659 | *****************************************************************************/ |
||
| 660 | void SendSetParamMsg(UINT8 paramType, |
||
| 661 | UINT8 *p_paramData, |
||
| 662 | UINT8 paramDataLength) |
||
| 663 | { |
||
| 664 | UINT8 hdr[4]; |
||
| 665 | |||
| 666 | hdr[0] = WF_MGMT_REQUEST_TYPE; |
||
| 667 | hdr[1] = WF_SET_PARAM_SUBTYPE; |
||
| 668 | hdr[2] = 0x00; /* MS 8 bits of param Id, always 0 */ |
||
| 669 | hdr[3] = paramType; /* LS 8 bits of param ID */ |
||
| 670 | |||
| 671 | SendMgmtMsg(hdr, /* header */ |
||
| 672 | sizeof(hdr), /* size of header */ |
||
| 673 | p_paramData, /* param data */ |
||
| 674 | paramDataLength); /* param data length */ |
||
| 675 | |||
| 676 | /* wait for MRF24WB0M management response; free response because not needed */ |
||
| 677 | WaitForMgmtResponse(WF_SET_PARAM_SUBTYPE, FREE_MGMT_BUFFER); |
||
| 678 | } |
||
| 679 | |||
| 680 | /******************************************************************************* |
||
| 681 | Function: |
||
| 682 | void SendGetParamMsg(UINT8 paramType, |
||
| 683 | UINT8 *p_paramData, |
||
| 684 | UINT8 paramDataLength) |
||
| 685 | |||
| 686 | Summary: |
||
| 687 | Sends a GetParam Mgmt request to MRF24WB0M and waits for response. |
||
| 688 | |||
| 689 | Description: |
||
| 690 | After response is received the param data is read from message and written |
||
| 691 | to p_paramData. It is up to the caller to fix up endianness. |
||
| 692 | |||
| 693 | Index Get Param Request |
||
| 694 | ----- ----------------- |
||
| 695 | |||
| 696 | 1 subtype (always 0x10 signifying a Get Param Msg) |
||
| 697 | 2 param ID [msb] (MS byte of parameter ID being requested, e.g. |
||
| 698 | PARAM_SYSTEM_VERSION) |
||
| 699 | 3 param ID [lsb] (LS byte of parameter ID being requested, e.g. |
||
| 700 | PARAM_SYSTEM_VERSION) |
||
| 701 | |||
| 702 | Index Get Param Response |
||
| 703 | ------ ------------------ |
||
| 704 | |||
| 705 | 1 subtype (always 0x10 signifying a Param Response Msg |
||
| 706 | 2 result (1 if successful -- any other value indicates failure |
||
| 707 | 3 mac state (not used) |
||
| 708 | 4 data length Length of response data starting at index 6 (in bytes) |
||
| 709 | 5 not used |
||
| 710 | 6 Data[0] first byte of returned parameter data |
||
| 711 | N Data[N] Nth byte of param data |
||
| 712 | |||
| 713 | Precondition: |
||
| 714 | MACInit must be called first. |
||
| 715 | |||
| 716 | Parameters: |
||
| 717 | |||
| 718 | Returns: |
||
| 719 | None. |
||
| 720 | |||
| 721 | Remarks: |
||
| 722 | None. |
||
| 723 | *****************************************************************************/ |
||
| 724 | void SendGetParamMsg(UINT8 paramType, |
||
| 725 | UINT8 *p_paramData, |
||
| 726 | UINT8 paramDataLength) |
||
| 727 | { |
||
| 728 | UINT8 hdr[4]; |
||
| 729 | |||
| 730 | hdr[0] = WF_MGMT_REQUEST_TYPE; |
||
| 731 | hdr[1] = WF_GET_PARAM_SUBTYPE; |
||
| 732 | hdr[2] = 0x00; /* MS 8 bits of param Id, always 0 */ |
||
| 733 | hdr[3] = paramType; /* LS 8 bits of param ID */ |
||
| 734 | |||
| 735 | SendMgmtMsg(hdr, /* header */ |
||
| 736 | sizeof(hdr), /* size of header */ |
||
| 737 | NULL, /* no data */ |
||
| 738 | 0); /* no data */ |
||
| 739 | |||
| 740 | WaitForMgmtResponseAndReadData(WF_GET_PARAM_SUBTYPE, /* expected subtype */ |
||
| 741 | paramDataLength, /* num data bytes to read */ |
||
| 742 | MSG_PARAM_START_DATA_INDEX, /* data for GetParam always starts at index 6 */ |
||
| 743 | p_paramData); /* write the response data here */ |
||
| 744 | } |
||
| 745 | #endif /* WF_CS_TRIS */ |
Powered by WebSVN v2.8.3