APM:Libraries
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ChibiOS::RCOutput Class Reference

#include <RCOutput.h>

Inheritance diagram for ChibiOS::RCOutput:
[legend]
Collaboration diagram for ChibiOS::RCOutput:
[legend]

Classes

struct  irq_state
 
struct  pwm_group
 

Public Member Functions

void init ()
 
void set_freq (uint32_t chmask, uint16_t freq_hz)
 
uint16_t get_freq (uint8_t ch)
 
void enable_ch (uint8_t ch)
 
void disable_ch (uint8_t ch)
 
void write (uint8_t ch, uint16_t period_us)
 
uint16_t read (uint8_t ch)
 
void read (uint16_t *period_us, uint8_t len)
 
uint16_t read_last_sent (uint8_t ch) override
 
void read_last_sent (uint16_t *period_us, uint8_t len) override
 
void set_esc_scaling (uint16_t min_pwm, uint16_t max_pwm) override
 
bool get_esc_scaling (uint16_t &min_pwm, uint16_t &max_pwm) override
 
void set_output_mode (uint16_t mask, enum output_mode mode) override
 
float scale_esc_to_unity (uint16_t pwm) override
 
void cork (void) override
 
void push (void) override
 
bool force_safety_on (void) override
 
void force_safety_off (void) override
 
void set_safety_pwm (uint32_t chmask, uint16_t period_us) override
 
bool enable_px4io_sbus_out (uint16_t rate_hz) override
 
void set_default_rate (uint16_t rate_hz) override
 
void timer_tick (void) override
 
bool setup_serial_output (uint16_t chan_mask, ByteBuffer *buffer, uint32_t baudrate)
 
bool serial_setup_output (uint8_t chan, uint32_t baudrate) override
 
bool serial_write_bytes (const uint8_t *bytes, uint16_t len) override
 
uint16_t serial_read_bytes (uint8_t *buf, uint16_t len) override
 
void serial_end (void) override
 
void set_telem_request_mask (uint16_t mask)
 
AP_HAL::Util::safety_state _safety_switch_state (void)
 
- Public Member Functions inherited from AP_HAL::RCOutput
virtual void set_failsafe_pwm (uint32_t chmask, uint16_t period_us)
 
virtual void force_safety_no_wait (void)
 

Private Member Functions

void push_local (void)
 
void trigger_groups (void)
 
void set_freq_group (pwm_group &group)
 
void safety_update (void)
 
void dma_allocate (Shared_DMA *ctx)
 
void dma_deallocate (Shared_DMA *ctx)
 
uint16_t create_dshot_packet (const uint16_t value, bool telem_request)
 
void fill_DMA_buffer_dshot (uint32_t *buffer, uint8_t stride, uint16_t packet, uint16_t clockmul)
 
void dshot_send (pwm_group &group, bool blocking)
 
bool mode_requires_dma (enum output_mode mode) const
 
bool setup_group_DMA (pwm_group &group, uint32_t bitrate, uint32_t bit_width, bool active_high)
 
void send_pulses_DMAR (pwm_group &group, uint32_t buffer_length)
 
void set_group_mode (pwm_group &group)
 
bool serial_write_byte (uint8_t b)
 
bool serial_read_byte (uint8_t &b)
 
void fill_DMA_buffer_byte (uint32_t *buffer, uint8_t stride, uint8_t b, uint32_t bitval)
 

Static Private Member Functions

static void dma_irq_callback (void *p, uint32_t flags)
 
static void serial_bit_irq (void)
 

Private Attributes

struct pwm_groupserial_group
 
thread_t * serial_thread
 
tprio_t serial_priority
 
uint16_t _esc_pwm_min
 
uint16_t _esc_pwm_max
 
uint8_t chan_offset
 
uint8_t num_fmu_channels
 
uint8_t active_fmu_channels
 
uint16_t last_sent [max_channels]
 
uint32_t en_mask
 
uint16_t period [max_channels]
 
uint16_t safe_pwm [max_channels]
 
bool corked
 
uint16_t fast_channel_mask
 
uint16_t io_fast_channel_mask
 
uint64_t min_pulse_trigger_us
 
mutex_t trigger_mutex
 
uint8_t trigger_groupmask
 
uint16_t trigger_widest_pulse
 
