Skip to content

Commit be35b3f

Browse files
committed
spi: Added default spi_master_block_write implementation to REALTEK_RTL8195AM
There is an easy default implementation of spi_master_block_write that just calls spi_master_write in a loop, so the default implementation of spi_master_block_write has been added to all targets.
1 parent 3c3a9a6 commit be35b3f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/spi_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ int spi_master_write (spi_t *obj, int value)
241241
return ssi_read(obj);
242242
}
243243

244+
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length)
245+
{
246+
int total = (tx_length > rx_length) ? tx_length : rx_length;
247+
248+
for (int i = 0; i < total; i++) {
249+
char out = (i < tx_length) ? tx_buffer[i] : 0xff;
250+
char in = spi_master_write(obj, out);
251+
if (i < rx_length) {
252+
rx_buffer[i] = in;
253+
}
254+
}
255+
256+
return total;
257+
}
258+
244259
int spi_slave_receive (spi_t *obj)
245260
{
246261
PHAL_SSI_ADAPTOR pHalSsiAdaptor;

0 commit comments

Comments
 (0)