APM:Libraries
Classes | Macros | Functions
AP_Common.h File Reference

Common definitions and utility routines for the ArduPilot libraries. More...

#include <AP_HAL/AP_HAL_Boards.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
Include dependency graph for AP_Common.h:

Go to the source code of this file.

Classes

struct  Location_Option_Flags
 
struct  Location
 

Macros

#define PACKED   __attribute__((__packed__))
 
#define UNUSED_FUNCTION   __attribute__((unused))
 
#define OPTIMIZE(level)   __attribute__((optimize(level)))
 
#define NOINLINE   __attribute__((noinline))
 
#define FMT_PRINTF(a, b)   __attribute__((format(printf, a, b)))
 
#define FMT_SCANF(a, b)   __attribute__((format(scanf, a, b)))
 
#define FALLTHROUGH
 
#define ToRad(x)   radians(x)
 
#define ToDeg(x)   degrees(x)
 
#define DEFINE_BYTE_ARRAY_METHODS
 
#define LOCATION_ALT_MAX_M   83000
 
#define BIT_IS_SET(value, bitnumber)   (((value) & (1U<<(bitnumber))) != 0)
 
#define LOWBYTE(i)   ((uint8_t)(i))
 
#define HIGHBYTE(i)   ((uint8_t)(((uint16_t)(i))>>8))
 
#define ARRAY_SIZE(_arr)   sizeof(_ARRAY_SIZE_HELPER(_arr))
 
#define ARRAY_SIZE_SIMPLE(_arr)   (sizeof(_arr)/sizeof(_arr[0]))
 
#define _UNUSED_RESULT(uniq_, expr_)
 
#define UNUSED_RESULT(expr_)   _UNUSED_RESULT(__unique_name_##__COUNTER__, expr_)
 

Functions

template<typename T , size_t N>
char(& _ARRAY_SIZE_HELPER (T(&_arr)[N]))[N]
 
template<typename T >
char(& _ARRAY_SIZE_HELPER (T(&_arr)[0]))[0]
 

Conversions

Conversion macros and factors.

#define SITL_printf(fmt, args ...)   do { ::printf("%s(%u): " fmt, __FILE__, __LINE__, ##args); } while(0)
 
bool is_bounded_int32 (int32_t value, int32_t lower_bound, int32_t upper_bound)
 

Detailed Description

Common definitions and utility routines for the ArduPilot libraries.

Definition in file AP_Common.h.

Macro Definition Documentation

◆ _UNUSED_RESULT

#define _UNUSED_RESULT (   uniq_,
  expr_ 
)
Value:
do { \
decltype(expr_) uniq_ __attribute__((unused)); \
uniq_ = expr_; \
} while (0)
__attribute__((used))
Definition: stubs.c:88

Definition at line 92 of file AP_Common.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   _arr)    sizeof(_ARRAY_SIZE_HELPER(_arr))

Definition at line 80 of file AP_Common.h.

Referenced by SITL::Calibration::_calibration_poses(), AP_BattMonitor_Bebop::_compute_compensation(), HALSITL::SITL_State::_parse_command_line(), PX4::PX4AnalogSource::_pin_scaler(), VRBRAIN::VRBRAINAnalogSource::_pin_scaler(), HALSITL::SITL_State::_simulator_servos(), Linux::RCInput_Navio2::_timer_tick(), HALSITL::SITL_State::_update_gps_ubx(), accept_unsigned_callback(), AP_BoardConfig::board_setup_sbus(), AP_GPS_SBF::broadcast_configuration_failure_reason(), AP_GPS_UBLOX::broadcast_configuration_failure_reason(), AP_BattMonitor::convert_params(), AP_GPS::detect_instance(), Linux::RCOutput_Disco::disable_ch(), Linux::RCOutput_Disco::enable_ch(), SITL::Frame::find_frame(), SITL::FlightAxis::FlightAxis(), Linux::RCOutput_Disco::get_freq(), Linux::RCInput_Navio2::init(), AP_RAMTRON::init(), Linux::Scheduler::init(), AP_RangeFinder_VL53L0X::init(), AP_Airspeed_MS4525::init(), AP_Airspeed_SDP3X::init(), AP_Airspeed_MS5525::init(), AnalogSource_IIO::init_pins(), AP_GPS_SBF::is_configured(), F4Light::RCOutput::lateInit(), DataFlash_Class::Log_Write_Current_instance(), loop(), AP_GPS_SBF::parse(), Linux::RCOutput_PRU::push(), GCS_MAVLINK::push_deferred_messages(), AP_BoardConfig::px4_setup_pwm(), AP_BoardConfig::px4_start_driver(), AP_Arming::rc_checks_copter_sub(), AP_Compass_HIL::read(), Linux::RCOutput_Disco::read(), AP_GPS_SBF::read(), read_calibration_data(), GCS_MAVLINK::send_message(), Linux::RCOutput_Disco::set_freq(), SchedTest::setup(), DataFlashTest::setup(), setup(), DataFlashTest_AllTypes::setup(), AP_OpticalFlow_Pixart::setup_sensor(), AP_OpticalFlow_Pixart::srom_download(), AP_AutoTune::start(), test_conversions(), test_matrix_eulers(), test_offset(), test_passed_waypoint(), test_printf(), test_quaternion_eulers(), test_wrap_cd(), AP_OpticalFlow_SITL::update(), SRV_Channels::upgrade_motors_servo(), SRV_Channels::upgrade_parameters(), and Linux::RCOutput_Disco::write().

