From d309dc0217fe6e0165f1f425503f4f6112a3914d Mon Sep 17 00:00:00 2001 From: Julian T Date: Mon, 8 Jun 2020 11:50:57 +0200 Subject: =?UTF-8?q?F=C3=A6rdiggjorde=20embedded.=20Bestod=20:-D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sem4/embedded/m7/m7.ino | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sem4/embedded/m7/m7.ino (limited to 'sem4/embedded/m7/m7.ino') diff --git a/sem4/embedded/m7/m7.ino b/sem4/embedded/m7/m7.ino new file mode 100644 index 0000000..27b1ea2 --- /dev/null +++ b/sem4/embedded/m7/m7.ino @@ -0,0 +1,51 @@ +#include +#define STACK 200 + +char stk1[STACK]; +char stk2[STACK]; +struct k_t *tsk1, *tsk2, *sem1, *sem2; + +#define DELAY 100000 +void f1() { + k_set_sem_timer(sem1, 50); + for(;;) { + k_wait(sem1, 0); + PORTD &= ~(1 << 5); + PORTD |= (1 << 4); + k_eat_msec_time(20); + PORTD &= ~(1 << 4); + } +} + +void f2() { + k_set_sem_timer(sem2, 80); + for(;;) { + k_wait(sem2, 0); + PORTD &= ~(1 << 5); + PORTD |= (1 << 3); + k_eat_msec_time(20); + PORTD &= ~(1 << 3); + } +} + +void setup() { + pinMode(13, OUTPUT); + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(115200); + Serial.println("Starting"); + + k_init(2, 2, 0); + + sem1 = k_crt_sem(0, 1); + sem2 = k_crt_sem(0, 1); + + tsk1 = k_crt_task(f1, 10, stk1, STACK); + tsk2 = k_crt_task(f2, 10, stk2, STACK); + + k_start(1); +} + +void loop() { + +} -- cgit v1.2.3