esp32s2-saola-1: Add support for I2C chardev driver
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
parent
0657621848
commit
01b3ddd22f
60
boards/xtensa/esp32s2/esp32s2-saola-1/configs/i2c/defconfig
Normal file
60
boards/xtensa/esp32s2/esp32s2-saola-1/configs/i2c/defconfig
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s2-saola-1"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S2_SAOLA_1=y
|
||||
CONFIG_ARCH_CHIP="esp32s2"
|
||||
CONFIG_ARCH_CHIP_ESP32S2=y
|
||||
CONFIG_ARCH_CHIP_ESP32S2WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_ERROR=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_I2C=y
|
||||
CONFIG_DEBUG_I2C_ERROR=y
|
||||
CONFIG_DEBUG_I2C_INFO=y
|
||||
CONFIG_DEBUG_I2C_WARN=y
|
||||
CONFIG_DEBUG_INFO=y
|
||||
CONFIG_DEBUG_WARN=y
|
||||
CONFIG_ESP32S2_I2C0=y
|
||||
CONFIG_ESP32S2_I2C1=y
|
||||
CONFIG_ESP32S2_UART0=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2CTOOL_DEFFREQ=100000
|
||||
CONFIG_I2CTOOL_MAXBUS=1
|
||||
CONFIG_I2C_RESET=y
|
||||
CONFIG_I2C_TRACE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=28
|
||||
CONFIG_START_MONTH=6
|
||||
CONFIG_START_YEAR=2022
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
@ -41,6 +41,10 @@ ifeq ($(CONFIG_ONESHOT),y)
|
||||
CSRCS += esp32s2_oneshot.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2C_DRIVER),y)
|
||||
CSRCS += esp32s2_board_i2c.c
|
||||
endif
|
||||
|
||||
SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32s2.template.ld
|
||||
SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32s2_out.ld
|
||||
|
||||
|
@ -117,5 +117,21 @@ int esp32s2_gpio_init(void);
|
||||
int board_oneshot_init(int timer, uint16_t resolution);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2c_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2C driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C_DRIVER
|
||||
int board_i2c_init(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_XTENSA_ESP32S2_ESP32S2_SAOLA_1_SRC_ESP32S2_SAOLA_1_H */
|
||||
|
@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_board_i2c.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
|
||||
#include "esp32s2_i2c.h"
|
||||
#include "esp32s2-saola-1.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int i2c_driver_init(int bus)
|
||||
{
|
||||
struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
i2c = esp32s2_i2cbus_initialize(bus);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
i2cerr("Failed to get I2C%d interface\n", bus);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = i2c_register(i2c, bus);
|
||||
if (ret < 0)
|
||||
{
|
||||
i2cerr("Failed to register I2C%d driver: %d\n", bus, ret);
|
||||
esp32s2_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2c_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the I2C driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_i2c_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2C0
|
||||
ret = i2c_driver_init(ESP32S2_I2C0);
|
||||
if (ret != OK)
|
||||
{
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2C1
|
||||
ret = i2c_driver_init(ESP32S2_I2C1);
|
||||
#endif
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
@ -192,6 +192,16 @@ int esp32s2_bringup(void)
|
||||
|
||||
#endif /* CONFIG_ONESHOT */
|
||||
|
||||
#ifdef CONFIG_I2C_DRIVER
|
||||
/* Configure I2C peripheral interfaces */
|
||||
|
||||
ret = board_i2c_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize I2C driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we got here then perhaps not all initialization was successful, but
|
||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||
* capabilities.
|
||||
|
Loading…
Reference in New Issue
Block a user