Paparazzi UAS  v5.15_devel-113-g1b57ff1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 "subsystems/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 
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 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
float phi
in radians
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1143
#define LED_OFF(i)
Definition: led_hw.h:52
float psi
in radians
struct Imu imu
global IMU state
Definition: imu.c:108
void logger_uart_periodic(void)
Definition: logger_uart.c:37
euler angles
float theta
in radians
int32_t r
in rad/s with INT32_RATE_FRAC
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
Inertial Measurement Unit interface.
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
int32_t p
in rad/s with INT32_RATE_FRAC
arch independent LED (Light Emitting Diodes) API
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
static float p[2][2]
#define LED_ON(i)
Definition: led_hw.h:51
void logger_uart_init(void)
Definition: logger_uart.c:32
int32_t q
in rad/s with INT32_RATE_FRAC
struct logger_uart_data_struct logger_uart_data
Definition: logger_uart.c:30