34#ifndef _FREERTOS_DRIVERS_COMMON_SPI_HXX_
35#define _FREERTOS_DRIVERS_COMMON_SPI_HXX_
63 __attribute__((optimize(
"-O3")))
79 __attribute__((optimize(
"-O3")))
87 for (
int i = 0; i < num; ++i, ++msgs)
90 if (UNLIKELY(result < 0))
107 __attribute__((optimize(
"-O3")))
162 virtual int transfer(
struct spi_ioc_transfer *msg) = 0;
181 int ioctl(
File *file,
unsigned long int key,
unsigned long data)
override;
208 ssize_t
read(
File *file,
void *buf,
size_t count)
override;
216 ssize_t
write(
File *file,
const void *buf,
size_t count)
override;
const char * name
device name
This class provides a mutex API.
void unlock()
Unlock a mutex.
Private data for an SPI device.
ssize_t read(File *file, void *buf, size_t count) override
Read from a file or device.
uint8_t mode
one of four SPI modes
ssize_t write(File *file, const void *buf, size_t count) override
Write to a file or device.
SPI()
Default constructor.
virtual int transfer(struct spi_ioc_transfer *msg)=0
Method to transmit/receive the data.
ChipSelectMethod csDeassert
function pointer to a method that deasserts chip select.
int transfer_messages(struct spi_ioc_transfer *msgs, int num)
Conduct multiple message transfers with one stop at the end.
uint32_t speedHz
Max default speed in Hz.
ChipSelectMethod csAssert
function pointer to a method that asserts chip select.
virtual int update_configuration()=0
Update the configuration of the bus.
void flush_buffers() override
Discards all pending buffers.
virtual int transfer_polled(struct spi_ioc_transfer *msg)=0
Method to transmit/receive the data, but always in polled mode.
int transfer_with_cs_assert(struct spi_ioc_transfer *msg)
Method to transmit/receive the data.
void bus_unlock()
Unlock the bus shared by many chip selects.
void bus_lock()
Lock the bus shared by many chip selects.
bool lsbFirst
transmit LSB first if true
uint8_t bitsPerWord
number of bits per word transaction
OSMutex * busLock
Mutual exclusion for the bus among many chip selects.
int ioctl(File *file, unsigned long int key, unsigned long data) override
Request an ioctl transaction.
void(* ChipSelectMethod)()
Function point for the chip select assert and deassert methods.
int transfer_with_cs_assert_polled(struct spi_ioc_transfer *msgs, int num=1)
Method to transmit/receive the data.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.