Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_um6.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Michal Podhradsky
3  * Utah State University, http://aggieair.usu.edu/
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
33 #ifndef IMU_UM6_H
34 #define IMU_UM6_H
35 
36 #include "generated/airframe.h"
37 #include "subsystems/imu.h"
38 #include "mcu_periph/uart.h"
39 #include "subsystems/ahrs.h"
40 #include "subsystems/ins.h"
41 
42 #define __UM6Link(dev, _x) dev##_x
43 #define _UM6Link(dev, _x) __UM6Link(dev, _x)
44 #define UM6Link(_x) _UM6Link(UM6_LINK, _x)
45 
46 #define UM6Buffer() UM6Link(ChAvailable())
47 
48 #ifdef ImuScaleGyro
49 #undef ImuScaleGyro
50 #endif
51 #define ImuScaleGyro(_imu) {}
52 
53 #ifdef ImuScaleAccel
54 #undef ImuScaleAccel
55 #endif
56 #define ImuScaleAccel(_imu) {}
57 
58 #ifdef ImuScaleMag
59 #undef ImuScaleMag
60 #endif
61 #define ImuScaleMag(_imu) {}
62 
63 #define IMU_UM6_BUFFER_LENGTH 32
64 #define IMU_UM6_DATA_OFFSET 5
65 #define IMU_UM6_LONG_DELAY 4000000
66 
67 #define IMU_UM6_COMMUNICATION_REG 0x00
68 #define IMU_UM6_MISC_CONFIG_REG 0x01
69 #define IMU_UM6_GET_FIRMWARE_CMD 0xAA
70 #define IMU_UM6_ZERO_GYROS_CMD 0xAC
71 #define IMU_UM6_RESET_EKF_CMD 0xAD
72 #define IMU_UM6_GET_DATA 0xAE
73 #define IMU_UM6_SET_ACCEL_REF 0xAF
74 #define IMU_UM6_SET_MAG_REF 0xB0
75 
76 #define IMU_UM6_GYRO_PROC 0x5C
77 #define IMU_UM6_ACCEL_PROC 0x5E
78 #define IMU_UM6_MAG_PROC 0x60
79 #define IMU_UM6_EULER 0x62
80 #define IMU_UM6_QUAT 0x64
81 
82 extern void UM6_packet_read_message(void);
83 extern void UM6_packet_parse(uint8_t c);
84 
85 extern struct UM6Packet UM6_packet;
86 
87 extern uint8_t PacketLength;
88 extern uint8_t PacketType;
89 extern uint8_t PacketAddr;
90 
91 extern uint16_t chk_calc;
92 extern uint16_t chk_rec;
93 
94 extern enum UM6Status UM6_status;
95 extern volatile uint8_t UM6_imu_available;
96 
97 extern struct FloatEulers UM6_eulers;
98 extern struct FloatQuat UM6_quat;
99 
100 struct UM6Packet {
107 };
108 
116 };
117 
118 enum UM6Status {
121 };
122 
123 #define imu_um6_event(_callback1, _callback2, _callback3) { \
124  if (UM6Buffer()) { \
125  ReadUM6Buffer(); \
126  } \
127  if (UM6_packet.msg_available) { \
128  UM6_packet.msg_available = FALSE; \
129  UM6_packet_read_message(); \
130  _callback1(); \
131  _callback2(); \
132  _callback3(); \
133  } \
134 }
135 
136 #define ReadUM6Buffer() { \
137  while (UM6Link(ChAvailable())&&!UM6_packet.msg_available) \
138  UM6_packet_parse(UM6Link(Getch())); \
139  }
140 
141 #define ImuEvent(_gyro_handler, _accel_handler, _mag_handler) { \
142  imu_um6_event(_gyro_handler, _accel_handler, _mag_handler); \
143 }
144 
145 #endif /* IMU_UM6_H*/
struct UM6Packet UM6_packet
Definition: imu_um6.c:37
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
Attitude and Heading Reference System interface.
uint8_t msg_buf[IMU_UM6_BUFFER_LENGTH]
Definition: imu_um6.h:104
void UM6_packet_parse(uint8_t c)
Definition: imu_um6.c:286
uint16_t chk_rec
Definition: imu_um6.c:47
UM6PacketStatus
Definition: imu_um6.h:109
Integrated Navigation System interface.
uint8_t msg_idx
Definition: imu_um6.h:106
euler angles
UM6Status
Definition: imu_um6.h:118
#define IMU_UM6_BUFFER_LENGTH
Definition: imu_um6.h:63
Roation quaternion.
volatile uint8_t UM6_imu_available
unsigned long uint32_t
Definition: types.h:18
struct FloatEulers UM6_eulers
Definition: imu_um6.c:52
bool_t msg_available
Definition: imu_um6.h:101
struct FloatQuat UM6_quat
Definition: imu_um6.c:53
Inertial Measurement Unit interface.
void UM6_packet_read_message(void)
Definition: imu_um6.c:208
uint8_t PacketLength
Definition: imu_um6.c:41
uint8_t status
Definition: imu_um6.h:105
uint16_t chk_calc
Definition: imu_um6.c:46
enum UM6Status UM6_status
Definition: imu_um6.c:44
unsigned char uint8_t
Definition: types.h:14
uint32_t hdr_error
Definition: imu_um6.h:103
uint8_t PacketAddr
Definition: imu_um6.c:43
uint8_t PacketType
Definition: imu_um6.c:42
uint32_t chksm_error
Definition: imu_um6.h:102
static struct point c
Definition: discsurvey.c:39