kosmos/source/test/blinky/main.c

50 lines
1.1 KiB
C
Raw Permalink Normal View History

2016-08-15 14:11:00 +00:00
//
// This file is part of the GNU ARM Eclipse distribution.
// Copyright (c) 2014 Liviu Ionescu.
//
2016-08-16 11:08:49 +00:00
#include <stdbool.h>
2016-08-15 14:11:00 +00:00
#include <stdio.h>
#include <stdlib.h>
2016-08-16 11:08:49 +00:00
#include "stack.h"
#include "queue.h"
#include "kernel.h"
2016-08-15 20:25:35 +00:00
#include "board.h"
#include "driver.h"
2016-08-15 14:11:00 +00:00
// Sample pragmas to cope with warnings. Please note the related line at
// the end of this function, used to pop the compiler diagnostics status.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wreturn-type"
2016-08-16 11:08:49 +00:00
#define TH_STACK_SIZE 256
stack_t th_stack[TH_STACK_SIZE];
struct thread_context th_ctx;
static void th_func(void *arg)
2016-08-15 14:11:00 +00:00
{
2016-08-15 20:25:35 +00:00
drv_open(&gpio_d12);
2016-08-16 11:08:49 +00:00
drv_write(&gpio_d12, "0", 1);
2016-08-15 19:41:22 +00:00
while(1) {
2016-08-16 11:08:49 +00:00
sleep_ms(1000);
2016-08-15 20:25:35 +00:00
drv_write(&gpio_d12, "1", 1);
2016-08-16 11:08:49 +00:00
sleep_ms(1000);
2016-08-15 20:25:35 +00:00
drv_write(&gpio_d12, "0", 1);
2016-08-15 19:41:22 +00:00
}
2016-08-15 14:11:00 +00:00
}
2016-08-16 11:08:49 +00:00
int main(int argc, char* argv[])
{
board_init();
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
schedule_start();
return 0;
}
2016-08-15 14:11:00 +00:00
#pragma GCC diagnostic pop