Nucleo-F072RB: Add support for the I2C driver used by I2C tools.

This commit is contained in:
Gregory Nutt 2017-04-30 08:02:03 -06:00
parent b688d41516
commit 446af7e987
3 changed files with 50 additions and 8 deletions

View File

@ -135,6 +135,8 @@ Serial Console
PA14
PD5
See "Virtual COM Port" and "RS-232 Shield" below.
USART3
------
Pins and Connectors:
@ -148,8 +150,6 @@ Serial Console
PC10
D8
See "Virtual COM Port" and "RS-232 Shield" below.
USART3
------
Pins and Connectors:
@ -177,8 +177,8 @@ Serial Console
Configuring USART2 is the same as given above.
Question: What BAUD should be configure to interface with the Virtual
COM port? 115200 8N1?
115200 8N1 BAUD should be configure to interface with the Virtual COM
port.
Default
-------

View File

@ -230,12 +230,19 @@
/* Alternate Pin Functions **********************************************************/
/* USART 1 */
#define GPIO_USART1_TX GPIO_USART1_TX_2
#define GPIO_USART1_RX GPIO_USART1_RX_2
#define GPIO_USART1_TX GPIO_USART1_TX_2 /* PA9 CN10 pin 21 */
#define GPIO_USART1_RX GPIO_USART1_RX_2 /* PA10 CN10 pin 33 */
/* USART 2 */
#define GPIO_USART2_TX GPIO_USART2_TX_3
#define GPIO_USART2_RX GPIO_USART2_RX_3
#define GPIO_USART2_TX GPIO_USART2_TX_3 /* PA2 St-Link VCOM */
#define GPIO_USART2_RX GPIO_USART2_RX_3 /* PA3 St-Link VCOM */
/* I2C1 */
#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 CN5 pin 10, D15 */
#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 CN5 pin 9, D14 */
/* I2C2 */
#endif /* __CONFIG_NUCLEO_F072RB_INCLUDE_BOARD_H */

View File

@ -43,8 +43,20 @@
#include <sys/types.h>
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include "stm32f0_i2c.h"
#include "nucleo-f072rb.h"
/****************************************************************************
* Pre-processor Defintiionis
****************************************************************************/
#undef HAVE_I2C_DRIVER
#if defined(CONFIG_STM32F0_I2C1) && defined(CONFIG_I2C_DRIVER)
# define HAVE_I2C_DRIVER 1
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -65,6 +77,9 @@
int stm32_bringup(void)
{
#ifdef HAVE_I2C_DRIVER
FAR struct i2c_master_s *i2c;
#endif
int ret;
#ifdef CONFIG_FS_PROCFS
@ -77,6 +92,26 @@ int stm32_bringup(void)
}
#endif
#ifdef HAVE_I2C_DRIVER
/* Get the I2C lower half instance */
i2c = stm32f0_i2cbus_initialize(0);
if (i2c == NULL)
{
i2cerr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
}
else
{
/* Regiser the I2C character driver */
ret = i2c_register(i2c, 0);
if (ret < 0)
{
i2cerr("ERROR: Failed to register I2C device: %d\n", ret);
}
}
#endif
UNUSED(ret);
return OK;
}