diff options
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/include/libmaple/adc.h | 6 | ||||
-rw-r--r-- | libmaple/include/libmaple/spi.h | 15 | ||||
-rw-r--r-- | libmaple/include/libmaple/usart.h | 19 | ||||
-rw-r--r-- | libmaple/stm32f1/adc.c | 2 | ||||
-rw-r--r-- | libmaple/stm32f1/include/series/spi.h | 32 | ||||
-rw-r--r-- | libmaple/stm32f1/spi.c | 15 | ||||
-rw-r--r-- | libmaple/stm32f1/usart.c | 8 | ||||
-rw-r--r-- | libmaple/stm32f2/adc.c | 2 | ||||
-rw-r--r-- | libmaple/stm32f2/usart.c | 8 |
9 files changed, 77 insertions, 30 deletions
diff --git a/libmaple/include/libmaple/adc.h b/libmaple/include/libmaple/adc.h index ff9a5e4..a500af7 100644 --- a/libmaple/include/libmaple/adc.h +++ b/libmaple/include/libmaple/adc.h @@ -262,10 +262,14 @@ extern void adc_foreach(void (*fn)(const adc_dev*)); struct gpio_dev; /** * @brief Configure a GPIO pin for ADC conversion. + * @param dev ADC device to use for conversion (currently ignored on + * all targets). * @param gdev GPIO device to configure. * @param bit Bit on gdev to configure for ADC conversion. */ -extern void adc_gpio_cfg(struct gpio_dev *gdev, uint8 bit); +extern void adc_config_gpio(const struct adc_dev *dev, + struct gpio_dev *gdev, + uint8 bit); /** * @brief Enable an ADC and configure it for single conversion mode. diff --git a/libmaple/include/libmaple/spi.h b/libmaple/include/libmaple/spi.h index 3805b2e..90e2036 100644 --- a/libmaple/include/libmaple/spi.h +++ b/libmaple/include/libmaple/spi.h @@ -224,13 +224,14 @@ struct gpio_dev; * @param miso_bit MISO pin's GPIO bit on comm_dev * @param mosi_bit MOSI pin's GPIO bit on comm_dev */ -void spi_gpio_cfg(uint8 as_master, - struct gpio_dev *nss_dev, - uint8 nss_bit, - struct gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit); +extern void spi_config_gpios(spi_dev *dev, + uint8 as_master, + struct gpio_dev *nss_dev, + uint8 nss_bit, + struct gpio_dev *comm_dev, + uint8 sck_bit, + uint8 miso_bit, + uint8 mosi_bit); /** * @brief SPI mode configuration. diff --git a/libmaple/include/libmaple/usart.h b/libmaple/include/libmaple/usart.h index 293d59e..26a64d3 100644 --- a/libmaple/include/libmaple/usart.h +++ b/libmaple/include/libmaple/usart.h @@ -395,12 +395,21 @@ typedef struct usart_dev { void usart_init(usart_dev *dev); -/* FIXME document this function */ struct gpio_dev; /* forward declaration */ -void usart_async_gpio_cfg(usart_dev *udev, - struct gpio_dev *rx_dev, uint8 rx, - struct gpio_dev *tx_dev, uint8 tx, - unsigned flags); +/* FIXME [PRE 0.0.13] decide if flags are necessary */ +/** + * @brief Configure GPIOs for use as USART TX/RX. + * @param udev USART device to use + * @param rx_dev RX pin gpio_dev + * @param rx RX pin bit on rx_dev + * @param tx_dev TX pin gpio_dev + * @param tx TX pin bit on tx_dev + * @param flags Currently ignored + */ +extern void usart_config_gpios_async(usart_dev *udev, + struct gpio_dev *rx_dev, uint8 rx, + struct gpio_dev *tx_dev, uint8 tx, + unsigned flags); #define USART_USE_PCLK 0 void usart_set_baud_rate(usart_dev *dev, uint32 clock_speed, uint32 baud); diff --git a/libmaple/stm32f1/adc.c b/libmaple/stm32f1/adc.c index facc6bd..ecfbc1c 100644 --- a/libmaple/stm32f1/adc.c +++ b/libmaple/stm32f1/adc.c @@ -99,7 +99,7 @@ void adc_foreach(void (*fn)(const adc_dev*)) { #endif } -void adc_gpio_cfg(gpio_dev *gdev, uint8 bit) { +void adc_config_gpio(const adc_dev *ignored, gpio_dev *gdev, uint8 bit) { gpio_set_mode(gdev, bit, GPIO_INPUT_ANALOG); } diff --git a/libmaple/stm32f1/include/series/spi.h b/libmaple/stm32f1/include/series/spi.h index 167df0c..8cc4c4d 100644 --- a/libmaple/stm32f1/include/series/spi.h +++ b/libmaple/stm32f1/include/series/spi.h @@ -34,6 +34,8 @@ #ifndef _LIBMAPLE_STM32F1_SPI_H_ #define _LIBMAPLE_STM32F1_SPI_H_ +#include <libmaple/libmaple_types.h> + #ifdef __cplusplus extern "C" { #endif @@ -63,6 +65,36 @@ extern struct spi_dev *SPI2; extern struct spi_dev *SPI3; #endif +/* + * Routines + */ + +/* spi_gpio_cfg(): Backwards compatibility shim to spi_config_gpios() */ +struct gpio_dev; +extern void spi_config_gpios(struct spi_dev*, uint8, + struct gpio_dev*, uint8, + struct gpio_dev*, uint8, uint8, uint8); +/** + * @brief Deprecated. Use spi_config_gpios() instead. + * @see spi_config_gpios() + */ +static __always_inline void spi_gpio_cfg(uint8 as_master, + struct gpio_dev *nss_dev, + uint8 nss_bit, + struct gpio_dev *comm_dev, + uint8 sck_bit, + uint8 miso_bit, + uint8 mosi_bit) { + /* We switched style globally to foo_config_gpios() and always + * taking a foo_dev* argument (that last bit is the important + * part) after this function was written. + * + * However, spi_config_gpios() just ignores the spi_dev* on F1, so + * we can still keep this around for older code. */ + spi_config_gpios(NULL, as_master, nss_dev, nss_bit, + comm_dev, sck_bit, miso_bit, mosi_bit); +} + #ifdef __cplusplus } #endif diff --git a/libmaple/stm32f1/spi.c b/libmaple/stm32f1/spi.c index 8b6e495..72f2ef4 100644 --- a/libmaple/stm32f1/spi.c +++ b/libmaple/stm32f1/spi.c @@ -69,13 +69,14 @@ spi_dev *SPI3 = &spi3; * Routines */ -void spi_gpio_cfg(uint8 as_master, - gpio_dev *nss_dev, - uint8 nss_bit, - gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit) { +void spi_config_gpios(spi_dev *ignored, + uint8 as_master, + gpio_dev *nss_dev, + uint8 nss_bit, + gpio_dev *comm_dev, + uint8 sck_bit, + uint8 miso_bit, + uint8 mosi_bit) { if (as_master) { gpio_set_mode(nss_dev, nss_bit, GPIO_AF_OUTPUT_PP); gpio_set_mode(comm_dev, sck_bit, GPIO_AF_OUTPUT_PP); diff --git a/libmaple/stm32f1/usart.c b/libmaple/stm32f1/usart.c index eed420e..b3b849f 100644 --- a/libmaple/stm32f1/usart.c +++ b/libmaple/stm32f1/usart.c @@ -101,10 +101,10 @@ usart_dev *UART5 = &uart5; * Routines */ -void usart_async_gpio_cfg(usart_dev *udev, - gpio_dev *rx_dev, uint8 rx, - gpio_dev *tx_dev, uint8 tx, - unsigned flags) { +void usart_config_gpios_async(usart_dev *udev, + gpio_dev *rx_dev, uint8 rx, + gpio_dev *tx_dev, uint8 tx, + unsigned flags) { gpio_set_mode(rx_dev, rx, GPIO_INPUT_FLOATING); gpio_set_mode(tx_dev, tx, GPIO_AF_OUTPUT_PP); } diff --git a/libmaple/stm32f2/adc.c b/libmaple/stm32f2/adc.c index 0380736..a400d7b 100644 --- a/libmaple/stm32f2/adc.c +++ b/libmaple/stm32f2/adc.c @@ -74,7 +74,7 @@ void adc_foreach(void (*fn)(const adc_dev*)) { fn(ADC3); } -void adc_gpio_cfg(gpio_dev *gdev, uint8 bit) { +void adc_config_gpio(const adc_dev *ignored, gpio_dev *gdev, uint8 bit) { gpio_set_modef(gdev, bit, GPIO_MODE_ANALOG, GPIO_MODEF_PUPD_NONE); } diff --git a/libmaple/stm32f2/usart.c b/libmaple/stm32f2/usart.c index 2dd3afc..9a1acf3 100644 --- a/libmaple/stm32f2/usart.c +++ b/libmaple/stm32f2/usart.c @@ -107,10 +107,10 @@ usart_dev *USART6 = &usart6; * Routines */ -void usart_async_gpio_cfg(usart_dev *udev, - gpio_dev *rx_dev, uint8 rx, - gpio_dev *tx_dev, uint8 tx, - unsigned flags) { +void usart_config_gpios_async(usart_dev *udev, + gpio_dev *rx_dev, uint8 rx, + gpio_dev *tx_dev, uint8 tx, + unsigned flags) { gpio_af af; /* TODO: break this out into a user-facing function. */ switch (udev->clk_id) { |