This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3120MOD: Could it possible to implement spi_Write(Fd_t fd, unsigned char *pBuff, int len) function in callback mode?

Part Number: CC3120MOD
Other Parts Discussed in Thread: CC3120

Hello,

I am porting CC3120 Host driver to STM32 micro controller. I found that SPI interface having five macro which we will have to implement and port according to host architecture.

1. sl_IfOpen

2. sl_IfClose

3. sl_IfRead

4. sl_IfWrite

5. sl_IfRegIntHdlr

But one thing I have to confirm that,  could we implement sl_IfWrite/sl_IfRead in callback mode (Interrupt mode)? I think that these function could only be implemented in blocking mode as I found in comments of   sl_IfWrite (I have mentioned that comment below in code section, please read that comment). It is mention in comment that these function sl_IfWrite/sl_IfRead will return after completion of data transfer on SPI and also found that all example implemented in blocking mode only. I have also gone through Programming guide of CC3120 and not found anything related to sl_IfWrite/sl_IfRead in blocking and callback mode.

So please tell me is there any way to implement these sl_IfWrite/sl_IfRead function in callback mode in CC3120 spi interface driver. If it is possible then how it will implement?

Or these sl_IfWrite/sl_IfRead  function could only be implemented in blocking mode (polling mode), return after the completion of data transfer on SPI?

/////////////////////////////////////////////////Please read this comment of code (took from porting folder of CC3120 SDK, file cc_pal.h)/////////////////////////////////////////////////////////////
/*!
\brief attempts to write up to len bytes to the SPI channel

\param fd - file descriptor of an opened SPI channel

\param pBuff - points to first location to start getting the data from

\param len - number of bytes to write to the SPI channel

\return upon successful completion, the function shall return 0.
Otherwise, -1 shall be returned

\sa spi_Open , spi_Read           
\note This function could be implemented as zero copy and return only upon successful completion
of writing the whole buffer, but in cases that memory allocation is not too tight, the
function could copy the data to internal buffer, return back and complete the write in
parallel to other activities as long as the other SPI activities would be blocked untill
the entire buffer write would be completed
\warning
*/
extern int spi_Write(Fd_t fd,
unsigned char *pBuff,
int len);