aboutsummaryrefslogtreecommitdiffstats
path: root/examples/spi_master.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/spi_master.cpp')
-rw-r--r--examples/spi_master.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/examples/spi_master.cpp b/examples/spi_master.cpp
index 2b62c8d..9f6d81b 100644
--- a/examples/spi_master.cpp
+++ b/examples/spi_master.cpp
@@ -59,12 +59,19 @@ void loop() {
delay(1000);
}
-int main(void) {
- init();
- setup();
+// Force init to be called *first*, i.e. before static object allocation.
+// Otherwise, statically allocated object that need libmaple may fail.
+ __attribute__(( constructor )) void premain() {
+ init();
+}
+
+int main(void)
+{
+ setup();
- while (1) {
- loop();
- }
- return 0;
+ while (1) {
+ loop();
+ }
+ return 0;
}
+