bool iomcu_oneshot125
 
AP_HAL::Util::safety_state safety_state
 
uint32_t safety_update_ms
 
uint8_t led_counter
 
int8_t safety_button_counter
 
uint16_t safety_mask
 
const uint8_t dshot_post = 6
 
const uint16_t dshot_bit_length = 16 + dshot_post
 
const uint16_t dshot_buffer_length = dshot_bit_length*4*sizeof(uint32_t)
 
uint32_t dshot_pulse_time_us
 
uint16_t telem_request_mask
 

Static Private Attributes

static struct ChibiOS::RCOutput::irq_state irq
 
static pwm_group pwm_group_list []
 
static const uint8_t max_channels = 16
 
static const eventmask_t serial_event_mask = EVENT_MASK(1)
 

Additional Inherited Members

- Public Types inherited from AP_HAL::RCOutput
enum  output_mode {
  MODE_PWM_NONE, MODE_PWM_NORMAL, MODE_PWM_ONESHOT, MODE_PWM_ONESHOT125,
  MODE_PWM_BRUSHED, MODE_PWM_DSHOT150, MODE_PWM_DSHOT300, MODE_PWM_DSHOT600,
  MODE_PWM_DSHOT1200
}
 

Detailed Description

Definition at line 26 of file RCOutput.h.

Member Function Documentation

◆ _safety_switch_state()

AP_HAL::Util::safety_state RCOutput::_safety_switch_state ( void  )

Definition at line 1274 of file RCOutput.cpp.

Referenced by safety_update(), and set_telem_request_mask().

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

◆ cork()

void RCOutput::cork ( void  )
overridevirtual

Implements AP_HAL::RCOutput.

Definition at line 677 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ create_dshot_packet()

uint16_t RCOutput::create_dshot_packet ( const uint16_t  value,
bool  telem_request 
)
private

Definition at line 826 of file RCOutput.cpp.

Referenced by dshot_send().

Here is the caller graph for this function:

◆ disable_ch()

void RCOutput::disable_ch ( uint8_t  ch)
virtual

Implements AP_HAL::RCOutput.

Definition at line 280 of file RCOutput.cpp.

◆ dma_allocate()

void RCOutput::dma_allocate ( Shared_DMA ctx)
private

Definition at line 800 of file RCOutput.cpp.

Referenced by setup_group_DMA().

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

◆ dma_deallocate()

void RCOutput::dma_deallocate ( Shared_DMA ctx)
private

Definition at line 813 of file RCOutput.cpp.

Referenced by setup_group_DMA().

Here is the caller graph for this function:

◆ dma_irq_callback()

void RCOutput::dma_irq_callback ( void *  p,
uint32_t  flags 
)
staticprivate

Definition at line 954 of file RCOutput.cpp.

Referenced by dma_allocate().

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

◆ dshot_send()

void RCOutput::dshot_send ( pwm_group group,
bool  blocking 
)
private

Definition at line 866 of file RCOutput.cpp.

Referenced by timer_tick(), and trigger_groups().

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

◆ enable_ch()

void RCOutput::enable_ch ( uint8_t  ch)
virtual

Implements AP_HAL::RCOutput.

Definition at line 260 of file RCOutput.cpp.

◆ enable_px4io_sbus_out()

bool RCOutput::enable_px4io_sbus_out ( uint16_t  rate_hz)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 704 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ fill_DMA_buffer_byte()

void RCOutput::fill_DMA_buffer_byte ( uint32_t *  buffer,
uint8_t  stride,
uint8_t  b,
uint32_t  bitval 
)
private

Definition at line 1041 of file RCOutput.cpp.

Referenced by serial_write_byte().

Here is the caller graph for this function:

◆ fill_DMA_buffer_dshot()

void RCOutput::fill_DMA_buffer_dshot ( uint32_t *  buffer,
uint8_t  stride,
uint16_t  packet,
uint16_t  clockmul 
)
private

Definition at line 851 of file RCOutput.cpp.

Referenced by dshot_send().

Here is the caller graph for this function:

◆ force_safety_off()

void RCOutput::force_safety_off ( void  )
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 1303 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ force_safety_on()

bool RCOutput::force_safety_on ( void  )
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 1287 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ get_esc_scaling()

