69 } __attribute__((packed));
76 } __attribute__((packed));
85 } __attribute__((packed));
118 __attribute__((always_inline))
136 __attribute__((always_inline))
158 __attribute__((always_inline))
169 const uint8_t m_cpol;
233 __attribute__((always_inline))
235 if (m_dev->m_pulse <
PULSE_LOW) m_dev->m_cs.toggle();
243 __attribute__((always_inline))
245 m_dev->m_cs.toggle();
246 if (m_dev->m_pulse >
ACTIVE_HIGH) m_dev->m_cs.toggle();
257 __attribute__((always_inline))
261 register uint8_t cntl = m_dev->m_usicr;
264 }
while ((USISR & _BV(USIOIF)) == 0);
274 __attribute__((always_inline))
276 m_dev->m_data = data;
285 __attribute__((always_inline))
297 __attribute__((always_inline))
327 __attribute__((always_inline))
330 loop_until_bit_is_set(SPSR, SPIF);
340 __attribute__((always_inline))
351 __attribute__((always_inline))
353 loop_until_bit_is_set(SPSR, SPIF);
364 __attribute__((always_inline))
366 loop_until_bit_is_set(SPSR, SPIF);
396 void transfer(
void* buf,
size_t count);
406 void transfer(
void* dst,
const void* src,
size_t count);
414 void read(
void* buf,
size_t count);
422 void write(
const void* buf,
size_t count);
430 void write_P(
const void* buf,
size_t count);
438 __attribute__((always_inline))
441 write(vp->buf, vp->size);
447 volatile bool m_busy;
uint8_t m_spsr
SPI/SPSR hardware status register.
static Clock cycle(uint16_t ns)
IOStream & operator<<(IOStream &outs, SPI::Clock rate)
Pulse high on end of transaction.
Divide system clock by 4.
void acquire(Driver *dev)
uint8_t transfer_next(uint8_t data)
Interrupt::Handler * m_irq
Interrupt handler.
void set_clock(Clock rate)
Least significant bit first.
Driver * m_next
List of drivers.
Divide system clock by 128.
void set_clock(uint32_t freq)
Divide system clock by 8.
void transfer_start(uint8_t data)
void write(const iovec_t *vec)
Divide system clock by 16.
uint8_t transfer(uint8_t data)
uint8_t m_spcr
SPI/SPCR hardware control register setting.
void * buf
Buffer pointer.
Divide system clock by 64.
static Clock clock(uint32_t freq)
Active high logic during transaction.
Divide system clock by 32.
void write_P(const void *buf, size_t count)
Active low logic during transaction.
Divide system clock by 2.
Most significant bit first.
Pulse low on end of transaction.
void read(void *buf, size_t count)
OutputPin m_cs
Device chip select pin.
Driver(Board::DigitalPin cs, Pulse pulse=DEFAULT_PULSE, Clock rate=DEFAULT_CLOCK, uint8_t mode=0, Order order=MSB_ORDER, Interrupt::Handler *irq=NULL)
Pulse m_pulse
Chip select pulse width.
void write(const void *buf, size_t count)