Browse Source

STM32L4 Support

Add excepions to support the
[arduino-STM32L4](https://github.com/GrumpyOldPizza/arduino-STM32L4)
core by @GrumpyOldPizza.

Tested on an STM32L433CC running on the [BlackIce
Board](https://forum.mystorm.uk/) using the arduino-mystorm board
support package.

- Additional info and setup on the forum:
  https://forum.mystorm.uk/t/arduino-board-package-for-blackice/279
- Github source:
  https://github.com/millerresearch/arduino-mystorm
- Note: Had to switch the SPI bus to SPI1 for the BlackIce board.
AnthonyDiGirolamo 6 years ago
parent
commit
b72feea4c7
2 changed files with 13 additions and 5 deletions
  1. 11 3
      GD2.h
  2. 2 2
      transports/wiring.h

+ 11 - 3
GD2.h

@@ -82,6 +82,14 @@ static class ASPI_t ASPI;
 
 #endif
 
+#if defined(ARDUINO_STM32L4_BLACKICE)
+// BlackIce Board uses SPI1 on the Arduino header.
+#define SPI SPI1
+// Board Support:
+//   JSON: http://www.hamnavoe.com/package_millerresearch_mystorm_index.json
+//   Source: https://github.com/millerresearch/arduino-mystorm
+#endif
+
 #if SDCARD
 
 #if defined(VERBOSE) && (VERBOSE > 0)
@@ -204,7 +212,7 @@ class sdcard {
     pin = p;
 
     pinMode(pin, OUTPUT);
-#if !defined(__DUE__) && !defined(TEENSYDUINO)
+#if !defined(__DUE__) && !defined(TEENSYDUINO) && !defined(ARDUINO_ARCH_STM32L4)
     SPI.setClockDivider(SPI_CLOCK_DIV64);
 #endif
     desel();
@@ -280,7 +288,7 @@ class sdcard {
     for (;;);
 #endif
 
-#if !defined(__DUE__) && !defined(ESP8266)
+#if !defined(__DUE__) && !defined(ESP8266) && !defined(ARDUINO_ARCH_STM32L4)
     SPI.setClockDivider(SPI_CLOCK_DIV2);
     SPSR = (1 << SPI2X);
 #endif
@@ -1383,7 +1391,7 @@ public:
  * compiler. So redefine PROGMEM to nothing.
  */
 
-#if defined(ESP8266)
+#if defined(ESP8266) || defined(ARDUINO_ARCH_STM32L4)
 #undef PROGMEM
 #define PROGMEM
 #endif

+ 2 - 2
transports/wiring.h

@@ -26,7 +26,7 @@ public:
     ios();
 
     SPI.begin();
-#ifdef TEENSYDUINO
+#if defined(TEENSYDUINO) || defined(ARDUINO_ARCH_STM32L4)
     SPI.beginTransaction(SPISettings(3000000, MSBFIRST, SPI_MODE0));
 #else
 #if !defined(__DUE__) && !defined(ESP8266)
@@ -221,7 +221,7 @@ public:
       *dst++ = SPI.transfer(0);
     stream();
   }
-#if defined(ARDUINO) && !defined(__DUE__) && !defined(ESP8266)
+#if defined(ARDUINO) && !defined(__DUE__) && !defined(ESP8266) && !defined(ARDUINO_ARCH_STM32L4)
   void wr_n(uint32_t addr, byte *src, uint16_t n)
   {
     __end(); // stop streaming