Expand description
AW9523B I2C GPIO expander driver for M5Stack CoreS3 (I2C 0x58).
Register map (AW9523B English datasheet V1.5, §5 “Register Description”): 0x00 Input P0 port 0 pin levels; READING CLEARS the interrupt 0x01 Input P1 port 1 pin levels; READING CLEARS the interrupt 0x02 Output P0 output latch for port 0 (default 0x00) 0x03 Output P1 output latch for port 1 (default 0x00) 0x04 Config P0 direction: 0=output, 1=input (default 0xFF = all input) 0x05 Config P1 direction: 0=output, 1=input (default 0xFF = all input) 0x06 Int P0 interrupt mask: 0=enabled, 1=DISABLED (default 0x00) 0x07 Int P1 interrupt mask, port 1 0x12 LEDMODE P0 0=LED current mode, 1=GPIO push-pull (default 0x00) 0x13 LEDMODE P1 0=LED current mode, 1=GPIO push-pull (default 0x00)
Pin assignment (CoreS3 schematic v1.0 + M5Unified Power_Class.cpp):
P0_0 TOUCH_RST active-LOW reset for FT6336U
P0_1 BUS_OUT_EN active-HIGH — enables the M-Bus/Grove 5V output (load switch)
P0_2 AW_RST self-reset (active-LOW)
P0_5 USB_OTG_EN active-HIGH — enables USB OTG (kills USB-JTAG if asserted)
P1_0 CAM_RST camera reset (active-LOW)
P1_1 LCD_RST ILI9342C reset (active-LOW)
P1_2 TOUCH_INT FT6336U interrupt (input)
P1_3 AW_INT the chip’s own INTN, looped back as an input
The INTN pin leaves the expander and reaches the ESP32-S3 on GPIO21
(M5Unified’s CoreS3 _wakeupPin, commented there as I2C_INT). So the
touch chain is FT6336U TOUCH_INT -> P1_2 -> INTN -> GPIO21, which makes
touch a usable deep-sleep wake source: GPIO21 is an RTC IO. The P1_3
entry above is the loopback, NOT the end of the chain – reading it as the
end is how this file previously implied touch could not wake the board.
P1_7 BOOST_EN active-HIGH — enables the SY7088 5V boost converter
NOTE: the BUS_OUT_EN polarity was verified active-HIGH against M5Unified
(setExtOutput(true) sets the P0_1 bit) and the ME1502 load-switch topology
— an earlier revision of this file wrongly documented it active-LOW.
SAFETY: init() modifies P0 via read-modify-write touching ONLY P0_0
(TOUCH_RST), preserving all other P0 bits at their power-on defaults so
BUS_OUT_EN / USB_OTG_EN stay deasserted. The 5V output is brought up only by
an explicit enable_bus_5v call.
Datasheet: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/products/core/CoreS3/AW9523B-EN.pdf CoreS3 schematic: https://m5stack-doc.oss-cn-shenzhen.aliyuncs.com/490/Sch_M5_CoreS3_v1.0.pdf M5Unified: https://github.com/m5stack/M5Unified/blob/master/src/utility/Power_Class.cpp