Re: Pic32 to Pic32 firmware upgrade?
Hi Guys, I have modified the bootloader from harmony and am now able to send and receive commands over SPI. I'm not sure how to manage data of varied length. I will probably need to have a data ready signal from slave to master. Otherwise I am not sure how the master will know if the returning data on SPI line is valid.
I am not too familiar with the SPI Slave implementation.
I am not sure how to manage incoming data on SPI bus of variable length. With harmony API DRV_SPI_BufferAddRead2
I can specify the number of bytes I want to receive from master. If I specify 4 bytes but master sends 8 I will get a buffer event complete and access to these 4 bytes but the rest will be lost.
In other case where the master sends smaller packet the buffer complete might never occur and master will have to time out if no ACK was received.
Is there a way to check how many bytes master has sent while CS pin was low. E.g. CS= LOW - Mastter sends X number of bytes - CS HIGH, how can I get X?
I want to replicate the UDP data flow where the api allows to check how many bytes are in the rx buffer.
avlBytes = TCPIP_UDP_GetIsReady(udpsocket);
avlBytes = TCPIP_UDP_ArrayGet(udpsocket, &bootloaderData.data->buffers.buff1, avlBytes);
currDir = IDLE;
handler(DATASTREAM_BUFFER_EVENT_COMPLETE, (DATASTREAM_BUFFER_HANDLE)_bufferHandle, avlBytes);