[주의!] 문서의 이전 버전(에 수정)을 보고 있습니다. 최신 버전으로 이동
스테이터스 | ||||||||||
분노도 | ||||||||||
/*
Include
#include "../ubiconfig.h"
// standard c library include
#include <stdio.h>
#include <sam4e.h>
// ubinos library include
#include "itf_ubinos/itf/bsp.h"
#include "itf_ubinos/itf/ubinos.h"
#include "itf_ubinos/itf/bsp_fpu.h"
// chipset driver include
#include "ioport.h"
#include "pio/pio.h"
// new estk driver include
#include "lib_new_estk_api/itf/new_estk_led.h"
#include "lib_new_estk_api/itf/new_estk_glcd.h"
#include "lib_switch/itf/lib_switch.h"
#include "lib_motor_driver/itf/lib_motor_driver.h"
#include "lib_EV3_sensor/itf/lib_EV3_sensor.h"
// custom library header file include
#include "../../lib_new/itf/lib_new.h"
// user header file include
/*-
Global variables
// standard c library include
#include <stdio.h>
#include <sam4e.h>
// ubinos library include
#include "itf_ubinos/itf/bsp.h"
#include "itf_ubinos/itf/ubinos.h"
#include "itf_ubinos/itf/bsp_fpu.h"
// chipset driver include
#include "ioport.h"
#include "pio/pio.h"
// new estk driver include
#include "lib_new_estk_api/itf/new_estk_led.h"
#include "lib_new_estk_api/itf/new_estk_glcd.h"
#include "lib_switch/itf/lib_switch.h"
#include "lib_motor_driver/itf/lib_motor_driver.h"
#include "lib_EV3_sensor/itf/lib_EV3_sensor.h"
// custom library header file include
#include "../../lib_new/itf/lib_new.h"
// user header file include
/*
Global variables
/*
Prototypes
static void rootfunc(void * arg);
void sw0_isr(void);
void sw1_isr(void);
/*-
Function Definitions
void sw0_isr(void);
void sw1_isr(void);
/*
Function Definitions
int usrmain(int argc, char * argv[]) {
int r;
printf("nnnr");
printf("================================================================================nr");
printf("exe_ubinos_test (build time: %s %s)nr", TIME, DATE);
printf("================================================================================nr");
r = task_create(NULL, rootfunc, NULL, task_getmiddlepriority(), 256, "root");
if (0 != r) {
logme("fail at task_creatern");
}
ubik_comp_start();
return 0;
}
void sw0_isr(void){
led_toggle(LED1);
}
void sw1_isr(void){
led_toggle(LED2);
}
static void rootfunc(void * arg) {
int sensor0;
int MSpeed = 0;
printf("hello world!nr");
print_add_lib_success();
printf("================================================================================nr");
printf("Initial Process Start...rn");
printf("================================================================================nr");
led_init();
motor_init();
encoder_init();
glcd_init();
mylib_comp_init();
switch_init(sw0_isr,sw1_isr);
printf("switch interrupt on");
ev3_sensor_init(0,COL_COLOR);
for(;;)
{
sensor0 = ev3_sensor_get(0);
/*
int r;
printf("nnnr");
printf("================================================================================nr");
printf("exe_ubinos_test (build time: %s %s)nr", TIME, DATE);
printf("================================================================================nr");
r = task_create(NULL, rootfunc, NULL, task_getmiddlepriority(), 256, "root");
if (0 != r) {
logme("fail at task_creatern");
}
ubik_comp_start();
return 0;
}
void sw0_isr(void){
led_toggle(LED1);
}
void sw1_isr(void){
led_toggle(LED2);
}
static void rootfunc(void * arg) {
int sensor0;
int MSpeed = 0;
printf("hello world!nr");
print_add_lib_success();
printf("================================================================================nr");
printf("Initial Process Start...rn");
printf("================================================================================nr");
led_init();
motor_init();
encoder_init();
glcd_init();
mylib_comp_init();
switch_init(sw0_isr,sw1_isr);
printf("switch interrupt on");
ev3_sensor_init(0,COL_COLOR);
for(;;)
{
sensor0 = ev3_sensor_get(0);
/*
Yellow -> motor speed 500
RED -> motor speed -500
BLACK -> motor speed 1000
*/
switch(sensor0)
{
case 1:
MSpeed = 1000;
break;
case 4:
MSpeed = 500;
break;
case 5:
MSpeed = -500;
break;
default:
break;
}
glcd_clear();
glcdGotoChar(0,0);
glcd_printf("color : %d n", sensor0);
glcd_printf("speed : %d n", MSpeed);
motor_set(0,MSpeed);
task_sleep(200);
}
}
BLACK -> motor speed 1000
*/
switch(sensor0)
{
case 1:
MSpeed = 1000;
break;
case 4:
MSpeed = 500;
break;
case 5:
MSpeed = -500;
break;
default:
break;
}
glcd_clear();
glcdGotoChar(0,0);
glcd_printf("color : %d n", sensor0);
glcd_printf("speed : %d n", MSpeed);
motor_set(0,MSpeed);
task_sleep(200);
}
}