engine_control/source/application/test/main.c
2016-07-28 17:01:49 +02:00

58 lines
991 B
C

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "driver.h"
#include "board_devices.h"
#include "stack.h"
#include "queue.h"
#include "kernel.h"
#include "driver.h"
#define STACK_SIZE 256
stack_t tc_1_stack[STACK_SIZE];
struct thread_context tc_1;
void task1(void *arg)
{
char rd = '0';
open(&led_4);
write(&led_4, &rd, 1);
while(1) {
sleep_ms(1000);
read(&led_4, &rd, 1);
if(rd == '0')
rd = '1';
else
rd = '0';
write(&led_4, &rd, 1);
write(&uart_1, "Driver test\r\n", 13);
}
}
char rx_buf[80];
void task2(void *arg)
{
while(1) {
int i = read(&uart_1, rx_buf, 80);
if(i > 0) {
write(&uart_1, rx_buf, i);
}
}
}
stack_t tc_2_stack[STACK_SIZE];
struct thread_context tc_2;
int main(void)
{
open(&uart_1);
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;
}