PX4 Firmware
PX4 Autopilot Software http://px4.io
AK09916 Class Reference

#include <ak09916.hpp>

Inheritance diagram for AK09916:
Collaboration diagram for AK09916:

Public Member Functions

 AK09916 (int bus, const char *path, enum Rotation rotation)
 
 ~AK09916 ()
 
virtual int init () override
 
void start ()
 
void stop ()
 
void print_info ()
 
int probe ()
 

Protected Member Functions

int setup ()
 
int setup_master_i2c ()
 
bool check_id ()
 
void Run ()
 
void try_measure ()
 
bool is_ready ()
 
void measure ()
 
int reset ()
 
uint8_t read_reg (uint8_t reg)
 
void read_block (uint8_t reg, uint8_t *val, uint8_t count)
 
void write_reg (uint8_t reg, uint8_t value)
 

Private Member Functions

 AK09916 (const AK09916 &)=delete
 
AK09916 operator= (const AK09916 &)=delete
 

Private Attributes

PX4Magnetometer _px4_mag
 
uint32_t _cycle_interval {0}
 
perf_counter_t _mag_reads
 
perf_counter_t _mag_errors
 
perf_counter_t _mag_overruns
 
perf_counter_t _mag_overflows
 

Detailed Description

Definition at line 83 of file ak09916.hpp.

Constructor & Destructor Documentation

◆ AK09916() [1/2]

AK09916::AK09916 ( int  bus,
const char *  path,
enum Rotation  rotation 
)

Definition at line 137 of file ak09916.cpp.

References _px4_mag, AK09916_MAG_RANGE_GA, DRV_MAG_DEVTYPE_AK09916, PX4Magnetometer::set_device_type(), and PX4Magnetometer::set_scale().

Here is the call graph for this function:

◆ ~AK09916()

AK09916::~AK09916 ( )

Definition at line 150 of file ak09916.cpp.

References _mag_errors, _mag_overflows, _mag_overruns, _mag_reads, and perf_free().

Here is the call graph for this function:

◆ AK09916() [2/2]

AK09916::AK09916 ( const AK09916 )
privatedelete

Member Function Documentation

◆ check_id()

bool AK09916::check_id ( )
protected

Definition at line 252 of file ak09916.cpp.

References AK09916_DEVICE_ID_A, AK09916REG_WIA, and read_reg().

Referenced by probe().

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

◆ init()

int AK09916::init ( )
overridevirtual

Definition at line 159 of file ak09916.cpp.

References ToneAlarmInterface::init(), OK, reset(), and start().

Here is the call graph for this function:

◆ is_ready()

bool AK09916::is_ready ( )
protected

Definition at line 190 of file ak09916.cpp.

References _mag_overruns, AK09916_ST1_DOR, AK09916_ST1_DRDY, AK09916REG_ST1, OK, and perf_count().

Referenced by try_measure().

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

◆ measure()

void AK09916::measure ( )
protected

Definition at line 208 of file ak09916.cpp.

References _mag_errors, _mag_overflows, _px4_mag, AK09916_ST2_HOFL, AK09916REG_HXL, hrt_absolute_time(), hrt_abstime, OK, perf_count(), perf_event_count(), PX4Magnetometer::set_error_count(), PX4Magnetometer::set_external(), ak09916_regs::st2, PX4Magnetometer::update(), ak09916_regs::x, ak09916_regs::y, and ak09916_regs::z.

Referenced by try_measure().

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

◆ operator=()

AK09916 AK09916::operator= ( const AK09916 )
privatedelete

◆ print_info()

void AK09916::print_info ( )

Definition at line 232 of file ak09916.cpp.

References _mag_errors, _mag_overruns, _mag_reads, _px4_mag, perf_print_counter(), and PX4Magnetometer::print_status().

Here is the call graph for this function:

◆ probe()

int AK09916::probe ( )

Definition at line 283 of file ak09916.cpp.

References AK09916_RESET, AK09916REG_CNTL3, check_id(), OK, and write_reg().

Referenced by reset().

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

◆ read_block()

void AK09916::read_block ( uint8_t  reg,
uint8_t *  val,
uint8_t  count 
)
protected

◆ read_reg()

uint8_t AK09916::read_reg ( uint8_t  reg)
protected

Definition at line 241 of file ak09916.cpp.

Referenced by check_id().

Here is the caller graph for this function:

◆ reset()

int AK09916::reset ( )
protected

Definition at line 267 of file ak09916.cpp.

References AK09916_RESET, AK09916REG_CNTL3, OK, probe(), setup(), and write_reg().

Referenced by init().

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

◆ Run()

void AK09916::Run ( )
protected

Definition at line 326 of file ak09916.cpp.

References _cycle_interval, and try_measure().

Here is the call graph for this function:

◆ setup()

int AK09916::setup ( )
protected

Definition at line 301 of file ak09916.cpp.

References AK09916_CNTL2_CONTINOUS_MODE_100HZ, AK09916REG_CNTL2, OK, and write_reg().

Referenced by reset().

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

◆ setup_master_i2c()

int AK09916::setup_master_i2c ( )
protected

◆ start()

void AK09916::start ( )

Definition at line 309 of file ak09916.cpp.

References _cycle_interval, and AK09916_CONVERSION_INTERVAL_us.

Referenced by init().

Here is the caller graph for this function:

◆ stop()

void AK09916::stop ( )

Definition at line 317 of file ak09916.cpp.

References _cycle_interval.

◆ try_measure()

void AK09916::try_measure ( )
protected

Definition at line 180 of file ak09916.cpp.

References is_ready(), and measure().

Referenced by Run().

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

◆ write_reg()

void AK09916::write_reg ( uint8_t  reg,
uint8_t  value 
)
protected

Definition at line 260 of file ak09916.cpp.

Referenced by probe(), reset(), and setup().

Here is the caller graph for this function:

Member Data Documentation

◆ _cycle_interval

uint32_t AK09916::_cycle_interval {0}
private

Definition at line 113 of file ak09916.hpp.

Referenced by Run(), start(), and stop().

◆ _mag_errors

perf_counter_t AK09916::_mag_errors
private

Definition at line 116 of file ak09916.hpp.

Referenced by measure(), print_info(), and ~AK09916().

◆ _mag_overflows

perf_counter_t AK09916::_mag_overflows
private

Definition at line 118 of file ak09916.hpp.

Referenced by measure(), and ~AK09916().

◆ _mag_overruns

perf_counter_t AK09916::_mag_overruns
private

Definition at line 117 of file ak09916.hpp.

Referenced by is_ready(), print_info(), and ~AK09916().

◆ _mag_reads

perf_counter_t AK09916::_mag_reads
private

Definition at line 115 of file ak09916.hpp.

Referenced by print_info(), and ~AK09916().

◆ _px4_mag

PX4Magnetometer AK09916::_px4_mag
private

Definition at line 111 of file ak09916.hpp.

Referenced by AK09916(), measure(), and print_info().


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