Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Actuators driver for AutoQuad ESC32 motor controllers. More...
#include "modules/actuators/actuators.h"
#include "modules/actuators/actuators_esc32.h"
#include "mcu_periph/sys_time.h"
#include "mcu_periph/can.h"
#include "autopilot.h"
#include <libopencm3/stm32/can.h>
#include <limits.h>
Go to the source code of this file.
Macros | |
#define | ACTUATORS_ESC32_START_DELAY 500 |
Functions | |
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. More... | |
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 match) More... | |
static void | actuators_esc32_arm (uint32_t tt, uint8_t tid) |
Arms the ESC. More... | |
static void | actuators_esc32_disarm (uint32_t tt, uint8_t tid) |
Disarms the ESC. More... | |
static void | actuators_esc32_start (uint32_t tt, uint8_t tid) |
Starts the ESC (let's it turn when armed) More... | |
static void | actuators_esc32_duty (uint32_t tt, uint8_t tid, uint16_t *cmds) |
Set the duty cycle of an ESC. More... | |
static void | actuators_esc32_dir (uint32_t tt, uint8_t tid) |
Changes the direction the ESC is turing. More... | |
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. More... | |
static void | actuators_esc32_can_rx_cb (uint32_t id, uint8_t *data, int len) |
When receiving messages on the CAN bus. More... | |
static void | actuators_esc32_grant_idx (uint8_t *data) |
When we receive a message to grant an id. More... | |
static void | actuators_esc32_proc_telem (uint8_t *data) |
When we receive a telemetry message. More... | |
void | actuators_esc32_set (uint8_t i, uint16_t v) |
Set the commands (either RPM or duty cycle) More... | |
void | actuators_esc32_config_cmd (uint8_t i) |
When receiving a configuration setting command. More... | |
void | actuators_esc32_init (void) |
Initializes the ESCs. More... | |
void | actuators_esc32_commit (void) |
Commits the commands and sends them to the ESCs. More... | |
Variables | |
struct ESC32 | actuators_esc32 |
static uint16_t | actuators_esc32_melody [][2] |
static uint8_t | actuators_esc32_melody_size |
Actuators driver for AutoQuad ESC32 motor controllers.
Definition in file actuators_esc32.c.
#define ACTUATORS_ESC32_START_DELAY 500 |
Definition at line 36 of file actuators_esc32.c.
Arms the ESC.
Definition at line 213 of file actuators_esc32.c.
References actuators_esc32_send(), ESC32_CAN_CMD_ARM, ESC32_CAN_FID_CMD, and ESC32_CAN_LCC_NORMAL.
Referenced by actuators_esc32_commit(), and actuators_esc32_config_cmd().
|
inlinestatic |
Let an ESC beep for a certain amount of time with a specified frequency(frequency doesn't really match)
Definition at line 203 of file actuators_esc32.c.
References actuators_esc32_send(), ESC32_CAN_CMD_BEEP, ESC32_CAN_FID_CMD, and ESC32_CAN_LCC_NORMAL.
Referenced by actuators_esc32_config_cmd(), and actuators_esc32_play_melody().
When receiving messages on the CAN bus.
When the CAN bus receives a message.
Definition at line 300 of file actuators_esc32.c.
References actuators_esc32, actuators_esc32_grant_idx(), actuators_esc32_proc_telem(), ESC32_response::data, ESC32_CAN_FID_ACK, ESC32_CAN_FID_MASK, ESC32_CAN_FID_NACK, ESC32_CAN_FID_REPLY, ESC32_CAN_FID_REQ_ADDR, ESC32_CAN_FID_TELEM, ESC32_CAN_SEQ_MASK, ESC32_response::fid, and ESC32::responses.
Referenced by actuators_esc32_init().
void actuators_esc32_commit | ( | void | ) |
Commits the commands and sends them to the ESCs.
Definition at line 147 of file actuators_esc32.c.
References actuators_esc32, actuators_esc32_arm(), actuators_esc32_disarm(), actuators_esc32_duty(), actuators_esc32_melody, actuators_esc32_melody_size, actuators_esc32_play_melody(), actuators_esc32_start(), autopilot_get_motors_on(), ESC32::cmds, ESC32_CAN_TT_GROUP, ESC32_STATUS_MELODY, ESC32_STATUS_RUNNING, ESC32_STATUS_UNARMED, ESC32::melody_status, and ESC32::status.
void actuators_esc32_config_cmd | ( | uint8_t | i | ) |
When receiving a configuration setting command.
Definition at line 83 of file actuators_esc32.c.
References actuators_esc32, actuators_esc32_arm(), actuators_esc32_beep(), actuators_esc32_dir(), actuators_esc32_disarm(), actuators_esc32_duty(), actuators_esc32_start(), cmds, ESC32::config_cmd, ESC32::config_idx, ESC32_CAN_TT_NODE, ESC32_CONFIG_CMD_BEEP, ESC32_CONFIG_CMD_DIR, ESC32_CONFIG_CMD_IDLE, ESC32_CONFIG_CMD_TURN, ESC32_STATUS_UNARMED, ESC32::escs_sorted, and ESC32::status.
Changes the direction the ESC is turing.
Definition at line 241 of file actuators_esc32.c.
References actuators_esc32, actuators_esc32_send(), ESC32_response::data, ESC32_CAN_DATA_PARAM_ID, ESC32_CAN_DATA_PARAM_NAME1, ESC32_CAN_DATA_PARAM_NAME2, ESC32_CAN_FID_GET, ESC32_CAN_FID_SET, ESC32_CAN_LCC_NORMAL, ESC32_response::fid, and ESC32::responses.
Referenced by actuators_esc32_config_cmd().
Disarms the ESC.
Definition at line 220 of file actuators_esc32.c.
References actuators_esc32_send(), ESC32_CAN_CMD_DISARM, ESC32_CAN_FID_CMD, and ESC32_CAN_LCC_NORMAL.
Referenced by actuators_esc32_commit(), and actuators_esc32_config_cmd().
Set the duty cycle of an ESC.
Definition at line 234 of file actuators_esc32.c.
References actuators_esc32_send(), cmds, ESC32_CAN_CMD_SETPOINT16, ESC32_CAN_FID_CMD, and ESC32_CAN_LCC_NORMAL.
Referenced by actuators_esc32_commit(), and actuators_esc32_config_cmd().
|
inlinestatic |
When we receive a message to grant an id.
Definition at line 330 of file actuators_esc32.c.
References actuators_esc32, actuators_esc32_send(), ESC32_com::can_id, ESC32_CAN_FID_GRANT_ADDR, ESC32_CAN_LCC_HIGH, ESC32_CAN_TID_MASK, ESC32_CAN_TT_NODE, ESC32_STATUS_ESC_FREE, ESC32_STATUS_ESC_INIT, ESC32_STATUS_ESC_RDY, ESC32_STATUS_MELODY, ESC32::escs, ESC32::escs_sorted, ESC32_com::network_id, ESC32_com::status, ESC32::status, ESC32_com::type, and ESC32_com::uuid.
Referenced by actuators_esc32_can_rx_cb().
void actuators_esc32_init | ( | void | ) |
Initializes the ESCs.
Definition at line 122 of file actuators_esc32.c.
References actuators_esc32, actuators_esc32_can_rx_cb(), actuators_esc32_melody, actuators_esc32_melody_size, actuators_esc32_send(), ESC32_CAN_FID_RESET_BUS, ESC32_CAN_LCC_EXCEPTION, ESC32_CAN_TT_GROUP, ESC32_STATUS_ESC_FREE, ESC32_STATUS_INIT, ESC32::escs, ESC32::melody_status, ppz_can_init(), ESC32_com::status, and ESC32::status.
|
static |
Plays a full melody.
Definition at line 275 of file actuators_esc32.c.
References actuators_esc32_beep(), ACTUATORS_ESC32_START_DELAY, counter, SysTimeTimer, SysTimeTimerStart, and timeout.
Referenced by actuators_esc32_commit().
|
inlinestatic |
When we receive a telemetry message.
Definition at line 379 of file actuators_esc32.c.
Referenced by actuators_esc32_can_rx_cb().
|
static |
Transmit a message on the CAN bus.
Send a message to an esc or a group.
Definition at line 192 of file actuators_esc32.c.
References actuators_esc32, ESC32::can_seq_idx, ESC32_RESPONSE_CNT, ESC32_response::fid, ppz_can_transmit(), and ESC32::responses.
Referenced by actuators_esc32_arm(), actuators_esc32_beep(), actuators_esc32_dir(), actuators_esc32_disarm(), actuators_esc32_duty(), actuators_esc32_grant_idx(), actuators_esc32_init(), and actuators_esc32_start().
Set the commands (either RPM or duty cycle)
Definition at line 73 of file actuators_esc32.c.
References actuators_esc32, ESC32::cmds, and ESC32::escs_sorted.
Starts the ESC (let's it turn when armed)
Definition at line 227 of file actuators_esc32.c.
References actuators_esc32_send(), ESC32_CAN_CMD_START, ESC32_CAN_FID_CMD, and ESC32_CAN_LCC_NORMAL.
Referenced by actuators_esc32_commit(), and actuators_esc32_config_cmd().
struct ESC32 actuators_esc32 |
Definition at line 1 of file actuators_esc32.c.
Referenced by actuators_esc32_can_rx_cb(), actuators_esc32_commit(), actuators_esc32_config_cmd(), actuators_esc32_dir(), actuators_esc32_grant_idx(), actuators_esc32_init(), actuators_esc32_send(), and actuators_esc32_set().
|
static |
Definition at line 37 of file actuators_esc32.c.
Referenced by actuators_esc32_commit(), and actuators_esc32_init().
|
static |
Definition at line 53 of file actuators_esc32.c.
Referenced by actuators_esc32_commit(), and actuators_esc32_init().