vision/main/eye_i2c.h

80 lines
2.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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 0x08
* 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 WiFi are off until CMD 5 / wifi credentials write.
* Detection runs locally when camera is on and FLAGS.local=1 (no WiFi 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 WiFi
* ssid_len<=32, pass_len<=64
* 0x21..0x24 IP R IPv4 octets (0.0.0.0 if not connected)
*
* 0x25 RGB_R W status LED (WS2812 on GPIO48)
* 0x26 RGB_G W
* 0x27 RGB_B W write any/all three to update the LED
*/
#define EYE_I2C_ADDR 0x42
#define EYE_I2C_SDA_GPIO 19
#define EYE_I2C_SCL_GPIO 20
#define EYE_I2C_RAM_SIZE 40 /* 0x00..0x27 — includes RGB at 0x25..0x27 */
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