Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 
41 #define IMU_UM6_BUFFER_LENGTH 32
42 #define IMU_UM6_DATA_OFFSET 5
43 #define IMU_UM6_LONG_DELAY 4000000
44 
45 #define IMU_UM6_COMMUNICATION_REG 0x00
46 #define IMU_UM6_MISC_CONFIG_REG 0x01
47 #define IMU_UM6_GET_FIRMWARE_CMD 0xAA
48 #define IMU_UM6_ZERO_GYROS_CMD 0xAC
49 #define IMU_UM6_RESET_EKF_CMD 0xAD
50 #define IMU_UM6_GET_DATA 0xAE
51 #define IMU_UM6_SET_ACCEL_REF 0xAF
52 #define IMU_UM6_SET_MAG_REF 0xB0
53 
54 #define IMU_UM6_GYRO_PROC 0x5C
55 #define IMU_UM6_ACCEL_PROC 0x5E
56 #define IMU_UM6_MAG_PROC 0x60
57 #define IMU_UM6_EULER 0x62
58 #define IMU_UM6_QUAT 0x64
59 
60 extern void UM6_packet_read_message(void);
61 extern void UM6_packet_parse(uint8_t c);
62 extern void imu_um6_publish(void);
63 
64 extern struct UM6Packet UM6_packet;
65 
66 extern uint8_t PacketLength;
67 extern uint8_t PacketType;
68 extern uint8_t PacketAddr;
69 
70 extern uint16_t chk_calc;
71 extern uint16_t chk_rec;
72 
73 extern enum UM6Status UM6_status;
74 extern volatile uint8_t UM6_imu_available;
75 
76 extern struct FloatEulers UM6_eulers;
77 extern struct FloatQuat UM6_quat;
78 
79 struct UM6Packet {
86 };
87 
95 };
96 
97 enum UM6Status {
100 };
101 
102 extern void imu_um6_init(void);
103 extern void imu_um6_periodic(void);
104 
105 static inline void imu_um6_event(void)
106 {
107  if (uart_char_available(&(UM6_LINK))) {
108  while (uart_char_available(&(UM6_LINK)) && !UM6_packet.msg_available) {
109  UM6_packet_parse(uart_getch(&(UM6_LINK)));
110  }
112  UM6_packet.msg_available = false;
114  imu_um6_publish();
115  }
116  }
117 }
118 
119 #endif /* IMU_UM6_H*/
struct UM6Packet UM6_packet
Definition: imu_um6.c:38
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t msg_idx
Definition: imu_um6.h:85
Dispatcher to register actual AHRS implementations.
uint8_t uart_getch(struct uart_periph *p)
Definition: uart_arch.c:840
void UM6_packet_parse(uint8_t c)
Definition: imu_um6.c:290
uint16_t uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition: uart_arch.c:324
static void imu_um6_event(void)
Definition: imu_um6.h:105
uint16_t chk_rec
Definition: imu_um6.c:48
UM6PacketStatus
Definition: imu_um6.h:88
uint32_t hdr_error
Definition: imu_um6.h:82
UM6Status
Definition: imu_um6.h:97
euler angles
void imu_um6_init(void)
Definition: imu_um6.c:135
Roation quaternion.
#define IMU_UM6_BUFFER_LENGTH
Definition: imu_um6.h:41
bool msg_available
Definition: imu_um6.h:80
volatile uint8_t UM6_imu_available
uint8_t msg_buf[IMU_UM6_BUFFER_LENGTH]
Definition: imu_um6.h:83
void imu_um6_periodic(void)
Definition: imu_um6.c:195
unsigned long uint32_t
Definition: types.h:18
struct FloatEulers UM6_eulers
Definition: imu_um6.c:53
struct FloatQuat UM6_quat
Definition: imu_um6.c:54
Inertial Measurement Unit interface.
void UM6_packet_read_message(void)
Definition: imu_um6.c:211
uint8_t PacketLength
Definition: imu_um6.c:42
uint16_t chk_calc
Definition: imu_um6.c:47
enum UM6Status UM6_status
Definition: imu_um6.c:45
unsigned char uint8_t
Definition: types.h:14
uint8_t PacketAddr
Definition: imu_um6.c:44
uint8_t PacketType
Definition: imu_um6.c:43
void imu_um6_publish(void)
Definition: imu_um6.c:369
uint8_t status
Definition: imu_um6.h:84
uint32_t chksm_error
Definition: imu_um6.h:81