#pragma once #include "esp_err.h" #ifdef __cplusplus extern "C" { #endif /* * I2C slave for RP2040 (or any master) <-> ESP32-S3 eye. * * Pins: SDA=GPIO19, SCL=GPIO20 (external pull-ups recommended) * Addr: 0x42 (7-bit) * Port: I2C1 (camera SCCB stays on I2C0) * * Mode: I2C slave driver v2 (FIFO + on_receive / on_request). * Master still uses EEPROM-style readfrom_mem / writeto_mem. * * Compact register map (software 32-byte window) * ------------------------------------------ * 0x00 WHOAMI R 0xA5 * 0x01 VERSION R 0x07 * 0x02 STATUS R b0 wifi (has IP), b1 cam, b2 local, b3 found * 0x03 FLAGS R/W b0 local, b1 show_mask, b2 mask_full, b3 morph_roi * 0x04 METHOD R/W 0=contour, 1=rect * 0x05 CMD W 0=stop,1=up,2=down,3=left,4=right, * 5=cam_on,6=cam_off,7=wifi_on,8=wifi_off * * Boot: camera and Wi‑Fi are off until CMD 5 / wifi credentials write. * Detection runs locally when camera is on and FLAGS.local=1 (no Wi‑Fi required). * 0x06 STRIDE R/W 2 or 4 * 0x07 MIN_AREA_L R/W uint16 LE * 0x08 MIN_AREA_H R/W * 0x09 H R/W * 0x0A S R/W * 0x0B V R/W * 0x0C H_TOL R/W * 0x0D S_TOL R/W * 0x0E V_TOL R/W * 0x0F APPLY W b0=apply BGR from 0x1D..0x1F, b1=pick apply (uses 0x1D.. as xy packed) * * 0x10 FOUND R 0/1 * 0x11 CX_L R int16 LE * 0x12 CX_H R * 0x13 CY_L R * 0x14 CY_H R * 0x15 RADIUS_L R uint16 LE * 0x16 RADIUS_H R * 0x17 AREA_L R * 0x18 AREA_H R * 0x19 TOTAL_MS_L R * 0x1A TOTAL_MS_H R * 0x1B DETECT_MS_L R * 0x1C DETECT_MS_H R * * 0x1D..0x1F R/W scratch (BGR or pick coords — see APPLY) * * 0x20 WIFI_CRED W extended write (not mirrored for reads): * [ssid_len][ssid…][pass_len][pass…] then enables Wi‑Fi * ssid_len<=32, pass_len<=64 * 0x21..0x24 IP R IPv4 octets (0.0.0.0 if not connected) */ #define EYE_I2C_ADDR 0x42 #define EYE_I2C_SDA_GPIO 19 #define EYE_I2C_SCL_GPIO 20 #define EYE_I2C_RAM_SIZE 37 /* 0x00..0x24 — includes IPv4 at 0x21..0x24 */ esp_err_t eye_i2c_init(void); void eye_i2c_set_cam_mutex(void *mutex); void eye_i2c_load_wifi_bufs(const char *ssid, const char *pass); #ifdef __cplusplus } #endif