在线时间2106 小时
UID3253523
注册时间2016-3-21
NXP金币1950
该用户从未签到
超级版主
- 积分
- 20098
- 最后登录
- 2024-5-1
|
发表于 2021-2-18 15:03:35
|
显示全部楼层
楼主你好!
对于SPI从机,通常是由主机决定何时收发数据,因为只有等到主机片选并且给出CLK信号,从机才会一边接收数据一边把主机buffer数据移出去。
LPSPI_SlaveTransferNonBlocking这个函数,从函数API描述,也可以知道具体功能:
/*!
* brief LPSPI slave transfer data using an interrupt method.
*
* This function transfer data using an interrupt method. This is a non-blocking function, which returns right away.
* When all data
* is transferred, the callback function is called.
*
* Note:
* The transfer data size should be integer multiples of bytesPerFrame if bytesPerFrame is less than or equal to 4.
* For bytesPerFrame greater than 4:
* The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4.
* Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.
*
* param base LPSPI peripheral address.
* param handle pointer to lpspi_slave_handle_t structure which stores the transfer state.
* param transfer pointer to lpspi_transfer_t structure.
* return status of status_t.
*/
使用中断方式去传输从机数据,如果主机有信号过来,该函数会启动接收中断,把收到的SPI数据放到slaveRxData中,长度为slaveXfer.dataSize。
当接收完成的时候,可以再LPSPI_SlaveUserCallback中显示传输结束,然后再判断具体接收结束。
从你贴的代码,似乎你还看了freertos的代码,对于:
xSemaphoreTake(m_cb_msg.sem, portMAX_DELAY);
这个是freertos中的信号接收函数,具体你可以查看freertos的情况,用来接收信号量。 |
|