]> Zhao Yanbai Git Server - acecode.git/commitdiff
...
authorAceVest <zhaoyanbai@126.com>
Mon, 18 Jun 2018 08:08:43 +0000 (16:08 +0800)
committerAceVest <zhaoyanbai@126.com>
Mon, 18 Jun 2018 08:08:43 +0000 (16:08 +0800)
arduino/hardware/ace/avr/cores/avr/AceAvr.h
arduino/hardware/ace/avr/cores/avr/app.cpp [new file with mode: 0644]
arduino/hardware/ace/avr/cores/avr/kernel.cpp
arduino/hardware/ace/avr/cores/avr/kernel.h

index 9324addd7016b0d072a4f1c0ad070ada9034c90f..5bae26b24c37d1cb1666258f0f05599ba5d8376f 100644 (file)
@@ -13,6 +13,9 @@
 #include <avr/pgmspace.h>
 #include <avr/interrupt.h>
 
+#include <HardwareSerial.h>
+#include <kernel.h>
+
 #define LOW  0
 #define HIGH 1
 
diff --git a/arduino/hardware/ace/avr/cores/avr/app.cpp b/arduino/hardware/ace/avr/cores/avr/app.cpp
new file mode 100644 (file)
index 0000000..1806ef3
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: app.cpp
+ *      Author: Zhao Yanbai
+ *              2018-06-18 16:01:26 Monday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+#include <AceAvr.h>
+
+uint8_t debug_task_stack[TASK_STACK_SIZE];
+void debug_task() {
+    while(1) {
+        Serial.println("debug task");
+        task_delay(1000);
+    }
+}
+
+uint8_t led_task_stack[TASK_STACK_SIZE];
+void led_task() {
+    uint8_t pin = 13;
+    set_digital_pin_mode(pin, OUTPUT);
+    while(1) {
+        digital_write(pin, HIGH);
+        task_delay(10);
+        digital_write(pin, LOW);
+        task_delay(10);
+    }
+}
+
+uint8_t user_task1_stack[TASK_STACK_SIZE];
+void user_task1() {
+    while(1) {
+        Serial.println("user task 1");
+        task_delay(100);
+    }
+}
+
+
+
+
+void app_main() {
+    Serial.begin(9600);
+    create_task(led_task, led_task_stack, 0);
+    create_task(user_task1, user_task1_stack, 1);
+    create_task(debug_task, debug_task_stack, 3);
+}
+
+
index df4f042e11715160dca39d56525b521f8d3ce1ff..64a571fa8964e54a48379ad730707262e8af0331 100644 (file)
@@ -8,7 +8,6 @@
  */
 #include <AceAvr.h>
 #include <kernel.h>
-#include <HardwareSerial.h>
 
 void delay(unsigned long ms);
 
@@ -25,46 +24,15 @@ int8_t kernel_initialized = 0;
 
 void task_scheduler();
 
-uint8_t debug_task_stack[TASK_STACK_SIZE];
-void debug_task() {
-    Serial.begin(9600);
-
-    while(1) {
-        Serial.println("fuck");
-        task_delay(100);
-    }
-
-    while(1) task_delay(1000);
-    uint8_t pin = 12;
-    set_digital_pin_mode(pin, OUTPUT);
-    while(1) {
-        digital_write(pin, HIGH);
-        task_delay(20);
-        digital_write(pin, LOW);
-        task_delay(20);
-    }
-}
-
-uint8_t led_task_stack[TASK_STACK_SIZE];
-void led_task() {
-    uint8_t pin = 13;
-    set_digital_pin_mode(pin, OUTPUT);
-    while(1) {
-        digital_write(pin, HIGH);
-        task_delay(10);
-        digital_write(pin, LOW);
-        task_delay(10);
-    }
-}
-
-
 // idle_task 在没有进程READY的情况下都会调度运行
 // 所以task_delay不能在此进程生效
 uint8_t idle_task_stack[TASK_STACK_SIZE];
 uint32_t idle_cnt = 0;
+void app_main();
 void idle_task() {
     sei();
     kernel_initialized = 1;
+    app_main();
     uint8_t pin = 12;
     set_digital_pin_mode(pin, OUTPUT);
     uint8_t state = LOW;
@@ -296,8 +264,6 @@ void init_tasks() {
         t->delay_ticks  = 0;
     }
 
-    create_task(led_task, led_task_stack, 0);
-    create_task(debug_task, debug_task_stack, 1);
     create_task(idle_task, idle_task_stack, idle_task_priority);
     current_task = IDLE_TASK;
     IDLE_TASK->stack = idle_task_stack+TASK_STACK_SIZE - 3;
index 6cf0863ee3073e8cb5fb52f34d94a493e92ae68b..517f19e4cdeae3265a404c8496e61096614e0932 100644 (file)
@@ -32,7 +32,7 @@ struct task {
 };
 
 void init_tasks();
-void create_task(void (*handler)(), char *stack, uint8_t priority);
+void create_task(void (*handler)(), uint8_t *stack, uint8_t priority);
 void task_switch(struct task *prev, struct task *next);
 void task_delay(uint16_t ticks);
 //void yield(void);