t

Fork of mbed-dev by mbed official

Revision:
171:19eb464bc2be
Parent:
170:e3b6fe271b81
Child:
175:b96e65c34a4d
diff -r e3b6fe271b81 -r 19eb464bc2be drivers/SPI.cpp
--- a/drivers/SPI.cpp	Wed Jul 19 17:31:21 2017 +0100
+++ b/drivers/SPI.cpp	Thu Aug 03 13:13:39 2017 +0100
@@ -32,7 +32,8 @@
 #endif
         _bits(8),
         _mode(0),
-        _hz(1000000) {
+        _hz(1000000),
+        _write_fill(SPI_FILL_CHAR) {
     // No lock needed in the constructor
 
     spi_init(&_spi, mosi, miso, sclk, ssel);
@@ -102,7 +103,7 @@
 int SPI::write(const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length) {
     lock();
     _acquire();
-    int ret = spi_master_block_write(&_spi, tx_buffer, tx_length, rx_buffer, rx_length);
+    int ret = spi_master_block_write(&_spi, tx_buffer, tx_length, rx_buffer, rx_length, _write_fill);
     unlock();
     return ret;
 }
@@ -115,6 +116,12 @@
     _mutex->unlock();
 }
 
+void SPI::set_default_write_value(char data) {
+    lock();
+    _write_fill = data;
+    unlock();
+}
+
 #if DEVICE_SPI_ASYNCH
 
 int SPI::transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)