mirror of
https://github.com/apache/nuttx.git
synced 2026-10-03 20:27:53 +00:00
The CH422G offers eight bi-directional pins, IO0-IO7, and four open-drain
outputs, OC0-OC3. It appears on boards that have run out of usable GPIOs
once a parallel RGB panel has taken its share, the Waveshare
ESP32-S3-Touch-LCD-7 among them, where it holds the panel and touch
controller in and out of reset and switches the backlight.
Two things about the device do not fit the shape a register-per-address
I2C driver usually takes, and both are handled here rather than pushed on
to board logic:
- A register is selected by the I2C address the transfer is addressed
to, not by a register address written ahead of the data. Each access
carries a single byte to one of four addresses.
- None of the write-only registers can be read back, so the driver
keeps a shadow copy of each and updates it in step with the device.
IO0-IO7 have no individual direction control; one bit of the system
parameter register drives the whole group. The driver records the
direction asked of each pin and puts the group in output mode once at
least one of them is an output, which is what a board that drives some of
the pins would expect. Reading a pin of a group held in output mode
reports the value last written, because the hardware cannot report the
level, and that is documented rather than hidden.
The four open-drain outputs are presented as pins 8-11 of the same
ioexpander_dev_s so that one instance covers the chip, which means
CONFIG_IOEXPANDER_NPINS must be at least 12.
Builds clean with no new warnings on esp32s3-touch-lcd7:usbnsh and passes
nxstyle.
Signed-off-by: Alan Carvalho de Assis <acassis@gmail.com>
Assisted-by: Claude Code
109 lines
2.6 KiB
CMake
109 lines
2.6 KiB
CMake
# ##############################################################################
|
|
# drivers/ioexpander/CMakeLists.txt
|
|
#
|
|
# 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.
|
|
#
|
|
# ##############################################################################
|
|
|
|
set(SRCS)
|
|
|
|
# Check if I/O expander support is enabled
|
|
|
|
if(CONFIG_IOEXPANDER)
|
|
# Include the selected I/O expander drivers
|
|
|
|
if(CONFIG_IOEXPANDER_RPMSG)
|
|
list(APPEND SRCS ioe_rpmsg.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_DUMMY)
|
|
list(APPEND SRCS ioe_dummy.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_ICJX)
|
|
list(APPEND SRCS icjx.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_ISO1H812G)
|
|
list(APPEND SRCS iso1h812g.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_ISO1I813T)
|
|
list(APPEND SRCS iso1i813t.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_PCA9555)
|
|
list(APPEND SRCS pca9555.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_PCA9538)
|
|
list(APPEND SRCS pca9538.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_PI4IOE5V6408)
|
|
list(APPEND SRCS pi4ioe5v6408.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_CH422G)
|
|
list(APPEND SRCS ch422g.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_PCA9557)
|
|
list(APPEND SRCS pca9557.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_TCA64XX)
|
|
list(APPEND SRCS tca64xx.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_PCF8574)
|
|
list(APPEND SRCS pcf8574.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_PCF8575)
|
|
list(APPEND SRCS pcf8575.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_MCP23X08)
|
|
list(APPEND SRCS mcp23x08.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_MCP23X17)
|
|
list(APPEND SRCS mcp23x17.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_SX1509)
|
|
list(APPEND SRCS sx1509.c)
|
|
endif()
|
|
|
|
if(CONFIG_IOEXPANDER_AW9523B)
|
|
list(APPEND SRCS aw9523b.c)
|
|
endif()
|
|
endif()
|
|
|
|
# GPIO test device driver (independent of IOEXPANDERS)
|
|
|
|
if(CONFIG_DEV_GPIO)
|
|
list(APPEND SRCS gpio.c)
|
|
|
|
if(CONFIG_GPIO_LOWER_HALF)
|
|
list(APPEND SRCS gpio_lower_half.c)
|
|
endif()
|
|
endif()
|
|
|
|
target_sources(drivers PRIVATE ${SRCS})
|