SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
The SimpleLink Wi-Fi CC3120 device supports two standard communication interfaces: SPI and UART.
The device automatically detects the active interface during initialization. From the device perspective, after the detection, the second interface is closed and cannot be used. The host driver uses a unified interface for both communication interfaces (abstract layer). The following functions should be implemented:
_SlFd_t sl_IfOpen(char* pIfName , unsigned long flags);
int sl_IfClose(_SlFd Fd);
int sl_IfRead(_SlFd Fd , char* pBuff , int Len);
int sl_IfWrite(_SlFd Fd , char* pBuff , int Len);
sl_IfRegIntHdlr(InterruptHdl , pValue);
The way these functions are implemented has a direct impact on the performances of the SimpleLink Wi-Fi device. Consider using DMA or jitter buffer, if possible.
The function sl_IfOpen returns a file descriptor used later by sl_IfClose, sl_IfRead, and sl_IfWrite. The host application can define the type of this descriptor to any type required by defining _SlFd_t as a macro or typedef in user.h.
Example:
typedef _u32 _SlFd_t;
The sl_IfOpen function opens and configures the interface communication port using given interface name and option flags. The interface name is a parameter of the sl_Start function that passes as is to the sl_IfOpen function. The value of the option flags can be set to a constant value by defining the macro _SlIfOpenFlags in user.h.
The baud rate, clock polarity, clock phase, chip select, flow control, or any other specific attributes of the communication channel must be configured in this function. If the interface name and option flags are not enough for this configuration and the communication channel could not be entirely configured on this function, the host application alternatively can leave the sl_IfOpen function empty, and open and configure the communication channel externally before calling sl_Start. In this method, the host application should provide to sl_Start the file descriptor of the opened channel. The sl_IfClose function is always called on sl_Stop, even if the host application opened the communication channel externally.
For most of the platforms, implementing the five macros above for the interface communication is sufficient.
By default, the host driver is running in a zero-copy method. This method is good for most cases, but essential for microcontrollers with tight availability of resources. However, it means that some commands or messages are sent in several transactions. In some platforms, it can be more efficient, in terms of performances, to copy the data to a temporary buffer and send it all at once. The driver allows this method by implementing additional two macros in user.h:
int sl_IfStartWriteSequence (_SlFd Fd);
int sl_IfEndWriteSequence (_SlFd Fd);
In some platforms, the host application might need to mask the IRQ line whenever this interrupt could be masked. The host driver provides a method to implement such schema. To allow this functionality, the user can define and implement the following macros: