10#ifndef SEMF_COMMUNICATION_SPIMASTERHARDWARE_H_
11#define SEMF_COMMUNICATION_SPIMASTERHARDWARE_H_
34 Read_BufferSizeIsZero,
39 WriteRead_WriteDataIsNullptr,
40 WriteRead_ReadBufferIsNullptr,
42 SetChipSelectPin_IsBusy
59 void write(
const uint8_t data[],
size_t dataSize)
override;
66 void read(uint8_t buffer[],
size_t bufferSize)
override;
92 void writeRead(
const uint8_t writeData[], uint8_t readBuffer[],
size_t size)
override;
141 virtual void writeReadHardware(
const uint8_t writeData[], uint8_t readBuffer[],
size_t size) = 0;
176 Gpio* m_chipSelectPin =
nullptr;
178 bool m_isBusy =
false;
186 static constexpr Error::ClassID kSemfClassId = Error::ClassID::SpiMasterHardware;
@ FirstAndLast
start AND stop condition
This interface standardized the read and write interface for synchronous master hardware,...
Class for representing errors. Every error should have a unique source code. As a user feel encourage...
Interface class for using a GPIO pin of the microcontroller.
Interface for SPI specific functionalities, which are not solved in a generic way in CommunicationHar...
Class for using SPI hardware in master mode.
void setWireMode(WireMode mode)
Sets the wire mode.
void setTransmissionMode(TransmissionMode mode)
Sets the transmission mode.
virtual ~SpiMasterHardware()=default
void onError(Error thrown)
Is called if an error occurred by hardware read or write access. Will throw error signal.
CommunicationHardware::Frame frame() const
Returns the actual frame mode setting.
void setFrame(CommunicationHardware::Frame frame) override
Sets the selected usage of start and stop condition.
virtual void stopWriteHardware()=0
bool isBusyWriting() const override
Communication hardware is busy writing at the moment.
virtual void writeHardware(const uint8_t data[], size_t dataSize)=0
Hardware will write data.
virtual void readHardware(uint8_t buffer[], size_t bufferSize)=0
Hardware will read data.
void setBusy(bool isBusy)
Sets the busy flag.
void writeRead(const uint8_t writeData[], uint8_t readBuffer[], size_t size) override
For writing and reading data parallel through the communication hardware 1) For interrupt or one shot...
bool isBusyReading() const override
Communication hardware is busy reading at the moment.
virtual void setFrequency(uint32_t hz)=0
Sets the speed.
ErrorCode
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring...
void write(const uint8_t data[], size_t dataSize) override
For writing data, dataWritten signal will be emitted after successful write.
virtual void writeReadHardware(const uint8_t writeData[], uint8_t readBuffer[], size_t size)=0
Hardware will read and write data parallel.
SpiMasterHardware()=default
virtual void setFormatHardware(uint8_t bits, TransmissionMode transmission, WireMode wire)=0
Configures the hardware for insuring the given configuration.
virtual void stopReadHardware()=0
void setFormat(uint8_t bits, TransmissionMode transmission, WireMode wire) override
Sets the format for the spi slave device.
void read(uint8_t buffer[], size_t bufferSize) override
For reading data, dataAvailable signal will be emitted after successful read.
void stopWrite() override
virtual void setChipSelectPin(Gpio &chipSelectPin)
Sets a new chip select pin read and write operations.