WiFi - WiFiフローチャート

「WiFi - WiFiフローチャート」の編集履歴(バックアップ)一覧はこちら

WiFi - WiFiフローチャート」(2007/07/16 (月) 03:17:40) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

**Wifi 送信 To transmit data via wifi (Assuming you've already initialized wifi and changed channels to the channel you want): -(1) Copy the TX Header followed by the 802.11 packet to send anywhere it will fit in MAC memory (halfword-aligned) -(2) Take the offset from start of MAC memory that you put the packet, divide it by 2, and or with 0x8000 - store this in one of the W_TXLOC registers -(3) Set W_RETRLIMIT, to allow your packet to be retried until an ack is received (set it to 7, or something similar) -(4) Store the bit associated with the W_TXLOC register you used into W_TXCNT - this will send the packet. -(5) You can then read the result data in W_TXSTAT when the TX is over (you can tell either by polling or interrupt) to find out how many retries were used, and if the packet was ACK'd Of course, this is just the simplest approach, you can be a lot more clever about it. **Wifi 受信 To receive data via wifi, you either need to handle the wifi received data interrupt, or you need to poll W_RXHWWRITECSR - whenever it is != W_RXREADCSR, there is a new packet. When there is a new packet, take the following approach: (1) Calculate the length of the new packet (read "received frame length" which is +8 bytes from the start of the packet) - total frame length is (12 + received frame length) padded to a multiple of 4 bytes. (2) Read the data out of the RX FIFO area (keep in mind it's a circular buffer and you may have to wrap around the end of the buffer) (3) Set the value of W_RXREADCSR to the location of the next packet (add the length of the packet, and wrap around if necessary) Keep in mind, W_RXREADCSR and W_RXHWWRITECSR must be multiplied by 2 to get a byte offset from the start of MAC memory. **Wifi チャンネル変更 You can set the channel to any channel number between 1 and 13 (inclusive) on the DS hardware. here's some pseudocode to do it: read 3 bytes of flash starting at (0xF2+(channel-1)*6) to a temporary value call RF_Write with the 3 bytes you just read (as a 0-padded long value) read 3 bytes of flash starting at (0xF5+(channel-1)*6) to a temporary value call RF_Write with the 3 bytes you just read (as a 0-padded long value) delay a few milliseconds call BB_Write with parameters 0x1E, and the byte in flash at 0x146+(channel-1) Congrats, you are now ready to transmit/receive on whatever channel you picked. **ハードウェア TX ヘッダ The TX header is a structure needed by the wifi hardware, it contains important information such as the length of the packet being sent and the rate at which to send (possibly other things too). The TX header is always 12 bytes, it immediately precedes the data to be sent, and should be put at the location that will be given to the register activating a transmission. The TX header takes the following form: (entries are halfwords) Offset Description +0 Unknown (used by hardware) +2 Unknown (used by hardware) +4 Unknown (used by hardware) +6 Unknown (used by hardware) +8 Transmit rate (speed in megabits multiplied by 10) (1.0Mbit is 0x0A, 2.0Mbit is 0x14) +10 Transmit length (bytes) transmits the data at +12 through +12+length-1 inclusive. Important note! TX length includes the length of a 4-byte "FCS" (checksum) for the packet. The hardware generates the FCS for you, but you still must include it in the packet length. Also note that if the 802.11 WEP enabled bit is set in the header, the packet will be automatically encrypted via the wep algorithm - however, the software is responsible for providing the 4-byte IV block with the WEP key ID and the 24bit IV value. - ALSO, you must include the length of the *encrypted* FCS used in packets that have wep enabled (increase the tx length by another 4 bytes) - this value is calculated automaticly for you, but you are responsible for including it in the length of your packet (if you have data there, it'll be replaced by the FCS.) **ハードウェア RX ヘッダ The RX header is an informational structure that provides needed information about a received packet. It is written right before the received packet data in the rx circular buffer. The RX header is always 12 bytes. The RX header takes the following form: (entries are halfwords) Offset Description +0 Unknown (used by hardware) +2 Unknown (used by hardware) +4 Unknown (used by hardware) +6 Unknown (used by hardware) +8 Received frame length (bytes) +10 RSSI Range (Bottom 8 bits are MAX RSSI, top 8 bits are MIN RSSI, during the receipt of the packet) Important Note: Received frame lengths are always multiples of 4 bytes. While the actual header length + received frame length may be less, when incrementing the read cursor you must pad the length to a multiple of 4 bytes **XXX..............known (W) mirrors Read from (W) Mirrors to 070h W_BUF_WR_DATA 060h W_BUF_RD_DATA (passive mirror) 158h W_BBSIOCNT 15Ch W_BBSIOREAD 178h 17Ch W_RFSIODATA2 ----
**Wifi 送信 WiFiでのデータ送信 既にWiFiの初期化とチャンネル変更を済ませたものと仮定して書いています。 -(1) 送信の準備のために、TX ヘッダを MAC メモリ に合わせて 802.11 パケットにコピーします。(ハーフワード境界) -(2) パケットの準備のために、MAC メモリ の開始位置のオフセットを取得します。2で割って、0x8000との論理和を取ります。- W_TXLOCレジスタのうち1つにこれを入れます。 -(3) ACKが受信されるまでのパケットの再送信のために、W_RETRLIMITのセットをします。 (7 もしくは、それに近い値をいれます) -(4) パケットを送信します。W_TXLOC レジスタ に、W_TXCNTを使って値をセットします。 -(5) TX後に、W_TXSTAT から結果データを読み込むことができます。 (ポーリングか割り込みを使って問い合わせることができます。)再送信を何回やったかを見つけるためと、パケットが ACK だった時。 上記は一番単純な方法でのやりかたです。 **Wifi 受信 To receive data via wifi, you either need to handle the wifi received data interrupt, or you need to poll W_RXHWWRITECSR - whenever it is != W_RXREADCSR, there is a new packet. When there is a new packet, take the following approach: (1) Calculate the length of the new packet (read "received frame length" which is +8 bytes from the start of the packet) - total frame length is (12 + received frame length) padded to a multiple of 4 bytes. (2) Read the data out of the RX FIFO area (keep in mind it's a circular buffer and you may have to wrap around the end of the buffer) (3) Set the value of W_RXREADCSR to the location of the next packet (add the length of the packet, and wrap around if necessary) Keep in mind, W_RXREADCSR and W_RXHWWRITECSR must be multiplied by 2 to get a byte offset from the start of MAC memory. **Wifi チャンネル変更 You can set the channel to any channel number between 1 and 13 (inclusive) on the DS hardware. here's some pseudocode to do it: read 3 bytes of flash starting at (0xF2+(channel-1)*6) to a temporary value call RF_Write with the 3 bytes you just read (as a 0-padded long value) read 3 bytes of flash starting at (0xF5+(channel-1)*6) to a temporary value call RF_Write with the 3 bytes you just read (as a 0-padded long value) delay a few milliseconds call BB_Write with parameters 0x1E, and the byte in flash at 0x146+(channel-1) Congrats, you are now ready to transmit/receive on whatever channel you picked. **ハードウェア TX ヘッダ The TX header is a structure needed by the wifi hardware, it contains important information such as the length of the packet being sent and the rate at which to send (possibly other things too). The TX header is always 12 bytes, it immediately precedes the data to be sent, and should be put at the location that will be given to the register activating a transmission. The TX header takes the following form: (entries are halfwords) Offset Description +0 Unknown (used by hardware) +2 Unknown (used by hardware) +4 Unknown (used by hardware) +6 Unknown (used by hardware) +8 Transmit rate (speed in megabits multiplied by 10) (1.0Mbit is 0x0A, 2.0Mbit is 0x14) +10 Transmit length (bytes) transmits the data at +12 through +12+length-1 inclusive. Important note! TX length includes the length of a 4-byte "FCS" (checksum) for the packet. The hardware generates the FCS for you, but you still must include it in the packet length. Also note that if the 802.11 WEP enabled bit is set in the header, the packet will be automatically encrypted via the wep algorithm - however, the software is responsible for providing the 4-byte IV block with the WEP key ID and the 24bit IV value. - ALSO, you must include the length of the *encrypted* FCS used in packets that have wep enabled (increase the tx length by another 4 bytes) - this value is calculated automaticly for you, but you are responsible for including it in the length of your packet (if you have data there, it'll be replaced by the FCS.) **ハードウェア RX ヘッダ The RX header is an informational structure that provides needed information about a received packet. It is written right before the received packet data in the rx circular buffer. The RX header is always 12 bytes. The RX header takes the following form: (entries are halfwords) Offset Description +0 Unknown (used by hardware) +2 Unknown (used by hardware) +4 Unknown (used by hardware) +6 Unknown (used by hardware) +8 Received frame length (bytes) +10 RSSI Range (Bottom 8 bits are MAX RSSI, top 8 bits are MIN RSSI, during the receipt of the packet) Important Note: Received frame lengths are always multiples of 4 bytes. While the actual header length + received frame length may be less, when incrementing the read cursor you must pad the length to a multiple of 4 bytes **XXX..............known (W) mirrors Read from (W) Mirrors to 070h W_BUF_WR_DATA 060h W_BUF_RD_DATA (passive mirror) 158h W_BBSIOCNT 15Ch W_BBSIOREAD 178h 17Ch W_RFSIODATA2 ----

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。