aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/stm32f1
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-21 15:04:39 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-22 14:06:10 -0400
commitbaf9dd6a8275160fdf5a4ff63efa2678f16b1cc3 (patch)
tree1ea72208adc17873ab2287f25cc3720cf40576bf /libmaple/stm32f1
parentf34ba402c9a39acc43828918313a30d2fbc4e186 (diff)
downloadlibrambutan-baf9dd6a8275160fdf5a4ff63efa2678f16b1cc3.tar.gz
librambutan-baf9dd6a8275160fdf5a4ff63efa2678f16b1cc3.zip
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 <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/stm32f1')
-rw-r--r--libmaple/stm32f1/i2c.c16
1 files changed, 16 insertions, 0 deletions
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
@@ -40,6 +40,22 @@ i2c_dev* const I2C1 = &i2c1;
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
*/