mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Revision:
167:e84263d55307
Parent:
149:156823d33999
Child:
170:19eb464bc2be
--- a/targets/TARGET_NXP/TARGET_LPC15XX/spi_api.c	Thu Jun 08 15:02:37 2017 +0100
+++ b/targets/TARGET_NXP/TARGET_LPC15XX/spi_api.c	Wed Jun 21 17:46:44 2017 +0100
@@ -248,6 +248,20 @@
     return spi_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)
 {
     return (spi_readable(obj) && !spi_busy(obj)) ? (1) : (0);