APM:Libraries
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
F4Light::SPIDevice Class Reference

#include <SPIDevice.h>

Inheritance diagram for F4Light::SPIDevice:
[legend]
Collaboration diagram for F4Light::SPIDevice:
[legend]

Public Member Functions

 SPIDevice (const SPIDesc &device_desc)
 
 ~SPIDevice ()
 
bool set_speed (AP_HAL::Device::Speed speed) override
 
bool transfer (const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) override
 
uint8_t transfer (uint8_t out)
 
void send (uint8_t out)
 
bool transfer_fullduplex (const uint8_t *send, uint8_t *recv, uint32_t len) override
 
void apply_speed ()
 
uint16_t send_strobe (const uint8_t *buffer, uint16_t len)
 
void wait_busy ()
 
uint8_t wait_for (uint8_t out, spi_WaitFunc cb, uint32_t dly)
 
F4Light::Semaphoreget_semaphore ()
 
AP_HAL::Device::PeriodicHandle register_periodic_callback (uint32_t period_usec, AP_HAL::Device::PeriodicCb proc) override
 
bool adjust_periodic_callback (AP_HAL::Device::PeriodicHandle h, uint32_t period_usec) override
 
bool unregister_callback (PeriodicHandle h)
 
void register_completion_callback (Handler h)
 
void register_completion_callback (AP_HAL::MemberProc proc)
 
void register_completion_callback (AP_HAL::Proc proc)
 
void dma_isr ()
 
void spi_isr ()
 
- Public Member Functions inherited from AP_HAL::SPIDevice
 SPIDevice ()
 
virtual bool clock_pulse (uint32_t len)
 
virtual Device::PeriodicHandle register_periodic_callback (uint32_t period_usec, Device::PeriodicCb) override=0
 
- Public Member Functions inherited from AP_HAL::Device
 FUNCTOR_TYPEDEF (PeriodicCb, void)
 
 Device (enum BusType type)
 
enum BusType bus_type (void) const
 
uint8_t bus_num (void) const
 
uint32_t get_bus_id (void) const
 
uint8_t get_bus_address (void) const
 
void set_device_type (uint8_t devtype)
 
virtual ~Device ()
 
virtual void set_address (uint8_t address)
 
bool read_registers (uint8_t first_reg, uint8_t *recv, uint32_t recv_len)
 
bool write_register (uint8_t reg, uint8_t val, bool checked=false)
 
void set_checked_register (uint8_t reg, uint8_t val)
 
bool setup_checked_registers (uint8_t num_regs, uint8_t frequency=10)
 
bool check_next_register (void)
 
bool read (uint8_t *recv, uint32_t recv_len)
 
virtual PeriodicHandle register_periodic_callback (uint32_t period_usec, PeriodicCb)=0
 
virtual bool set_chip_select (bool set)
 
void set_read_flag (uint8_t flag)
 
uint32_t get_bus_id_devtype (uint8_t devtype)
 
virtual void set_retries (uint8_t retries)
 

Protected Member Functions

void init (void)
 
void _cs_assert ()
 
void _cs_release ()
 
const spi_pinsdev_to_spi_pins (const spi_dev *dev)
 
spi_baud_rate determine_baud_rate (SPIFrequency freq)
 
uint8_t _transfer (uint8_t data)
 
void get_dma_ready ()
 
void setup_dma_transfer (const uint8_t *send, const uint8_t *recv, uint32_t btr)
 
void setup_isr_transfer ()
 
void start_dma_transfer ()
 
uint8_t do_transfer (bool is_DMA, uint32_t nbytes)
 
void isr_transfer_finish ()
 
void disable_dma ()
 
- Protected Member Functions inherited from AP_HAL::Device
void set_device_address (uint8_t address)
 
void set_device_bus (uint8_t bus)
 

Protected Attributes

const SPIDesc_desc
 
DigitalSource_cs
 
SPIFrequency _speed
 
bool _initialized
 
uint8_t byte_time
 
Handler _completion_cb
 
void * _task
 
