Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
gps_intermcu.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
25
27#include "modules/core/abi.h"
28#include "pprzlink/intermcu_msg.h"
29
30struct GpsState gps_imcu = {0};
31
34{
36 gps_imcu.pdop = 0;
37 gps_imcu.sacc = 0;
38 gps_imcu.pacc = 0;
39 gps_imcu.cacc = 0;
40 gps_imcu.comp_id = GPS_IMCU_ID;
41}
42
44{
45 uint32_t now_ts = get_sys_time_usec();
46
47 gps_imcu.ecef_pos.x = DL_IMCU_REMOTE_GPS_ecef_x(buf);
48 gps_imcu.ecef_pos.y = DL_IMCU_REMOTE_GPS_ecef_y(buf);
49 gps_imcu.ecef_pos.z = DL_IMCU_REMOTE_GPS_ecef_z(buf);
50 SetBit(gps_imcu.valid_fields, GPS_VALID_POS_ECEF_BIT);
51
52 gps_imcu.lla_pos.alt = DL_IMCU_REMOTE_GPS_alt(buf);
53 gps_imcu.hmsl = DL_IMCU_REMOTE_GPS_hmsl(buf);
54 SetBit(gps_imcu.valid_fields, GPS_VALID_HMSL_BIT);
55
56 gps_imcu.ecef_vel.x = DL_IMCU_REMOTE_GPS_ecef_xd(buf);
57 gps_imcu.ecef_vel.y = DL_IMCU_REMOTE_GPS_ecef_yd(buf);
58 gps_imcu.ecef_vel.z = DL_IMCU_REMOTE_GPS_ecef_zd(buf);
59 SetBit(gps_imcu.valid_fields, GPS_VALID_VEL_ECEF_BIT);
60
61 gps_imcu.course = DL_IMCU_REMOTE_GPS_course(buf);
62 gps_imcu.gspeed = DL_IMCU_REMOTE_GPS_gspeed(buf);
63 SetBit(gps_imcu.valid_fields, GPS_VALID_COURSE_BIT);
64
65 gps_imcu.pacc = DL_IMCU_REMOTE_GPS_pacc(buf);
66 gps_imcu.sacc = DL_IMCU_REMOTE_GPS_sacc(buf);
67 gps_imcu.num_sv = DL_IMCU_REMOTE_GPS_numsv(buf);
68 gps_imcu.fix = DL_IMCU_REMOTE_GPS_fix(buf);
69
70 // set gps msg time
71 gps_imcu.last_msg_ticks = sys_time.nb_sec_rem;
72 gps_imcu.last_msg_time = sys_time.nb_sec;
73 if (gps_imcu.fix >= GPS_FIX_3D) {
74 gps_imcu.last_3dfix_ticks = sys_time.nb_sec_rem;
75 gps_imcu.last_3dfix_time = sys_time.nb_sec;
76 }
77
78 AbiSendMsgGPS(GPS_IMCU_ID, now_ts, &gps_imcu);
79}
80
Main include for ABI (AirBorneInterface).
#define GPS_IMCU_ID
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define GPS_VALID_VEL_ECEF_BIT
Definition gps.h:51
#define GPS_FIX_NONE
No GPS fix.
Definition gps.h:42
#define GPS_VALID_POS_ECEF_BIT
Definition gps.h:48
#define GPS_VALID_HMSL_BIT
Definition gps.h:53
#define GPS_FIX_3D
3D GPS fix
Definition gps.h:44
#define GPS_VALID_COURSE_BIT
Definition gps.h:54
data structure for GPS information
Definition gps.h:90
struct GpsState gps_imcu
void gps_intermcu_init(void)
GPS initialization.
void gps_intermcu_parse_IMCU_REMOTE_GPS(uint8_t *buf)
GPS system based on intermcu.
volatile uint32_t nb_sec
full seconds since startup
Definition sys_time.h:80
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
Definition sys_time.h:81
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.