bool ChibiOS::RCOutput::get_esc_scaling ( uint16_t &  min_pwm,
uint16_t &  max_pwm 
)
inlineoverridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 42 of file RCOutput.h.

Here is the call graph for this function:

◆ get_freq()

uint16_t RCOutput::get_freq ( uint8_t  ch)
virtual

Implements AP_HAL::RCOutput.

Definition at line 236 of file RCOutput.cpp.

◆ init()

void RCOutput::init ( void  )
virtual

Implements AP_HAL::RCOutput.

Definition at line 49 of file RCOutput.cpp.

Here is the call graph for this function:

◆ mode_requires_dma()

bool RCOutput::mode_requires_dma ( enum output_mode  mode) const
private

Definition at line 477 of file RCOutput.cpp.

Referenced by set_freq_group(), and set_output_mode().

Here is the caller graph for this function:

◆ push()

void RCOutput::push ( void  )
overridevirtual

Implements AP_HAL::RCOutput.

Definition at line 690 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ push_local()

void RCOutput::push_local ( void  )
private

Definition at line 344 of file RCOutput.cpp.

Referenced by push(), and write().

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

◆ read() [1/2]

uint16_t RCOutput::read ( uint8_t  ch)
virtual

Implements AP_HAL::RCOutput.

Definition at line 423 of file RCOutput.cpp.

◆ read() [2/2]

void RCOutput::read ( uint16_t *  period_us,
uint8_t  len 
)
virtual

Implements AP_HAL::RCOutput.

Definition at line 437 of file RCOutput.cpp.

◆ read_last_sent() [1/2]

uint16_t RCOutput::read_last_sent ( uint8_t  ch)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 456 of file RCOutput.cpp.

Referenced by read_last_sent().

Here is the caller graph for this function:

◆ read_last_sent() [2/2]

void RCOutput::read_last_sent ( uint16_t *  period_us,
uint8_t  len 
)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 464 of file RCOutput.cpp.

Here is the call graph for this function:

◆ safety_update()

void RCOutput::safety_update ( void  )
private

Definition at line 1335 of file RCOutput.cpp.

Referenced by timer_tick().

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

◆ scale_esc_to_unity()

float ChibiOS::RCOutput::scale_esc_to_unity ( uint16_t  pwm)
inlineoverridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 49 of file RCOutput.h.

Here is the call graph for this function:

◆ send_pulses_DMAR()

void RCOutput::send_pulses_DMAR ( pwm_group group,
uint32_t  buffer_length 
)
private

Definition at line 920 of file RCOutput.cpp.

Referenced by dshot_send(), and serial_write_byte().

Here is the caller graph for this function:

◆ serial_bit_irq()

void RCOutput::serial_bit_irq ( void  )
staticprivate

Definition at line 1111 of file RCOutput.cpp.

Referenced by serial_read_bytes().

Here is the caller graph for this function:

◆ serial_end()

void RCOutput::serial_end ( void  )
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 1251 of file RCOutput.cpp.

Referenced by scale_esc_to_unity(), and serial_setup_output().

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

◆ serial_read_byte()

bool RCOutput::serial_read_byte ( uint8_t &  b)
private

Definition at line 1165 of file RCOutput.cpp.

Referenced by serial_read_bytes().

Here is the caller graph for this function:

◆ serial_read_bytes()

uint16_t RCOutput::serial_read_bytes ( uint8_t *  buf,
uint16_t  len 
)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 1192 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ serial_setup_output()

bool RCOutput::serial_setup_output ( uint8_t  chan,
uint32_t  baudrate 
)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 977 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ serial_write_byte()

bool RCOutput::serial_write_byte ( uint8_t  b)
private

Definition at line 1063 of file RCOutput.cpp.

Referenced by serial_write_bytes().

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

◆ serial_write_bytes()

bool RCOutput::serial_write_bytes ( const uint8_t *  bytes,
uint16_t  len 
)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 1085 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ set_default_rate()

void RCOutput::set_default_rate ( uint16_t  rate_hz)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 216 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ set_esc_scaling()

void ChibiOS::RCOutput::set_esc_scaling ( uint16_t  min_pwm,
uint16_t  max_pwm 
)
inlineoverridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 38 of file RCOutput.h.

◆ set_freq()

