Prusa MINI Firmware overview
SoftSPI< MisoPin, MosiPin, SckPin, Mode > Class Template Reference

Fast software SPI. More...

#include <softspi.h>

Public Member Functions

void begin ()
 
FORCE_INLINE uint8_t receive ()
 
FORCE_INLINE void send (uint8_t data)
 
FORCE_INLINE uint8_t transfer (uint8_t txData)
 

Detailed Description

template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin, uint8_t Mode = 0>
class SoftSPI< MisoPin, MosiPin, SckPin, Mode >

Fast software SPI.

Member Function Documentation

◆ begin()

template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin, uint8_t Mode = 0>
void SoftSPI< MisoPin, MosiPin, SckPin, Mode >::begin ( void  )

Initialize SoftSPI pins.

661  {
663  fastPinConfig(MosiPin, MOSI_MODE, !MODE_CPHA(Mode));
664  fastPinConfig(SckPin, SCK_MODE, MODE_CPOL(Mode));
665  }
Here is the caller graph for this function:

◆ receive()

template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin, uint8_t Mode = 0>
FORCE_INLINE uint8_t SoftSPI< MisoPin, MosiPin, SckPin, Mode >::receive ( )

Soft SPI receive byte.

Returns
Data byte received.
671  {
672  uint8_t data = 0;
673  receiveBit(7, &data);
674  receiveBit(6, &data);
675  receiveBit(5, &data);
676  receiveBit(4, &data);
677  receiveBit(3, &data);
678  receiveBit(2, &data);
679  receiveBit(1, &data);
680  receiveBit(0, &data);
681  return data;
682  }
Here is the caller graph for this function:

◆ send()

template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin, uint8_t Mode = 0>
FORCE_INLINE void SoftSPI< MisoPin, MosiPin, SckPin, Mode >::send ( uint8_t  data)

Soft SPI send byte.

Parameters
[in]dataData byte to send.
688  {
689  sendBit(7, data);
690  sendBit(6, data);
691  sendBit(5, data);
692  sendBit(4, data);
693  sendBit(3, data);
694  sendBit(2, data);
695  sendBit(1, data);
696  sendBit(0, data);
697  }
Here is the caller graph for this function:

◆ transfer()

template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin, uint8_t Mode = 0>
FORCE_INLINE uint8_t SoftSPI< MisoPin, MosiPin, SckPin, Mode >::transfer ( uint8_t  txData)

Soft SPI transfer byte.

Parameters
[in]txDataData byte to send.
Returns
Data byte received.
704  {
705  uint8_t rxData = 0;
706  transferBit(7, &rxData, txData);
707  transferBit(6, &rxData, txData);
708  transferBit(5, &rxData, txData);
709  transferBit(4, &rxData, txData);
710  transferBit(3, &rxData, txData);
711  transferBit(2, &rxData, txData);
712  transferBit(1, &rxData, txData);
713  transferBit(0, &rxData, txData);
714  return rxData;
715  }
SCK_MODE
const bool SCK_MODE
Definition: softspi.h:650
MISO_MODE
const bool MISO_MODE
Definition: softspi.h:647
fastPinConfig
static FORCE_INLINE void fastPinConfig(uint8_t pin, bool mode, bool level)
Definition: softspi.h:558
data
uint8_t data[8]
Definition: masstorage.h:49
uint8_t
const uint8_t[]
Definition: 404_html.c:3
MOSI_MODE
const bool MOSI_MODE
Definition: softspi.h:649
MISO_LEVEL
const bool MISO_LEVEL
Definition: softspi.h:648