bt_can.h
Go to the documentation of this file.
00001 #ifndef BT_RTCAN_H_
00002 #define BT_RTCAN_H_
00003 
00004 #include "bt_circular_buffer.h"
00005 
00006 //#define DEFAULT_TIMER
00007 #define MACHINE_TIMER
00008 
00009 #define MAX_BIOTACS_FOR_JACO              3             // should be 3 for BarrettHand BH8-280
00010 
00011 //=========================================================================
00012 // DEFAULT CONSTANTS
00013 //=========================================================================
00014 #define BT_SPI_BITRATE_KHZ_DEFAULT            3000
00015 #define BT_AFTERSAMPLE_DELAY_DEFAULT          50000     /* Delay after sampling command */
00016 #define BT_INTERWORD_DELAY_DEFAULT            10000   /* Delay between words in communication */
00017 #define BT_SAMPLE_RATE_HZ_DEFAULT           3000
00018 #define BT_FRAMES_IN_BATCH_DEFAULT            1
00019 #define BT_BATCH_MS_DEFAULT               1/BT_SAMPLE_RATE_HZ_DEFAULT*1000
00020 #define BT_FRAME_STRUCTURE_DEFAULT            {\
00021                             BT_E01_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E02_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00022                             BT_E03_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E04_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00023                             BT_E05_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E06_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00024                             BT_E07_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E08_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00025                             BT_E09_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E10_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00026                             BT_E11_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E12_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00027                             BT_E13_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E14_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00028                             BT_E15_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E16_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00029                             BT_E17_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_E18_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00030                             BT_E19_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_PDC_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, \
00031                             BT_TAC_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, BT_TDC_SAMPLING_COMMAND, BT_PAC_SAMPLING_COMMAND, '\0'}
00032 #ifndef BOOL
00033 typedef int                       BOOL;
00034 #endif
00035 #define PARITY_GOOD                   (BOOL)0
00036 #define PARITY_BAD                    (BOOL)!PARITY_GOOD
00037 
00038 //=========================================================================
00039 // TYPEDEFS
00040 //=========================================================================
00041 
00042 #include <stdint.h>
00043 typedef uint8_t   u08;
00044 typedef uint16_t  u16;
00045 typedef uint32_t  u32;
00046 typedef uint64_t  u64;
00047 typedef int8_t    s08;
00048 typedef int16_t   s16;
00049 typedef int32_t   s32;
00050 typedef int64_t   s64;
00051 
00052 //=========================================================================
00053 // DEFAULT CONSTANTS
00054 //=========================================================================
00055 #ifndef BOOL
00056 typedef int                       BOOL;
00057 #endif
00058 #define PARITY_GOOD                   (BOOL)0
00059 #define PARITY_BAD                    (BOOL)!PARITY_GOOD
00060 #define PARITY_NOT_AVALIBLE               -1
00061 
00062 //=========================================================================
00063 // BioTac commands define
00064 //=========================================================================
00065 #define BT_PAC_SAMPLING                 0           // command index: 00
00066 #define BT_PDC_SAMPLING                 1           // command index: 01
00067 #define BT_TAC_SAMPLING                 2           // command index: 02
00068 #define BT_TDC_SAMPLING                 3           // command index: 03
00069 
00070 #define BT_E01_SAMPLING                 17            // command index: 17
00071 #define BT_E02_SAMPLING                 18            // command index: 18
00072 #define BT_E03_SAMPLING                 19            // command index: 19
00073 #define BT_E04_SAMPLING                 20            // command index: 20
00074 #define BT_E05_SAMPLING                 21            // command index: 21
00075 #define BT_E06_SAMPLING                 22            // command index: 22
00076 #define BT_E07_SAMPLING                 23            // command index: 23
00077 #define BT_E08_SAMPLING                 24            // command index: 24
00078 #define BT_E09_SAMPLING                 25            // command index: 25
00079 #define BT_E10_SAMPLING                 26            // command index: 26
00080 #define BT_E11_SAMPLING                 27            // command index: 27
00081 #define BT_E12_SAMPLING                 28            // command index: 28
00082 #define BT_E13_SAMPLING                 29            // command index: 29
00083 #define BT_E14_SAMPLING                 30            // command index: 30
00084 #define BT_E15_SAMPLING                 31            // command index: 31
00085 #define BT_E16_SAMPLING                 32            // command index: 32
00086 #define BT_E17_SAMPLING                 33            // command index: 33
00087 #define BT_E18_SAMPLING                 34            // command index: 34
00088 #define BT_E19_SAMPLING                 35            // command index: 35
00089 
00090 #define BT_SAMPLING_PATTERN_READ_LENGTH         44
00091 #define BT_CPU_SPEED_READ_LENGTH            2
00092 
00093 //=========================================================================
00094 // Error codes definitions
00095 //=========================================================================
00096 #define BT_OK                     0
00097 #define BT_WRONG_MAX_BIOTAC_NUMBER            -3
00098 #define BT_RTCAN_WRONG_ARGUMENT             -10
00099 
00100 //=========================================================================
00101 // channel id mode definitions
00102 //=========================================================================
00103 #define INTEGER                     1
00104 #define STRING                      2
00105 
00106 //=========================================================================
00107 // time mode definitions
00108 //=========================================================================
00109 #define ZERO                      0
00110 #define ELAPSED                     1
00111 #define ABSOLUTE_TIME                 2
00112 
00113 //=========================================================================
00114 // Data structure definition
00115 //=========================================================================
00116 typedef int BioTac;
00117 
00118 typedef struct
00119 {
00120   unsigned long long index;
00121   double time;
00122   double frame_index;
00123   double batch_index;
00124   u08 channel_id;
00125   union
00126   {
00127     u16 word;
00128     u08 byte[2];
00129   } d[MAX_BIOTACS_FOR_JACO];
00130   s08 bt_parity[MAX_BIOTACS_FOR_JACO];
00131 } bt_data;
00132 
00133 typedef struct
00134 {
00135   int spi_clock_speed;
00136   int number_of_biotacs;
00137   int sample_rate_Hz;
00138   struct
00139   {
00140     int frame_type;
00141     int frame_size;
00142     char frame_structure[100];
00143   } frame;
00144   struct
00145   {
00146     int batch_frame_count;
00147     int batch_ms;
00148   } batch;
00149 } bt_info;
00150 
00151 //=========================================================================
00152 // CONSTANTS
00153 //=========================================================================
00154 static const unsigned char parity_values[] = \
00155 {
00156   0x01, 0x02, 0x04, 0x07, 0x08, 0x0B, 0x0D, 0x0E, \
00157   0x10, 0x13, 0x15, 0x16, 0x19, 0x1A, 0x1C, 0x1F, \
00158   0x20, 0x23, 0x25, 0x26, 0x29, 0x2A, 0x2C, 0x2F, \
00159   0x31, 0x32, 0x34, 0x37, 0x38, 0x3B, 0x3D, 0x3E, \
00160   0x40, 0x43, 0x45, 0x46, 0x49, 0x4A, 0x4C, 0x4F, \
00161   0x51, 0x52, 0x54, 0x57, 0x58, 0x5B, 0x5D, 0x5E, \
00162   0x61, 0x62, 0x64, 0x67, 0x68, 0x6B, 0x6D, 0x6E, \
00163   0x70, 0x73, 0x75, 0x76, 0x79, 0x7A, 0x7C, 0x7F, \
00164   0x80, 0x83, 0x85, 0x86, 0x89, 0x8A, 0x8C, 0x8F, \
00165   0x91, 0x92, 0x94, 0x97, 0x98, 0x9B, 0x9D, 0x9E, \
00166   0xA1, 0xA2, 0xA4, 0xA7, 0xA8, 0xAB, 0xAD, 0xAE, \
00167   0xB0, 0xB3, 0xB5, 0xB6, 0xB9, 0xBA, 0xBC, 0xBF, \
00168   0xC1, 0xC2, 0xC4, 0xC7, 0xC8, 0xCB, 0xCD, 0xCE, \
00169   0xD0, 0xD3, 0xD5, 0xD6, 0xD9, 0xDA, 0xDC, 0xDF, \
00170   0xE0, 0xE3, 0xE5, 0xE6, 0xE9, 0xEA, 0xEC, 0xEF, \
00171   0xF1, 0xF2, 0xF4, 0xF7, 0xF8, 0xFB, 0xFD, 0xFE
00172 };
00173 
00174 static const char *command_name[] = \
00175 {
00176   "PAC", "PDC", "TAC", "TDC", "   ", "   ", "   ", "   ", "   ", "   ", \
00177   "   ", "   ", "   ", "   ", "   ", "HAL", "REV", "E01", "E02", "E03", \
00178   "E04", "E05", "E06", "E07", "E08", "E09", "E10", "E11", "E12", "E13", \
00179   "E14", "E15", "E16", "E17", "E18", "E19", "   ", "   ", "   ", "   ", \
00180   "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", \
00181   "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", \
00182   "   ", "   ", "   ", "   "
00183 };
00184 
00185 #endif /* BIOTAC_CAN_H_ */


numatac_can_driver
Author(s):
autogenerated on Thu Jun 6 2019 21:19:30