48 * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also |
48 * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also |
49 * used by VoE handlers. |
49 * used by VoE handlers. |
50 * - Added ecrt_master_slave() to get information about a certain slave. |
50 * - Added ecrt_master_slave() to get information about a certain slave. |
51 * - Removed 'const' from argument of ecrt_sdo_request_state(), because the |
51 * - Removed 'const' from argument of ecrt_sdo_request_state(), because the |
52 * userspace library has to modify object internals. |
52 * userspace library has to modify object internals. |
|
53 * - Added 64-bit data access macros. |
53 * |
54 * |
54 * @{ |
55 * @{ |
55 */ |
56 */ |
56 |
57 |
57 /*****************************************************************************/ |
58 /*****************************************************************************/ |
1128 |
1129 |
1129 #if __BYTE_ORDER == __LITTLE_ENDIAN |
1130 #if __BYTE_ORDER == __LITTLE_ENDIAN |
1130 |
1131 |
1131 #define le16_to_cpu(x) x |
1132 #define le16_to_cpu(x) x |
1132 #define le32_to_cpu(x) x |
1133 #define le32_to_cpu(x) x |
|
1134 #define le64_to_cpu(x) x |
1133 |
1135 |
1134 #define cpu_to_le16(x) x |
1136 #define cpu_to_le16(x) x |
1135 #define cpu_to_le32(x) x |
1137 #define cpu_to_le32(x) x |
|
1138 #define cpu_to_le64(x) x |
1136 |
1139 |
1137 #elif __BYTE_ORDER == __BIG_ENDIAN |
1140 #elif __BYTE_ORDER == __BIG_ENDIAN |
1138 |
1141 |
1139 #define swap16(x) \ |
1142 #define swap16(x) \ |
1140 ((uint16_t)( \ |
1143 ((uint16_t)( \ |
1144 ((uint32_t)( \ |
1147 ((uint32_t)( \ |
1145 (((uint32_t)(x) & 0x000000ffUL) << 24) | \ |
1148 (((uint32_t)(x) & 0x000000ffUL) << 24) | \ |
1146 (((uint32_t)(x) & 0x0000ff00UL) << 8) | \ |
1149 (((uint32_t)(x) & 0x0000ff00UL) << 8) | \ |
1147 (((uint32_t)(x) & 0x00ff0000UL) >> 8) | \ |
1150 (((uint32_t)(x) & 0x00ff0000UL) >> 8) | \ |
1148 (((uint32_t)(x) & 0xff000000UL) >> 24) )) |
1151 (((uint32_t)(x) & 0xff000000UL) >> 24) )) |
|
1152 #define swap64(x) \ |
|
1153 ((uint64_t)( \ |
|
1154 (((uint64_t)(x) & 0x00000000000000ffULL) << 56) | \ |
|
1155 (((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \ |
|
1156 (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \ |
|
1157 (((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \ |
|
1158 (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \ |
|
1159 (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \ |
|
1160 (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \ |
|
1161 (((uint64_t)(x) & 0xff00000000000000ULL) >> 56) )) |
1149 |
1162 |
1150 #define le16_to_cpu(x) swap16(x) |
1163 #define le16_to_cpu(x) swap16(x) |
1151 #define le32_to_cpu(x) swap32(x) |
1164 #define le32_to_cpu(x) swap32(x) |
|
1165 #define le64_to_cpu(x) swap64(x) |
1152 |
1166 |
1153 #define cpu_to_le16(x) swap16(x) |
1167 #define cpu_to_le16(x) swap16(x) |
1154 #define cpu_to_le32(x) swap32(x) |
1168 #define cpu_to_le32(x) swap32(x) |
|
1169 #define cpu_to_le64(x) swap64(x) |
1155 |
1170 |
1156 #endif |
1171 #endif |
1157 |
1172 |
1158 #define le16_to_cpup(x) le16_to_cpu(*((uint16_t *)(x))) |
1173 #define le16_to_cpup(x) le16_to_cpu(*((uint16_t *)(x))) |
1159 #define le32_to_cpup(x) le32_to_cpu(*((uint32_t *)(x))) |
1174 #define le32_to_cpup(x) le32_to_cpu(*((uint32_t *)(x))) |
|
1175 #define le64_to_cpup(x) le64_to_cpu(*((uint64_t *)(x))) |
1160 |
1176 |
1161 #endif /* ifndef __KERNEL__ */ |
1177 #endif /* ifndef __KERNEL__ */ |
1162 |
1178 |
1163 /****************************************************************************** |
1179 /****************************************************************************** |
1164 * Read macros |
1180 * Read macros |
1208 * \param DATA EtherCAT data pointer |
1224 * \param DATA EtherCAT data pointer |
1209 * \return EtherCAT data value |
1225 * \return EtherCAT data value |
1210 */ |
1226 */ |
1211 #define EC_READ_S32(DATA) \ |
1227 #define EC_READ_S32(DATA) \ |
1212 ((int32_t) le32_to_cpup((void *) (DATA))) |
1228 ((int32_t) le32_to_cpup((void *) (DATA))) |
|
1229 |
|
1230 /** Read a 64-bit unsigned value from EtherCAT data. |
|
1231 * |
|
1232 * \param DATA EtherCAT data pointer |
|
1233 * \return EtherCAT data value |
|
1234 */ |
|
1235 #define EC_READ_U64(DATA) \ |
|
1236 ((uint64_t) le64_to_cpup((void *) (DATA))) |
|
1237 |
|
1238 /** Read a 64-bit signed value from EtherCAT data. |
|
1239 * |
|
1240 * \param DATA EtherCAT data pointer |
|
1241 * \return EtherCAT data value |
|
1242 */ |
|
1243 #define EC_READ_S64(DATA) \ |
|
1244 ((int64_t) le64_to_cpup((void *) (DATA))) |
1213 |
1245 |
1214 /****************************************************************************** |
1246 /****************************************************************************** |
1215 * Write macros |
1247 * Write macros |
1216 *****************************************************************************/ |
1248 *****************************************************************************/ |
1217 |
1249 |
1264 * \param DATA EtherCAT data pointer |
1296 * \param DATA EtherCAT data pointer |
1265 * \param VAL new value |
1297 * \param VAL new value |
1266 */ |
1298 */ |
1267 #define EC_WRITE_S32(DATA, VAL) EC_WRITE_U32(DATA, VAL) |
1299 #define EC_WRITE_S32(DATA, VAL) EC_WRITE_U32(DATA, VAL) |
1268 |
1300 |
|
1301 /** Write a 64-bit unsigned value to EtherCAT data. |
|
1302 * |
|
1303 * \param DATA EtherCAT data pointer |
|
1304 * \param VAL new value |
|
1305 */ |
|
1306 #define EC_WRITE_U64(DATA, VAL) \ |
|
1307 do { \ |
|
1308 *((uint64_t *) (DATA)) = cpu_to_le64((uint64_t) (VAL)); \ |
|
1309 } while (0) |
|
1310 |
|
1311 /** Write a 64-bit signed value to EtherCAT data. |
|
1312 * |
|
1313 * \param DATA EtherCAT data pointer |
|
1314 * \param VAL new value |
|
1315 */ |
|
1316 #define EC_WRITE_S64(DATA, VAL) EC_WRITE_U64(DATA, VAL) |
|
1317 |
1269 /*****************************************************************************/ |
1318 /*****************************************************************************/ |
1270 |
1319 |
1271 /** @} */ |
1320 /** @} */ |
1272 |
1321 |
1273 #endif |
1322 #endif |