Applying Hardware Reset
Once the RST line has been properly configured, you can reset the GA1000 or WA2000 at any time by executing a simple code shown below. Note that the Wi-Fi module has to be reset in the beginning. The proper hardware reset is not optional!
If your design has no GPIO line to spare, the reset signal can be derived from the combination of CS and CLK line signals (check Connecting GA1000 and WA2000, diagram B). When there is a dedicated RST line, this line is manipulated directly.
The RST line is active low. The WA2000 requires the reset pulse to be at least 1ms long. The GA1000 doesn't care how short the reset pulse is (within the range that you can achieve on Tibbo devices). The code below takes care of the reset for both Wi-Fi devices and on all platforms.
Notice also the while...wend loop. It is there for the proper module reset after it has already been up and running. When the hardware reset is applied, the GA1000 or WA2000 will go offline, and the wln. object will detect this in a matter of milliseconds. Your program should not try to work with the wln. object again until the wln.enabled property goes to 0- NO in response to the hardware reset. Your code can stay and wait for this (as shown below) or rely on the on_wln_event(PL_WLN_EVENT_DISABLED). Once the event is triggered, you are free to repeat the whole process of bringing up Wi-Fi interface.
** Tibbo Basic **
'----- reset Wi-Fi module ----- #If WLN_RESET_MODE 'reset is controlled by the combination of CS and CLK io.lineset(wln.csmap,HIGH) io.lineset(wln.clkmap,LOW) io.lineset(wln.clkmap,HIGH) #Else 'there is a dedicated reset line io.num=WLN_RST io.state=LOW 'The WA2000 requires a longer reset pulse (1ms), and the GA1000 will not mind it '32-bit platforms offers a convenient sys.timercountms method 'Since the WA2000 only works on 32-bit platforms, let's write the code like this: #if PLATFORM_TYPE_32 sys.timercountms=0 while sys.timercountms<1 wend #endif io.state=HIGH #endif 'in case we called wln_init() after it has already been up and running While wln.enabled=YES Wend