Paparazzi UAS
v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
main_demo5.c
Go to the documentation of this file.
1
#include "
std.h
"
2
#include "
mcu.h
"
3
#include "
mcu_periph/sys_time.h
"
4
#include "
led.h
"
5
#include "
mcu_periph/uart.h
"
6
7
#include "pprzlink/messages.h"
8
#include "
modules/datalink/downlink.h
"
9
10
static
inline
void
main_init
(
void
);
11
static
inline
void
main_periodic_task
(
void
);
12
static
inline
void
main_event_task
(
void
);
13
14
static
inline
void
main_dl_parse_msg
(
void
);
15
16
int
main
(
void
)
17
{
18
main_init
();
19
while
(1) {
20
if
(
sys_time_check_and_ack_timer
(0)) {
21
main_periodic_task
();
22
}
23
main_event_task
();
24
}
25
return
0;
26
}
27
28
static
inline
void
main_init
(
void
)
29
{
30
mcu_init
();
31
sys_time_register_timer
((1. / PERIODIC_FREQUENCY), NULL);
32
uart0_init_tx();
33
}
34
35
static
inline
void
main_periodic_task
(
void
)
36
{
37
// LED_TOGGLE(1);
38
uint16_t
time_sec =
sys_time
.
nb_sec
;
39
DOWNLINK_SEND_TAKEOFF(&time_sec);
40
}
41
42
static
inline
void
main_event_task
(
void
)
43
{
44
if
(PprzBuffer()) {
45
ReadPprzBuffer();
46
if
(pprz_msg_received) {
47
pprz_parse_payload();
48
pprz_msg_received =
false
;
49
}
50
}
51
if
(
dl_msg_available
) {
52
main_dl_parse_msg
();
53
dl_msg_available
=
false
;
54
LED_TOGGLE
(1);
55
}
56
}
57
58
uint16_t
foo
;
59
60
bool
dl_msg_available
;
61
62
#define MSG_SIZE 256
63
uint8_t
dl_buffer
[
MSG_SIZE
] __attribute__((aligned));
64
65
#include "generated/settings.h"
66
67
#define IdOfMsg(x) (x[1])
68
69
static
inline
void
main_dl_parse_msg
(
void
)
70
{
71
uint8_t
msg_id =
IdOfMsg
(
dl_buffer
);
72
if
(msg_id == DL_SETTING) {
73
uint8_t
i = DL_SETTING_index(
dl_buffer
);
74
float
var = DL_SETTING_value(
dl_buffer
);
75
DlSetting(i, var);
76
DOWNLINK_SEND_DL_VALUE(&i, &var);
77
}
78
}
main_event_task
static void main_event_task(void)
Definition:
main_demo5.c:42
dl_buffer
uint8_t dl_buffer[MSG_SIZE]
Definition:
main_demo5.c:63
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition:
vl53l1_types.h:98
main_init
static void main_init(void)
Definition:
main_demo5.c:28
LED_TOGGLE
#define LED_TOGGLE(i)
Definition:
led_hw.h:53
foo
uint16_t foo
Definition:
main_demo5.c:58
MSG_SIZE
#define MSG_SIZE
Definition:
main_demo5.c:62
std.h
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
mcu.h
Arch independent mcu ( Micro Controller Unit ) utilities.
sys_time.h
Architecture independent timing functions.
led.h
arch independent LED (Light Emitting Diodes) API
IdOfMsg
#define IdOfMsg(x)
Definition:
main_demo5.c:67
downlink.h
Common code for AP and FBW telemetry.
dl_msg_available
bool dl_msg_available
Definition:
main_demo5.c:60
sys_time
Definition:
sys_time.h:71
main
int main(void)
Definition:
main_demo5.c:16
main_periodic_task
static void main_periodic_task(void)
Definition:
main_demo5.c:35
sys_time_register_timer
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition:
sys_time.c:43
main_dl_parse_msg
static void main_dl_parse_msg(void)
Definition:
main_demo5.c:69
sys_time::nb_sec
volatile uint32_t nb_sec
full seconds since startup
Definition:
sys_time.h:72
uint16_t
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition:
vl53l1_types.h:88
mcu_init
void mcu_init(void)
Microcontroller peripherals initialization.
Definition:
mcu.c:97
sys_time_check_and_ack_timer
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition:
sys_time.h:123
sw
airborne
firmwares
tutorial
main_demo5.c
Generated on Thu May 19 2022 23:03:47 for Paparazzi UAS by
1.8.17