@@ -53,10 +53,17 @@ task waits for this semaphore to be given before queueing a transmission.
53
53
Pins in use. The SPI Master can use the GPIO mux, so feel free to change these if needed.
54
54
*/
55
55
#define GPIO_HANDSHAKE 2
56
+ #if 0 // original config in esp-idf example
56
57
#define GPIO_MOSI 12
57
58
#define GPIO_MISO 13
58
59
#define GPIO_SCLK 15
59
60
#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
60
67
61
68
//The semaphore indicating the slave is ready to receive stuff.
62
69
static xQueueHandle rdySem ;
@@ -100,7 +107,7 @@ void app_main()
100
107
.command_bits = 0 ,
101
108
.address_bits = 0 ,
102
109
.dummy_bits = 0 ,
103
- .clock_speed_hz = 5000000 ,
110
+ .clock_speed_hz = 100000 , // TODO
104
111
.duty_cycle_pos = 128 , //50% duty cycle
105
112
.mode = 0 ,
106
113
.spics_io_num = GPIO_CS ,
@@ -117,8 +124,8 @@ void app_main()
117
124
};
118
125
119
126
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 };
122
129
spi_transaction_t t ;
123
130
memset (& t , 0 , sizeof (t ));
124
131
@@ -142,18 +149,21 @@ void app_main()
142
149
xSemaphoreGive (rdySem );
143
150
144
151
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 );
147
153
if (res >= sizeof (sendbuf )) {
148
154
printf ("Data truncated\n" );
149
155
}
150
156
t .length = sizeof (sendbuf )* 8 ;
151
157
t .tx_buffer = sendbuf ;
152
158
t .rx_buffer = recvbuf ;
153
159
//Wait for slave to be ready for next byte before sending
160
+ #if 0 // TODO: implement an interrupt GPIO output from DepthAI
154
161
xSemaphoreTake (rdySem , portMAX_DELAY ); //Wait until slave is ready
162
+ #else
163
+ vTaskDelay (30 / portTICK_PERIOD_MS );
164
+ #endif
155
165
ret = spi_device_transmit (handle , & t );
156
- printf ("Received: %s\n" , recvbuf );
166
+ printf ("[RECV-%d] %s\n" , n , recvbuf );
157
167
n ++ ;
158
168
}
159
169
0 commit comments