const uint8_t * _send_address
 
uint16_t _send_len
 
uint16_t _dummy_len
 
uint8_t * _recv_address
 
uint16_t _recv_len
 
SPI_ISR_MODE _isr_mode
 
spi_WaitFunc _compare_cb
 
uint8_t _recv_data
 
- Protected Attributes inherited from AP_HAL::Device
uint8_t _read_flag = 0
 
union DeviceId _bus_id
 

Static Protected Attributes

static F4Light::Semaphore _semaphores [MAX_BUS_NUM]
 
static void * owner [MAX_BUS_NUM]
 
static uint8_t * buffer [MAX_BUS_NUM]
 

Additional Inherited Members

- Public Types inherited from AP_HAL::Device
enum  BusType { BUS_TYPE_UNKNOWN = 0, BUS_TYPE_I2C = 1, BUS_TYPE_SPI = 2, BUS_TYPE_UAVCAN = 3 }
 
enum  Speed { SPEED_HIGH, SPEED_LOW }
 
typedef void * PeriodicHandle
 
- Static Public Member Functions inherited from AP_HAL::Device
static uint32_t make_bus_id (enum BusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype)
 
static uint32_t change_bus_id (uint32_t old_id, uint8_t devtype)
 

Detailed Description

Definition at line 113 of file SPIDevice.h.

Constructor & Destructor Documentation

◆ SPIDevice()

SPIDevice::SPIDevice ( const SPIDesc device_desc)

Definition at line 449 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ ~SPIDevice()

F4Light::SPIDevice::~SPIDevice ( )
inlinevirtual

Reimplemented from AP_HAL::SPIDevice.

Definition at line 117 of file SPIDevice.h.

Member Function Documentation

◆ _cs_assert()

void F4Light::SPIDevice::_cs_assert ( )
inlineprotected

Definition at line 190 of file SPIDevice.h.

Referenced by transfer(), and transfer_fullduplex().

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

◆ _cs_release()

void F4Light::SPIDevice::_cs_release ( )
inlineprotected

Definition at line 191 of file SPIDevice.h.

Referenced by init(), isr_transfer_finish(), transfer(), and transfer_fullduplex().

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

◆ _transfer()

uint8_t SPIDevice::_transfer ( uint8_t  data)
protected

Definition at line 159 of file SPIDevice.cpp.

Referenced by transfer(), and transfer_fullduplex().

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

◆ adjust_periodic_callback()

bool F4Light::SPIDevice::adjust_periodic_callback ( AP_HAL::Device::PeriodicHandle  h,
uint32_t  period_usec 
)
inlineoverridevirtual

Reimplemented from AP_HAL::SPIDevice.

Definition at line 151 of file SPIDevice.h.

Here is the call graph for this function:

◆ apply_speed()

void F4Light::SPIDevice::apply_speed ( )
inline

Definition at line 134 of file SPIDevice.h.

Here is the call graph for this function:

◆ determine_baud_rate()

spi_baud_rate SPIDevice::determine_baud_rate ( SPIFrequency  freq)
protected

Definition at line 478 of file SPIDevice.cpp.

Referenced by init(), transfer(), and transfer_fullduplex().

Here is the caller graph for this function:

◆ dev_to_spi_pins()

const spi_pins * SPIDevice::dev_to_spi_pins ( const spi_dev dev)
protected

Definition at line 465 of file SPIDevice.cpp.

Referenced by init().

Here is the caller graph for this function:

◆ disable_dma()

void SPIDevice::disable_dma ( )
protected

Definition at line 602 of file SPIDevice.cpp.

Referenced by dma_isr(), and do_transfer().

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

◆ dma_isr()

void SPIDevice::dma_isr ( )

Definition at line 614 of file SPIDevice.cpp.

Referenced by setup_dma_transfer().

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

◆ do_transfer()

uint8_t SPIDevice::do_transfer ( bool  is_DMA,
uint32_t  nbytes 
)
protected

Definition at line 771 of file SPIDevice.cpp.

