diff --git a/cpu/samd21/Makefile.include b/cpu/samd21/Makefile.include index ab5f80f11d4c49451a77578132e7c3c9cd8dc891..9e534e08384ecbb75d5e5061af7b2b5d42dd6554 100644 --- a/cpu/samd21/Makefile.include +++ b/cpu/samd21/Makefile.include @@ -6,4 +6,7 @@ export CFLAGS += -DDONT_USE_CMSIS_INIT # use the hwtimer compatibility layer USEMODULE += hwtimer_compat +# use common periph functions +USEMODULE += periph_common + include $(RIOTCPU)/Makefile.include.cortexm_common diff --git a/cpu/samd21/include/periph_cpu.h b/cpu/samd21/include/periph_cpu.h index 8e743a050d1b090097fb4afed75b9c499a71ea0d..69ca15fcb0e77621602ba1cb1f4056f91204d541 100644 --- a/cpu/samd21/include/periph_cpu.h +++ b/cpu/samd21/include/periph_cpu.h @@ -88,6 +88,15 @@ typedef enum { */ int gpio_init_mux(gpio_t dev, gpio_mux_t mux); +/** + * @brief declare needed generic SPI functions + * @{ + */ +#define PERIPH_SPI_NEEDS_TRANSFER_BYTES +#define PERIPH_SPI_NEEDS_TRANSFER_REG +#define PERIPH_SPI_NEEDS_TRANSFER_REGS +/** @} */ + #ifdef __cplusplus } #endif diff --git a/cpu/samd21/periph/spi.c b/cpu/samd21/periph/spi.c index 7b41029713213be201dfeed36f466fed4347f7f9..1193de8e1c7706a16d1b037ee8f807bb924254ba 100644 --- a/cpu/samd21/periph/spi.c +++ b/cpu/samd21/periph/spi.c @@ -258,47 +258,6 @@ int spi_transfer_byte(spi_t dev, char out, char *in) return 1; } -int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length) -{ - int transfered = 0; - - if (out != NULL) { - DEBUG("out*: %p out: %x length: %x\n", out, *out, length); - while (length--) { - int ret = spi_transfer_byte(dev, *(out)++, 0); - if (ret < 0) { - return ret; - } - transfered += ret; - } - } - if (in != NULL) { - while (length--) { - int ret = spi_transfer_byte(dev, 0, in++); - if (ret < 0) { - return ret; - } - transfered += ret; - } - DEBUG("in*: %p in: %x transfered: %x\n", in, *(in-transfered), transfered); - } - - DEBUG("sent %x byte(s)\n", transfered); - return transfered; -} - -int spi_transfer_reg(spi_t dev, uint8_t reg, char out, char *in) -{ - spi_transfer_byte(dev, reg, NULL); - return spi_transfer_byte(dev, out, in); -} - -int spi_transfer_regs(spi_t dev, uint8_t reg, char *out, char *in, unsigned int length) -{ - spi_transfer_byte(dev, reg, NULL); - return spi_transfer_bytes(dev, out, in, length); -} - void spi_poweron(spi_t dev) { switch(dev) {