r6
| 1 | ||<tablealign=center><white><-11><:>스테이터스|| |
|---|
r8
| 2 | ||<white><:>분노도 ||<green><:>||<white><:>||<:>||<:>||<:>||<:>||<:>||<:>||<:>||<:>|| |
|---|
| 3 | ##||<white><:>분노도 ||<green><:>||<green><:>||<green><:>||<yellow><:>||<yellow><:>||<yellow><:>||<red><:>||<red><:>||<red><:>||<red><:>|| |
|---|
r2
| 4 | |
|---|
r3
| 5 | |
|---|
r8
| 6 | /* ------------------------------------------------------------------------- |
|---|
| 7 | Include |
|---|
| 8 | ------------------------------------------------------------------------- */ |
|---|
| 9 | #include "../ubiconfig.h" |
|---|
r3
| 10 | |
|---|
r8
| 11 | // standard c library include |
|---|
| 12 | #include <stdio.h> |
|---|
| 13 | #include <sam4e.h> |
|---|
| 14 | |
|---|
| 15 | // ubinos library include |
|---|
| 16 | #include "itf_ubinos/itf/bsp.h" |
|---|
| 17 | #include "itf_ubinos/itf/ubinos.h" |
|---|
| 18 | #include "itf_ubinos/itf/bsp_fpu.h" |
|---|
| 19 | |
|---|
| 20 | // chipset driver include |
|---|
| 21 | #include "ioport.h" |
|---|
| 22 | #include "pio/pio.h" |
|---|
| 23 | |
|---|
| 24 | // new estk driver include |
|---|
| 25 | #include "lib_new_estk_api/itf/new_estk_led.h" |
|---|
| 26 | #include "lib_new_estk_api/itf/new_estk_glcd.h" |
|---|
| 27 | #include "lib_switch/itf/lib_switch.h" |
|---|
| 28 | #include "lib_motor_driver/itf/lib_motor_driver.h" |
|---|
| 29 | #include "lib_EV3_sensor/itf/lib_EV3_sensor.h" |
|---|
| 30 | |
|---|
| 31 | // custom library header file include |
|---|
| 32 | #include "../../lib_new/itf/lib_new.h" |
|---|
| 33 | |
|---|
| 34 | // user header file include |
|---|
| 35 | /* ------------------------------------------------------------------------- |
|---|
| 36 | Global variables |
|---|
| 37 | ------------------------------------------------------------------------- */ |
|---|
| 38 | |
|---|
| 39 | /* ------------------------------------------------------------------------- |
|---|
| 40 | Prototypes |
|---|
| 41 | ------------------------------------------------------------------------- */ |
|---|
| 42 | static void rootfunc(void * arg); |
|---|
| 43 | void sw0_isr(void); |
|---|
| 44 | void sw1_isr(void); |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | /* ------------------------------------------------------------------------- |
|---|
| 48 | Function Definitions |
|---|
| 49 | ------------------------------------------------------------------------- */ |
|---|
| 50 | int usrmain(int argc, char * argv[]) { |
|---|
| 51 | int r; |
|---|
| 52 | |
|---|
| 53 | printf("\n\n\n\r"); |
|---|
| 54 | printf("================================================================================\n\r"); |
|---|
| 55 | printf("exe_ubinos_test (build time: %s %s)\n\r", __TIME__, __DATE__); |
|---|
| 56 | printf("================================================================================\n\r"); |
|---|
| 57 | |
|---|
| 58 | r = task_create(NULL, rootfunc, NULL, task_getmiddlepriority(), 256, "root"); |
|---|
| 59 | if (0 != r) { |
|---|
| 60 | logme("fail at task_create\r\n"); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | ubik_comp_start(); |
|---|
| 64 | |
|---|
| 65 | return 0; |
|---|
| 66 | } |
|---|
| 67 | void sw0_isr(void){ |
|---|
| 68 | led_toggle(LED1); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | void sw1_isr(void){ |
|---|
| 72 | led_toggle(LED2); |
|---|
| 73 | } |
|---|
| 74 | static void rootfunc(void * arg) { |
|---|
| 75 | int sensor0; |
|---|
| 76 | int MSpeed = 0; |
|---|
| 77 | |
|---|
| 78 | printf("hello world!\n\r"); |
|---|
| 79 | print_add_lib_success(); |
|---|
| 80 | |
|---|
| 81 | printf("================================================================================\n\r"); |
|---|
| 82 | printf("Initial Process Start...\r\n"); |
|---|
| 83 | printf("================================================================================\n\r"); |
|---|
| 84 | led_init(); |
|---|
| 85 | motor_init(); |
|---|
| 86 | encoder_init(); |
|---|
| 87 | glcd_init(); |
|---|
| 88 | mylib_comp_init(); |
|---|
| 89 | switch_init(sw0_isr,sw1_isr); |
|---|
| 90 | printf("switch interrupt on"); |
|---|
| 91 | ev3_sensor_init(0,COL_COLOR); |
|---|
| 92 | for(;;) |
|---|
| 93 | { |
|---|
| 94 | sensor0 = ev3_sensor_get(0); |
|---|
| 95 | /* |
|---|
| 96 | Yellow -> motor speed 500 |
|---|
| 97 | RED -> motor speed -500 |
|---|
| 98 | BLACK -> motor speed 1000 |
|---|
| 99 | */ |
|---|
| 100 | switch(sensor0) |
|---|
| 101 | { |
|---|
| 102 | case 1: |
|---|
| 103 | MSpeed = 1000; |
|---|
| 104 | break; |
|---|
| 105 | case 4: |
|---|
| 106 | MSpeed = 500; |
|---|
| 107 | break; |
|---|
| 108 | case 5: |
|---|
| 109 | MSpeed = -500; |
|---|
| 110 | break; |
|---|
| 111 | default: |
|---|
| 112 | break; |
|---|
| 113 | } |
|---|
| 114 | glcd_clear(); |
|---|
| 115 | glcdGotoChar(0,0); |
|---|
| 116 | glcd_printf("color : %d \n", sensor0); |
|---|
| 117 | glcd_printf("speed : %d \n", MSpeed); |
|---|
| 118 | motor_set(0,MSpeed); |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | task_sleep(200); |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | |
|---|