我正在把一个老的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