Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
actuators_esc32.c File Reference

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>
+ Include dependency graph for actuators_esc32.c:

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
 

Detailed Description

Actuators driver for AutoQuad ESC32 motor controllers.

Definition in file actuators_esc32.c.

Macro Definition Documentation

◆ ACTUATORS_ESC32_START_DELAY

#define ACTUATORS_ESC32_START_DELAY   500

Definition at line 36 of file actuators_esc32.c.

Function Documentation

◆ actuators_esc32_arm()

static void actuators_esc32_arm ( uint32_t  tt,
uint8_t  tid 
)
inlinestatic

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_beep()

static void actuators_esc32_beep ( uint32_t  tt,
uint8_t  tid,
uint16_t  freq,
uint16_t  dur 
)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_can_rx_cb()

void actuators_esc32_can_rx_cb ( uint32_t  id,
uint8_t data,
int  len 
)
static

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_commit()

◆ actuators_esc32_config_cmd()

◆ actuators_esc32_dir()

static void actuators_esc32_dir ( uint32_t  tt,
uint8_t  tid 
)
inlinestatic

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_disarm()

static void actuators_esc32_disarm ( uint32_t  tt,
uint8_t  tid 
)
inlinestatic

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_duty()

static void actuators_esc32_duty ( uint32_t  tt,
uint8_t  tid,
uint16_t cmds 
)
inlinestatic

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_grant_idx()

static void actuators_esc32_grant_idx ( uint8_t data)
inlinestatic

◆ actuators_esc32_init()

◆ actuators_esc32_play_melody()

static bool actuators_esc32_play_melody ( uint32_t  tt,
uint8_t  tid,
uint32_t status_sub,
uint16_t  melody[][2],
uint8_t  length 
)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_proc_telem()

static void actuators_esc32_proc_telem ( uint8_t data)
inlinestatic

When we receive a telemetry message.

Definition at line 379 of file actuators_esc32.c.

Referenced by actuators_esc32_can_rx_cb().

+ Here is the caller graph for this function:

◆ actuators_esc32_send()

static uint8_t actuators_esc32_send ( uint32_t  id,
uint8_t  tid,
uint8_t  length,
uint8_t data 
)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_esc32_set()

void actuators_esc32_set ( uint8_t  i,
uint16_t  v 
)

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.

◆ actuators_esc32_start()

static void actuators_esc32_start ( uint32_t  tt,
uint8_t  tid 
)
inlinestatic

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ actuators_esc32

◆ actuators_esc32_melody

uint16_t actuators_esc32_melody[][2]
static
Initial value:
= {
{660, 75},
{0, 100},
{660, 75},
{0, 200},
{660, 75},
{0, 200},
{770, 75},
{0, 66},
{660, 75},
{0, 200},
{510, 75},
{0, 366},
{1120, 75},
{0, 500},
}

Definition at line 37 of file actuators_esc32.c.

Referenced by actuators_esc32_commit(), and actuators_esc32_init().

◆ actuators_esc32_melody_size

uint8_t actuators_esc32_melody_size
static
Initial value:
static uint16_t actuators_esc32_melody[][2]

Definition at line 53 of file actuators_esc32.c.

Referenced by actuators_esc32_commit(), and actuators_esc32_init().