Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __ethercat_defs_h__
00034 #define __ethercat_defs_h__
00035
00036
00037
00038
00039 #include <stdint.h>
00040 #include <string.h>
00041 inline uint16_t le16_to_cpu(uint16_t data)
00042 {
00043 return data;
00044 }
00045 inline uint16_t le16_to_cpu(int16_t data)
00046 {
00047 return (uint16_t) data;
00048 }
00049 inline uint32_t le32_to_cpu(uint32_t data)
00050 {
00051 return data;
00052 }
00053 inline uint32_t le32_to_cpu(int32_t data)
00054 {
00055 return (uint32_t) data;
00056 }
00057 inline uint16_t cpu_to_le16(uint16_t data)
00058 {
00059 return data;
00060 }
00061 inline uint16_t cpu_to_le16(int16_t data)
00062 {
00063 return (uint16_t) data;
00064 }
00065 inline uint32_t cpu_to_le32(uint32_t data)
00066 {
00067 return data;
00068 }
00069 inline uint32_t cpu_to_le32(int32_t data)
00070 {
00071 return (uint32_t) data;
00072 }
00073 inline unsigned char * host2nw(unsigned char * a_buffer, int8_t a_value)
00074 {
00075 *a_buffer++ = static_cast<unsigned char> (a_value);
00076 return a_buffer;
00077 }
00078 inline unsigned char * host2nw(unsigned char * a_buffer, uint8_t a_value)
00079 {
00080 *a_buffer++ = static_cast<unsigned char> (a_value);
00081 return a_buffer;
00082 }
00083 inline unsigned char * host2nw(unsigned char * a_buffer, int16_t a_value)
00084 {
00085 uint16_t tmp = cpu_to_le16(a_value);
00086 memcpy(a_buffer, &tmp, sizeof (tmp));
00087 return a_buffer + sizeof (tmp);
00088 }
00089 inline unsigned char * host2nw(unsigned char * a_buffer, uint16_t a_value)
00090 {
00091 uint16_t tmp = cpu_to_le16(a_value);
00092 memcpy(a_buffer, &tmp, sizeof (tmp));
00093 return a_buffer + sizeof (tmp);
00094 }
00095 inline unsigned char * host2nw(unsigned char * a_buffer, int32_t a_value)
00096 {
00097 uint32_t tmp = cpu_to_le32(a_value);
00098 memcpy(a_buffer, &tmp, sizeof (tmp));
00099 return a_buffer + sizeof (tmp);
00100 }
00101 inline unsigned char * host2nw(unsigned char * a_buffer, uint32_t a_value)
00102 {
00103 uint32_t tmp = cpu_to_le32(a_value);
00104 memcpy(a_buffer, &tmp, sizeof (tmp));
00105 return a_buffer + sizeof (tmp);
00106 }
00107 inline unsigned char * host2nw(unsigned char * a_buffer, const unsigned char * a_data,
00108 size_t a_datalen)
00109 {
00110 memcpy(a_buffer, a_data, a_datalen);
00111 return a_buffer + a_datalen;
00112 }
00113 inline const unsigned char * nw2host(const unsigned char * a_data, int8_t& a_value)
00114 {
00115 a_value = static_cast<int8_t> (*a_data);
00116 return a_data + sizeof (a_value);
00117 }
00118 inline const unsigned char * nw2host(const unsigned char * a_data, uint8_t& a_value)
00119 {
00120 a_value = static_cast<uint8_t> (*a_data);
00121 return a_data + sizeof (a_value);
00122 }
00123 inline const unsigned char * nw2host(const unsigned char * a_data, int16_t& a_value)
00124 {
00125 uint16_t tmp;
00126 memcpy(&tmp, a_data, sizeof (tmp));
00127 tmp = le16_to_cpu(tmp);
00128
00129 a_value = static_cast<int16_t> (tmp);
00130 return a_data + sizeof (a_value);
00131 }
00132 inline const unsigned char * nw2host(const unsigned char * a_data, uint16_t& a_value)
00133 {
00134 uint16_t tmp;
00135 memcpy(&tmp, a_data, sizeof (tmp));
00136 tmp = le16_to_cpu(tmp);
00137
00138 a_value = tmp;
00139 return a_data + sizeof (a_value);
00140 }
00141 inline const unsigned char * nw2host(const unsigned char * a_data, int32_t& a_value)
00142 {
00143 uint32_t tmp;
00144 memcpy(&tmp, a_data, sizeof (tmp));
00145 tmp = le32_to_cpu(tmp);
00146
00147 a_value = static_cast<int32_t> (tmp);
00148 return a_data + sizeof (a_value);
00149 }
00150 inline const unsigned char * nw2host(const unsigned char * a_data, uint32_t& a_value)
00151 {
00152 uint32_t tmp;
00153 memcpy(&tmp, a_data, sizeof (tmp));
00154 tmp = le32_to_cpu(tmp);
00155
00156 a_value = static_cast<uint32_t> (tmp);
00157 return a_data + sizeof (a_value);
00158 }
00159
00160 #endif // __ethercat_defs_h__
ros_ethercat_eml
Author(s): Tom Panis, Klaas Gadeyne, Bob Koninckx, Austin Hendrix, Manos Nikolaidis
autogenerated on Thu Jul 4 2019 20:01:49