当前位置: 首页> 文旅> 旅游 > 今日最新财经新闻_电商货源网站_药品网络营销公司_厦门seo收费

今日最新财经新闻_电商货源网站_药品网络营销公司_厦门seo收费

时间:2025/8/25 21:29:50来源:https://blog.csdn.net/qq_41164088/article/details/146979678 浏览次数:2次
今日最新财经新闻_电商货源网站_药品网络营销公司_厦门seo收费

一. SPI通信API

static boolean Sa9471SpiSync(Sa47321SpiCmd_e cmd, const Sa47321RegAddr_e addr, const uint8 wData, uint8* rData)
{boolean rRet = TRUE;uint8   parityValue = 0;Spi_SeqResultType seqRet = SPI_SEQ_OK;/* SPI_SEQ_OK = 0,     ///<  @brief  The last transmission of the Sequence has been finished successfully. SPI_SEQ_PENDING,    ///<  @brief  The SPI handler/Driver is performing a SPI Sequence. SPI_SEQ_FAILED,     ///<  @brief  The last transmission of the Sequence has failed. SPI_SEQ_CANCELLED   ///<  @brief  The last transmission of the Sequence has been cancelled by the user. */Std_ReturnType ret = E_OK;///< Set setup an external buffer to be used by a specific channel.ret = Spi_SetupEB(DS_SA47321_SPI_CHANNEL, (uint8*)&s_Dssa47321.TxFrame.U, (uint8*)&s_Dssa47321.RxFrame.U, 2);if(ret == E_OK){s_Dssa47321.RxFrame.U       = 0;s_Dssa47321.TxFrame.U       = 0;s_Dssa47321.TxFrame.B.Cmd   = cmd;s_Dssa47321.TxFrame.B.A0_A5 = addr;s_Dssa47321.TxFrame.B.D0_D7 = wData;for(uint8 i=1; i<16; i++){if(s_Dssa47321.TxFrame.U & (1<<i)){parityValue++;}}s_Dssa47321.TxFrame.B.T = ((parityValue%2) != 0)? 1:0;///< Start transmit data of sequence on the SPI bus synchronously.ret = Spi_SyncTransmit(DS_SA47321_SPI_SEQUENCE);if(ret == E_OK){do{///< Get the last transmission result of the specified Sequence.seqRet = Spi_GetSequenceResult(DS_SA47321_SPI_SEQUENCE);if((seqRet == SPI_SEQ_OK) && (cmd == ReadReg)){*rData = s_Dssa47321.RxFrame.B.D0_D7;break;}else if(seqRet == SPI_SEQ_FAILED){rRet = FALSE;break;}} while (seqRet == SPI_SEQ_PENDING);  }else{rRet = FALSE;}}else{rRet = FALSE;}return rRet;
}
  • Spi_SetupEB():设置SPI发送接收缓存buffer。
  • Spi_SyncTransmit():启动同步传输,该接口中完成数据的发送和接收。
  • Spi_GetSequenceResult():获取当前SPI通信状态。
  • 返回值:当读写操作成功完成后,返回TRUE否则返回FALSE。
    | - 执行写操作时,SA47321接收到写操作并执行成功后,会将发送的数据从SDO引脚返回给MCU。
    | - 执行完读操作时,SA47321接收到读操作并执行成功后,CMD默认回复1,S0~S5为全0,D0 ~ D7但会寄存器数据,T返回奇偶校验位。

二. 获取SPI通信状态API

static boolean GetSpiState(void)
{boolean ret = FALSE;for (uint8 i = 0; i < 5; i++){
关键字:今日最新财经新闻_电商货源网站_药品网络营销公司_厦门seo收费

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: