@@ -300,87 +300,6 @@ void ArduinoSPI::transfer(void *buf, size_t count)
300
300
}
301
301
}
302
302
303
- void ArduinoSPI::transfer (void *buf, void *rxbuf, size_t count)
304
- {
305
- if (_is_sci) {
306
- _spi_cb_event[_cb_event_idx] = SPI_EVENT_TRANSFER_ABORTED;
307
-
308
- _write_then_read (&_spi_sci_ctrl, buf, rxbuf, count, SPI_BIT_WIDTH_8_BITS);
309
-
310
- for (auto const start = millis ();
311
- (SPI_EVENT_TRANSFER_COMPLETE != _spi_cb_event[_cb_event_idx]) && (millis () - start < 1000 ); )
312
- {
313
- __NOP ();
314
- }
315
- if (SPI_EVENT_TRANSFER_ABORTED == _spi_cb_event[_cb_event_idx])
316
- {
317
- end ();
318
- }
319
- }
320
- else {
321
- size_t n32 = count / 4U ;
322
- if (n32 != 0U ) {
323
- _spi_ctrl.p_regs ->SPCR_b .SPE = 0 ; /* disable SPI unit */
324
- _spi_ctrl.p_regs ->SPDCR = R_SPI0_SPDCR_SPLW_Msk; /* SPI word access */
325
- _spi_ctrl.p_regs ->SPCMD_b [0 ].SPB = 2 ; /* spi bit width = 32 */
326
- _spi_ctrl.p_regs ->SPCR_b .SPE = 1 ; /* enable SPI unit */
327
-
328
- const uint32_t * tx32 = (const uint32_t *) buf;
329
- uint32_t * rx32 = (uint32_t *) rxbuf;
330
- size_t index_rx = 0 ;
331
- size_t index_tx = 0 ;
332
-
333
- while ((index_tx < 2U ) && (index_tx < n32)) {
334
- if (_spi_ctrl.p_regs ->SPSR_b .SPTEF ) {
335
- _spi_ctrl.p_regs ->SPDR = (buf != NULL ) ? tx32[index_tx] : 0xFFFFFFFF ;
336
- index_tx++;
337
- }
338
- }
339
-
340
- while (index_tx < n32) {
341
- if (_spi_ctrl.p_regs ->SPSR_b .SPRF ) {
342
- uint32_t tmp = _spi_ctrl.p_regs ->SPDR ;
343
- _spi_ctrl.p_regs ->SPDR = (buf != NULL ) ? tx32[index_tx] : 0xFFFFFFFF ;
344
- if (rxbuf != NULL ) {
345
- rx32[index_rx] = tmp;
346
- }
347
- index_rx++;
348
- index_tx++;
349
- }
350
- }
351
-
352
- while (index_rx < n32) { /* collect the last word received */
353
- if (_spi_ctrl.p_regs ->SPSR_b .SPRF ) {
354
- uint32_t tmp = _spi_ctrl.p_regs ->SPDR ;
355
- if (rxbuf != NULL ) {
356
- rx32[index_rx] = tmp;
357
- }
358
- index_rx++;
359
- }
360
- }
361
-
362
- _spi_ctrl.p_regs ->SPCR_b .SPE = 0 ; /* disable SPI unit */
363
- _spi_ctrl.p_regs ->SPDCR = R_SPI0_SPDCR_SPBYT_Msk; /* SPI byte access */
364
- _spi_ctrl.p_regs ->SPCMD_b [0 ].SPB = 7 ; /* spi bit width = 8 */
365
- _spi_ctrl.p_regs ->SPCR_b .SPE = 1 ; /* enable SPI unit */
366
- }
367
-
368
- /* send the remaining bytes with 8-bit transfers */
369
- if (count != (4U * n32)) {
370
- uint8_t *rx = (uint8_t *) rxbuf;
371
- const uint8_t * tx = (const uint8_t *) buf;
372
- for (size_t i = 4U * n32; i < count; i++) {
373
- _spi_ctrl.p_regs ->SPDR_BY = (buf != NULL ) ? tx[i] : 0xFF ;
374
- while (0U == _spi_ctrl.p_regs ->SPSR_b .SPRF ) {}
375
- uint8_t tmp = _spi_ctrl.p_regs ->SPDR_BY ;
376
- if (rxbuf != NULL ) {
377
- rx[i] = tmp;
378
- }
379
- }
380
- }
381
- }
382
- }
383
-
384
303
void ArduinoSPI::beginTransaction (arduino::SPISettings settings)
385
304
{
386
305
if (!_is_initialized)
0 commit comments