|
Brining Up Wi-Fi Interface |
Top Previous Next |
A number of steps have to be taken in order to bring up the Wi-Fi module. The following is the "boilerplate" code that should be included in your project. Typically, the code would be in the on_sys_init event handler.
The code includes the following steps:
And now the code itself:
'BRINGING UP THE WI-FI MODULE
Sub On_sys_init() ... ... 'allocate buffer memory for the TX buffer of the WLN object wln.buffrq(6) 'you may get away with allocating fewer pages ... 'other buffer allocations as needed for the project sys.buffalloc
'enable power to the Wi-Fi module io.num=PL_IO_NUM_51 io.enabled=YES io.state=LOW
'configure the CS line wln.csmap=PL_IO_NUM_49 io.num=PL_IO_NUM_49 io.state=HIGH 'VERY IMPORTANT! -- you must have this line, and it must be placed before... io.enabled=YES '...this line!
'set the mac address wln.mac="0.1.2.3.4.5" 'set correct MAC here
'set the domain wln.domain=PL_WLN_DOMAIN_FCC
'boot it up romfile.open("wln_fwar.bin") If wln.boot(romfile.offset)=NG Then 'something is wrong, react to this ... End If ... ... wln.ip="192.168.100.40" 'And don't forget to set a correct IP-address ... 'set output power to maximum If wln.settxpower(255)<>OK Then 'the task was rejected for some reason ... End If 'wait for the task to be completed While wln.task<>PL_WLN_TASK_IDLE Wend ... End Sub
|