From 21c774fd8231ab6edc4aa239097e311edfed1b55 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser <kaspar@schleiser.de> Date: Thu, 13 Aug 2015 15:20:39 +0200 Subject: [PATCH] cpu: saml21: use periph_common SPI functions --- cpu/saml21/Makefile.include | 3 +++ cpu/saml21/include/periph_cpu.h | 9 +++++++++ cpu/saml21/periph/spi.c | 35 --------------------------------- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/cpu/saml21/Makefile.include b/cpu/saml21/Makefile.include index 389ec9f25b..8967988c8d 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 2e2788f0c5..1c6dc5eae2 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 846a818ac0..0f9e7f7378 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; -- GitLab