File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -143,20 +143,21 @@ void SpiDispatcher::processSpiIoRequest(SpiIoTransaction * spi_io_transaction)
143
143
size_t bytes_received = 0 ,
144
144
bytes_sent = 0 ;
145
145
for (;
146
- bytes_received < io_request->bytes_to_read ;
146
+ bytes_received < std::max ( io_request->bytes_to_read , io_request-> bytes_to_write ) ;
147
147
bytes_received++, bytes_sent++)
148
148
{
149
149
byte tx_byte = 0 ;
150
150
151
- if (bytes_sent < io_request->bytes_to_write )
151
+ if (io_request-> write_buf && ( bytes_sent < io_request->bytes_to_write ) )
152
152
tx_byte = io_request->write_buf [bytes_sent];
153
153
else
154
154
tx_byte = config->fill_symbol ();
155
155
156
156
byte const rx_byte = config->spi ().transfer (tx_byte);
157
157
158
- io_request->read_buf [bytes_received] = rx_byte;
159
- }
158
+ if (io_request->read_buf && (bytes_received < io_request->bytes_to_read ))
159
+ io_request->read_buf [bytes_received] = rx_byte;
160
+ }
160
161
config->spi ().endTransaction ();
161
162
162
163
config->deselect ();
You can’t perform that action at this time.
0 commit comments