From baf9dd6a8275160fdf5a4ff63efa2678f16b1cc3 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 21 Jun 2012 15:04:39 -0400 Subject: I2C: Add i2c_config_gpios(), i2c_master_release_bus(). These are necessary to pull out some calls to gpio_set_mode(). Signed-off-by: Marti Bolivar --- libmaple/stm32f1/i2c.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libmaple/stm32f1') diff --git a/libmaple/stm32f1/i2c.c b/libmaple/stm32f1/i2c.c index 9ebcb40..ed0ca97 100644 --- a/libmaple/stm32f1/i2c.c +++ b/libmaple/stm32f1/i2c.c @@ -39,6 +39,22 @@ i2c_dev* const I2C1 = &i2c1; /** STM32F1 I2C device 2 */ i2c_dev* const I2C2 = &i2c2; +/* + * Routines + */ + +void i2c_config_gpios(const i2c_dev *dev) { + gpio_set_mode(dev->gpio_port, dev->sda_pin, GPIO_AF_OUTPUT_OD); + gpio_set_mode(dev->gpio_port, dev->scl_pin, GPIO_AF_OUTPUT_OD); +} + +void i2c_master_release_bus(const i2c_dev *dev) { + gpio_write_bit(dev->gpio_port, dev->scl_pin, 1); + gpio_write_bit(dev->gpio_port, dev->sda_pin, 1); + gpio_set_mode(dev->gpio_port, dev->scl_pin, GPIO_OUTPUT_OD); + gpio_set_mode(dev->gpio_port, dev->sda_pin, GPIO_OUTPUT_OD); +} + /* * IRQ handlers */ -- cgit v1.2.3