diff --git a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/Make.defs b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/Make.defs index c67548ec16a..79ec70db973 100644 --- a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/Make.defs +++ b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/Make.defs @@ -56,3 +56,7 @@ endif ifeq ($(CONFIG_LCD),y) CSRCS += esp32s3_board_lcd.c endif + +ifeq ($(CONFIG_INPUT_FT5X06),y) +CSRCS += esp32s3_ft5x06.c +endif diff --git a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3-szpi.h b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3-szpi.h index bf84ddf189d..bf888c54ea6 100644 --- a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3-szpi.h +++ b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3-szpi.h @@ -40,6 +40,9 @@ #define GPIO_LCD_RST (-1) #define SZPI_LCD_CS_PATH "/dev/gpio0" +#define FT5X06_I2C_ADDRESS (0x38) +#define FT5X06_FREQUENCY (400000) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -186,5 +189,9 @@ int esp_openeth_initialize(void); int esp32s3_pca9557_initialize(void); #endif +#ifdef CONFIG_INPUT_FT5X06 +int esp32s3_ft5x06_initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_XTENSA_ESP32S3_LCKFB_SZPI_ESP32S3_SRC_ESP32S3_DEVKIT_H */ diff --git a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_bringup.c index ede3b748936..2eee0df9cf8 100644 --- a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_bringup.c @@ -315,6 +315,14 @@ int esp32s3_bringup(void) } #endif +#ifdef CONFIG_INPUT_FT5X06 + ret = esp32s3_ft5x06_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize FT5X06 driver: %d\n", ret); + } +#endif + #ifdef CONFIG_SENSORS_BMP180 /* Try to register BMP180 device in I2C0 */ diff --git a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_ft5x06.c b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_ft5x06.c new file mode 100644 index 00000000000..f6e59502a77 --- /dev/null +++ b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_ft5x06.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_ft5x06.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 + +#include +#include +#include +#include +#include +#include +#include + +#include "esp32s3_i2c.h" +#include "esp32s3-szpi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_FT5X06_POLLMODE +#error "Only support poll mode currently!" +#endif + +#define ESP32S3_FT5X06_I2C_PORT (0) + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct ft5x06_config_s g_ft5x06_config = +{ + .address = FT5X06_I2C_ADDRESS, + .frequency = FT5X06_FREQUENCY, +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int esp32s3_ft5x06_initialize(void) +{ + FAR struct i2c_master_s *i2c; + int ret; + + i2c = esp32s3_i2cbus_initialize(ESP32S3_FT5X06_I2C_PORT); + if (!i2c) + { + i2cerr("Initialize I2C bus failed!\n"); + return -EINVAL; + } + + ret = ft5x06_register(i2c, &g_ft5x06_config, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to register FT5X06 driver: %d\n", ret); + } + + return 0; +}