Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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*/
UM6Packet::msg_idx
uint8_t msg_idx
Definition: imu_um6.h:85
c
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
UM6_packet
struct UM6Packet UM6_packet
Definition: imu_um6.c:38
uint16_t
unsigned short uint16_t
Definition: types.h:16
chk_calc
uint16_t chk_calc
Definition: imu_um6.c:47
UM6_packet_parse
void UM6_packet_parse(uint8_t c)
Definition: imu_um6.c:290
uart_getch
uint8_t uart_getch(struct uart_periph *p)
Definition: uart_arch.c:968
UM6_eulers
struct FloatEulers UM6_eulers
Definition: imu_um6.c:53
UM6PacketReadingN
@ UM6PacketReadingN
Definition: imu_um6.h:91
UM6_packet_read_message
void UM6_packet_read_message(void)
Definition: imu_um6.c:211
chk_rec
uint16_t chk_rec
Definition: imu_um6.c:48
uart_char_available
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition: uart_arch.c:323
uint32_t
unsigned long uint32_t
Definition: types.h:18
UM6PacketStatus
UM6PacketStatus
Definition: imu_um6.h:88
UM6Status
UM6Status
Definition: imu_um6.h:97
PacketLength
uint8_t PacketLength
Definition: imu_um6.c:42
UM6Packet::chksm_error
uint32_t chksm_error
Definition: imu_um6.h:81
UM6Uninit
@ UM6Uninit
Definition: imu_um6.h:98
UM6Packet::hdr_error
uint32_t hdr_error
Definition: imu_um6.h:82
imu.h
FloatQuat
Roation quaternion.
Definition: pprz_algebra_float.h:63
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
imu_um6_init
void imu_um6_init(void)
Definition: imu_um6.c:135
UM6_imu_available
volatile uint8_t UM6_imu_available
UM6PacketReadingAddr
@ UM6PacketReadingAddr
Definition: imu_um6.h:93
UM6Packet::msg_available
bool msg_available
Definition: imu_um6.h:80
uint8_t
unsigned char uint8_t
Definition: types.h:14
UM6Packet::msg_buf
uint8_t msg_buf[IMU_UM6_BUFFER_LENGTH]
Definition: imu_um6.h:83
UM6PacketReadingPT
@ UM6PacketReadingPT
Definition: imu_um6.h:92
ahrs.h
UM6_quat
struct FloatQuat UM6_quat
Definition: imu_um6.c:54
UM6Packet
Definition: imu_um6.h:79
UM6Running
@ UM6Running
Definition: imu_um6.h:99
UM6_status
enum UM6Status UM6_status
Definition: imu_um6.c:45
PacketAddr
uint8_t PacketAddr
Definition: imu_um6.c:44
PacketType
uint8_t PacketType
Definition: imu_um6.c:43
imu_um6_event
static void imu_um6_event(void)
Definition: imu_um6.h:105
imu_um6_publish
void imu_um6_publish(void)
Definition: imu_um6.c:369
UM6PacketReadingS
@ UM6PacketReadingS
Definition: imu_um6.h:90
FloatEulers
euler angles
Definition: pprz_algebra_float.h:84
imu_um6_periodic
void imu_um6_periodic(void)
Definition: imu_um6.c:195
UM6PacketWaiting
@ UM6PacketWaiting
Definition: imu_um6.h:89
UM6Packet::status
uint8_t status
Definition: imu_um6.h:84
IMU_UM6_BUFFER_LENGTH
#define IMU_UM6_BUFFER_LENGTH
Definition: imu_um6.h:41
UM6PacketReadingData
@ UM6PacketReadingData
Definition: imu_um6.h:94