Fast SPI write, added LPC812 Target

Dependents:   wsDrive

Fork of BurstSPI by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Sat May 16 11:09:59 2015 +0000
Parent:
12:c99022511536
Child:
14:83e3b8ba3f43
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
--- 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"
--- /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
+
--- 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