void RCOutput::set_freq ( uint32_t  chmask,
uint16_t  freq_hz 
)
virtual

Implements AP_HAL::RCOutput.

Definition at line 163 of file RCOutput.cpp.

Referenced by init().

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

◆ set_freq_group()

void RCOutput::set_freq_group ( pwm_group group)
private

Definition at line 92 of file RCOutput.cpp.

Referenced by serial_end(), set_freq(), and set_group_mode().

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

◆ set_group_mode()

void RCOutput::set_group_mode ( pwm_group group)
private

Definition at line 573 of file RCOutput.cpp.

Referenced by serial_end(), and set_output_mode().

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

◆ set_output_mode()

void RCOutput::set_output_mode ( uint16_t  mask,
enum output_mode  mode 
)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 641 of file RCOutput.cpp.

Referenced by get_esc_scaling().

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

◆ set_safety_pwm()

void RCOutput::set_safety_pwm ( uint32_t  chmask,
uint16_t  period_us 
)
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 1318 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ set_telem_request_mask()

void ChibiOS::RCOutput::set_telem_request_mask ( uint16_t  mask)
inlinevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 128 of file RCOutput.h.

Here is the call graph for this function:

◆ setup_group_DMA()

bool RCOutput::setup_group_DMA ( pwm_group group,
uint32_t  bitrate,
uint32_t  bit_width,
bool  active_high 
)
private

Definition at line 497 of file RCOutput.cpp.

Referenced by serial_setup_output(), and set_group_mode().

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

◆ setup_serial_output()

bool ChibiOS::RCOutput::setup_serial_output ( uint16_t  chan_mask,
ByteBuffer buffer,
uint32_t  baudrate 
)

Referenced by scale_esc_to_unity().

Here is the caller graph for this function:

◆ timer_tick()

void RCOutput::timer_tick ( void  )
overridevirtual

Reimplemented from AP_HAL::RCOutput.

Definition at line 768 of file RCOutput.cpp.

Referenced by scale_esc_to_unity().

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

◆ trigger_groups()

void RCOutput::trigger_groups ( void  )
private

Definition at line 717 of file RCOutput.cpp.

Referenced by push_local(), and timer_tick().

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

◆ write()

void RCOutput::write ( uint8_t  ch,
uint16_t  period_us 
)
virtual

Implements AP_HAL::RCOutput.

Definition at line 301 of file RCOutput.cpp.

Referenced by set_group_mode().

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

Member Data Documentation

◆ _esc_pwm_max

uint16_t ChibiOS::RCOutput::_esc_pwm_max
private

◆ _esc_pwm_min

uint16_t ChibiOS::RCOutput::_esc_pwm_min
private

◆ active_fmu_channels

uint8_t ChibiOS::RCOutput::active_fmu_channels
private

Definition at line 221 of file RCOutput.h.

Referenced by push_local(), and write().

◆ chan_offset

uint8_t ChibiOS::RCOutput::chan_offset
private

◆ corked

bool ChibiOS::RCOutput::corked
private

Definition at line 232 of file RCOutput.h.

Referenced by cork(), push(), and write().

◆ dshot_bit_length

const uint16_t ChibiOS::RCOutput::dshot_bit_length = 16 + dshot_post
private

Definition at line 277 of file RCOutput.h.

Referenced by set_group_mode().

◆ dshot_buffer_length

const uint16_t ChibiOS::RCOutput::dshot_buffer_length = dshot_bit_length*4*sizeof(uint32_t)
private

Definition at line 278 of file RCOutput.h.

Referenced by dshot_send(), serial_write_bytes(), and setup_group_DMA().

◆ dshot_post

const uint8_t ChibiOS::RCOutput::dshot_post = 6
private

Definition at line 276 of file RCOutput.h.

◆ dshot_pulse_time_us

uint32_t ChibiOS::RCOutput::dshot_pulse_time_us
private

Definition at line 279 of file RCOutput.h.

Referenced by push_local(), and set_group_mode().

◆ en_mask

uint32_t ChibiOS::RCOutput::en_mask
private

Definition at line 229 of file RCOutput.h.

Referenced by disable_ch(), enable_ch(), and push_local().

◆ fast_channel_mask

uint16_t ChibiOS::RCOutput::fast_channel_mask
private

Definition at line 234 of file RCOutput.h.

