Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
actuators_sts3032.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Flo&Fab <surname.name@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 
26 #ifndef SERVO_STS3032_H
27 #define SERVO_STS3032_H
28 
29 #include <stdint.h>
30 #include "mcu_periph/uart.h"
31 #include "utils/circular_buffer.h"
32 #include "generated/airframe.h"
33 
34 
39 };
40 
41 struct sts3032 {
43 
44 
45  uint8_t ids[SERVOS_STS3032_NB];
46  uint8_t states[SERVOS_STS3032_NB];
47  uint16_t pos[SERVOS_STS3032_NB];
48 
49  uint32_t time_last_msg; // last send msg time
50 
51 
57  bool echo; // wait for sended message
59  bool wait_reply;
61 
62  struct circular_buffer msg_buf;
63 };
64 
65 
66 extern struct sts3032 sts;
67 
68 extern void actuators_sts3032_init(void);
69 extern void actuators_sts3032_periodic(void);
70 extern void actuators_sts3032_event(void);
71 uint8_t id_idx(struct sts3032 *sts, uint8_t id);
72 void sts3032_write_pos(struct sts3032 *sts, uint8_t id, int16_t position);
73 
74 /* Actuator macros */
75 #define ActuatorSTS3032Set(_i, _v) { if(sts3032_enabled) {sts3032_write_pos(&sts, sts.ids[_i], _v);} }
76 #define ActuatorsSTS3032Init() actuators_sts3032_init()
77 #define ActuatorsSTS3032Commit() {}
78 
79 extern int sts3032_enabled;
80 extern int sts3032_current_id;
81 extern int sts3032_future_id;
82 extern int sts3032_lock_eprom;
83 extern int sts3032_move;
84 extern int sts3032_response_level;
85 
86 extern void actuators_sts3032_set_id(float future_id);
87 extern void actuators_sts3032_lock_eprom(float lock);
88 extern void actuators_sts3032_move(float pos);
89 extern void actuators_sts3032_set_response_level(float level);
90 
91 #endif // SERVO_STS3032_H
void actuators_sts3032_set_id(float future_id)
uint8_t rx_checksum
uint8_t buf_header[2]
int sts3032_response_level
void actuators_sts3032_init(void)
struct sts3032 sts
uint8_t rx_id
void actuators_sts3032_set_response_level(float level)
void sts3032_write_pos(struct sts3032 *sts, uint8_t id, int16_t position)
int sts3032_current_id
uint8_t nb_bytes_expected
uint16_t pos[SERVOS_STS3032_NB]
int sts3032_enabled
uint8_t states[SERVOS_STS3032_NB]
void actuators_sts3032_event(void)
uint32_t time_last_msg
int sts3032_lock_eprom
struct uart_periph * periph
void actuators_sts3032_move(float pos)
uint16_t nb_failed_checksum
int sts3032_future_id
enum sts3032_rx_state rx_state
struct circular_buffer msg_buf
void actuators_sts3032_lock_eprom(float lock)
uint8_t id_idx(struct sts3032 *sts, uint8_t id)
void actuators_sts3032_periodic(void)
uint8_t ids[SERVOS_STS3032_NB]
sts3032_rx_state
@ STS3032_RX_IDLE
@ STS3032_RX_HEAD_OK
@ STS3032_RX_GOT_LENGTH
int sts3032_move
uint8_t read_addr
This is a general purpose circular buffer for storing buffers in a FIFO order.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
UART peripheral.
Definition: uart.h:72
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98