Erik - / BurstSPI

Dependents:   MakerBotServer epaper_mbed_130411_KL25Z epaper_mbed_test epaper_mbed_test_copy1 ... more

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Sat May 16 11:09:59 2015 +0000
Parent:
12:c99022511536
Commit message:
Added STM F4XX support.
;
; (And seriously STM, it has the same SPI as the already supported L152, but you just had to go ahead and change all your driver files)

Changed in this revision

BurstSPI_NUCLEO_L152RE.cpp Show annotated file Show diff for this revision Revisions of this file
BurstSPI_STM32F4.cpp Show annotated file Show diff for this revision Revisions of this file
BurstSPI_Unsupported.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c99022511536 -r bc069279eb37 BurstSPI_NUCLEO_L152RE.cpp
--- a/BurstSPI_NUCLEO_L152RE.cpp	Fri Apr 03 06:14:57 2015 +0000
+++ b/BurstSPI_NUCLEO_L152RE.cpp	Sat May 16 11:09:59 2015 +0000
@@ -1,5 +1,3 @@
-    
-
 /* BurstSPI_NUCLEO_L152RE.cpp */
 #ifdef TARGET_NUCLEO_L152RE
 #include "BurstSPI.h"
diff -r c99022511536 -r bc069279eb37 BurstSPI_STM32F4.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BurstSPI_STM32F4.cpp	Sat May 16 11:09:59 2015 +0000
@@ -0,0 +1,23 @@
+#if defined(TARGET_STM32F4)
+#include "BurstSPI.h"
+ 
+void BurstSPI::fastWrite(int data) {
+    
+    SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
+    // Check if data is transmitted
+    while ((spi->SR & SPI_SR_TXE) == 0);
+    spi->DR = data;
+}
+    
+void BurstSPI::clearRX( void ) {
+    //Check if the RX buffer is busy
+    SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
+    //While busy, keep checking
+    while (spi->SR & SPI_SR_BSY){   
+        // Check RX buffer readable
+        while ((spi->SR & SPI_SR_RXNE) == 0);
+        int dummy = spi->DR;
+    }
+}
+#endif
+
diff -r c99022511536 -r bc069279eb37 BurstSPI_Unsupported.cpp
--- a/BurstSPI_Unsupported.cpp	Fri Apr 03 06:14:57 2015 +0000
+++ b/BurstSPI_Unsupported.cpp	Sat May 16 11:09:59 2015 +0000
@@ -1,6 +1,6 @@
 #if !(defined(TARGET_KL25Z) || defined(TARGET_KL46Z))
 #if !(defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX) || defined(TARGET_LPC1549))
-#if !(defined(TARGET_NUCLEO_L152RE))
+#if !(defined(TARGET_NUCLEO_L152RE) || defined(TARGET_STM32F4))
 
 #warning BurstSPI target not supported, reverting to regular SPI