Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
net.hpp
00001 #ifndef __NET_H__ 00002 #define __NET_H__ 00003 00004 #include "common_types.h" 00005 00006 #define CAN_FLAG_EMPTY 0x00 00007 #define CAN_FLAG_RECEIVED 0x01 00008 #define CAN_FLAG_SEND 0x02 00009 00010 #define CAN_THREAD_PERIOD 100 //ms 00011 00012 00013 00014 #define CMD_ECHO 0x0A0A 00015 00016 /************************************************** 00017 * GLOBAL DEFINES 00018 **************************************************/ 00019 #define CAN_CMD_BODY_ID 0xAA 00020 #define CAN_STS_BODY_ID 0xAB 00021 #define CAN_CMD_ENGINE_ID 0x0A 00022 #define CAN_CMD_TIME_ID 0xBB 00023 #define CAN_CMD_DRIVER_ID 0x11 00024 #define CAN_STS_DRIVER_ID 0x10 00025 00026 #define PERIOD_3s (3000/CAN_THREAD_PERIOD) 00027 #define PERIOD_1s (1000/CAN_THREAD_PERIOD) 00028 #define PERIOD_500ms (500/CAN_THREAD_PERIOD) 00029 #define PERIOD_400ms (400/CAN_THREAD_PERIOD) 00030 #define PERIOD_300ms (300/CAN_THREAD_PERIOD) 00031 #define PERIOD_200ms (200/CAN_THREAD_PERIOD) 00032 #define PERIOD_100ms (100/CAN_THREAD_PERIOD) 00033 00034 #define CAN_STS_BODY_PERIOD PERIOD_1s 00035 00036 00037 #define CAN_MISSING_DETECTION PERIOD_3s 00038 00039 #define CAN_MISSING_BODY_ID 0 00040 #define CAN_MISSING_ENGINE_ID 1 00041 #define CAN_MISSING_TIME_ID 2 00042 00043 #define CAN_RX_PERIODIC_MSG 3 00044 00045 /************************************************** 00046 * GLOBAL TYPES 00047 **************************************************/ 00048 #define CAN_CMD_PAYLOAD_BODY 4 00049 #define CAN_STS_PAYLOAD_BODY 8 00050 #define CAN_CMD_PAYLOAD_ENGINE 4 00051 #define CAN_CMD_PAYLOAD_TIME 4 00052 #define CAN_CMD_PAYLOAD_DRIVER 8 00053 #define CAN_STS_PAYLOAD_DRIVER 4 00054 00055 typedef union can_cmd_body_payload_s { 00056 uint8 buf[CAN_CMD_PAYLOAD_BODY]; 00057 struct { 00058 uint32 light_r:1; 00059 uint32 light_c:1; 00060 uint32 light_l:1; 00061 uint32 unused:29; 00062 } msg; 00063 } can_cmd_body_payload_t; 00064 typedef struct can_cmd_body_s { 00065 can_cmd_body_payload_t payload; 00066 uint8 flag; 00067 } can_cmd_body_t; 00068 00069 typedef union can_sts_body_payload_s { 00070 uint8 buf[CAN_STS_PAYLOAD_BODY]; 00071 struct { 00072 uint32 hit_front:1; 00073 uint32 hit_rear:1; 00074 uint32 hit_left:1; 00075 uint32 hit_right:1; 00076 uint32 light_sens:1; 00077 uint32 unused:3; 00078 uint32 eye_back_l:8; 00079 uint32 eye_back_r:8; 00080 uint32 eye_front:16; 00081 } msg; 00082 } can_sts_body_payload_t; 00083 typedef struct can_sts_body_s { 00084 can_sts_body_payload_t payload; 00085 uint8 flag; 00086 } can_sts_body_t; 00087 00088 typedef union can_cmd_engine_payload_s { 00089 uint8 buf[CAN_CMD_PAYLOAD_BODY]; 00090 struct { 00091 uint32 steering:8; 00092 uint32 power:8; 00093 uint32 direction:1; 00094 uint32 breaking:1; 00095 uint32 unused:14; 00096 } msg; 00097 } can_cmd_engine_payload_t; 00098 typedef struct can_cmd_engine_s { 00099 can_cmd_engine_payload_t payload; 00100 uint8 flag; 00101 } can_cmd_engine_t; 00102 00103 typedef union can_cmd_time_payload_s { 00104 uint8 buf[CAN_CMD_PAYLOAD_TIME]; 00105 struct { 00106 uint32 time; 00107 } msg; 00108 } can_cmd_time_payload_t; 00109 typedef struct can_cmd_time_s { 00110 can_cmd_time_payload_t payload; 00111 uint8 flag; 00112 } can_cmd_time_t; 00113 00114 typedef union can_cmd_driver_payload_s { 00115 uint8 buf[CAN_CMD_PAYLOAD_DRIVER]; 00116 struct { 00117 uint32 cmd:16; 00118 uint32 opt:16; 00119 uint32 data; 00120 } msg; 00121 } can_cmd_driver_payload_t; 00122 typedef struct can_cmd_driver_s { 00123 can_cmd_driver_payload_t payload; 00124 uint8 flag; 00125 } can_cmd_driver_t; 00126 00127 typedef union can_sts_driver_payload_s { 00128 uint8 buf[CAN_STS_PAYLOAD_DRIVER]; 00129 struct { 00130 uint32 data; 00131 } msg; 00132 } can_sts_driver_payload_t; 00133 typedef struct can_sts_driver_time_s { 00134 can_sts_driver_payload_t payload; 00135 uint8 flag; 00136 } can_sts_driver_t; 00137 00138 /************************************************** 00139 * DATA STRUCTURES 00140 **************************************************/ 00141 00142 00143 #endif //__NET_H__
Generated on Fri Jul 29 2022 02:07:14 by
1.7.2