initial commit

This commit is contained in:
tkl
2016-07-23 07:59:54 +02:00
commit cb58a410f1
1378 changed files with 372066 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
INCLUDES += application/example_semaphore
DOC_SRC += application/example_semaphore
SUB_FOLDER += application/example_semaphore

View File

@@ -0,0 +1,51 @@
#include <stdbool.h>
#include "board.h"
#include "ctx.h"
#include "stack.h"
#include "queue.h"
#include "thread.h"
#include "schedule.h"
#include "isr.h"
#include "sys_tick.h"
#include "semaphore.h"
#define STACK_SIZE 256
static stack_t tc_1_stack[STACK_SIZE];
static struct thread_context tc_1;
static stack_t tc_2_stack[STACK_SIZE];
static struct thread_context tc_2;
static struct semaphore sem;
void task2(void *arg)
{
gpio_open(&led_1);
gpio_write(&led_1, 0);
while(1) {
semaphore_wait(&sem);
gpio_toggle(&led_1);
}
}
void task1(void *arg)
{
while(1) {
sleep_ms(3000);
semaphore_post(&sem);
}
}
int main(void)
{
board_init();
sys_tick_init(&timer_1);
semaphore_init( &sem, 0);
thread_create(&tc_1, tc_1_stack, STACK_SIZE, task1, NULL, THREAD_PRIO_LOW);
thread_create(&tc_2, tc_2_stack, STACK_SIZE, task2, NULL, THREAD_PRIO_LOW);
schedule_start();
return 0;
}