mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/stm32f1: Add remap support for stm32f1 cpus and boards
This commit fixes configuration problems when trying to use i2c pins that need to be remapped. All B8 and B9 pins for STM32F1 need to be remapped, so a check is done if the remappable pins are selected.
This commit is contained in:
parent
e0997b4fc7
commit
d7eb070eb4
@ -155,7 +155,8 @@ static const uart_conf_t uart_config[] = {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name I2C configuration
|
||||
* @name I2C configuration
|
||||
* @note This board may require external pullup resistors for i2c operation.
|
||||
* @{
|
||||
*/
|
||||
static const i2c_conf_t i2c_config[] = {
|
||||
|
@ -144,7 +144,8 @@ static const uart_conf_t uart_config[] = {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name I2C configuration
|
||||
* @name I2C configuration
|
||||
* @note This board may require external pullup resistors for i2c operation.
|
||||
* @{
|
||||
*/
|
||||
static const i2c_conf_t i2c_config[] = {
|
||||
|
@ -109,6 +109,14 @@ void i2c_init(i2c_t dev)
|
||||
gpio_init(i2c_config[dev].scl_pin, GPIO_OD_PU);
|
||||
gpio_init(i2c_config[dev].sda_pin, GPIO_OD_PU);
|
||||
#ifdef CPU_FAM_STM32F1
|
||||
/* This is needed in case the remapped pins are used */
|
||||
if (i2c_config[dev].scl_pin == GPIO_PIN(PORT_B, 8) ||
|
||||
i2c_config[dev].sda_pin == GPIO_PIN(PORT_B, 9)) {
|
||||
/* The remapping periph clock must first be enabled */
|
||||
RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;
|
||||
/* Then the remap can occur */
|
||||
AFIO->MAPR |= AFIO_MAPR_I2C1_REMAP;
|
||||
}
|
||||
gpio_init_af(i2c_config[dev].scl_pin, GPIO_AF_OUT_OD);
|
||||
gpio_init_af(i2c_config[dev].sda_pin, GPIO_AF_OUT_OD);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user