Added reset function to i2c convenience functions.

This commit is contained in:
Piotr Esden-Tempski 2012-02-24 17:14:50 -08:00
parent cbef43ddd8
commit 2b3f07ee08
2 changed files with 16 additions and 0 deletions

View File

@ -316,6 +316,7 @@
/* --- I2C funtion prototypes----------------------------------------------- */
void i2c_reset(u32 i2c);
void i2c_peripheral_enable(u32 i2c);
void i2c_peripheral_disable(u32 i2c);
void i2c_send_start(u32 i2c);

View File

@ -18,6 +18,21 @@
*/
#include <libopencm3/stm32/i2c.h>
#include <libopencm3/stm32/f4/rcc.h>
void i2c_reset(u32 i2c)
{
switch (i2c) {
case I2C1:
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_I2C1RST);
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_I2C1RST);
break;
case I2C2:
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_I2C2RST);
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_I2C2RST);
break;
}
}
void i2c_peripheral_enable(u32 i2c)
{