45 return (F_CPU / frequency);
78 virtual uint8_t
transfer(uint8_t value) = 0;
85 __attribute__((always_inline))
96 __attribute__((always_inline))
110 virtual void transfer(
void* dest,
const void* src,
size_t count)
112 if (count == 0 || dest == NULL || src == NULL)
return;
113 const uint8_t* sp = (
const uint8_t*) src;
114 uint8_t* dp = (uint8_t*) dest;
115 do *dp++ =
transfer(*sp++);
while (--count);
124 virtual void read(
void* buf,
size_t count)
126 if (count == 0 || buf == NULL)
return;
127 uint8_t* bp = (uint8_t*) buf;
128 do *bp++ =
transfer(0);
while (--count);
137 virtual void write(
const void* buf,
size_t count)
139 if (count == 0 || buf == NULL)
return;
140 uint8_t* bp = (uint8_t*) buf;
141 do transfer(*bp++);
while (--count);
151 template<u
int8_t MODE, u
int8_t BITORDER, u
int32_t FREQ, BOARD::pin_t SS_PIN>
172 __attribute__((always_inline))
182 __attribute__((always_inline))
194 __attribute__((always_inline))
206 void transfer(
void* dest,
const void* src,
size_t count)
207 __attribute__((always_inline))
217 void read(
void* buf,
size_t count)
218 __attribute__((always_inline))
228 void write(
const void* buf,
size_t count)
229 __attribute__((always_inline))
253 __attribute__((always_inline))
255 while (m_busy) yield();
263 __attribute__((always_inline))
virtual void read(void *buf, size_t count)
void read(void *buf, size_t count)
virtual uint8_t prescale(uint32_t frequency)
virtual uint8_t transfer(uint8_t value)=0
Device(SPI &spi, bool ss=HIGH)
static const uint32_t MAX_FREQ
virtual void acquire(uint8_t mode, uint8_t bitorder, uint8_t prescale)
void write(const void *buf, size_t count)
virtual void transfer(void *dest, const void *src, size_t count)
void transfer(void *dest, const void *src, size_t count)
SPI & operator>>(uint8_t &value)
SPI & operator<<(uint8_t value)
virtual void write(const void *buf, size_t count)
uint8_t transfer(uint8_t value)