mirror of https://github.com/MLXXXp/Arduboy2.git
Add function SPItransferAndRead()
Suggested by @MrBlinky Same as SPItransfer() but also returns the byte received. Provided for use with homemade or expanded units that have had additional peripherals added to the SPI bus that are capable of sending data.
This commit is contained in:
parent
5563599c6d
commit
d7758249fa
|
@ -107,6 +107,7 @@ setTextColor KEYWORD2
|
|||
setTextSize KEYWORD2
|
||||
setTextWrap KEYWORD2
|
||||
SPItransfer KEYWORD2
|
||||
SPItransferAndRead KEYWORD2
|
||||
systemButtons KEYWORD2
|
||||
toggle KEYWORD2
|
||||
waitNoButtons KEYWORD2
|
||||
|
|
|
@ -251,6 +251,13 @@ void Arduboy2Core::SPItransfer(uint8_t data)
|
|||
while (!(SPSR & _BV(SPIF))) { } // wait
|
||||
}
|
||||
|
||||
// Write to and read from the SPI bus (out to MOSI pin, in from MISO pin)
|
||||
uint8_t Arduboy2Core::SPItransferAndRead(uint8_t data)
|
||||
{
|
||||
SPItransfer(data);
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
void Arduboy2Core::safeMode()
|
||||
{
|
||||
if (buttonsState() == UP_BUTTON)
|
||||
|
|
|
@ -402,10 +402,32 @@ class Arduboy2Core : public Arduboy2NoUSB
|
|||
* or as data to be placed on the screen, depending on the command/data
|
||||
* mode.
|
||||
*
|
||||
* \see LCDDataMode() LCDCommandMode() sendLCDCommand()
|
||||
* \see LCDDataMode() LCDCommandMode() sendLCDCommand() SPItransferAndRead()
|
||||
*/
|
||||
static void SPItransfer(uint8_t data);
|
||||
|
||||
/** \brief
|
||||
* Transfer a byte to, and read a byte from, the SPI bus.
|
||||
*
|
||||
* \param data The byte to be sent.
|
||||
*
|
||||
* \return The byte that was received.
|
||||
*
|
||||
* \details
|
||||
* This function does the same as the `SPItransfer()` function but also
|
||||
* reads and returns the byte of data that was received during the
|
||||
* transfer.
|
||||
*
|
||||
* This function is of no use for a standard Arduboy, since only the
|
||||
* display is connected to the SPI bus and data cannot be received from
|
||||
* the display. It has been provided for use with homemade or expanded
|
||||
* units that have had additional peripherals added to the SPI bus that
|
||||
* are capable of sending data.
|
||||
*
|
||||
* \see SPItransfer()
|
||||
*/
|
||||
static uint8_t SPItransferAndRead(uint8_t data);
|
||||
|
||||
/** \brief
|
||||
* Turn the display off.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue