engine_control/source/application/test/main.c

59 lines
1.0 KiB
C
Raw Normal View History

2016-07-23 05:59:54 +00:00
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.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 "ascii_font.h"
#include "bitmap.h"
#define STACK_SIZE 256
stack_t tc_1_stack[STACK_SIZE];
struct thread_context tc_1;
void task1(void *arg)
{
gpio_open(&led_1);
gpio_write(&led_1, 0);
while(1) {
sleep_ms(1000);
gpio_toggle(&led_1);
uart_write(&uart_1, "Hello world\r\n", 13);
2016-07-23 05:59:54 +00:00
}
}
char rx_buf[80];
void task2(void *arg)
{
while(1) {
int i = uart_read(&uart_1, rx_buf, 80);
if(i > 0) {
uart_write(&uart_1, rx_buf, i);
}
}
}
stack_t tc_2_stack[STACK_SIZE];
struct thread_context tc_2;
2016-07-23 05:59:54 +00:00
int main(void)
{
board_init();
sys_tick_init(&timer_1);
uart_open(&uart_1);
2016-07-23 05:59:54 +00:00
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);
2016-07-23 05:59:54 +00:00
schedule_start();
return 0;
}