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;
286 }
else if (counter < length &&
SysTimeTimer(timer) > timeout) {
287 if (melody[counter][0] != 0) {
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++) {
#define ESC32_CAN_LCC_HIGH
struct ESC32_response responses[ESC32_RESPONSE_CNT]
Responses of CAN messages.
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_proc_telem(uint8_t *data)
When we receive a telemetry message.
uint8_t data[8]
The data of the response.
struct ESC32_com escs[SERVOS_ESC32_NB]
The ESCs connected via CAN.
static void actuators_esc32_start(uint32_t tt, uint8_t tid)
Starts the ESC (let's it turn when armed)
static void actuators_esc32_dir(uint32_t tt, uint8_t tid)
Changes the direction the ESC is turing.
#define ESC32_CAN_FID_NACK
bool autopilot_get_motors_on(void)
get motors status
uint8_t config_idx
Selected ESC.
#define ESC32_CAN_TT_NODE
void ppz_can_init(can_rx_callback_t callback)
#define ESC32_CAN_FID_TELEM
enum ESC32_status status
The current status of all actuators.
static void actuators_esc32_grant_idx(uint8_t *data)
When we receive a message to grant an id.
void actuators_esc32_commit(void)
Commits the commands and sends them to the ESCs.
uint8_t fid
The FID of the response.
void actuators_esc32_init(void)
Initializes the ESCs.
#define ESC32_CAN_FID_CMD
uint8_t network_id
Index in the array +1.
uint32_t uuid
The UUID of the ESC.
Hardware independent API for actuators (servos, motor controllers).
int ppz_can_transmit(uint32_t id, const uint8_t *buf, uint8_t len)
#define ESC32_CAN_FID_ACK
#define ESC32_CAN_TID_MASK
Architecture independent timing functions.
static void actuators_esc32_arm(uint32_t tt, uint8_t tid)
Arms the ESC.
enum ESC32_esc_status status
The current status of the esc.
#define ESC32_CAN_FID_GRANT_ADDR
struct ESC32 actuators_esc32
static uint16_t actuators_esc32_melody[][2]
static void actuators_esc32_can_rx_cb(uint32_t id, uint8_t *data, int len)
When receiving messages on the CAN bus.
#define ESC32_CAN_LCC_EXCEPTION
void actuators_esc32_config_cmd(uint8_t i)
When receiving a configuration setting command.
#define ESC32_CAN_FID_SET
#define ESC32_CAN_TT_GROUP
uint8_t escs_sorted[SERVOS_ESC32_NB]
The ESCs sorted by uuid.
Core autopilot interface common to all firmwares.
#define ESC32_CAN_SEQ_MASK
#define ESC32_RESPONSE_CNT
uint8_t can_id
The CAN identifier.
uint8_t can_seq_idx
CAN seq ID used for communicating.
static void actuators_esc32_disarm(uint32_t tt, uint8_t tid)
Disarms the ESC.
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...
void actuators_esc32_set(uint8_t i, uint16_t v)
Set the commands (either RPM or duty cycle)
static uint8_t actuators_esc32_melody_size
#define ESC32_CAN_FID_REQ_ADDR
#define ESC32_CAN_LCC_NORMAL
#define ESC32_CAN_FID_RESET_BUS
uint8_t type
The type of ESC.
#define ESC32_CAN_FID_GET
#define SysTimeTimerStart(_t)
static void actuators_esc32_duty(uint32_t tt, uint8_t tid, uint16_t *cmds)
Set the duty cycle of an ESC.
#define ESC32_CAN_FID_MASK
#define ACTUATORS_ESC32_START_DELAY
uint16_t cmds[SERVOS_ESC32_NB]
Commands which need to be committed.
#define ESC32_CAN_FID_REPLY
Actuators driver for AutoQuad ESC32 motor controllers.
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.
enum ESC32_config_cmd config_cmd
The command.
uint32_t melody_status
The status of the melody.