Referenced by send_strobe(), transfer(), and transfer_fullduplex().

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

◆ get_dma_ready()

void SPIDevice::get_dma_ready ( )
protected

Definition at line 529 of file SPIDevice.cpp.

Referenced by transfer().

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

◆ get_semaphore()

F4Light::Semaphore* F4Light::SPIDevice::get_semaphore ( )
inlinevirtual

Implements AP_HAL::SPIDevice.

Definition at line 143 of file SPIDevice.h.

◆ init()

void SPIDevice::init ( void  )
protected

hardware

Definition at line 667 of file SPIDevice.cpp.

Referenced by set_speed(), transfer(), and transfer_fullduplex().

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

◆ isr_transfer_finish()

void SPIDevice::isr_transfer_finish ( )
protected

Definition at line 908 of file SPIDevice.cpp.

Referenced by dma_isr(), do_transfer(), spi_isr(), and wait_for().

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

◆ register_completion_callback() [1/3]

void SPIDevice::register_completion_callback ( Handler  h)

Definition at line 138 of file SPIDevice.cpp.

◆ register_completion_callback() [2/3]

void F4Light::SPIDevice::register_completion_callback ( AP_HAL::MemberProc  proc)
inlinevirtual

Reimplemented from AP_HAL::Device.

Definition at line 160 of file SPIDevice.h.

◆ register_completion_callback() [3/3]

void F4Light::SPIDevice::register_completion_callback ( AP_HAL::Proc  proc)
inlinevirtual

Reimplemented from AP_HAL::Device.

Definition at line 165 of file SPIDevice.h.

◆ register_periodic_callback()

AP_HAL::Device::PeriodicHandle F4Light::SPIDevice::register_periodic_callback ( uint32_t  period_usec,
AP_HAL::Device::PeriodicCb  proc 
)
inlineoverride

Definition at line 146 of file SPIDevice.h.

Here is the call graph for this function:

◆ send()

void SPIDevice::send ( uint8_t  out)

Definition at line 178 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ send_strobe()

uint16_t SPIDevice::send_strobe ( const uint8_t *  buffer,
uint16_t  len 
)

Definition at line 847 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ set_speed()

bool SPIDevice::set_speed ( AP_HAL::Device::Speed  speed)
overridevirtual

Implements AP_HAL::SPIDevice.

Definition at line 742 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ setup_dma_transfer()

void SPIDevice::setup_dma_transfer ( const uint8_t *  send,
const uint8_t *  recv,
uint32_t  btr 
)
protected

Definition at line 546 of file SPIDevice.cpp.

Referenced by dma_isr(), spi_isr(), transfer(), and transfer_fullduplex().

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

◆ setup_isr_transfer()

void SPIDevice::setup_isr_transfer ( )
protected

Definition at line 839 of file SPIDevice.cpp.

Referenced by dma_isr(), transfer(), and transfer_fullduplex().

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

◆ spi_isr()

void SPIDevice::spi_isr ( )

Definition at line 938 of file SPIDevice.cpp.

Referenced by send_strobe(), setup_isr_transfer(), and wait_for().

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

◆ start_dma_transfer()

void SPIDevice::start_dma_transfer ( )
protected

Definition at line 597 of file SPIDevice.cpp.

Referenced by dma_isr(), do_transfer(), and spi_isr().

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

◆ transfer() [1/2]

bool SPIDevice::transfer ( const uint8_t *  send,
uint32_t  send_len,
uint8_t *  recv,
uint32_t  recv_len 
)
overridevirtual

Implements AP_HAL::SPIDevice.

Definition at line 188 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ transfer() [2/2]

uint8_t SPIDevice::transfer ( uint8_t  out)

Definition at line 146 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ transfer_fullduplex()

bool SPIDevice::transfer_fullduplex ( const uint8_t *  send,
uint8_t *  recv,
uint32_t  len 
)
overridevirtual

Implements AP_HAL::SPIDevice.

Definition at line 368 of file SPIDevice.cpp.

Here is the call graph for this function:

