383 | | == Characterizing the Design == |
| 383 | ---- |
| 384 | |
| 385 | Finally, we need to call the {{{poll_hop}}} function. The first place we should call it is the primary {{{while(1)}}} loop in {{{main()}}}. In addition to calling this function, we should use the return value of this function to condition whether or not we allow new MPDU transmissions. Since MPDU transmissions being via IPC messages from CPU_HIGH, we can simply only poll for new IPC messages if {{{poll_hop}}} returns a value of {{{0}}}. Replace the {{{while(1)}}} loop with the following code snippet: |
| 386 | |
| 387 | {{{ |
| 388 | #!c |
| 389 | |
| 390 | while(1){ |
| 391 | //Poll PHY RX start |
| 392 | wlan_mac_low_poll_frame_rx(); |
| 393 | |
| 394 | //Poll the frequency hopping schedule and re-tune if needed |
| 395 | if(poll_hop() == 0){ |
| 396 | //Poll IPC rx |
| 397 | wlan_mac_low_poll_ipc_rx(); |
| 398 | } |
| 399 | |
| 400 | } |
| 401 | |
| 402 | }}} |
| 403 | |
| 404 | Next, we also need to call {{{poll_hop}}} in the context of the {{{frame_transmit()}}} function. If a transmission attempt fails (i.e. it goes un acknowledged), the DCF's error recovery system will allow a node to retransmit the frame. Between attempts, we need to be able to hop to new channel if the schedule dictates. Because the DCF code remains in the {{{frame_transmit()}}} context across retransmissions, the poll we added above to {{{main()}}} will not be called. We need to add a call to {{{poll_hop}}} while the transmit state machine in the MAC Support Core is pending, but not done. The below code snippet tells you where to place the new call to {{{poll_hop()}}}: |
| 405 | |
| 406 | |
| 407 | {{{ |
| 408 | #!c |
| 409 | |
| 410 | //Wait for the MPDU Tx to finish |
| 411 | do { //while(tx_status & WLAN_MAC_STATUS_MASK_TX_A_PENDING) |
| 412 | |
| 413 | //Poll the DCF core status register |
| 414 | mac_hw_status = wlan_mac_get_status(); |
| 415 | |
| 416 | if( mac_hw_status & WLAN_MAC_STATUS_MASK_TX_A_DONE ) { |
| 417 | // ... |
| 418 | } else { //else for if(mac_hw_status & WLAN_MAC_STATUS_MASK_TX_A_DONE) |
| 419 | if( mac_hw_status & \ |
| 420 | (WLAN_MAC_STATUS_MASK_RX_PHY_ACTIVE | \ |
| 421 | WLAN_MAC_STATUS_MASK_RX_PHY_BLOCKED_FCS_GOOD | \ |
| 422 | WLAN_MAC_STATUS_MASK_RX_PHY_BLOCKED) ) { |
| 423 | // ... |
| 424 | } else { |
| 425 | //We should poll our schedule and move to a new channel if need be |
| 426 | poll_hop(); |
| 427 | } |
| 428 | } |
| 429 | } while( mac_hw_status & WLAN_MAC_STATUS_MASK_TX_A_PENDING ); |
| 430 | |
| 431 | }}} |
| 432 | |
| 433 | == Characterization == |