Skip to content

Commit 619d485

Browse files
committed
esp32-app: works with DepthAI, receiving NN metadata as text
1 parent 1b41a02 commit 619d485

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

host/embedded/esp32-app/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ESP32 app build & flash with esp-idf:
2+
idf.py build
3+
idf.py -p /dev/ttyUSB0 flash
4+
5+
Open a serial terminal to see the prints, for example:
6+
cu -l /dev/ttyUSB0 -s 115200

host/embedded/esp32-app/main/app_main.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,17 @@ task waits for this semaphore to be given before queueing a transmission.
5353
Pins in use. The SPI Master can use the GPIO mux, so feel free to change these if needed.
5454
*/
5555
#define GPIO_HANDSHAKE 2
56+
#if 0 // original config in esp-idf example
5657
#define GPIO_MOSI 12
5758
#define GPIO_MISO 13
5859
#define GPIO_SCLK 15
5960
#define GPIO_CS 14
61+
#else // GPIOs used in the upcoming board: DepthAI with ESP-WROOM-32
62+
#define GPIO_MOSI 13
63+
#define GPIO_MISO 12
64+
#define GPIO_SCLK 14
65+
#define GPIO_CS 15
66+
#endif
6067

6168
//The semaphore indicating the slave is ready to receive stuff.
6269
static xQueueHandle rdySem;
@@ -100,7 +107,7 @@ void app_main()
100107
.command_bits=0,
101108
.address_bits=0,
102109
.dummy_bits=0,
103-
.clock_speed_hz=5000000,
110+
.clock_speed_hz=100000, // TODO
104111
.duty_cycle_pos=128, //50% duty cycle
105112
.mode=0,
106113
.spics_io_num=GPIO_CS,
@@ -117,8 +124,8 @@ void app_main()
117124
};
118125

119126
int n=0;
120-
char sendbuf[128] = {0};
121-
char recvbuf[128] = {0};
127+
static char sendbuf[256] = {0};
128+
static char recvbuf[256] = {0};
122129
spi_transaction_t t;
123130
memset(&t, 0, sizeof(t));
124131

@@ -142,18 +149,21 @@ void app_main()
142149
xSemaphoreGive(rdySem);
143150

144151
while(1) {
145-
int res = snprintf(sendbuf, sizeof(sendbuf),
146-
"Sender, transmission no. %04i. Last time, I received: \"%s\"", n, recvbuf);
152+
int res = snprintf(sendbuf, sizeof(sendbuf), "esp32-cnt:%d", n);
147153
if (res >= sizeof(sendbuf)) {
148154
printf("Data truncated\n");
149155
}
150156
t.length=sizeof(sendbuf)*8;
151157
t.tx_buffer=sendbuf;
152158
t.rx_buffer=recvbuf;
153159
//Wait for slave to be ready for next byte before sending
160+
#if 0 // TODO: implement an interrupt GPIO output from DepthAI
154161
xSemaphoreTake(rdySem, portMAX_DELAY); //Wait until slave is ready
162+
#else
163+
vTaskDelay(30 / portTICK_PERIOD_MS);
164+
#endif
155165
ret=spi_device_transmit(handle, &t);
156-
printf("Received: %s\n", recvbuf);
166+
printf("[RECV-%d] %s\n", n, recvbuf);
157167
n++;
158168
}
159169

0 commit comments

Comments
 (0)