From 674c4504167087de7a7777fcea1a57d6e40ed286 Mon Sep 17 00:00:00 2001
From: lilian <lilian.marazano@gmail.com>
Date: Tue, 22 Aug 2017 15:10:15 -0300
Subject: [PATCH] Fix SPI3 protocol with SSD1306

---
 extras/ssd1306/ssd1306.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/extras/ssd1306/ssd1306.c b/extras/ssd1306/ssd1306.c
index ca3b48a..4da3e10 100644
--- a/extras/ssd1306/ssd1306.c
+++ b/extras/ssd1306/ssd1306.c
@@ -99,7 +99,7 @@ static int inline i2c_send(const ssd1306_t *dev, uint8_t reg, uint8_t* data, uin
 /* Issue a command to SSD1306 device
  * I2C proto format:
  * |S|Slave Address|W|ACK|0x00|Command|Ack|P|
- * 
+ *
  * in case of two-bytes command here will be Data byte
  * right after the command byte.
  */
@@ -293,9 +293,19 @@ int ssd1306_load_frame_buffer(const ssd1306_t *dev, uint8_t buf[])
             {
                 spi_set_command(SPI_BUS,1,1); // data mode
                 if (buf)
-                    spi_transfer(SPI_BUS, buf, NULL, len, SPI_8BIT);
+                {
+                    for (i = 0; i < len; i++)
+                    {
+                        spi_transfer(SPI_BUS, &buf[i], NULL, 1, SPI_8BIT);
+                    }
+                }
                 else
-                    spi_repeat_send_8(SPI_BUS,0,len);
+                {
+                    for (i = 0; i < len; i++)
+                    {
+                        spi_transfer_8(SPI_BUS, 0);
+                    }
+                }
             }
             else
             {