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
ahrs_gx3.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  */
32 #ifndef AHRS_GX3_H
33 #define AHRS_GX3_H
34 
35 #include "generated/airframe.h"
36 #include "subsystems/imu.h"
37 #include "subsystems/ahrs.h"
38 #include "subsystems/ins.h"
39 #include "mcu_periph/uart.h"
41 
42 #include "state.h"
43 #include "led.h"
44 
45 #define __GX3Link(dev, _x) dev##_x
46 #define _GX3Link(dev, _x) __GX3Link(dev, _x)
47 #define GX3Link(_x) _GX3Link(GX3_LINK, _x)
48 
49 #define GX3Buffer() GX3Link(ChAvailable())
50 
51 #ifdef ImuScaleGyro
52 #undef ImuScaleGyro
53 #endif
54 #define ImuScaleGyro(_imu) {}
55 
56 #ifdef ImuScaleAccel
57 #undef ImuScaleAccel
58 #endif
59 #define ImuScaleAccel(_imu) {}
60 
61 #ifdef ImuScaleMag
62 #undef ImuScaleMag
63 #endif
64 #define ImuScaleMag(_imu) {}
65 
66 #define GX3_MAX_PAYLOAD 128
67 #define GX3_MSG_LEN 67
68 #define GX3_HEADER 0xC8
69 #define GX3_MIN_FREQ 300
70 
71 #define IMU_GX3_LONG_DELAY 4000000
72 
73 extern struct GX3_packet GX3_packet;
74 extern enum GX3Status GX3_status;
75 
76 extern void GX3_packet_read_message(void);
77 extern void GX3_packet_parse(uint8_t c);
78 
79 extern float GX3_freq;
80 extern uint16_t GX3_chksm;
81 extern uint16_t GX3_calcsm;
82 extern uint32_t GX3_time;
83 
84 struct GX3_packet {
85  bool_t msg_available;
91 };
92 
96 };
97 
98 enum GX3Status {
101 };
102 
103 //AHRS
108  float mag_offset;
109 };
110 
111 extern struct AhrsFloatQuat ahrs_impl;
112 
113 static inline void ReadGX3Buffer(void) {
114  while (GX3Link(ChAvailable()) && !GX3_packet.msg_available)
115  GX3_packet_parse(GX3Link(Getch()));
116 }
117 
118 static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void)) {
119  if (GX3Buffer()) {
120  ReadGX3Buffer();
121  }
124  _gyro_handler();
125  _accel_handler();
126  _mag_handler();
128  }
129 }
130 
131 #endif /* AHRS_GX3_H*/
Interface to align the AHRS via low-passed measurements at startup.
unsigned short uint16_t
Definition: types.h:16
#define GX3Link(_x)
Definition: ahrs_gx3.h:47
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t msg_idx
Definition: ahrs_gx3.h:90
Attitude and Heading Reference System interface.
uint8_t msg_buf[GX3_MAX_PAYLOAD]
Definition: ahrs_gx3.h:88
static void ImuEvent(void(*_gyro_handler)(void), void(*_accel_handler)(void), void(*_mag_handler)(void))
Definition: ahrs_gx3.h:118
angular rates
struct FloatRates imu_rate
Rotational velocity in IMU frame.
Definition: ahrs_gx3.h:107
void GX3_packet_parse(uint8_t c)
Definition: ahrs_gx3.c:242
Integrated Navigation System interface.
GX3Status
Definition: ahrs_gx3.h:98
uint32_t hdr_error
Definition: ahrs_gx3.h:87
euler angles
#define FALSE
Definition: imu_chimu.h:141
uint8_t status
Definition: ahrs_gx3.h:89
float mag_offset
Definition: ahrs_gx3.h:108
Roation quaternion.
#define GX3Buffer()
Definition: ahrs_gx3.h:49
uint16_t GX3_chksm
Definition: ahrs_gx3.c:48
bool_t msg_available
Definition: ahrs_gx3.h:85
struct AhrsFloatQuat ahrs_impl
Definition: ahrs_ardrone2.c:40
unsigned long uint32_t
Definition: types.h:18
uint16_t GX3_calcsm
Definition: ahrs_gx3.c:49
GX36PacketStatus
Definition: ahrs_gx3.h:93
float GX3_freq
Definition: ahrs_gx3.c:50
Inertial Measurement Unit interface.
#define GX3_MAX_PAYLOAD
Definition: ahrs_gx3.h:66
enum GX3Status GX3_status
Definition: ahrs_gx3.c:45
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
uint32_t chksm_error
Definition: ahrs_gx3.h:86
uint32_t GX3_time
Definition: ahrs_gx3.c:46
static void ReadGX3Buffer(void)
Definition: ahrs_gx3.h:113
arch independent LED (Light Emitting Diodes) API
struct FloatQuat ltp_to_imu_quat
Rotation from LocalTangentPlane to IMU frame as quaternions.
Definition: ahrs_gx3.h:106
struct FloatEulers ltp_to_imu_euler
Rotation from LocalTangentPlane to IMU frame as Euler angles.
Definition: ahrs_gx3.h:105
static struct point c
Definition: discsurvey.c:39
void GX3_packet_read_message(void)
Definition: ahrs_gx3.c:192