31 #include <libopencm3/stm32/can.h>
36 #define ACTUATORS_ESC32_START_DELAY 500
75 #ifdef ACTUAOTRS_ESC32_RPM
135 for (i = 0; i < SERVOS_ESC32_NB; i++) {
152 for (i = 1; i <= (SERVOS_ESC32_NB - 1) / 4 + 1; i++) {
243 char *name =
"DIRECTION";
264 *value = *value * -1;
278 uint32_t timer = (*status_sub & 0x00FFFFFF) << 8;
283 if (*status_sub == 0) {
285 *status_sub = *status_sub >> 8;
291 *status_sub = *status_sub + (1 << 24);
349 data[4] = (i / 4) + 1;
350 data[5] = (i % 4) + 1;
356 if (i >= SERVOS_ESC32_NB - 1) {
359 for (i = 0; i < SERVOS_ESC32_NB; i++) {
362 for (j = 0; j < SERVOS_ESC32_NB; j++) {
static bool actuators_esc32_play_melody(uint32_t tt, uint8_t tid, uint32_t *status_sub, uint16_t melody[][2], uint8_t length)
Plays a full melody.
static void actuators_esc32_dir(uint32_t tt, uint8_t tid)
Changes the direction the ESC is turing.
static uint16_t actuators_esc32_melody[][2]
static void actuators_esc32_arm(uint32_t tt, uint8_t tid)
Arms the ESC.
static void actuators_esc32_disarm(uint32_t tt, uint8_t tid)
Disarms the ESC.
#define ACTUATORS_ESC32_START_DELAY
static void actuators_esc32_duty(uint32_t tt, uint8_t tid, uint16_t *cmds)
Set the duty cycle of an ESC.
void actuators_esc32_commit(void)
Commits the commands and sends them to the ESCs.
struct ESC32 actuators_esc32
static uint8_t actuators_esc32_send(uint32_t id, uint8_t tid, uint8_t length, uint8_t *data)
Transmit a message on the CAN bus.
static void actuators_esc32_start(uint32_t tt, uint8_t tid)
Starts the ESC (let's it turn when armed)
void actuators_esc32_config_cmd(uint8_t i)
When receiving a configuration setting command.
static uint8_t actuators_esc32_melody_size
static void actuators_esc32_beep(uint32_t tt, uint8_t tid, uint16_t freq, uint16_t dur)
Let an ESC beep for a certain amount of time with a specified frequency(frequency doesn't really matc...
static void actuators_esc32_can_rx_cb(uint32_t id, uint8_t *data, int len)
When receiving messages on the CAN bus.
void actuators_esc32_init(void)
Initializes the ESCs.
static void actuators_esc32_grant_idx(uint8_t *data)
When we receive a message to grant an id.
void actuators_esc32_set(uint8_t i, uint16_t v)
Set the commands (either RPM or duty cycle)
static void actuators_esc32_proc_telem(uint8_t *data)
When we receive a telemetry message.
Actuators driver for AutoQuad ESC32 motor controllers.
uint8_t config_idx
Selected ESC.
#define ESC32_CAN_FID_GET
uint16_t cmds[SERVOS_ESC32_NB]
Commands which need to be committed.
#define ESC32_CAN_FID_TELEM
#define ESC32_CAN_LCC_NORMAL
struct ESC32_com escs[SERVOS_ESC32_NB]
The ESCs connected via CAN.
#define ESC32_CAN_FID_CMD
uint8_t type
The type of ESC.
#define ESC32_CAN_FID_RESET_BUS
#define ESC32_CAN_FID_ACK
#define ESC32_CAN_LCC_EXCEPTION
#define ESC32_CAN_TT_NODE
@ ESC32_CAN_DATA_PARAM_NAME2
@ ESC32_CAN_DATA_PARAM_NAME1
@ ESC32_CAN_DATA_PARAM_ID
#define ESC32_RESPONSE_CNT
enum ESC32_esc_status status
The current status of the esc.
#define ESC32_CAN_TID_MASK
uint8_t data[8]
The data of the response.
#define ESC32_CAN_FID_SET
#define ESC32_CAN_LCC_HIGH
#define ESC32_CAN_FID_GRANT_ADDR
uint8_t network_id
Index in the array +1.
@ ESC32_CAN_CMD_SETPOINT16
uint32_t uuid
The UUID of the ESC.
uint8_t can_seq_idx
CAN seq ID used for communicating.
enum ESC32_status status
The current status of all actuators.
uint8_t escs_sorted[SERVOS_ESC32_NB]
The ESCs sorted by uuid.
uint8_t can_id
The CAN identifier.
#define ESC32_CAN_SEQ_MASK
enum ESC32_config_cmd config_cmd
The command.
#define ESC32_CAN_FID_NACK
#define ESC32_CAN_TT_GROUP
#define ESC32_CAN_FID_REPLY
#define ESC32_CAN_FID_MASK
struct ESC32_response responses[ESC32_RESPONSE_CNT]
Responses of CAN messages.
uint32_t melody_status
The status of the melody.
#define ESC32_CAN_FID_REQ_ADDR
uint8_t fid
The FID of the response.
bool autopilot_get_motors_on(void)
get motors status
Core autopilot interface common to all firmwares.
int ppz_can_transmit(uint32_t id, const uint8_t *buf, uint8_t len)
void ppz_can_init(can_rx_callback_t callback)
Hardware independent API for actuators (servos, motor controllers).
Architecture independent timing functions.
#define SysTimeTimerStart(_t)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.