diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/spi_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/spi_api.c index 04402f7eb4..cec30a9b3b 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/spi_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/spi_api.c @@ -241,6 +241,21 @@ int spi_master_write (spi_t *obj, int value) return ssi_read(obj); } +int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length) +{ + int total = (tx_length > rx_length) ? tx_length : rx_length; + + for (int i = 0; i < total; i++) { + char out = (i < tx_length) ? tx_buffer[i] : 0xff; + char in = spi_master_write(obj, out); + if (i < rx_length) { + rx_buffer[i] = in; + } + } + + return total; +} + int spi_slave_receive (spi_t *obj) { PHAL_SSI_ADAPTOR pHalSsiAdaptor;