diff options
author | Perry Hung <iperry@gmail.com> | 2011-04-19 22:03:42 -0400 |
---|---|---|
committer | Perry Hung <iperry@gmail.com> | 2011-05-12 04:07:33 -0400 |
commit | 1c476012cdc88228ffc38723a36b652fa5c8831d (patch) | |
tree | d85121a565ddcf974e97ae714a092572304c96c4 /libmaple/gpio.c | |
parent | b687ae251329b073a5ab2d757797f0db5e0d7e0b (diff) | |
download | librambutan-1c476012cdc88228ffc38723a36b652fa5c8831d.tar.gz librambutan-1c476012cdc88228ffc38723a36b652fa5c8831d.zip |
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.
Diffstat (limited to 'libmaple/gpio.c')
-rw-r--r-- | libmaple/gpio.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; + } +} |