diff options
author | Karel Kočí <cynerd@email.cz> | 2015-10-11 13:06:28 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-10-11 13:06:28 +0200 |
commit | bab75a6068ab0a64fe22395ad11efafccbf0d842 (patch) | |
tree | 59344457d25c2e72904acac20118eb16633908fe /src/spi_usi.c | |
parent | 1b0b3cb1b61759be5c2e100d08c84e5eec924a58 (diff) | |
download | avr-ioe-bab75a6068ab0a64fe22395ad11efafccbf0d842.tar.gz avr-ioe-bab75a6068ab0a64fe22395ad11efafccbf0d842.tar.bz2 avr-ioe-bab75a6068ab0a64fe22395ad11efafccbf0d842.zip |
Implement SPI and remove files
Diffstat (limited to 'src/spi_usi.c')
-rw-r--r-- | src/spi_usi.c | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/spi_usi.c b/src/spi_usi.c deleted file mode 100644 index 8baa8e2..0000000 --- a/src/spi_usi.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "../spi_usi.h" -#include "../mcu/mcu_def.h" - -#ifdef IOE_SPI_USI_MASTER - -// TODO counter settings with interups -inline void ioe_spi_usi_init(void) { - // Set USCK and DO as output - DDR_USI |= _BV(DD_USCK) | _BV(DD_DO); - // Set DI pull up resistor - PORT_USI |= _BV(PORT_DI); - - USICR |= _BV(USIWM0) | _BV(USICS1) | _BV(USICLK); -} - -inline int8_t ioe_spi_usi_transfer(int8_t d) { - USISR |= _BV(USIOIF); - USIDR = d; - do { - USICR |= _BV(USITC); - } while (!(USISR & _BV(USIOIF))); - return USIDR; -} - -#else /* IOE_SPI_USI_MASTER */ - -inline void ioe_spi_usi_init(void) { - // Set DO as output - DDR_USI |= _BV(DD_DO); - // Set USCK and DI pull up resistor - PORT_USI |= _BV(PORT_USCK) | _BV(PORT_DI); - - USICR |= _BV(USIWM0) | _BV(USICS1) | _BV(USIOIE); -} - -inline void ioe_spi_usi_expose(int8_t data) { - USIDR = data; -} - -inline uint8_t ioe_spi_usi_busy(void) { - return USISR & 0x0F; -} - -inline void ioe_spi_usi_join(void) { - while (ioe_spi_usi_busy()) { - } -} - -SIGNAL(USI_OVF_vect) { - ioe_spi_usi_retrieve(USIDR); - USISR |= _BV(USIOIF); -} - -#endif /* IOE_SPI_USI_MASTER */ |