Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
logger_uart.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2013 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 #include "logger_uart.h"
24 
25 #include "state.h"
26 #include "led.h"
27 #include "modules/imu/imu.h"
28 #include "mcu_periph/uart.h"
29 
31 
32 void logger_uart_init(void)
33 {
34  logger_uart_data.id = 0;
35 }
36 
38 {
39  struct FloatEulers att = *stateGetNedToBodyEulers_f();
40 
41  logger_uart_data.start = 0x55CC;
43 
44  if (logger_uart_data.id & 0x0080) {
45  LED_ON(1);
46  } else {
47  LED_OFF(1);
48  }
49 
50  logger_uart_data.gyro_p = imu.gyro_unscaled.p;
51  logger_uart_data.gyro_q = imu.gyro_unscaled.q;
52  logger_uart_data.gyro_r = imu.gyro_unscaled.r;
53  logger_uart_data.acc_x = imu.accel_unscaled.x;
54  logger_uart_data.acc_y = imu.accel_unscaled.y;
55  logger_uart_data.acc_z = imu.accel_unscaled.z;
56  logger_uart_data.phi = (att.phi * 100.0f);
57  logger_uart_data.theta = (att.theta * 100.0f);
58  logger_uart_data.psi = (att.psi * 100.0f);
59 
60  uint8_t crc = 0;
62  for (int i=0; i<22; i++)
63  {
64  crc += p[i];
65  UART1Transmit(p[i]);
66  }
67  UART1Transmit(crc);
68 }
69 
70 
#define LED_ON(i)
Definition: led_hw.h:51
#define LED_OFF(i)
Definition: led_hw.h:52
float phi
in radians
float theta
in radians
float psi
in radians
euler angles
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1143
struct Imu imu
global IMU state
Definition: imu.c:337
Inertial Measurement Unit interface.
static float p[2][2]
arch independent LED (Light Emitting Diodes) API
struct logger_uart_data_struct logger_uart_data
Definition: logger_uart.c:30
void logger_uart_init(void)
Definition: logger_uart.c:32
void logger_uart_periodic(void)
Definition: logger_uart.c:37
API to get/set the generic vehicle states.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98