Referenced by set_default_rate(), set_freq(), and set_output_mode().

◆ io_fast_channel_mask

uint16_t ChibiOS::RCOutput::io_fast_channel_mask
private

Definition at line 235 of file RCOutput.h.

Referenced by set_freq(), set_output_mode(), and write().

◆ iomcu_oneshot125

bool ChibiOS::RCOutput::iomcu_oneshot125
private

Definition at line 250 of file RCOutput.h.

Referenced by set_output_mode(), and write().

◆ irq

struct ChibiOS::RCOutput::irq_state ChibiOS::RCOutput::irq
staticprivate

◆ last_sent

uint16_t ChibiOS::RCOutput::last_sent[max_channels]
private

Definition at line 226 of file RCOutput.h.

Referenced by read_last_sent(), and write().

◆ led_counter

uint8_t ChibiOS::RCOutput::led_counter
private

Definition at line 264 of file RCOutput.h.

Referenced by safety_update().

◆ max_channels

const uint8_t ChibiOS::RCOutput::max_channels = 16
staticprivate

Definition at line 223 of file RCOutput.h.

Referenced by disable_ch(), enable_ch(), get_freq(), read(), read_last_sent(), and write().

◆ min_pulse_trigger_us

uint64_t ChibiOS::RCOutput::min_pulse_trigger_us
private

Definition at line 238 of file RCOutput.h.

Referenced by timer_tick(), and trigger_groups().

◆ num_fmu_channels

uint8_t ChibiOS::RCOutput::num_fmu_channels
private

Definition at line 218 of file RCOutput.h.

Referenced by init(), and write().

◆ period

uint16_t ChibiOS::RCOutput::period[max_channels]
private

Definition at line 230 of file RCOutput.h.

Referenced by dshot_send(), push_local(), read(), and write().

◆ pwm_group_list

pwm_group ChibiOS::RCOutput::pwm_group_list[]
staticprivate

◆ safe_pwm

uint16_t ChibiOS::RCOutput::safe_pwm[max_channels]
private

Definition at line 231 of file RCOutput.h.

Referenced by dshot_send(), push_local(), set_safety_pwm(), and write().

◆ safety_button_counter

int8_t ChibiOS::RCOutput::safety_button_counter
private

Definition at line 265 of file RCOutput.h.

Referenced by safety_update().

◆ safety_mask

uint16_t ChibiOS::RCOutput::safety_mask
private

Definition at line 268 of file RCOutput.h.

Referenced by dshot_send(), push_local(), safety_update(), and write().

◆ safety_state

AP_HAL::Util::safety_state ChibiOS::RCOutput::safety_state
private

◆ safety_update_ms

uint32_t ChibiOS::RCOutput::safety_update_ms
private

Definition at line 263 of file RCOutput.h.

Referenced by safety_update().

◆ serial_event_mask

const eventmask_t ChibiOS::RCOutput::serial_event_mask = EVENT_MASK(1)
staticprivate

◆ serial_group

struct pwm_group* ChibiOS::RCOutput::serial_group
private

◆ serial_priority

tprio_t ChibiOS::RCOutput::serial_priority
private

Definition at line 208 of file RCOutput.h.

Referenced by serial_end(), and serial_setup_output().

◆ serial_thread

thread_t* ChibiOS::RCOutput::serial_thread
private

Definition at line 207 of file RCOutput.h.

Referenced by serial_end(), and serial_setup_output().

◆ telem_request_mask

uint16_t ChibiOS::RCOutput::telem_request_mask
private

Definition at line 280 of file RCOutput.h.

Referenced by dshot_send(), and set_telem_request_mask().

◆ trigger_groupmask

uint8_t ChibiOS::RCOutput::trigger_groupmask
private

Definition at line 244 of file RCOutput.h.

Referenced by push_local(), and trigger_groups().

◆ trigger_mutex

mutex_t ChibiOS::RCOutput::trigger_mutex
private

Definition at line 241 of file RCOutput.h.

Referenced by init(), and trigger_groups().

◆ trigger_widest_pulse

uint16_t ChibiOS::RCOutput::trigger_widest_pulse
private

Definition at line 247 of file RCOutput.h.

Referenced by push_local(), and trigger_groups().


The documentation for this class was generated from the following files: