Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
actuators_esc32.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
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 
26 #ifndef ACTUATORS_ESC32_H
27 #define ACTUATORS_ESC32_H
28 
29 #include "std.h"
30 #include "generated/airframe.h"
31 
32 #define ESC32_RESPONSE_CNT 12
33 
34 // Logical Communications Channel
35 // 2 bits [28:27]
36 #define ESC32_CAN_LCC_MASK ((uint32_t)0x3<<30)
37 #define ESC32_CAN_LCC_EXCEPTION ((uint32_t)0x0<<30)
38 #define ESC32_CAN_LCC_HIGH ((uint32_t)0x1<<30)
39 #define ESC32_CAN_LCC_NORMAL ((uint32_t)0x2<<30)
40 #define ESC32_CAN_LCC_INFO ((uint32_t)0x3<<30)
41 
42 // Target Type
43 // 1 bit [26:26]
44 #define ESC32_CAN_TT_MASK ((uint32_t)0x1<<29)
45 #define ESC32_CAN_TT_GROUP ((uint32_t)0x0<<29)
46 #define ESC32_CAN_TT_NODE ((uint32_t)0x1<<29)
47 
48 // Function ID
49 // 4 bits [25:22]
50 #define ESC32_CAN_FID_MASK ((uint32_t)0xf<<25)
51 #define ESC32_CAN_FID_RESET_BUS ((uint32_t)0x0<<25)
52 #define ESC32_CAN_FID_ACK ((uint32_t)0x1<<25)
53 #define ESC32_CAN_FID_NACK ((uint32_t)0x2<<25)
54 #define ESC32_CAN_FID_CMD ((uint32_t)0x3<<25)
55 #define ESC32_CAN_FID_GET ((uint32_t)0x4<<25)
56 #define ESC32_CAN_FID_SET ((uint32_t)0x5<<25)
57 #define ESC32_CAN_FID_REPLY ((uint32_t)0x6<<25)
58 #define ESC32_CAN_FID_REQ_ADDR ((uint32_t)0x7<<25)
59 #define ESC32_CAN_FID_GRANT_ADDR ((uint32_t)0x8<<25)
60 #define ESC32_CAN_FID_ERROR ((uint32_t)0x9<<25)
61 #define ESC32_CAN_FID_PING ((uint32_t)0xa<<25)
62 #define ESC32_CAN_FID_TELEM ((uint32_t)0xb<<25)
63 
64 // Data Object Code
65 // 6 bits [21:16]
66 #define ESC32_CAN_DOC_MASK ((uint32_t)0x3f<<19)
67 
68 // Source ID
69 // 5 bits [15:11]
70 #define ESC32_CAN_SID_MASK ((uint32_t)0x1f<<14)
71 
72 // Target ID
73 // 5 bits [10:6]
74 #define ESC32_CAN_TID_MASK ((uint32_t)0x1f<<9)
75 
76 // Sequence ID
77 // 6 bits [5:0]
78 #define ESC32_CAN_SEQ_MASK ((uint32_t)0x3f<<3)
79 
80 // types
81 enum {
90 };
91 
92 // commands
93 enum {
114 };
115 
116 // data types
117 enum {
130 };
131 
132 // telemetry values
133 enum {
144 };
145 
149 };
150 
151 // ESCs status
156 };
157 
158 struct ESC32_com {
164 };
165 
166 // ESC status
172 };
173 
174 // ESC status
180 };
181 
182 struct ESC32 {
185 
188 
189  struct ESC32_com escs[SERVOS_ESC32_NB];
190  uint8_t escs_sorted[SERVOS_ESC32_NB];
191  uint16_t cmds[SERVOS_ESC32_NB];
192 
195 };
196 
197 
198 extern struct ESC32 actuators_esc32;
199 
200 extern void actuators_esc32_init(void);
201 extern void actuators_esc32_commit(void);
202 extern void actuators_esc32_set(uint8_t i, uint16_t v);
203 extern void actuators_esc32_config_cmd(uint8_t i);
204 
205 #define ActuatorESC32Set(_i, _v) { actuators_esc32_set(_i, _v); }
206 #define ActuatorsESC32Init() actuators_esc32_init()
207 #define ActuatorsESC32Commit() actuators_esc32_commit()
208 
209 
210 #endif /* ACTUATORS_ESC32_H */
ESC32_CAN_CMD_OFF
@ ESC32_CAN_CMD_OFF
Definition: actuators_esc32.h:113
ESC32_CAN_CMD_DISARM
@ ESC32_CAN_CMD_DISARM
Definition: actuators_esc32.h:94
ESC32_CAN_DATA_TELEM
@ ESC32_CAN_DATA_TELEM
Definition: actuators_esc32.h:125
ESC32_CAN_TELEM_VALUE
@ ESC32_CAN_TELEM_VALUE
Definition: actuators_esc32.h:142
uint16_t
unsigned short uint16_t
Definition: types.h:16
ESC32::escs
struct ESC32_com escs[SERVOS_ESC32_NB]
The ESCs connected via CAN.
Definition: actuators_esc32.h:189
ESC32_CAN_CMD_STOP
@ ESC32_CAN_CMD_STOP
Definition: actuators_esc32.h:97
ESC32_config_cmd
ESC32_config_cmd
Definition: actuators_esc32.h:175
ESC32_CAN_DATA_VERSION
@ ESC32_CAN_DATA_VERSION
Definition: actuators_esc32.h:126
ESC32_CAN_TYPE_ESC
@ ESC32_CAN_TYPE_ESC
Definition: actuators_esc32.h:82
ESC32_STATUS_INIT
@ ESC32_STATUS_INIT
Definition: actuators_esc32.h:168
ESC32_CAN_TYPE_OSD
@ ESC32_CAN_TYPE_OSD
Definition: actuators_esc32.h:86
ESC32_CONFIG_CMD_IDLE
@ ESC32_CONFIG_CMD_IDLE
Definition: actuators_esc32.h:176
ESC32::responses
struct ESC32_response responses[ESC32_RESPONSE_CNT]
Responses of CAN messages.
Definition: actuators_esc32.h:187
ESC32_CONFIG_CMD_DIR
@ ESC32_CONFIG_CMD_DIR
Definition: actuators_esc32.h:179
ESC32_CAN_TELEM_ERRORS
@ ESC32_CAN_TELEM_ERRORS
Definition: actuators_esc32.h:141
ESC32_CAN_TELEM_RPM
@ ESC32_CAN_TELEM_RPM
Definition: actuators_esc32.h:140
ESC32_CAN_DATA_PARAM_NAME1
@ ESC32_CAN_DATA_PARAM_NAME1
Definition: actuators_esc32.h:128
ESC32_CAN_TYPE_UART
@ ESC32_CAN_TYPE_UART
Definition: actuators_esc32.h:87
uint32_t
unsigned long uint32_t
Definition: types.h:18
ESC32_CAN_DATA_PARAM_ID
@ ESC32_CAN_DATA_PARAM_ID
Definition: actuators_esc32.h:124
actuators_esc32
struct ESC32 actuators_esc32
Definition: actuators_esc32.c:34
ESC32_response::fid
uint8_t fid
The FID of the response.
Definition: actuators_esc32.h:147
ESC32_CAN_CMD_SETPOINT16
@ ESC32_CAN_CMD_SETPOINT16
Definition: actuators_esc32.h:100
ESC32_CAN_TYPE_NUM
@ ESC32_CAN_TYPE_NUM
Definition: actuators_esc32.h:89
ESC32_CAN_DATA_VALUE
@ ESC32_CAN_DATA_VALUE
Definition: actuators_esc32.h:127
ESC32_com::network_id
uint8_t network_id
Index in the array +1.
Definition: actuators_esc32.h:160
ESC32_com::status
enum ESC32_esc_status status
The current status of the esc.
Definition: actuators_esc32.h:159
ESC32::status
enum ESC32_status status
The current status of all actuators.
Definition: actuators_esc32.h:183
ESC32_CAN_TELEM_AMPS
@ ESC32_CAN_TELEM_AMPS
Definition: actuators_esc32.h:139
ESC32_CAN_DATA_ID
@ ESC32_CAN_DATA_ID
Definition: actuators_esc32.h:120
actuators_esc32_set
void actuators_esc32_set(uint8_t i, uint16_t v)
Set the commands (either RPM or duty cycle)
Definition: actuators_esc32.c:73
ESC32_STATUS_ESC_INIT
@ ESC32_STATUS_ESC_INIT
Definition: actuators_esc32.h:154
ESC32::config_idx
uint8_t config_idx
Selected ESC.
Definition: actuators_esc32.h:193
ESC32_CAN_CMD_CFG_WRITE
@ ESC32_CAN_CMD_CFG_WRITE
Definition: actuators_esc32.h:103
ESC32_CAN_CMD_RPM
@ ESC32_CAN_CMD_RPM
Definition: actuators_esc32.h:101
ESC32::escs_sorted
uint8_t escs_sorted[SERVOS_ESC32_NB]
The ESCs sorted by uuid.
Definition: actuators_esc32.h:190
std.h
ESC32_com::uuid
uint32_t uuid
The UUID of the ESC.
Definition: actuators_esc32.h:161
ESC32_RESPONSE_CNT
#define ESC32_RESPONSE_CNT
Definition: actuators_esc32.h:32
ESC32_CAN_CMD_CFG_READ
@ ESC32_CAN_CMD_CFG_READ
Definition: actuators_esc32.h:102
ESC32_CAN_CMD_TELEM_RATE
@ ESC32_CAN_CMD_TELEM_RATE
Definition: actuators_esc32.h:105
ESC32_CONFIG_CMD_TURN
@ ESC32_CONFIG_CMD_TURN
Definition: actuators_esc32.h:178
ESC32_CAN_CMD_RESET
@ ESC32_CAN_CMD_RESET
Definition: actuators_esc32.h:110
ESC32_CAN_TYPE_SWITCH
@ ESC32_CAN_TYPE_SWITCH
Definition: actuators_esc32.h:85
ESC32_CAN_CMD_START
@ ESC32_CAN_CMD_START
Definition: actuators_esc32.h:96
uint8_t
unsigned char uint8_t
Definition: types.h:14
ESC32_CAN_TELEM_VIN
@ ESC32_CAN_TELEM_VIN
Definition: actuators_esc32.h:138
ESC32_status
ESC32_status
Definition: actuators_esc32.h:167
ESC32_STATUS_MELODY
@ ESC32_STATUS_MELODY
Definition: actuators_esc32.h:169
ESC32_CAN_CMD_USER_DEFINED
@ ESC32_CAN_CMD_USER_DEFINED
Definition: actuators_esc32.h:109
ESC32_STATUS_ESC_RDY
@ ESC32_STATUS_ESC_RDY
Definition: actuators_esc32.h:155
ESC32_CAN_DATA_PARAM_NAME2
@ ESC32_CAN_DATA_PARAM_NAME2
Definition: actuators_esc32.h:129
ESC32_CAN_TYPE_SENSOR
@ ESC32_CAN_TYPE_SENSOR
Definition: actuators_esc32.h:84
ESC32_CONFIG_CMD_BEEP
@ ESC32_CONFIG_CMD_BEEP
Definition: actuators_esc32.h:177
ESC32_CAN_CMD_TELEM_VALUE
@ ESC32_CAN_CMD_TELEM_VALUE
Definition: actuators_esc32.h:106
ESC32_CAN_CMD_ON
@ ESC32_CAN_CMD_ON
Definition: actuators_esc32.h:112
ESC32_CAN_DATA_RUN_MODE
@ ESC32_CAN_DATA_RUN_MODE
Definition: actuators_esc32.h:122
ESC32_esc_status
ESC32_esc_status
Definition: actuators_esc32.h:152
ESC32_CAN_CMD_ARM
@ ESC32_CAN_CMD_ARM
Definition: actuators_esc32.h:95
ESC32_CAN_CMD_CFG_DEFAULT
@ ESC32_CAN_CMD_CFG_DEFAULT
Definition: actuators_esc32.h:104
ESC32_CAN_DATA_TYPE
@ ESC32_CAN_DATA_TYPE
Definition: actuators_esc32.h:119
ESC32_STATUS_RUNNING
@ ESC32_STATUS_RUNNING
Definition: actuators_esc32.h:171
actuators_esc32_init
void actuators_esc32_init(void)
Initializes the ESCs.
Definition: actuators_esc32.c:122
ESC32::cmds
uint16_t cmds[SERVOS_ESC32_NB]
Commands which need to be committed.
Definition: actuators_esc32.h:191
ESC32_CAN_CMD_POS
@ ESC32_CAN_CMD_POS
Definition: actuators_esc32.h:108
ESC32_CAN_CMD_SETPOINT12
@ ESC32_CAN_CMD_SETPOINT12
Definition: actuators_esc32.h:99
ESC32
Definition: actuators_esc32.h:182
ESC32_CAN_TYPE_HUB
@ ESC32_CAN_TYPE_HUB
Definition: actuators_esc32.h:88
ESC32_CAN_TELEM_NUM
@ ESC32_CAN_TELEM_NUM
Definition: actuators_esc32.h:143
ESC32_CAN_TYPE_SERVO
@ ESC32_CAN_TYPE_SERVO
Definition: actuators_esc32.h:83
ESC32_response
Definition: actuators_esc32.h:146
actuators_esc32_commit
void actuators_esc32_commit(void)
Commits the commands and sends them to the ESCs.
Definition: actuators_esc32.c:147
ESC32_CAN_TELEM_NONE
@ ESC32_CAN_TELEM_NONE
Definition: actuators_esc32.h:134
ESC32_CAN_CMD_STREAM
@ ESC32_CAN_CMD_STREAM
Definition: actuators_esc32.h:111
ESC32_com::can_id
uint8_t can_id
The CAN identifier.
Definition: actuators_esc32.h:163
ESC32_CAN_TELEM_STATUS
@ ESC32_CAN_TELEM_STATUS
Definition: actuators_esc32.h:135
ESC32_CAN_DATA_INPUT_MODE
@ ESC32_CAN_DATA_INPUT_MODE
Definition: actuators_esc32.h:121
ESC32_com
Definition: actuators_esc32.h:158
ESC32_response::data
uint8_t data[8]
The data of the response.
Definition: actuators_esc32.h:148
ESC32::can_seq_idx
uint8_t can_seq_idx
CAN seq ID used for communicating.
Definition: actuators_esc32.h:186
actuators_esc32_config_cmd
void actuators_esc32_config_cmd(uint8_t i)
When receiving a configuration setting command.
Definition: actuators_esc32.c:83
ESC32_CAN_CMD_SETPOINT10
@ ESC32_CAN_CMD_SETPOINT10
Definition: actuators_esc32.h:98
ESC32_CAN_TELEM_STATE
@ ESC32_CAN_TELEM_STATE
Definition: actuators_esc32.h:136
ESC32_CAN_DATA_STATE
@ ESC32_CAN_DATA_STATE
Definition: actuators_esc32.h:123
ESC32_CAN_TELEM_TEMP
@ ESC32_CAN_TELEM_TEMP
Definition: actuators_esc32.h:137
ESC32_com::type
uint8_t type
The type of ESC.
Definition: actuators_esc32.h:162
ESC32_STATUS_ESC_FREE
@ ESC32_STATUS_ESC_FREE
Definition: actuators_esc32.h:153
ESC32::config_cmd
enum ESC32_config_cmd config_cmd
The command.
Definition: actuators_esc32.h:194
ESC32_STATUS_UNARMED
@ ESC32_STATUS_UNARMED
Definition: actuators_esc32.h:170
ESC32_CAN_CMD_BEEP
@ ESC32_CAN_CMD_BEEP
Definition: actuators_esc32.h:107
ESC32::melody_status
uint32_t melody_status
The status of the melody.
Definition: actuators_esc32.h:184
ESC32_CAN_DATA_GROUP
@ ESC32_CAN_DATA_GROUP
Definition: actuators_esc32.h:118