Home Forums Sparkfun MP3 Shield Library Support Forum Suggested refinements Reply To: Suggested refinements


I’m not sure I agree with what you say about the usefulness of the SPI_CONTINUE flag. Here’s the source code for SPIClass::transfer():

byte SPIClass::transfer(byte _pin, uint8_t _data, SPITransferMode _mode) {

uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(_pin);


// Reverse bit order

if (bitOrder[ch] == LSBFIRST)

_data = __REV(__RBIT(_data));


uint32_t d = _data | SPI_PCS(ch);


if (_mode == SPI_LAST)



// SPI_Write(spi, _channel, _data);

while ((spi->SPI_SR & SPI_SR_TDRE) == 0)


spi->SPI_TDR = d;


// return SPI_Read(spi);

while ((spi->SPI_SR & SPI_SR_RDRF) == 0)


d = spi->SPI_RDR;


// Reverse bit order

if (bitOrder[ch] == LSBFIRST)

d = __REV(__RBIT(d));

return d & 0xFF;


Note that if SPI_LAST is passed as a flag, d is OR’d with SPI_TDR_LASTXFER and d (a 32-bit word) is written to the SPI port. So passing the SPI_CONTINUE flag does not simply affect how the Arduino code keeps track of the CS.

Thanks for the tip re. OutputCompare . I’ll try and find more information about it.