How to Access the SPI Bus
µC/TCP-IP currently supports only wireless devices that communicate with the host via SPI. Also, many other devices/hardware can share the same SPI bus, so each time the device driver needs to access the SPI bus it must acquire the access and set the SPI controller following the wireless device’s SPI requirements. This procedure must be followed each time the device driver needs to access the SPI:
- Acquire the SPI lock by calling network device’s BSP function pointer,
NetDev_WiFi_SPI_Lock()
. - Enable chip select of the wireless device via network device’s BSP function pointer,
NetDev_WiFi_SPI_ChipSelEn()
. - Configure the SPI controller by calling network device’s BSP function pointer,
NetDev_WiFi_SPI_SetCfg()
. - Write data and read data from the SPI with appropriate buffer pointer to write buffer and read buffer to the network device’s BSP function pointer,
Net_Dev_SPI_WrRd()
. - Disable the device’s chip select via network device’s BSP function pointer,
NetDev_WiFi_SPI_ChipSelDis()
. - Release the SPI lock by calling the network device’s BSP function pointer,
NetDev_WiFi_SPI_Unlock()
.