◆ ARRAY_SIZE_SIMPLE

#define ARRAY_SIZE_SIMPLE (   _arr)    (sizeof(_arr)/sizeof(_arr[0]))

◆ BIT_IS_SET

#define BIT_IS_SET (   value,
  bitnumber 
)    (((value) & (1U<<(bitnumber))) != 0)

Definition at line 68 of file AP_Common.h.

◆ DEFINE_BYTE_ARRAY_METHODS

#define DEFINE_BYTE_ARRAY_METHODS
Value:
inline uint8_t &operator[](size_t i) { return reinterpret_cast<uint8_t *>(this)[i]; } \
inline uint8_t operator[](size_t i) const { return reinterpret_cast<const uint8_t *>(this)[i]; }

Definition at line 58 of file AP_Common.h.

◆ FALLTHROUGH

#define FALLTHROUGH

◆ FMT_PRINTF

#define FMT_PRINTF (   a,
 
)    __attribute__((format(printf, a, b)))

Definition at line 39 of file AP_Common.h.

Referenced by Linux::Util::set_custom_storage_directory().

◆ FMT_SCANF

#define FMT_SCANF (   a,
 
)    __attribute__((format(scanf, a, b)))

Definition at line 40 of file AP_Common.h.

Referenced by Linux::Util::set_custom_storage_directory().

◆ HIGHBYTE

#define HIGHBYTE (   i)    ((uint8_t)(((uint16_t)(i))>>8))

◆ LOCATION_ALT_MAX_M

#define LOCATION_ALT_MAX_M   83000

Definition at line 62 of file AP_Common.h.

Referenced by AP_Mission::mavlink_int_to_mission_cmd().

◆ LOWBYTE

#define LOWBYTE (   i)    ((uint8_t)(i))

◆ NOINLINE

#define NOINLINE   __attribute__((noinline))

Definition at line 37 of file AP_Common.h.

◆ OPTIMIZE

#define OPTIMIZE (   level)    __attribute__((optimize(level)))

Definition at line 34 of file AP_Common.h.

◆ PACKED

#define PACKED   __attribute__((__packed__))

◆ SITL_printf

#define SITL_printf (   fmt,
  args ... 
)    do { ::printf("%s(%u): " fmt, __FILE__, __LINE__, ##args); } while(0)

Definition at line 167 of file AP_Common.h.

◆ ToDeg

#define ToDeg (   x)    degrees(x)

◆ ToRad

#define ToRad (   x)    radians(x)

◆ UNUSED_FUNCTION

#define UNUSED_FUNCTION   __attribute__((unused))

Definition at line 31 of file AP_Common.h.

◆ UNUSED_RESULT

#define UNUSED_RESULT (   expr_)    _UNUSED_RESULT(__unique_name_##__COUNTER__, expr_)

Definition at line 104 of file AP_Common.h.

Referenced by AP_Follow::handle_msg().

Function Documentation

◆ _ARRAY_SIZE_HELPER() [1/2]

template<typename T , size_t N>
char(& _ARRAY_SIZE_HELPER ( T(&)  _arr[N]) )[N]

◆ _ARRAY_SIZE_HELPER() [2/2]

template<typename T >
char(& _ARRAY_SIZE_HELPER ( T(&)  _arr[0]) )[0]

◆ is_bounded_int32()

bool is_bounded_int32 ( int32_t  value,
int32_t  lower_bound,
int32_t  upper_bound 
)

Definition at line 29 of file AP_Common.cpp.

Referenced by RC_Channel::in_trim_dz().

Here is the caller graph for this function: