PX4 Firmware
PX4 Autopilot Software http://px4.io
tap_esc_common Namespace Reference

Functions

static uint8_t crc8_esc (uint8_t *p, uint8_t len)
 
static uint8_t crc_packet (EscPacket &p)
 
void select_responder (uint8_t sel)
 Select tap esc responder data for serial interface by 74hct151. More...
 
int initialise_uart (const char *const device, int &uart_fd)
 Opens a device for use as UART. More...
 
int deinitialise_uart (int &uart_fd)
 Closes a device previously opened with initialise_uart(). More...
 
int enable_flow_control (int uart_fd, bool enabled)
 Enables/disables flow control for open UART device. More...
 
int send_packet (int uart_fd, EscPacket &packet, int responder)
 Sends a packet to all ESCs and requests a specific ESC to respond. More...
 
int read_data_from_uart (int uart_fd, ESC_UART_BUF *const uart_buf)
 Read data from the UART into a buffer. More...
 
int parse_tap_esc_feedback (ESC_UART_BUF *const serial_buf, EscPacket *const packetdata)
 Parse feedback from an ESC. More...
 

Variables

const uint8_t crc_table [256]
 Lookup-table for faster CRC computation when sending ESC packets. More...
 

Function Documentation

◆ crc8_esc()

static uint8_t tap_esc_common::crc8_esc ( uint8_t *  p,
uint8_t  len 
)
static

Definition at line 263 of file tap_esc_common.cpp.

References crc_table.

Referenced by crc_packet(), and parse_tap_esc_feedback().

Here is the caller graph for this function:

◆ crc_packet()

static uint8_t tap_esc_common::crc_packet ( EscPacket p)
static

Definition at line 274 of file tap_esc_common.cpp.

References EscPacket::bytes, crc8_esc(), EscPacket::d, and EscPacket::len.

Referenced by send_packet().

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

◆ deinitialise_uart()

int tap_esc_common::deinitialise_uart ( int &  uart_fd)

Closes a device previously opened with initialise_uart().

Parameters
uart_fdfile-descriptor of UART device as provided by initialise_uart()
Returns
0 on success, -1 on error

Definition at line 106 of file tap_esc_common.cpp.

Referenced by TAP_ESC::~TAP_ESC().

Here is the caller graph for this function:

◆ enable_flow_control()

int tap_esc_common::enable_flow_control ( int  uart_fd,
bool  enabled 
)

Enables/disables flow control for open UART device.

Parameters
uart_fdfile-descriptor of UART device
enabledSet true for enabling and false for disabling flow control
Returns
0 on success, -1 on error

Definition at line 117 of file tap_esc_common.cpp.

Referenced by Mavlink::get_instance_id(), and initialise_uart().

Here is the caller graph for this function:

◆ initialise_uart()

int tap_esc_common::initialise_uart ( const char *const  device,
int &  uart_fd 
)

Opens a device for use as UART.

Parameters
deviceUNIX path of UART device
uart_fdfile-descriptor of UART device
Returns
0 on success, -1 on error

Definition at line 66 of file tap_esc_common.cpp.

References B250000, and enable_flow_control().

Referenced by TAP_ESC::init().

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

◆ parse_tap_esc_feedback()

int tap_esc_common::parse_tap_esc_feedback ( ESC_UART_BUF *const  serial_buf,
EscPacket *const  packetdata 
)

Parse feedback from an ESC.

Parameters
serial_bufBuffer where incoming data will be stored
packetdataPacket that will be populated with information from buffer
Returns
0 on success, -1 on error

Definition at line 177 of file tap_esc_common.cpp.

References EscPacket::bytes, CRC, crc8_esc(), EscPacket::crc_data, EscPacket::d, ESC_UART_BUF::dat_cnt, DATA, ESC_UART_BUF::esc_feedback_buf, ESCBUS_MSG_ID_MAX_NUM, EscPacket::head, ESC_UART_BUF::head, HEAD, ID, EscPacket::len, LEN, EscPacket::msg_id, PACKET_HEAD, state, and UART_BUFFER_SIZE.

Referenced by TAP_ESC::cycle().

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

◆ read_data_from_uart()

int tap_esc_common::read_data_from_uart ( int  uart_fd,
ESC_UART_BUF *const  uart_buf 
)

Read data from the UART into a buffer.

Parameters
uart_fdfile-descriptor of UART device
uart_bufBuffer where incoming data will be stored
Returns
0 on success, -1 on error

Definition at line 154 of file tap_esc_common.cpp.

References arraySize, ESC_UART_BUF::dat_cnt, ESC_UART_BUF::esc_feedback_buf, read(), ESC_UART_BUF::tail, and UART_BUFFER_SIZE.

Referenced by TAP_ESC::cycle().

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

◆ select_responder()

void tap_esc_common::select_responder ( uint8_t  sel)

Select tap esc responder data for serial interface by 74hct151.

GPIOs to be defined in board_config.h

Parameters
selID of the ESC (responder) of which feedback is requested

Definition at line 57 of file tap_esc_common.cpp.

Referenced by send_packet().

Here is the caller graph for this function:

◆ send_packet()

int tap_esc_common::send_packet ( int  uart_fd,
EscPacket packet,
int  responder 
)

Sends a packet to all ESCs and requests a specific ESC to respond.

Parameters
uart_fdfile-descriptor of UART device
packetPacket to be sent to ESCs. CRC information will be added.
responderID of the ESC (responder) that should return feedback
Returns
On success number of bytes written, on error -1

Definition at line 138 of file tap_esc_common.cpp.

References crc_packet(), EscPacket::head, select_responder(), and write().

Referenced by Mavlink::begin_send(), TAP_ESC::init(), and TAP_ESC::send_esc_outputs().

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

Variable Documentation

◆ crc_table

const uint8_t tap_esc_common::crc_table
Initial value:
= {
0x00, 0xE7, 0x29, 0xCE, 0x52, 0xB5, 0x7B, 0x9C, 0xA4, 0x43, 0x8D, 0x6A,
0xF6, 0x11, 0xDF, 0x38, 0xAF, 0x48, 0x86, 0x61, 0xFD, 0x1A, 0xD4, 0x33,
0x0B, 0xEC, 0x22, 0xC5, 0x59, 0xBE, 0x70, 0x97, 0xB9, 0x5E, 0x90, 0x77,
0xEB, 0x0C, 0xC2, 0x25, 0x1D, 0xFA, 0x34, 0xD3, 0x4F, 0xA8, 0x66, 0x81,
0x16, 0xF1, 0x3F, 0xD8, 0x44, 0xA3, 0x6D, 0x8A, 0xB2, 0x55, 0x9B, 0x7C,
0xE0, 0x07, 0xC9, 0x2E, 0x95, 0x72, 0xBC, 0x5B, 0xC7, 0x20, 0xEE, 0x09,
0x31, 0xD6, 0x18, 0xFF, 0x63, 0x84, 0x4A, 0xAD, 0x3A, 0xDD, 0x13, 0xF4,
0x68, 0x8F, 0x41, 0xA6, 0x9E, 0x79, 0xB7, 0x50, 0xCC, 0x2B, 0xE5, 0x02,
0x2C, 0xCB, 0x05, 0xE2, 0x7E, 0x99, 0x57, 0xB0, 0x88, 0x6F, 0xA1, 0x46,
0xDA, 0x3D, 0xF3, 0x14, 0x83, 0x64, 0xAA, 0x4D, 0xD1, 0x36, 0xF8, 0x1F,
0x27, 0xC0, 0x0E, 0xE9, 0x75, 0x92, 0x5C, 0xBB, 0xCD, 0x2A, 0xE4, 0x03,
0x9F, 0x78, 0xB6, 0x51, 0x69, 0x8E, 0x40, 0xA7, 0x3B, 0xDC, 0x12, 0xF5,
0x62, 0x85, 0x4B, 0xAC, 0x30, 0xD7, 0x19, 0xFE, 0xC6, 0x21, 0xEF, 0x08,
0x94, 0x73, 0xBD, 0x5A, 0x74, 0x93, 0x5D, 0xBA, 0x26, 0xC1, 0x0F, 0xE8,
0xD0, 0x37, 0xF9, 0x1E, 0x82, 0x65, 0xAB, 0x4C, 0xDB, 0x3C, 0xF2, 0x15,
0x89, 0x6E, 0xA0, 0x47, 0x7F, 0x98, 0x56, 0xB1, 0x2D, 0xCA, 0x04, 0xE3,
0x58, 0xBF, 0x71, 0x96, 0x0A, 0xED, 0x23, 0xC4, 0xFC, 0x1B, 0xD5, 0x32,
0xAE, 0x49, 0x87, 0x60, 0xF7, 0x10, 0xDE, 0x39, 0xA5, 0x42, 0x8C, 0x6B,
0x53, 0xB4, 0x7A, 0x9D, 0x01, 0xE6, 0x28, 0xCF, 0xE1, 0x06, 0xC8, 0x2F,
0xB3, 0x54, 0x9A, 0x7D, 0x45, 0xA2, 0x6C, 0x8B, 0x17, 0xF0, 0x3E, 0xD9,
0x4E, 0xA9, 0x67, 0x80, 0x1C, 0xFB, 0x35, 0xD2, 0xEA, 0x0D, 0xC3, 0x24,
0xB8, 0x5F, 0x91, 0x76
}

Lookup-table for faster CRC computation when sending ESC packets.

Definition at line 282 of file tap_esc_common.cpp.

Referenced by crc8_esc().