diff --git a/cpu/saml21/Makefile.include b/cpu/saml21/Makefile.include index 389ec9f25b856171863dbd8b3d4e3a4be2d14946..8967988c8db2d30fae89ae4f19698b5f6eb19329 100644 --- a/cpu/saml21/Makefile.include +++ b/cpu/saml21/Makefile.include @@ -6,4 +6,7 @@ export CFLAGS += -DDONT_USE_CMSIS_INIT # use the hwtimer compatibility module USEMODULE += hwtimer_compat +# use common periph functions +USEMODULE += periph_common + include $(RIOTCPU)/Makefile.include.cortexm_common diff --git a/cpu/saml21/include/periph_cpu.h b/cpu/saml21/include/periph_cpu.h index 2e2788f0c552eaa492cbc716c94c8c5e480c22ed..1c6dc5eae25a5e9ead08424881c6ecbc8aa70bc9 100644 --- a/cpu/saml21/include/periph_cpu.h +++ b/cpu/saml21/include/periph_cpu.h @@ -87,6 +87,15 @@ typedef enum { */ void 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/saml21/periph/spi.c b/cpu/saml21/periph/spi.c index 846a818ac0f45f056732f3b382c369320e1e532c..0f9e7f73780d117ab2e1418d147d4ec8904393f0 100644 --- a/cpu/saml21/periph/spi.c +++ b/cpu/saml21/periph/spi.c @@ -219,41 +219,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; - int ret = 0; - - DEBUG("out*: %p out: %x length: %x\n", out, *out, length); - while (length--) { - if ((ret = spi_transfer_byte(dev, *out, in)) < 0) { - return ret; - } - - transfered += ret; - - if (out) { - out++; - } - if (in) { - in++; - } - } - 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) { SercomSpi* spi_dev = spi[dev].dev;