00001 00008 /* Includes */ 00009 #include "esos_comm_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; //toggle the HEARTBEAT LED 00021 } 00022 ESOS_TASK_END(); 00023 } 00024 00029 static ESOS_USER_TASK(hello) { 00030 ESOS_TASK_BEGIN(); 00031 ESOS_TASK_WAIT_ON_SEND_STRING("Comm initialized.\n"); 00032 ESOS_TASK_END(); 00033 } 00034 00044 void divvy_packet(void) { 00045 if (CommGetInDataIsValid()) { 00046 /* A packet may have been dropped but it is safe to distribute 00047 * the current packet. */ 00048 uint8 u8_test = CommGetInDataUInt8(); 00049 int8 i8_test = CommGetInDataInt8(); 00050 uint16 u16_test = CommGetInDataUInt16(); 00051 int16 i16_test = CommGetInDataInt16(); 00052 uint32 u32_test = CommGetInDataUInt32(); 00053 int32 i32_test = CommGetInDataInt32(); 00054 uint8 u8_error = CommGetInDataUInt8Error(); 00055 00056 CommPutOutDataUInt8(u8_error); 00057 CommPutOutDataUInt8(++u8_test); 00058 CommPutOutDataInt8(++i8_test); 00059 CommPutOutDataUInt16(++u16_test); 00060 CommPutOutDataInt16(++i16_test); 00061 CommPutOutDataUInt32(++u32_test); 00062 CommPutOutDataInt32(++i32_test); 00063 } else { 00064 /* The packet is not framed correctly, echo for troubleshooting. */ 00065 uint8 u8_test = CommGetInDataUInt8(); 00066 int8 i8_test = CommGetInDataInt8(); 00067 uint16 u16_test = CommGetInDataUInt16(); 00068 int16 i16_test = CommGetInDataInt16(); 00069 uint32 u32_test = CommGetInDataUInt32(); 00070 int32 i32_test = CommGetInDataInt32(); 00071 uint8 u8_error = CommGetInDataUInt8Error(); 00072 00073 /* Update the error bit, the old packet is re-sent. */ 00074 CommPutOutDataUInt8(u8_error); 00075 CommPutOutDataUInt8(u8_test); 00076 CommPutOutDataInt8(i8_test); 00077 CommPutOutDataUInt16(u16_test); 00078 CommPutOutDataInt16(i16_test); 00079 CommPutOutDataUInt32(u32_test); 00080 CommPutOutDataInt32(i32_test); 00081 } 00082 } 00083 00084 /* 00085 * This function is called by ESOS during initialization. From here, you may call 00086 * any initialization functions you want. The developer can make no assumptions about 00087 * task scheduling or timing. 00088 */ 00089 void user_init(void) { 00090 CONFIG_HEARTBEAT(); //HEARTBEAT LED is RB15, set as digital output 00091 00092 esos_RegisterTask(heartbeat); 00093 esos_RegisterTask(hello); 00094 initialize_comm(); 00095 }