Configuring the CS Line

Top  Previous  Next

The Wi-Fi module interacts with the EM1000 through the SPI interface. The SPI is a bus and more than one SPI "slave" can be connected to this bus. On the EM1000, one SPI device is always present -- this is the serial flash memory that stores the firmware, as well as the Tibbo Basic application and its data. When the Wi-Fi add-on is connected, it becomes the second "slave" device connected to the SPI bus of the EM1000.

Each slave SPI device on the SPI bus has its own  chip select (CS) signal. Both the serial flash and the Wi-Fi add-on have their own CS lines. The Wi-Fi module is selected when its CS line is driven LOW, and is not selected when its CS line is driven HIGH.

The CS input of the Wi-Fi module must be connected to one of the general-purpose I/O (GPIO) lines of the EM1000 (I/O line manipulation falls under the domain of the io object). From the EM1000's standpoint, any line can be used and "mapped" to serve as the CS of the Wi-Fi module -- all that is needed is that this GPIO line is connected to the CS input of the Wi-Fi module. When the Wi-Fi add-on is installed on top of the EM1000, the GPIO line #49 is the one connected to the CS input.

The firmware of the EM1000 will control the CS line automatically, but your application must specify correct mapping, set the line to HIGH, and configure it as output. The wln.csmap property is used to "map" the GPIO line, i.e. select the line that will serve as the CS control line. Your application must also set this line to HIGH and enable it (in this order, not the other way around).

 

 

'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!

 

 

Note that the CS line mapping can't be changed when the Wi-Fi hardware is already booted.

 

note_warning-wt

Incorrect handling of the CS line may cause SPI bus conflicts between the serial flash memory and the Wi-Fi add-on. As a result, your Tibbo Basic application can work incorrectly or hang-up. To avoid this, use the code presented above. Do not alter the code! It is very important that you set the line state to HIGH, and that you do so prior to enabling this line. After this setup, DO NOT manipulate this line in your application. The firmware of the EM1000 will control the CS line automatically.