00001
00008
00009 #include "esos_motor_example_config.h"
00010
00016 static ESOS_USER_TASK(heartbeat) {
00017 ESOS_TASK_BEGIN();
00018 while (TRUE) {
00019 ESOS_TASK_WAIT_TICKS(HALF_HEARTBEAT_PERIOD);
00020 HEARTBEAT = !HEARTBEAT;
00021 }
00022 ESOS_TASK_END();
00023 }
00024
00033 ESOS_USER_TASK(motor_demo) {
00034 static uint8 u8_state = 0;
00035
00036 ESOS_TASK_BEGIN();
00037 while (TRUE) {
00038 ESOS_TASK_WAIT_TICKS(3000);
00039 if (u8_state == 0) {
00040 update_motor_3(MOTOR_3_1, MOTOR_FORWARD, usToU16Ticks(300, MOTOR_PRESCALER_3));
00041 u8_state++;
00042 } else if (u8_state == 1) {
00043 update_motor_3(MOTOR_3_1, MOTOR_FORWARD, usToU16Ticks(400, MOTOR_PRESCALER_3));
00044 u8_state++;
00045 } else if (u8_state == 2) {
00046 update_motor_3(MOTOR_3_1, MOTOR_COAST, 0);
00047 u8_state++;
00048 } else if (u8_state == 3) {
00049 update_motor_3(MOTOR_3_1, MOTOR_REVERSE, usToU16Ticks(300, MOTOR_PRESCALER_3));
00050 u8_state++;
00051 } else if (u8_state == 4) {
00052 update_motor_3(MOTOR_3_1, MOTOR_REVERSE, usToU16Ticks(400, MOTOR_PRESCALER_3));
00053 u8_state++;
00054 } else if (u8_state == 5) {
00055 update_motor_3(MOTOR_3_1, MOTOR_BRAKEH, usToU16Ticks(300, MOTOR_PRESCALER_3));
00056 u8_state++;
00057 } else if (u8_state == 6) {
00058 update_motor_3(MOTOR_3_1, MOTOR_BRAKEL, usToU16Ticks(300, MOTOR_PRESCALER_3));
00059 u8_state = 0;
00060 } else {
00061 u8_state = 0;
00062 }
00063 }
00064 ESOS_TASK_END();
00065 }
00066
00067
00068
00069
00070
00071
00072 void user_init(void) {
00073 CONFIG_HEARTBEAT();
00074
00075 esos_RegisterTask(heartbeat);
00076 esos_RegisterTask(motor_demo);
00077 initialize_motor_3();
00078 }