Skip to content

Commit 0c83263

Browse files
authored
Atoms3r cam m12 echo base (#689)
* main/boards: Add camera support for M5Stack CoreS3. * main/boards: Add camera support for M5Stack AtomS3R-CAM/M12 + EchoBase.
1 parent 2b553ce commit 0c83263

File tree

3 files changed

+56
-21
lines changed

3 files changed

+56
-21
lines changed

main/boards/atoms3r-cam-m12-echo-base/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ idf.py menuconfig
3131
分别配置如下选项:
3232

3333
- `Xiaozhi Assistant``Board Type` → 选择 `AtomS3R CAM/M12 + Echo Base`
34+
- `Xiaozhi Assistant``IoT Protocol` → 选择 `MCP协议` 可开启摄像头识别功能
3435
- `Partition Table``Custom partition CSV file` → 删除原有内容,输入 `partitions_8M.csv`
3536
- `Serial flasher config``Flash size` → 选择 `8 MB`
3637

main/boards/atoms3r-cam-m12-echo-base/atoms3r_cam_m12_echo_base.cc

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
#include <esp_log.h>
1111
#include <driver/i2c_master.h>
1212
#include <wifi_station.h>
13+
#include "esp32_camera.h"
1314

14-
#define TAG "AtomS3R M12+EchoBase"
15+
#define TAG "AtomS3R CAM/M12 + EchoBase"
1516

1617
#define PI4IOE_ADDR 0x43
1718
#define PI4IOE_REG_CTRL 0x00
@@ -39,6 +40,7 @@ class AtomS3rCamM12EchoBaseBoard : public WifiBoard {
3940
i2c_master_bus_handle_t i2c_bus_;
4041
Pi4ioe* pi4ioe_ = nullptr;
4142
bool is_echo_base_connected_ = false;
43+
Esp32Camera* camera_;
4244

4345
void InitializeI2c() {
4446
// Initialize I2C peripheral
@@ -122,7 +124,37 @@ class AtomS3rCamM12EchoBaseBoard : public WifiBoard {
122124

123125
ESP_LOGI(TAG, "Camera Power Enabled");
124126

125-
vTaskDelay(pdMS_TO_TICKS(200));
127+
vTaskDelay(pdMS_TO_TICKS(300));
128+
}
129+
130+
void InitializeCamera() {
131+
camera_config_t config = {};
132+
config.pin_d0 = CAMERA_PIN_D0;
133+
config.pin_d1 = CAMERA_PIN_D1;
134+
config.pin_d2 = CAMERA_PIN_D2;
135+
config.pin_d3 = CAMERA_PIN_D3;
136+
config.pin_d4 = CAMERA_PIN_D4;
137+
config.pin_d5 = CAMERA_PIN_D5;
138+
config.pin_d6 = CAMERA_PIN_D6;
139+
config.pin_d7 = CAMERA_PIN_D7;
140+
config.pin_xclk = CAMERA_PIN_XCLK;
141+
config.pin_pclk = CAMERA_PIN_PCLK;
142+
config.pin_vsync = CAMERA_PIN_VSYNC;
143+
config.pin_href = CAMERA_PIN_HREF;
144+
config.pin_sccb_sda = CAMERA_PIN_SIOD;
145+
config.pin_sccb_scl = CAMERA_PIN_SIOC;
146+
config.sccb_i2c_port = 1;
147+
config.pin_pwdn = CAMERA_PIN_PWDN;
148+
config.pin_reset = CAMERA_PIN_RESET;
149+
config.xclk_freq_hz = XCLK_FREQ_HZ;
150+
config.pixel_format = PIXFORMAT_RGB565;
151+
config.frame_size = FRAMESIZE_QVGA;
152+
config.jpeg_quality = 12;
153+
config.fb_count = 1;
154+
config.fb_location = CAMERA_FB_IN_PSRAM;
155+
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
156+
camera_ = new Esp32Camera(config);
157+
camera_->SetHMirror(false);
126158
}
127159

128160
// 物联网初始化,添加对 AI 可见设备
@@ -131,9 +163,13 @@ class AtomS3rCamM12EchoBaseBoard : public WifiBoard {
131163
thing_manager.AddThing(iot::CreateThing("Speaker"));
132164
}
133165

166+
virtual Camera* GetCamera() override {
167+
return camera_;
168+
}
134169
public:
135170
AtomS3rCamM12EchoBaseBoard() {
136171
EnableCameraPower(); // IO18 还会控制指示灯
172+
InitializeCamera();
137173
InitializeI2c();
138174
I2cDetect();
139175
CheckEchoBaseConnection();

main/boards/atoms3r-cam-m12-echo-base/config.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,25 @@
2525
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
2626
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
2727

28-
#define CAMERA_PIN_PWDN (-1)
29-
#define CAMERA_PIN_RESET (-1)
30-
31-
#define CAMERA_PIN_VSYNC (10)
32-
#define CAMERA_PIN_HREF (14)
33-
#define CAMERA_PIN_PCLK (40)
34-
#define CAMERA_PIN_XCLK (21)
35-
36-
#define CAMERA_PIN_SIOD (12)
37-
#define CAMERA_PIN_SIOC ( 9)
38-
39-
#define CAMERA_PIN_D0 ( 3)
40-
#define CAMERA_PIN_D1 (42)
41-
#define CAMERA_PIN_D2 (46)
42-
#define CAMERA_PIN_D3 (48)
43-
#define CAMERA_PIN_D4 ( 4)
44-
#define CAMERA_PIN_D5 (17)
45-
#define CAMERA_PIN_D6 (11)
46-
#define CAMERA_PIN_D7 (13)
4728

29+
#define CAMERA_PIN_PWDN GPIO_NUM_NC
30+
#define CAMERA_PIN_RESET GPIO_NUM_NC
31+
#define CAMERA_PIN_VSYNC GPIO_NUM_10
32+
#define CAMERA_PIN_HREF GPIO_NUM_14
33+
#define CAMERA_PIN_PCLK GPIO_NUM_40
34+
#define CAMERA_PIN_XCLK GPIO_NUM_21
35+
#define CAMERA_PIN_SIOD GPIO_NUM_12
36+
#define CAMERA_PIN_SIOC GPIO_NUM_9
37+
#define CAMERA_PIN_D0 GPIO_NUM_3
38+
#define CAMERA_PIN_D1 GPIO_NUM_42
39+
#define CAMERA_PIN_D2 GPIO_NUM_46
40+
#define CAMERA_PIN_D3 GPIO_NUM_48
41+
#define CAMERA_PIN_D4 GPIO_NUM_4
42+
#define CAMERA_PIN_D5 GPIO_NUM_17
43+
#define CAMERA_PIN_D6 GPIO_NUM_11
44+
#define CAMERA_PIN_D7 GPIO_NUM_13
4845
#define CAMERA_XCLK_FREQ (20000000)
46+
#define XCLK_FREQ_HZ CAMERA_XCLK_FREQ
4947

5048

5149
#endif // _BOARD_CONFIG_H_

0 commit comments

Comments
 (0)