mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
configs/nucleo-l432kc/src/stm32_appinit.c: Add support for I2C driver initialization.
This commit is contained in:
committed by
Gregory Nutt
parent
5bf7890d32
commit
5bbd831222
@@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
#include <stm32l4.h>
|
#include <stm32l4.h>
|
||||||
#include <stm32l4_uart.h>
|
#include <stm32l4_uart.h>
|
||||||
|
#include <stm32l4_i2c.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
@@ -65,6 +66,15 @@
|
|||||||
# include "stm32l4_rtc.h"
|
# include "stm32l4_rtc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#undef HAVE_I2C_DRIVER
|
||||||
|
#if defined(CONFIG_STM32L4_I2C1) && defined(CONFIG_I2C_DRIVER)
|
||||||
|
# define HAVE_I2C_DRIVER 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -95,7 +105,7 @@ void up_netinitialize(void)
|
|||||||
* arg - The boardctl() argument is passed to the board_app_initialize()
|
* arg - The boardctl() argument is passed to the board_app_initialize()
|
||||||
* implementation without modification. The argument has no
|
* implementation without modification. The argument has no
|
||||||
* meaning to NuttX; the meaning of the argument is a contract
|
* meaning to NuttX; the meaning of the argument is a contract
|
||||||
* between the board-specific initalization logic and the
|
* between the board-specific initialization logic and the
|
||||||
* matching application logic. The value cold be such things as a
|
* matching application logic. The value cold be such things as a
|
||||||
* mode enumeration value, a set of DIP switch switch settings, a
|
* mode enumeration value, a set of DIP switch switch settings, a
|
||||||
* pointer to configuration data read from a file or serial FLASH,
|
* pointer to configuration data read from a file or serial FLASH,
|
||||||
@@ -113,6 +123,9 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
#ifdef HAVE_RTC_DRIVER
|
#ifdef HAVE_RTC_DRIVER
|
||||||
FAR struct rtc_lowerhalf_s *rtclower;
|
FAR struct rtc_lowerhalf_s *rtclower;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_I2C_DRIVER
|
||||||
|
FAR struct i2c_master_s *i2c;
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
int index;
|
int index;
|
||||||
char buf[9];
|
char buf[9];
|
||||||
@@ -170,6 +183,26 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_I2C_DRIVER
|
||||||
|
/* Get the I2C lower half instance */
|
||||||
|
|
||||||
|
i2c = stm32l4_i2cbus_initialize(1);
|
||||||
|
if (i2c == NULL)
|
||||||
|
{
|
||||||
|
i2cerr("ERROR: Initialize I2C1: %d\n", ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Register the I2C character driver */
|
||||||
|
|
||||||
|
ret = i2c_register(i2c, 1);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
i2cerr("ERROR: Failed to register I2C1 device: %d\n", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AT45DB
|
#ifdef HAVE_AT45DB
|
||||||
/* Initialize and register the ATDB FLASH file system. */
|
/* Initialize and register the ATDB FLASH file system. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user