30 #define PERIODIC_C_MAIN
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wunused-parameter"
34 #include "generated/periodic_telemetry.h"
35 #pragma GCC diagnostic pop
37 #include "generated/airframe.h"
38 #include "generated/settings.h"
39 #include "generated/modules.h"
79 for (i = 0; i < ACTUATORS_NB; i++) {
96 for (
int i = 0; i < ACTUATORS_NB; i++) {
97 v[i] = actuators[i].driver_val;
105 modules_periodic_task();
112 modules_event_task();
116 #define IdOfMsg(x) (x[1])
118 void dl_parse_msg(
struct link_device *
dev __attribute__((unused)),
struct transport_tx *trans __attribute__((unused)),
uint8_t *buf)
121 if (msg_id == DL_SET_ACTUATOR) {
122 uint8_t actuator_no = DL_SET_ACTUATOR_no(buf);
123 uint16_t actuator_value __attribute__((unused)) = DL_SET_ACTUATOR_value(buf);
130 switch (actuator_no) {
132 case 0: ActuatorSet(0, actuator_value);
break;
135 case 1: ActuatorSet(1, actuator_value);
break;
138 case 2: ActuatorSet(2, actuator_value);
break;
141 case 3: ActuatorSet(3, actuator_value);
break;
144 case 4: ActuatorSet(4, actuator_value);
break;
147 case 5: ActuatorSet(5, actuator_value);
break;
150 case 6: ActuatorSet(6, actuator_value);
break;
153 case 7: ActuatorSet(7, actuator_value);
break;
156 case 8: ActuatorSet(8, actuator_value);
break;
166 else if (msg_id == DL_SETTING && DL_SETTING_ac_id(buf) == AC_ID) {
167 uint8_t i = DL_SETTING_index(buf);
168 float val = DL_SETTING_value(buf);
173 ActuatorSet(0, actuators[SERVO_0_IDX]);
176 ActuatorSet(1, actuators[SERVO_1_IDX]);
179 ActuatorSet(2, actuators[SERVO_2_IDX]);
182 ActuatorSet(3, actuators[SERVO_3_IDX]);
185 ActuatorSet(4, actuators[SERVO_4_IDX]);
188 ActuatorSet(5, actuators[SERVO_5_IDX]);
191 ActuatorSet(6, actuators[SERVO_6_IDX]);
194 ActuatorSet(7, actuators[SERVO_7_IDX]);
197 ActuatorSet(8, actuators[SERVO_8_IDX]);
201 }
else if (msg_id == DL_GET_SETTING && DL_GET_SETTING_ac_id(buf) == AC_ID) {
202 uint8_t i = DL_GET_SETTING_index(buf);
203 float val = settings_get_value(i);
void datalink_init(void)
init function
Handling of messages coming from ground and other A/Cs.
Common code for AP and FBW telemetry.
void mcu_init(void)
Microcontroller peripherals initialization.
void mcu_event(void)
MCU event functions.
arch independent LED (Light Emitting Diodes) API
Arch independent mcu ( Micro Controller Unit ) utilities.
void actuators_init(void)
Hardware independent API for actuators (servos, motor controllers).
void pprz_dl_init(void)
Init function.
void pprz_dl_event(void)
Datalink Event.
Datalink using PPRZ protocol.
static void main_event(void)
static void main_periodic(void)
void dl_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
Should be called when chars are available in dl_buffer.
static void main_init(void)
static const struct usb_device_descriptor dev
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Architecture independent timing functions.
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.