1. 程式人生 > >【程式】STM32F407VE微控制器驅動Marvell 88W8801 WiFi模組的程式(20181010版)

【程式】STM32F407VE微控制器驅動Marvell 88W8801 WiFi模組的程式(20181010版)

本程式所用的微控制器型號為:STM32F407VE
PD14埠為復位引腳(PDN),請務必連線!
晶振用的是8MHz,請注意檢查自己的開發板,看看晶振是不是8MHz。如果是25MHz,請修改system_stm32f4xx.c檔案!

程式支援連線無密碼的熱點以及WEP、WPA-PSK和WPA2-PSK認證型別的熱點,加密方式支援TKIP和AES。WEP加密型別僅支援新增一個金鑰。
程式暫不支援建立AP熱點(路由器熱點)。
88W8801不支援Ad-Hoc點對點模式, 請不要使用程式中與Ad-Hoc有關的函式。

用Keil5編寫程式的時候,工程資料夾路徑最好不要出現中文哦!不然程式碼提示可能會有問題
wifi_88w8801是主程式,直接開啟下載執行即可。該程式裸機執行,不帶作業系統,執行最新的lwip-2.0.3協議棧

sd8801_uapsta.c是WiFi模組的韌體,上電執行時必須由單片機發送給WiFi模組執行
該韌體資料非常大,為了節約程式編譯下載的時間,可以執行flash_saver程式將這些資料儲存到Flash固定區域
然後根據串列埠提示,修改WiFi.h中WIFI_FIRMWAREAREA_ADDR的值(取消註釋)
這樣就可以移除sd8801_uapsta.c檔案,大幅度降低程式燒寫時間了

【模組連線】

D0~D3接PC8~11,CMD接PD2,CLK接PC12,RESET懸空,PDN接PD14。GND接電源負極,VCC直接接到電源正極。

【Keil5工程截圖】

【筆者所用的開發板和WiFi模組】

在筆者所用的開發板上,Wi-Fi模組的VCC不是直接接到電源上的,而是串聯了一個場效電晶體,當PA15為低電平時Wi-Fi模組通電。

【程式執行截圖】

1. 串列埠輸出

 

2. ping IP地址和計算機名

3. IE瀏覽器通過計算機名訪問板上的HTTP伺服器

4. 路由器管理頁面中看到的DHCP客戶端列表

5. TCP和UDP資料傳送速度測試結果

 

【描述移植過程的Word文件(壓縮包內)】

【程式執行結果】

STM32F407VE SDIO 88W8801
RESPCMD63, RESP1_b0ff8000
RESPCMD63, RESP1_b0300000
Number of I/O Functions: 3
Memory Present: 0
Relative Card Address: 0x0001
Card selected! RESP1_00001e00
SDIO Clock: 24MHz
[CIS] func=0, ptr=0x00008000
Product Information: Marvell 802.11 SDIO ID: 48
Manufacturer Code: 0x02df
Manufacturer Information: 0x9138
Card Function Code: 0x0c
System Initialization Bit Mask: 0x00
Maximum Block Size: 256
Maximum Transfer Rate Code: 0x5a
[CIS] func=1, ptr=0x00008080
Manufacturer Code: 0x02df
Manufacturer Information: 0x9139
Card Function Code: 0x0c
System Initialization Bit Mask: 0x00
Maximum Block Size: 512
[CIS] func=2, ptr=0x00008100
[CIS] func=3, ptr=0x00008180
Firmware is successfully downloaded!
CMDRESP 0x804d at 19ms
MAC Addr: 14:6B:9C:17:50:73
CMDRESP 0x8006 at 433ms
SSID 'O(n_n)O??~', MAC F0:B4:29:23:C3:59, RSSI 65, Channel 3
  Capability: 0x0c11 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 9.0Mbps 18.0Mbps 36.0Mbps 54.0Mbps
CMDRESP 0x8006 at 433ms
SSID 'CMCC-EDU', MAC C6:14:4B:57:E0:2D, RSSI 68, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID '???', MAC E4:F3:F5:21:55:DC, RSSI 48, Channel 6
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'CMCC-EDU', MAC C6:14:4B:62:AB:CD, RSSI 68, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC 66:14:4B:58:0A:E7, RSSI 70, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC 66:14:4B:57:FE:57, RSSI 64, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC E6:14:4B:58:06:D0, RSSI 71, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC C6:14:4B:57:E0:2E, RSSI 68, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC 66:14:4B:57:FE:58, RSSI 63, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC 66:14:4B:58:0A:E8, RSSI 71, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC E6:14:4B:58:06:DF, RSSI 69, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'NJSGHMP', MAC C8:3A:35:4B:47:F8, RSSI 70, Channel 7
  Capability: 0x0411 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
CMDRESP 0x8006 at 435ms
SSID 'k(j?m)l', MAC 40:31:3C:D3:33:E0, RSSI 52, Channel 9
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'CMCC-EDU', MAC 46:14:4B:57:F8:45, RSSI 68, Channel 11
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'Oct1158-2', MAC FC:D7:33:FE:D6:02, RSSI 22, Channel 11
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'cdu??', MAC C8:ED:7D:87:78:E0, RSSI 53, Channel 11
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'CMCC-Young', MAC 46:14:4B:57:F8:46, RSSI 68, Channel 11
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'FAST_6666', MAC D4:83:04:E3:99:9C, RSSI 33, Channel 11
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'CMCC-EDU', MAC 56:14:4B:62:E9:E6, RSSI 49, Channel 11
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC 56:14:4B:62:E9:E7, RSSI 51, Channel 11
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
CMDRESP 0x8006 at 220ms
Scan finished!
CMDRESP 0x80c4 at 0ms
CMDRESP 0x8028 at 0ms
CMDRESP 0x8006 at 1497ms
CMDRESP 0x8012 at 12ms
Waiting for authentication!
[Event 23] size=77
WMM status change event occurred!
[Event 43] size=10
Authenticated!
[Send] len=350, port=1
[Recv] len=590, port=1
[Send] len=350, port=2
[Recv] len=590, port=2
[Send] len=42, port=3
[Send] len=42, port=4
[Send] len=42, port=5
DHCP supplied address!
IP address: 192.168.1.101
Subnet mask: 255.255.255.0
Default gateway: 192.168.1.1
DNS Server: 202.115.80.132
[Send] len=42, port=6
Not in cache!
[Recv] len=42, port=3
[Send] len=79, port=7
[Send] len=42, port=8
[Send] len=79, port=9
[Recv] len=223, port=4
DNS Found IP: 208.118.235.79
Connecting to 208.118.235.79...
[Send] len=58, port=10
[Send] len=42, port=11
Packet on port 1 ACK at 1969ms
Packet on port 2 ACK at 1967ms
Packet on port 3 ACK at 1965ms
Packet on port 4 ACK at 1820ms
Packet on port 5 ACK at 1322ms
Packet on port 6 ACK at 1311ms
Packet on port 7 ACK at 1308ms
Packet on port 8 ACK at 1244ms
Packet on port 9 ACK at 1246ms
Packet on port 10 ACK at 1027ms
[Send] len=42, port=1
[Send] len=58, port=2
[Send] len=42, port=3
[Send] len=58, port=4
[Send] len=58, port=5
[Send] len=58, port=6
[Send] len=58, port=7
[Send] len=58, port=8
Connection error! code=-13
[Recv] len=42, port=5