summaryrefslogtreecommitdiffstats
path: root/zpu/sw/freertos/sample/test1.c
diff options
context:
space:
mode:
authorBert Lange <b.lange@hzdr.de>2015-04-15 13:36:55 +0200
committerBert Lange <b.lange@hzdr.de>2015-04-15 13:36:55 +0200
commita1c964908b51599bf624bd2d253419c7e629f195 (patch)
tree06125d59e83b7dde82d1bb57bc0e09ca83451b98 /zpu/sw/freertos/sample/test1.c
parentbbfe29a15f11548eb7c9fa71dcb4d2d18c164a53 (diff)
parent8679e4f91dcae05aef40f96629f33f0f4161f14a (diff)
downloadzpu-a1c964908b51599bf624bd2d253419c7e629f195.zip
zpu-a1c964908b51599bf624bd2d253419c7e629f195.tar.gz
Merge branch 'master' of https://github.com/zylin/zpu
Diffstat (limited to 'zpu/sw/freertos/sample/test1.c')
-rw-r--r--zpu/sw/freertos/sample/test1.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/zpu/sw/freertos/sample/test1.c b/zpu/sw/freertos/sample/test1.c
new file mode 100644
index 0000000..41b4296
--- /dev/null
+++ b/zpu/sw/freertos/sample/test1.c
@@ -0,0 +1,67 @@
+/* Scheduler includes. */
+#include "FreeRTOS.h"
+#include "task.h"
+
+#include "devices.h"
+
+#define mainTINY_STACK 256
+void vTest(void *pvParameters);
+void vTest2(void *pvParameters);
+
+/*-----------------------------------------------------------*/
+
+/*
+ * Create all the demo tasks - then start the scheduler.
+ */
+int main (void)
+{
+ /* When re-starting a debug session (rather than cold booting) we want
+ to ensure the installed interrupt handlers do not execute until after the
+ scheduler has been started. */
+ portDISABLE_INTERRUPTS();
+
+ #if configUSE_PREEMPTION == 1
+ xTaskCreate( vTest, "TST1", mainTINY_STACK, ( void * ) 10, tskIDLE_PRIORITY, NULL );
+ xTaskCreate( vTest2, "TST2", mainTINY_STACK, ( void * ) 10, tskIDLE_PRIORITY, NULL );
+ #endif
+
+ /* Finally start the scheduler. */
+ vTaskStartScheduler();
+
+ /* Should not get here as the processor is now under control of the
+ scheduler! */
+
+ return 0;
+}
+
+void vTest(void *pvParameters)
+{
+const portTickType xDelay = 100 / portTICK_RATE_MS;
+ unsigned bit = 16;
+ unsigned dir = 0;
+
+ for(;;)
+ {
+ CLEAR_BIT(SP3SK_GPIO, bit);
+ if(dir == 0) { if(++bit == 23) { dir=1; } }
+ else { if(--bit == 16) { dir=0;} }
+ SET_BIT(SP3SK_GPIO, bit);
+ vTaskDelay( xDelay );
+ }
+}
+
+void vTest2(void *pvParameters)
+{
+const portTickType xDelay = 250 / portTICK_RATE_MS;
+ unsigned pos;
+ char marcas[] = "|/-\\";
+
+ for(;;)
+ {
+ uart1_printline("\r");
+ uart1_printline("Running...");
+ uart1_printchar(marcas[pos]);
+ if(++pos == 4) pos = 0;
+ vTaskDelay( xDelay );
+ }
+}
OpenPOWER on IntegriCloud