diff --git a/cpu/stm32_common/include/periph_cpu_common.h b/cpu/stm32_common/include/periph_cpu_common.h index 6737f6cf2c..c3168e3312 100644 --- a/cpu/stm32_common/include/periph_cpu_common.h +++ b/cpu/stm32_common/include/periph_cpu_common.h @@ -84,6 +84,10 @@ typedef uint32_t gpio_t; * @brief Available MUX values for configuring a pin's alternate function */ typedef enum { +#ifdef CPU_FAM_STM32F1 + GPIO_AF_OUT_PP = 0xb, /**< alternate function output - push-pull */ + GPIO_AF_OUT_OD = 0xf, /**< alternate function output - open-drain */ +#else GPIO_AF0 = 0, /**< use alternate function 0 */ GPIO_AF1, /**< use alternate function 1 */ GPIO_AF2, /**< use alternate function 2 */ @@ -102,6 +106,7 @@ typedef enum { GPIO_AF14, /**< use alternate function 14 */ GPIO_AF15 /**< use alternate function 15 */ #endif +#endif } gpio_af_t; /** @@ -152,6 +157,14 @@ void periph_clk_en(bus_t bus, uint32_t mask); */ void periph_clk_dis(bus_t bus, uint32_t mask); +/** + * @brief Configure the alternate function for the given pin + * + * @param[in] pin pin to configure + * @param[in] af alternate function to use + */ +void gpio_init_af(gpio_t pin, gpio_af_t af); + /** * @brief Configure the given pin to be used as ADC input * diff --git a/cpu/stm32f0/include/periph_cpu.h b/cpu/stm32f0/include/periph_cpu.h index a0e64eb9aa..a76b262074 100644 --- a/cpu/stm32f0/include/periph_cpu.h +++ b/cpu/stm32f0/include/periph_cpu.h @@ -65,7 +65,7 @@ typedef enum { #endif /* ndef DOXYGEN */ /** - * @brief Available ports on the STM32F4 family + * @brief Available ports on the STM32F0 family */ enum { PORT_A = 0, /**< port A */ @@ -108,16 +108,6 @@ typedef struct { uint8_t chan; /**< DAC device used for this line */ } dac_conf_t; -/** - * @brief Configure the alternate function for the given pin - * - * @note This is meant for internal use in STM32F4 peripheral drivers only - * - * @param[in] pin pin to configure - * @param[in] af alternate function to use - */ -void gpio_init_af(gpio_t pin, gpio_af_t af); - #ifdef __cplusplus } #endif diff --git a/cpu/stm32f1/include/periph_cpu.h b/cpu/stm32f1/include/periph_cpu.h index 4ebe15fd98..518733bd5a 100644 --- a/cpu/stm32f1/include/periph_cpu.h +++ b/cpu/stm32f1/include/periph_cpu.h @@ -106,17 +106,6 @@ enum { PORT_G = 6, /**< port G */ }; -/** - * @brief Define alternate function modes - * - * On this CPU, only the output pins have alternate function modes. The input - * pins have to be configured using the default gpio_init() function. - */ -typedef enum { - GPIO_AF_OUT_PP = 0xb, /**< alternate function output - push-pull */ - GPIO_AF_OUT_OD = 0xf, /**< alternate function output - open-drain */ -} gpio_af_out_t; - /** * @brief ADC channel configuration data */ @@ -146,16 +135,6 @@ typedef struct { uint8_t chan; /**< DAC device used for this line */ } dac_conf_t; -/** - * @brief Configure the alternate function for the given pin - * - * @note This is meant for internal use in STM32F1 peripheral drivers only - * - * @param[in] pin pin to configure - * @param[in] af alternate function to use - */ -void gpio_init_af(gpio_t pin, gpio_af_out_t af); - #ifdef __cplusplus } #endif diff --git a/cpu/stm32f1/periph/gpio.c b/cpu/stm32f1/periph/gpio.c index f7670120a4..ccd03b2646 100644 --- a/cpu/stm32f1/periph/gpio.c +++ b/cpu/stm32f1/periph/gpio.c @@ -134,7 +134,7 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, return 0; } -void gpio_init_af(gpio_t pin, gpio_af_out_t af) +void gpio_init_af(gpio_t pin, gpio_af_t af) { int pin_num = _pin_num(pin); GPIO_TypeDef *port = _port(pin); diff --git a/cpu/stm32f2/include/periph_cpu.h b/cpu/stm32f2/include/periph_cpu.h index 2c15dce26d..ca3d155a65 100644 --- a/cpu/stm32f2/include/periph_cpu.h +++ b/cpu/stm32f2/include/periph_cpu.h @@ -127,16 +127,6 @@ typedef struct { uint8_t chan; /**< DAC device used for this line */ } dac_conf_t; -/** - * @brief Configure the alternate function for the given pin - * - * @note This is meant for internal use in STM32F2 peripheral drivers only - * - * @param[in] pin pin to configure - * @param[in] af alternate function to use - */ -void gpio_init_af(gpio_t pin, gpio_af_t af); - /** * @brief Configure the given pin to be used as ADC input * diff --git a/cpu/stm32f4/include/periph_cpu.h b/cpu/stm32f4/include/periph_cpu.h index c010d32cbb..70cbbafb49 100644 --- a/cpu/stm32f4/include/periph_cpu.h +++ b/cpu/stm32f4/include/periph_cpu.h @@ -136,16 +136,6 @@ typedef struct { uint8_t chan; /**< DAC device used for this line */ } dac_conf_t; -/** - * @brief Configure the alternate function for the given pin - * - * @note This is meant for internal use in STM32F4 peripheral drivers only - * - * @param[in] pin pin to configure - * @param[in] af alternate function to use - */ -void gpio_init_af(gpio_t pin, gpio_af_t af); - /** * @brief Power on the DMA device the given stream belongs to * diff --git a/cpu/stm32l1/include/periph_cpu.h b/cpu/stm32l1/include/periph_cpu.h index 37bbeb9c0f..1ffd93850d 100644 --- a/cpu/stm32l1/include/periph_cpu.h +++ b/cpu/stm32l1/include/periph_cpu.h @@ -76,16 +76,6 @@ typedef struct { uint8_t chan; /**< DAC device used for this line */ } dac_conf_t; -/** - * @brief Configure the alternate function for the given pin - * - * @note This is meant for internal use in STM32L1 peripheral drivers only - * - * @param[in] pin pin to configure - * @param[in] af alternate function to use - */ -void gpio_init_af(gpio_t pin, gpio_af_t af); - /** * @brief I2C configuration data structure */