@@ 47,15 47,16 @@ enum spi_bitorder {
SPI_BITORDER_LSB = REG_SPCR_DORD_LSB,
};
-static inline void spi_init_master(enum spi_mode mode,
- enum spi_clock clock,
- enum spi_bitorder bitorder,
- bool interrupt)
+static inline void __spi_init(enum spi_mode mode,
+ enum spi_clock clock,
+ enum spi_bitorder bitorder,
+ bool interrupt,
+ bool master)
{
uint8_t spcr;
uint8_t spsr;
- spcr = REG_SPCR_SPE | REG_SPCR_MSTR;
+ spcr = REG_SPCR_SPE;
spsr = 0;
switch (mode) {
@@ 100,12 101,23 @@ static inline void spi_init_master(enum
if (interrupt)
spcr |= REG_SPCR_SPIE;
+ if (master)
+ spcr |= REG_SPCR_MSTR;
+
spcr |= bitorder;
mmregs->spcr = spcr;
mmregs->spsr = spsr;
}
+static inline void spi_init_master(enum spi_mode mode,
+ enum spi_clock clock,
+ enum spi_bitorder bitorder,
+ bool interrupt)
+{
+ __spi_init(mode, clock, bitorder, interrupt, true);
+}
+
/* transmit a single byte, CS is left up to the caller */
static inline void spi_tx_byte(uint8_t byte)
{