From fa00154f2ade7aaa6a94fada58c281ea76307f5c 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: stm32f3: use periph_common SPI functions --- cpu/stm32f3/Makefile.include | 3 ++ cpu/stm32f3/include/periph_cpu.h | 9 +++++ cpu/stm32f3/periph/spi.c | 56 -------------------------------- 3 files changed, 12 insertions(+), 56 deletions(-) diff --git a/cpu/stm32f3/Makefile.include b/cpu/stm32f3/Makefile.include index ed4584a485..a47fb55833 100644 --- a/cpu/stm32f3/Makefile.include +++ b/cpu/stm32f3/Makefile.include @@ -3,4 +3,7 @@ export CPU_ARCH = cortex-m4f # use hwtimer compatibility module USEMODULE += hwtimer_compat +# includ common periph module +USEMODULE += periph_common + include $(RIOTCPU)/Makefile.include.cortexm_common diff --git a/cpu/stm32f3/include/periph_cpu.h b/cpu/stm32f3/include/periph_cpu.h index 6c456a3d33..8e86ebac7c 100644 --- a/cpu/stm32f3/include/periph_cpu.h +++ b/cpu/stm32f3/include/periph_cpu.h @@ -79,6 +79,15 @@ typedef enum { GPIO_AF15 /**< use alternate function 14 */ } gpio_af_t; +/** + * @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/stm32f3/periph/spi.c b/cpu/stm32f3/periph/spi.c index 1631998a13..160f5f348b 100644 --- a/cpu/stm32f3/periph/spi.c +++ b/cpu/stm32f3/periph/spi.c @@ -334,62 +334,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 i, trans_ret, trans_bytes = 0; - char in_temp; - - for (i = 0; i < length; i++) { - if (out != NULL) { - trans_ret = spi_transfer_byte(dev, out[i], &in_temp); - } - else { - trans_ret = spi_transfer_byte(dev, 0, &in_temp); - } - if (trans_ret < 0) { - return -1; - } - if (in != NULL) { - in[i] = in_temp; - } - trans_bytes++; - } - - return trans_bytes++; -} - -int spi_transfer_reg(spi_t dev, uint8_t reg, char out, char *in) -{ - int trans_ret; - - trans_ret = spi_transfer_byte(dev, reg, in); - if (trans_ret < 0) { - return -1; - } - trans_ret = spi_transfer_byte(dev, out, in); - if (trans_ret < 0) { - return -1; - } - - return 1; -} - -int spi_transfer_regs(spi_t dev, uint8_t reg, char *out, char *in, unsigned int length) -{ - int trans_ret; - - trans_ret = spi_transfer_byte(dev, reg, in); - if (trans_ret < 0) { - return -1; - } - trans_ret = spi_transfer_bytes(dev, out, in, length); - if (trans_ret < 0) { - return -1; - } - - return trans_ret; -} - void spi_transmission_begin(spi_t dev, char reset_val) { if (dev < SPI_NUMOF) { -- GitLab