mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
esp32s3-devkit: Add support for I2C chardev driver
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
ea829cf7d5
commit
036e3375e8
@@ -32,6 +32,10 @@ ifeq ($(CONFIG_ESP32S3_SPIFLASH),y)
|
|||||||
CSRCS += esp32s3_board_spiflash.c
|
CSRCS += esp32s3_board_spiflash.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_I2C_DRIVER),y)
|
||||||
|
CSRCS += esp32s3_board_i2c.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path src
|
DEPPATH += --dep-path src
|
||||||
VPATH += :src
|
VPATH += :src
|
||||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32s3/common/src/esp32s3_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 "esp32s3_i2c.h"
|
||||||
|
#include "esp32s3-devkit.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int i2c_driver_init(int bus)
|
||||||
|
{
|
||||||
|
struct i2c_master_s *i2c;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
i2c = esp32s3_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);
|
||||||
|
esp32s3_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_ESP32S3_I2C0
|
||||||
|
ret = i2c_driver_init(ESP32S3_I2C0);
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_I2C1
|
||||||
|
ret = i2c_driver_init(ESP32S3_I2C1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
done:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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="esp32s3-devkit"
|
||||||
|
CONFIG_ARCH_BOARD_COMMON=y
|
||||||
|
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32s3"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3WROOM1=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_ESP32S3_I2C0=y
|
||||||
|
CONFIG_ESP32S3_I2C1=y
|
||||||
|
CONFIG_ESP32S3_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
|
||||||
@@ -81,5 +81,21 @@ int esp32s3_bringup(void);
|
|||||||
int board_spiflash_init(void);
|
int board_spiflash_init(void);
|
||||||
#endif
|
#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 /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
||||||
|
|||||||
@@ -46,6 +46,10 @@
|
|||||||
# include "esp32s3_rt_timer.h"
|
# include "esp32s3_rt_timer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_I2C
|
||||||
|
# include "esp32s3_i2c.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_WATCHDOG
|
#ifdef CONFIG_WATCHDOG
|
||||||
# include "esp32s3_board_wdt.h"
|
# include "esp32s3_board_wdt.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -127,6 +131,16 @@ int esp32s3_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
#ifdef CONFIG_INPUT_BUTTONS
|
#ifdef CONFIG_INPUT_BUTTONS
|
||||||
/* Register the BUTTON driver */
|
/* Register the BUTTON driver */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user