boards/stm32f103-minimum: fix i2c driver register
This commit is contained in:
parent
c148e8f2af
commit
6deda9b3d2
|
@ -138,6 +138,11 @@
|
||||||
#include <nuttx/usb/adb.h>
|
#include <nuttx/usb/adb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_I2C_DRIVER
|
||||||
|
#include <nuttx/i2c/i2c_master.h>
|
||||||
|
#include "stm32_i2c.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -172,6 +177,37 @@
|
||||||
# define MMCSD_MINOR 0
|
# define MMCSD_MINOR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_i2c_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register one I2C drivers for the I2C tool.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
#ifdef CONFIG_I2C_DRIVER
|
||||||
|
static void stm32_i2c_register(int bus)
|
||||||
|
{
|
||||||
|
FAR struct i2c_master_s *i2c;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
i2c = stm32_i2cbus_initialize(bus);
|
||||||
|
if (i2c == NULL)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = i2c_register(i2c, bus);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
|
||||||
|
bus, ret);
|
||||||
|
stm32_i2cbus_uninitialize(i2c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -224,6 +260,19 @@ int stm32_bringup(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_I2C_DRIVER
|
||||||
|
/* Register I2C drivers on behalf of the I2C tool */
|
||||||
|
#ifdef CONFIG_STM32_I2C1
|
||||||
|
stm32_i2c_register(1);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_STM32_I2C2
|
||||||
|
stm32_i2c_register(2);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_STM32_I2C3
|
||||||
|
stm32_i2c_register(3);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_BACKPACK
|
#ifdef CONFIG_LCD_BACKPACK
|
||||||
/* slcd:0, i2c:1, rows=2, cols=16 */
|
/* slcd:0, i2c:1, rows=2, cols=16 */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue