• 发文章

  • 发资料

  • 发帖

  • 提问

  • 发视频

创作活动
0
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
返回

电子发烧友 电子发烧友

  • 全文搜索
    • 全文搜索
    • 标题搜索
  • 全部时间
    • 全部时间
    • 1小时内
    • 1天内
    • 1周内
    • 1个月内
  • 默认排序
    • 默认排序
    • 按时间排序
  • 全部板块
    • 全部板块
大家还在搜
  • 怎么通过SPI读写一个字节的功能

    我正在把一个老的MPLABX项目改编成和声框架。这个项目有两个函数,即SpReWreByTE()和SpReByTyter(),它允许在SPI接口上写入/读取一个字节。现在我遇到了一些问题。MHC中的SPI配置是阻塞模式-轮询模式-主模式-标准缓冲模式- 8位模式,而我的代码ISI在这里看到了一个例子,在“DrvISPixBuffEdReCuffe2函数”部分。上面的代码不起作用,我不明白为什么。谁能给我一个例子来写一个字节或者告诉我为什么我的函数不起作用? 以上来自于百度翻译 以下为原文 I'm adapting an old MPLABX project to the Harmony framework. This project had two functions, SPIWriteByte() and SPIReadByte(), which allow to write/read one byte over the SPI interface. Now in Harmony I have some problem. The SPI configuration in the MHC is - Blocking Mode- Polled Mode- Master Mode- Standard Buffer Mode- 8-bit Mode and my code is appData.spi0Handle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE|DRV_IO_INTENT_BLOCKING);DRV_SPI_BUFFER_HANDLE bufferHandle, bufferHandle2;unsigned char SPIWriteByte(unsigned char byte) { bufferHandle = DRV_SPI_BufferAddWrite2(appData.spi0Handle, &byte, 1, NULL, NULL, &bufferHandle2); if((bufferHandle2 != DRV_SPI_BUFFER_HANDLE_INVALID) && (DRV_SPI_BUFFER_EVENT_COMPLETE & DRV_SPI_BufferStatus( bufferHandle2 )))return 1; elsereturn 0;} //This is a simple main loopwhile(1){ ADS_CHIP_SELECT_Assert(); SPIWriteByte(0x20); ADS_CHIP_SELECT_Deassert();} I saw an example in the "DRV_SPI_BufferAddWrite2 Function" section here. The above code doesn't work and I don't understand why.Can anyone show me an example to write a single byte or tell me why my function doesn't work?

    2019-04-19 11:11