9 template <
typename T>
struct vector
14 enum deviceType { device_4200D, device_D20, device_D20H, device_auto };
15 enum sa0State { sa0_low, sa0_high, sa0_auto };
77 bool init(deviceType device = device_auto, sa0State sa0 = sa0_auto);
78 deviceType getDeviceType(
void) {
return _device; }
80 void enableDefault(
void);
82 void writeReg(
byte reg,
byte value);
83 byte readReg(
byte reg);
87 void setTimeout(
unsigned int timeout);
88 unsigned int getTimeout(
void);
89 bool timeoutOccurred(
void);
92 template <
typename Ta,
typename Tb,
typename To>
static void vector_cross(
const vector<Ta> *a,
const vector<Tb> *b, vector<To> *out);
93 template <
typename Ta,
typename Tb>
static float vector_dot(
const vector<Ta> *a,
const vector<Tb> *b);
94 static void vector_normalize(vector<float> *a);
100 unsigned int io_timeout;
103 int testReg(
byte address, regAddr reg);
106 template <
typename Ta,
typename Tb,
typename To>
void L3G::vector_cross(
const vector<Ta> *a,
const vector<Tb> *b, vector<To> *out)
108 out->x = (a->y * b->z) - (a->z * b->y);
109 out->y = (a->z * b->x) - (a->x * b->z);
110 out->z = (a->x * b->y) - (a->y * b->x);
113 template <
typename Ta,
typename Tb>
float L3G::vector_dot(
const vector<Ta> *a,
const vector<Tb> *b)
115 return (a->x * b->x) + (a->y * b->y) + (a->z * b->z);