MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / modSPIReadFromBuffer

Function modSPIReadFromBuffer

modules/pins/spi/esp/modSPI.c:374–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374static void modSPIReadFromBuffer(uint8_t *data, uint8_t bytes)
375{
376 if (64 == bytes) {
377 uint32_t *to = (uint32_t *)data, *from = (uint32_t *)SPI_FLASH_C0(HSPI);
378 *to++ = *from++;
379 *to++ = *from++;
380 *to++ = *from++;
381 *to++ = *from++;
382 *to++ = *from++;
383 *to++ = *from++;
384 *to++ = *from++;
385 *to++ = *from++;
386 *to++ = *from++;
387 *to++ = *from++;
388 *to++ = *from++;
389 *to++ = *from++;
390 *to++ = *from++;
391 *to++ = *from++;
392 *to++ = *from++;
393 *to = *from;
394 }
395 else {
396//@@ optimize this code
397 uint8_t i;
398 uint8_t shift = 0;
399 uint32_t buffer = 0;
400 for (i = 0; i < bytes; ++i) {
401 if ( (i % 4 == 0) ) {
402 buffer = ( *( (uint32_t *)SPI_FLASH_C0(HSPI) + i/4 ) );
403 shift = 0;
404 }
405 data[i] = (buffer >> shift) & 0xFF;
406 shift += 8;
407 }
408 }
409}
410
411void modSPITxRx(modSPIConfiguration config, uint8_t *data, uint16_t count)
412{

Callers 1

modSPITxRxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected