From 1c476012cdc88228ffc38723a36b652fa5c8831d Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Tue, 19 Apr 2011 22:03:42 -0400 Subject: i2c: Various fixes, extensions, documentation. -Fix clock calculations for fast-mode support -Add I2C_REMAP option to remap i2c1 (untested) -Add I2C_BUS_RESET option to reset bus on initialization -Add optional timeout parameter -Doxygen comments -Various cleanup 10-bit slave addressing is untested until I have a device that speaks such. --- libmaple/gpio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libmaple/gpio.c') diff --git a/libmaple/gpio.c b/libmaple/gpio.c index 5484e21..c250f68 100644 --- a/libmaple/gpio.c +++ b/libmaple/gpio.c @@ -174,3 +174,17 @@ void afio_exti_select(afio_exti_num exti, afio_exti_port gpio_port) { cr |= gpio_port << shift; *exti_cr = cr; } + +/** + * @brief Remap an alternate function peripheral to a different pin + * mapping + * @param peripheral to remap + */ +void afio_remap(AFIORemapPeripheral p) { + if (p & AFIO_REMAP_USE_MAPR2) { + p &= ~AFIO_REMAP_USE_MAPR2; + AFIO_BASE->MAPR2 |= p; + } else { + AFIO_BASE->MAPR |= p; + } +} -- cgit v1.2.3