MCPcopy Create free account
hub / github.com/SmingHub/Sming / rcvr_datablock

Function rcvr_datablock

Sming/Libraries/SDCard/SDCard.cpp:193–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191/*-----------------------------------------------------------------------*/
192
193bool rcvr_datablock( /* 1:OK, 0:Failed */
194 BYTE* buff, /* Data buffer to store received data */
195 UINT btr /* Byte count */
196)
197{
198 /* Wait for data packet in timeout of 100ms */
199 BYTE d{0xFF};
200 for(unsigned tmr = 1000; tmr; tmr--) {
201 d = SDCardSPI->transfer(0xff);
202 if(d != 0xFF) {
203 break;
204 }
205 dly_us(100);
206 }
207 if(d != 0xFE) {
208 return false; /* If not valid data token, return with error */
209 }
210
211 memset(buff, 0xFF, btr); /* Send 0xFF */
212 SDCardSPI->transfer(buff, btr); /* Receive the data block into buffer */
213 SDCardSPI->transfer16(0xffff); /* keep MOSI HIGH, discard CRC */
214
215 // success
216 return true;
217}
218
219/*-----------------------------------------------------------------------*/
220/* Send a data packet to the card */

Callers 2

disk_readFunction · 0.85
disk_ioctlFunction · 0.85

Calls 3

dly_usFunction · 0.85
transfer16Method · 0.80
transferMethod · 0.45

Tested by

no test coverage detected