EtherCAT slave that reads 3 Xsens IMU's connected to a Xbus Master
Dependencies: MODSERIAL mbed KL25Z_ClockControl
Fork of EtherCAT by
utypes.h
00001 /* 00002 * SOES Simple Open EtherCAT Slave 00003 * 00004 * File : utype.h 00005 * Version : 1.0.0 00006 * Date : 11-07-2010 00007 * Copyright (C) 2007-2010 Arthur Ketels 00008 * 00009 * SOES is free software; you can redistribute it and/or modify it under 00010 * the terms of the GNU General Public License version 2 as published by the Free 00011 * Software Foundation. 00012 * 00013 * SOES is distributed in the hope that it will be useful, but WITHOUT ANY 00014 * WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 * for more details. 00017 * 00018 * As a special exception, if other files instantiate templates or use macros 00019 * or inline functions from this file, or you compile this file and link it 00020 * with other works to produce a work based on this file, this file does not 00021 * by itself cause the resulting work to be covered by the GNU General Public 00022 * License. However the source code for this file must still be made available 00023 * in accordance with section (3) of the GNU General Public License. 00024 * 00025 * This exception does not invalidate any other reasons why a work based on 00026 * this file might be covered by the GNU General Public License. 00027 * 00028 * The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual 00029 * property of, and protected by Beckhoff Automation GmbH. 00030 */ 00031 00032 #ifndef _UTYPES_H_ 00033 #define _UTYPES_H_ 00034 00035 #include <stdint.h> 00036 #define uint8 uint8_t 00037 #define int8 int8_t 00038 #define uint16 uint16_t 00039 #define int16 int16_t 00040 #define uint32 uint32_t 00041 #define int32 int32_t 00042 #define APPSTATE_IDLE 0x00 00043 #define APPSTATE_INPUT 0x01 00044 #define APPSTATE_OUTPUT 0x02 00045 00046 typedef union 00047 { 00048 uint16 w; 00049 uint8 b[2]; 00050 } uint16union; 00051 00052 typedef struct __attribute__((packed)) 00053 { 00054 float q0; 00055 float q1; 00056 float q2; 00057 float q3; 00058 uint16_t samplecounter; 00059 00060 /* float acc[3]; 00061 float gyr[3]; 00062 float mag[3];*/ 00063 }xsense_slave; 00064 00065 typedef struct __attribute__((packed)) 00066 { 00067 //uint8 state; 00068 xsense_slave xsens_imu[3]; 00069 //xsense_slave second; 00070 //xsense_slave third; 00071 //uint16 timestamp; 00072 } _Rbuffer; 00073 00074 typedef struct 00075 { 00076 uint8 correct_offset; 00077 } _Wbuffer; 00078 00079 typedef struct 00080 { 00081 uint16 setting16; 00082 uint8 setting8; 00083 } _Ebuffer; 00084 00085 extern uint8 APPstate; 00086 extern _Rbuffer Rb; 00087 extern _Wbuffer Wb; 00088 extern _Ebuffer Eb; 00089 00090 #define EC_LITTLE_ENDIAN 00091 00092 #if !defined(EC_BIG_ENDIAN) && defined(EC_LITTLE_ENDIAN) 00093 00094 #define htoes(A) (A) 00095 #define htoel(A) (A) 00096 #define htoell(A) (A) 00097 #define etohs(A) (A) 00098 #define etohl(A) (A) 00099 #define etohll(A) (A) 00100 00101 #elif !defined(EC_LITTLE_ENDIAN) && defined(EC_BIG_ENDIAN) 00102 00103 #define htoes(A) ((((uint16)(A) & 0xff00) >> 8) | \ 00104 (((uint16)(A) & 0x00ff) << 8)) 00105 #define htoel(A) ((((uint32)(A) & 0xff000000) >> 24) | \ 00106 (((uint32)(A) & 0x00ff0000) >> 8) | \ 00107 (((uint32)(A) & 0x0000ff00) << 8) | \ 00108 (((uint32)(A) & 0x000000ff) << 24)) 00109 #define htoell(A) ((((uint64)(A) & (uint64)0xff00000000000000ULL) >> 56) | \ 00110 (((uint64)(A) & (uint64)0x00ff000000000000ULL) >> 40) | \ 00111 (((uint64)(A) & (uint64)0x0000ff0000000000ULL) >> 24) | \ 00112 (((uint64)(A) & (uint64)0x000000ff00000000ULL) >> 8) | \ 00113 (((uint64)(A) & (uint64)0x00000000ff000000ULL) << 8) | \ 00114 (((uint64)(A) & (uint64)0x0000000000ff0000ULL) << 24) | \ 00115 (((uint64)(A) & (uint64)0x000000000000ff00ULL) << 40) | \ 00116 (((uint64)(A) & (uint64)0x00000000000000ffULL) << 56)) 00117 00118 #define etohs htoes 00119 #define etohl htoel 00120 #define etohll htoell 00121 00122 #else 00123 00124 #error "Must define one of EC_BIG_ENDIAN or EC_LITTLE_ENDIAN" 00125 00126 #endif 00127 #endif // _UTYPES_H_ 00128
Generated on Wed Jul 13 2022 17:16:52 by
1.7.2