◆ unregister_callback()

bool F4Light::SPIDevice::unregister_callback ( PeriodicHandle  h)
inlinevirtual

Reimplemented from AP_HAL::Device.

Definition at line 156 of file SPIDevice.h.

Here is the call graph for this function:

◆ wait_busy()

void F4Light::SPIDevice::wait_busy ( )
inline

Definition at line 139 of file SPIDevice.h.

Here is the call graph for this function:

◆ wait_for()

uint8_t SPIDevice::wait_for ( uint8_t  out,
spi_WaitFunc  cb,
uint32_t  dly 
)

Definition at line 875 of file SPIDevice.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ _compare_cb

spi_WaitFunc F4Light::SPIDevice::_compare_cb
protected

Definition at line 219 of file SPIDevice.h.

Referenced by spi_isr(), and wait_for().

◆ _completion_cb

Handler F4Light::SPIDevice::_completion_cb
protected

◆ _cs

DigitalSource* F4Light::SPIDevice::_cs
protected

Definition at line 178 of file SPIDevice.h.

Referenced by init(), send_strobe(), spi_isr(), and SPIDevice().

◆ _desc

const SPIDesc& F4Light::SPIDevice::_desc
protected

◆ _dummy_len

uint16_t F4Light::SPIDevice::_dummy_len
protected

Definition at line 214 of file SPIDevice.h.

Referenced by do_transfer(), spi_isr(), and transfer().

◆ _initialized

bool F4Light::SPIDevice::_initialized
protected

Definition at line 185 of file SPIDevice.h.

Referenced by init(), set_speed(), transfer(), and transfer_fullduplex().

◆ _isr_mode

SPI_ISR_MODE F4Light::SPIDevice::_isr_mode
protected

◆ _recv_address

uint8_t* F4Light::SPIDevice::_recv_address
protected

Definition at line 215 of file SPIDevice.h.

Referenced by dma_isr(), spi_isr(), and transfer().

◆ _recv_data

uint8_t F4Light::SPIDevice::_recv_data
protected

Definition at line 220 of file SPIDevice.h.

Referenced by spi_isr(), and wait_for().

◆ _recv_len

uint16_t F4Light::SPIDevice::_recv_len
protected

Definition at line 216 of file SPIDevice.h.

Referenced by dma_isr(), do_transfer(), send_strobe(), spi_isr(), transfer(), and wait_for().

◆ _semaphores

F4Light::Semaphore F4Light::SPIDevice::_semaphores[MAX_BUS_NUM]
staticprotected

Definition at line 181 of file SPIDevice.h.

◆ _send_address

const uint8_t* F4Light::SPIDevice::_send_address
protected

Definition at line 212 of file SPIDevice.h.

Referenced by do_transfer(), send_strobe(), spi_isr(), and transfer().

◆ _send_len

uint16_t F4Light::SPIDevice::_send_len
protected

Definition at line 213 of file SPIDevice.h.

Referenced by dma_isr(), do_transfer(), send_strobe(), spi_isr(), transfer(), and wait_for().

◆ _speed

SPIFrequency F4Light::SPIDevice::_speed
protected

Definition at line 179 of file SPIDevice.h.

Referenced by set_speed(), transfer(), and transfer_fullduplex().

◆ _task

void* F4Light::SPIDevice::_task
protected

Definition at line 208 of file SPIDevice.h.

Referenced by do_transfer(), isr_transfer_finish(), and wait_for().

◆ buffer

uint8_t * SPIDevice::buffer
staticprotected

Definition at line 183 of file SPIDevice.h.

Referenced by dma_isr(), send_strobe(), spi_isr(), and transfer().

◆ byte_time

uint8_t F4Light::SPIDevice::byte_time
protected

Definition at line 186 of file SPIDevice.h.

Referenced by determine_baud_rate().

◆ owner

void * SPIDevice::owner
staticprotected

Definition at line 182 of file SPIDevice.h.

Referenced by set_speed(), transfer(), and transfer_fullduplex().


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