aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-06-24 14:38:35 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-06-24 14:38:35 -0400
commitb08c0f74786fe871e7c64a77d19d2a66329f62a4 (patch)
treece8ba7985fd93ad8910f8c0313722815137cabbd /examples
parent22b9ffc1a7b77cab2a55c4c9ebf9c9abdc6c790e (diff)
parent1a825f8a475f0b10c5c528cedd6c930a2f248255 (diff)
downloadlibrambutan-b08c0f74786fe871e7c64a77d19d2a66329f62a4.tar.gz
librambutan-b08c0f74786fe871e7c64a77d19d2a66329f62a4.zip
Merge branch 'freertos'
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/freertos-blinky.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/freertos-blinky.cpp b/examples/freertos-blinky.cpp
new file mode 100755
index 0000000..6f82d71
--- /dev/null
+++ b/examples/freertos-blinky.cpp
@@ -0,0 +1,43 @@
+#include "wirish.h"
+#include "libraries/FreeRTOS/MapleFreeRTOS.h"
+
+static void vLEDFlashTask(void *pvParameters) {
+ for (;;) {
+ vTaskDelay(1000);
+ digitalWrite(BOARD_LED_PIN, HIGH);
+ vTaskDelay(50);
+ digitalWrite(BOARD_LED_PIN, LOW);
+ }
+}
+
+void setup() {
+ // initialize the digital pin as an output:
+ pinMode(BOARD_LED_PIN, OUTPUT);
+
+ xTaskCreate(vLEDFlashTask,
+ (signed portCHAR *)"Task1",
+ configMINIMAL_STACK_SIZE,
+ NULL,
+ tskIDLE_PRIORITY + 2,
+ NULL);
+ vTaskStartScheduler();
+}
+
+void loop() {
+ // Insert background code here
+}
+
+// Force init to be called *first*, i.e. before static object allocation.
+// Otherwise, statically allocated objects that need libmaple may fail.
+__attribute__((constructor)) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (true) {
+ loop();
+ }
+ return 0;
+}