Added FMPI2C1 controller as 3rd available I2C

pull/1412/head
Rafal Fabich 2015-10-29 14:58:30 +01:00 committed by Wojciech Gorniak
parent d1e7f13c01
commit e38b06d0fd
3 changed files with 26 additions and 8 deletions

View File

@ -58,18 +58,15 @@ typedef enum {
typedef enum {
I2C_1 = (int)I2C1_BASE,
I2C_2 = (int)I2C2_BASE
// I2C_3 = (int)FMPI2C1_BASE /* is it a normal i2c? */
I2C_2 = (int)I2C2_BASE,
FMPI2C_1 = (int)FMPI2C1_BASE
} I2CName;
typedef enum {
PWM_1 = (int)TIM1_BASE,
// PWM_2 = (int)TIM2_BASE,
// PWM_3 = (int)TIM3_BASE,
// PWM_4 = (int)TIM4_BASE,
PWM_5 = (int)TIM5_BASE,
PWM_6 = (int)TIM6_BASE,
PWM_9 = (int)TIM9_BASE,
// PWM_10 = (int)TIM10_BASE,
PWM_11 = (int)TIM11_BASE
} PWMName;

View File

@ -67,12 +67,12 @@ const PinMap PinMap_I2C_SDA[] = {
// {PB_8, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, // Warning: also on SCL
{PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // ARDUINO
// {PB_9, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)},
//rf {PC_9, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
{PC_9, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)},
{NC, NC, 0}
};
const PinMap PinMap_I2C_SCL[] = {
//rf {PA_8, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
{PA_8, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)},
{PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
{PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // ARDUINO
{PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},

View File

@ -47,6 +47,7 @@ I2C_HandleTypeDef I2cHandle;
int i2c1_inited = 0;
int i2c2_inited = 0;
int i2c3_inited = 0;
int fmpi2c1_inited = 0;
void i2c_init(i2c_t *obj, PinName sda, PinName scl)
{
@ -89,6 +90,19 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
pin_mode(scl, OpenDrain);
}
#endif
#if defined FMPI2C1_BASE
// Enable I2C3 clock and pinout if not done
if ((obj->i2c == FMPI2C_1) && !fmpi2c1_inited) {
fmpi2c1_inited = 1;
__FMPI2C1_CLK_ENABLE();
// Configure I2C pins
pinmap_pinout(sda, PinMap_I2C_SDA);
pinmap_pinout(scl, PinMap_I2C_SCL);
pin_mode(sda, OpenDrain);
pin_mode(scl, OpenDrain);
}
#endif
// Reset to clear pending flags if any
i2c_reset(obj);
@ -322,6 +336,13 @@ void i2c_reset(i2c_t *obj)
__I2C3_RELEASE_RESET();
}
#endif
#if defined FMPI2C1_BASE
if (obj->i2c == FMPI2C_1) {
__FMPI2C1_FORCE_RESET();
__FMPI2C1_RELEASE_RESET();
}
#endif
}
#if DEVICE_I2CSLAVE