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.
pull/4438/head
Sam Grove 2017-06-03 17:14:11 -05:00
parent 3c3a9a67fe
commit be35b3fb81
1 changed files with 15 additions and 0 deletions

View File

@ -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;