Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sensor Device Stack

The sensor device service provides high-level interfaces and binary driver libraries for sensor devices on systems built around Atmel microcontrollers.

Common API for UC3, XMEGA, AVR MEGA, and SAM.

Modules

 Common Sensor API
 

Data Structures

struct  sensor_axis_vec_t
 Sensor Axis Descriptor. More...
 
struct  sensor_caps_t
 Sensor Capabilities. More...
 
struct  sensor_data_t
 Sensor Data Descriptor. More...
 
struct  sensor_desc
 Generic Sensor API Descriptor. More...
 
struct  sensor_device_t
 Sensor Device Driver Specific Descriptor. More...
 
interface  sensor_enum_callback
 Sensor Enumeration Handler Callback Type. More...
 
interface  sensor_event_callback
 Sensor Event Handler Callback Type. More...
 
struct  sensor_event_callback_t
 allocate one per event type (v. More...
 
struct  sensor_event_data_t
 Sensor Event Data Descriptor. More...
 
struct  sensor_funcs_t
 Sensor Driver Entry Point Table. More...
 
struct  sensor_hal
 Sensor Platform Hardware Abstraction Descriptor. More...
 
struct  sensor_map_t
 Sensor Operational Capabilities Descriptors. More...
 
struct  sensor_orient_t
 Sensor Orientation Descriptor. More...
 
struct  sensor_tap_params_t
 Sensor Tap Event Parameters. More...
 
struct  sensor_threshold_desc_t
 Sensor Threshold Descriptor. More...
 

Macros

#define SENSOR_CHANNEL_ALL   (-1)
 Sensor Channel Constants - used to select channel within device. More...
 

Typedefs

typedef struct sensor_hal sensor_hal_t
 Sensor Hardware Abstraction Descriptor. More...
 
typedef struct sensor_desc sensor_t
 Generic Sensor API Descriptor. More...
 

Enumerations

enum  sensor_calibration_t {
  AUTO_CALIBRATE,
  MANUAL_CALIBRATE,
  HARD_IRON_CALIBRATE,
  SOFT_IRON_CALIBRATE,
  FIELD_CALIBRATE,
  PROXIMITY_CALIBRATE
}
 Sensor Calibration Type Constants. More...
 
enum  sensor_command_t {
  SENSOR_INFO_QUERY,
  SENSOR_STATUS_RUNNING,
  SENSOR_STATUS_SLEEPING,
  SENSOR_STATUS_SUSPENDED,
  SENSOR_EXEC_SLEEP,
  SENSOR_EXEC_WAKE,
  SENSOR_EXEC_SUSPEND,
  SENSOR_EXEC_RESET,
  SENSOR_EXEC_SELFTEST,
  SENSOR_GET_RANGE,
  SENSOR_GET_BANDWIDTH,
  SENSOR_GET_POWER,
  SENSOR_GET_RESOLUTION,
  SENSOR_GET_SAMPLE_RATE,
  SENSOR_GET_THRESHOLD,
  SENSOR_GET_SLEEP_TIME,
  SENSOR_SET_STATE,
  SENSOR_SET_RANGE,
  SENSOR_SET_BANDWIDTH,
  SENSOR_SET_POWER,
  SENSOR_SET_CURRENT,
  SENSOR_SET_RESOLUTION,
  SENSOR_SET_SAMPLE_RATE,
  SENSOR_SET_THRESHOLD,
  SENSOR_SET_SLEEP_TIME,
  SENSOR_SET_TAP,
  SENSOR_ENABLE_EVENT,
  SENSOR_DISABLE_EVENT,
  SENSOR_READ_SCALAR,
  SENSOR_READ_VECTOR
}
 Sensor Command Constants - used for sensor ioctl operations. More...
 
enum  sensor_error_t {
  SENSOR_ERR_NONE = 0x0000,
  SENSOR_ERR_CALDATA = 0x0001,
  SENSOR_ERR_RAWDATA = 0x0002,
  SENSOR_ERR_COMPDATA = 0x0004,
  SENSOR_ERR_HARDWARE = 0x0008,
  SENSOR_ERR_SOFTWARE = 0x0010,
  SENSOR_ERR_PARAMS = 0x0020,
  SENSOR_ERR_CONFIG = 0x0040,
  SENSOR_ERR_SELFTEST = 0x0080,
  SENSOR_ERR_IO = 0x0100,
  SENSOR_ERR_DRIVER = 0x0200,
  SENSOR_ERR_UNSUPPORTED = 0x8000,
  SENSOR_ERR_FUNCTION = 0X8200,
  SENSOR_ERR_IOCTL = 0x8210
}
 Sensor Driver and API Error Constants. More...
 
enum  sensor_feature_t {
  SENSOR_CAPS_UNKNOWN = 0x0000,
  SENSOR_CAPS_1_AXIS = 0x0001,
  SENSOR_CAPS_2_AXIS = 0x0002,
  SENSOR_CAPS_3_AXIS = 0x0004,
  SENSOR_CAPS_SELFTEST = 0x0008,
  SENSOR_CAPS_AUX_TEMP = 0x0010,
  SENSOR_CAPS_HI_G_EVENT = 0x0020,
  SENSOR_CAPS_LO_G_EVENT = 0x0040,
  SENSOR_CAPS_TAP_EVENT = 0x0080,
  SENSOR_CAPS_S_TAP_EVENT = 0x0080,
  SENSOR_CAPS_D_TAP_EVENT = 0x0100,
  SENSOR_CAPS_TILT_EVENT = 0x0200,
  SENSOR_CAPS_DROP_EVENT = 0x0400,
  SENSOR_CAPS_AUTO_CAL = 0x0800,
  SENSOR_CAPS_AUX_ACCEL = 0x1000
}
 Sensor Feature Constants. More...
 
enum  sensor_proximity_t {
  PROXIMITY_NONE,
  PROXIMITY_FAR,
  PROXIMITY_MEDIUM,
  PROXIMITY_NEAR
}
 Sensor Proximity Indicator Constants. More...
 
enum  sensor_read_t {
  SENSOR_READ_ACCELERATION,
  SENSOR_READ_FIELD,
  SENSOR_READ_HEADING,
  SENSOR_READ_ID,
  SENSOR_READ_INTENSITY,
  SENSOR_READ_LIGHT,
  SENSOR_READ_PRESSURE,
  SENSOR_READ_PROXIMITY,
  SENSOR_READ_ROTATION,
  SENSOR_READ_TEMPERATURE
}
 Sensor Data Read Operations. More...
 
enum  sensor_state_t {
  SENSOR_STATE_UNKNOWN,
  SENSOR_STATE_NORMAL,
  SENSOR_STATE_SLEEP,
  SENSOR_STATE_SUSPEND,
  SENSOR_STATE_LOWEST_POWER,
  SENSOR_STATE_LOW_POWER,
  SENSOR_STATE_HIGH_POWER,
  SENSOR_STATE_HIGHEST_POWER,
  SENSOR_STATE_X_AXIS_STANDBY,
  SENSOR_STATE_Y_AXIS_STANDBY,
  SENSOR_STATE_Z_AXIS_STANDBY,
  SENSOR_STATE_RESET,
  SENSOR_STATE_POWER_DOWN,
  SENSOR_STATE_SINGLE,
  SENSOR_STATE_CONTINUOUS
}
 Sensor Operational State Type Constants. More...
 
enum  sensor_test_t {
  SENSOR_TEST_DEFAULT,
  SENSOR_TEST_BIAS_POS,
  SENSOR_TEST_BIAS_NEG,
  SENSOR_TEST_DEFLECTION,
  SENSOR_TEST_INTERRUPT
}
 Sensor Self Test Types. More...
 
enum  sensor_testerr_t {
  SENSOR_TEST_ERR_NONE = 0x0000,
  SENSOR_TEST_ERR_FUNCTION = 0x0001,
  SENSOR_TEST_ERR_READ = 0x0002,
  SENSOR_TEST_ERR_WRITE = 0x0003,
  SENSOR_TEST_ERR_RANGE = 0x0004
}
 Sensor Self-Test Error Constants. More...
 
enum  sensor_threshold_t {
  SENSOR_THRESHOLD_MOTION,
  SENSOR_THRESHOLD_LOW_G,
  SENSOR_THRESHOLD_HIGH_G,
  SENSOR_THRESHOLD_TAP,
  SENSOR_THRESHOLD_S_TAP,
  SENSOR_THRESHOLD_D_TAP,
  SENSOR_THRESHOLD_TILT,
  SENSOR_THRESHOLD_DURATION,
  SENSOR_THRESHOLD_LOW_LIGHT,
  SENSOR_THRESHOLD_HIGH_LIGHT,
  SENSOR_THRESHOLD_NEAR_PROXIMITY,
  SENSOR_THRESHOLD_MED_PROXIMITY,
  SENSOR_THRESHOLD_FAR_PROXIMITY
}
 Sensor Threshold Type Constants. More...
 
enum  sensor_type_t {
  SENSOR_TYPE_UNKNOWN = 0x0000,
  SENSOR_TYPE_ACCELEROMETER = 0x0001,
  SENSOR_TYPE_BAROMETER = 0x0002,
  SENSOR_TYPE_COMPASS = 0x0004,
  SENSOR_TYPE_GYROSCOPE = 0x0008,
  SENSOR_TYPE_HUMIDITY = 0x0010,
  SENSOR_TYPE_LIGHT = 0x0020,
  SENSOR_TYPE_MAGNETIC = 0x0040,
  SENSOR_TYPE_PRESSURE = 0x0080,
  SENSOR_TYPE_PROXIMITY = 0x0100,
  SENSOR_TYPE_TEMPERATURE = 0x0200,
  SENSOR_TYPE_VOLTAGE = 0x0400
}
 Sensor Type Constants. More...
 
enum  sensor_vendor_t {
  SENSOR_VENDOR_UNKNOWN,
  SENSOR_VENDOR_ADI,
  SENSOR_VENDOR_AKM,
  SENSOR_VENDOR_AVAGO,
  SENSOR_VENDOR_BOSCH,
  SENSOR_VENDOR_HONEYWELL,
  SENSOR_VENDOR_INTERSIL,
  SENSOR_VENDOR_INVENSENSE,
  SENSOR_VENDOR_KIONIX,
  SENSOR_VENDOR_OSRAM,
  SENSOR_VENDOR_STM,
  SENSOR_VENDOR_TAOS,
  SENSOR_VENDOR_FREESCALE
}
 Sensor Vendor Constants. More...
 

Sensor Physical Axis Definitions

enum  sensor_axis_t {
  SENSOR_AXIS_X = 0,
  SENSOR_AXIS_Y = 1,
  SENSOR_AXIS_Z = 2,
  SENSOR_AXIS_NONE = -1
}
 Sensor Axis Name Constants. More...
 
enum  sensor_sign_t {
  SENSOR_SIGN_POS = 1,
  SENSOR_SIGN_NEG = -1,
  SENSOR_SIGN_NONE = 0
}
 Sensor Axis Sign Constants. More...
 
#define AXIS_X_POS   {SENSOR_AXIS_X, SENSOR_SIGN_POS}
 
#define AXIS_X_NEG   {SENSOR_AXIS_X, SENSOR_SIGN_NEG}
 
#define AXIS_Y_POS   {SENSOR_AXIS_Y, SENSOR_SIGN_POS}
 
#define AXIS_Y_NEG   {SENSOR_AXIS_Y, SENSOR_SIGN_NEG}
 
#define AXIS_Z_POS   {SENSOR_AXIS_Z, SENSOR_SIGN_POS}
 
#define AXIS_Z_NEG   {SENSOR_AXIS_Z, SENSOR_SIGN_NEG}
 
#define AXIS_NONE   {SENSOR_AXIS_NONE, SENSOR_SIGN_NONE}
 

Sensor Event Interface

enum  sensor_event_t {
  SENSOR_EVENT_UNKNOWN = 0x0000,
  SENSOR_EVENT_NEW_DATA = 0x0001,
  SENSOR_EVENT_MOTION = 0x0002,
  SENSOR_EVENT_LOW_G = 0x0004,
  SENSOR_EVENT_HIGH_G = 0x0008,
  SENSOR_EVENT_TILT = 0x0010,
  SENSOR_EVENT_TAP = 0x0020,
  SENSOR_EVENT_S_TAP = 0x0020,
  SENSOR_EVENT_D_TAP = 0x0040,
  SENSOR_EVENT_DROP = 0x0080,
  SENSOR_EVENT_NEAR_PROXIMITY = 0x0100,
  SENSOR_EVENT_MED_PROXIMITY = 0x0200,
  SENSOR_EVENT_FAR_PROXIMITY = 0x0400,
  SENSOR_EVENT_LOW_LIGHT = 0x0800,
  SENSOR_EVENT_HIGH_LIGHT = 0x1000
}
 Sensor Event Types. More...
 
enum  sensor_tap_axis_t {
  SENSOR_TAP_AXIS_UNKNOWN = 0x0000,
  SENSOR_TAP_AXIS_X = 0x0001,
  SENSOR_TAP_AXIS_Y = 0x0002,
  SENSOR_TAP_AXIS_Z = 0x0004
}
 Sensor Tap Event. More...
 
enum  sensor_tap_direction_t {
  SENSOR_TAP_DIRECTION_UNKNOWN = 0x0000,
  SENSOR_TAP_DIRECTION_POS = 0x0001,
  SENSOR_TAP_DIRECTION_NEG = 0x0002
}
 Sensor Tap Event (event direction) More...
 
typedef void(* sensor_event_callback )(volatile sensor_event_data_t *, volatile void *)
 
typedef bool(* sensor_enum_callback )(const sensor_hal_t *, void *)
 

Sensor Sample Commands and Data Formats

!

enum  sample_format_t {
  SAMPLE_FORMAT_COUNTS,
  SAMPLE_FORMAT_SCALED
}
 Sensor Sample Data Format. More...
 
enum  sensor_units_t {
  SENSOR_UNITS_NONE,
  SENSOR_UNITS_g0,
  SENSOR_UNITS_gauss,
  SENSOR_UNITS_lux,
  SENSOR_UNITS_lumen,
  SENSOR_UNITS_pascal,
  SENSOR_UNITS_deg_per_sec,
  SENSOR_UNITS_deg_Celcius,
  SENSOR_UNITS_tesla,
  SENSOR_UNITS_volt_DC,
  SENSOR_UNITS_volt_AC
}
 Sensor Sample Units. More...
 
enum  sensor_scale_t {
  SENSOR_SCALE_micro = -6,
  SENSOR_SCALE_milli = -3,
  SENSOR_SCALE_centi = -2,
  SENSOR_SCALE_deci = -1,
  SENSOR_SCALE_one = 0,
  SENSOR_SCALE_deca = 1,
  SENSOR_SCALE_hecto = 2,
  SENSOR_SCALE_kilo = 3
}
 Sensor Sample Unit Scale. More...
 
typedef sensor_map_t sensor_range_t
 
typedef sensor_map_t sensor_band_t
 

Sensor API Convenience Macros and Functions

!

static int32_t raw_to_scaled (const sensor_hal_t *hal, int32_t counts)
 Convert raw sensor data to scaled engineering units. More...
 
static int32_t scaled_to_raw (const sensor_hal_t *hal, int32_t value)
 Convert scaled sensor data to raw counts. More...
 
void default_event_handler (volatile sensor_event_data_t *data, volatile void *arg)
 Default sensor event callback handler. More...
 
#define ARRAYSIZE(a)   (sizeof(a) / sizeof(a[0]))
 
#define sensor_get_x(sensor, data)   (sensor_get_axis(sensor, data, 0))
 
#define sensor_get_y(sensor, data)   (sensor_get_axis(sensor, data, 1))
 
#define sensor_get_z(sensor, data)   (sensor_get_axis(sensor, data, 2))
 
#define sensor_get_pitch(sensor, data)   (sensor_get_angle(sensor, data, 0))
 
#define sensor_get_roll(sensor, data)   (sensor_get_angle(sensor, data, 1))
 
#define sensor_get_yaw(sensor, data)   (sensor_get_angle(sensor, data, 2))
 

Sensor Bus I/O Wrapper Routines

#define sensor_bus_init   bus_init
 
#define sensor_bus_read(hal,...)   bus_read( & (hal)->bus, __VA_ARGS__)
 
#define sensor_bus_write(hal,...)   bus_write( & (hal)->bus, __VA_ARGS__)
 
#define sensor_bus_probe(hal,...)   bus_probe( & (hal)->bus, __VA_ARGS__)
 
#define sensor_bus_get(hal,...)   bus_get( & (hal)->bus, __VA_ARGS__)
 
#define sensor_bus_put(hal,...)   bus_put( & (hal)->bus, __VA_ARGS__)
 
#define sensor_reg_bitclear(hal,...)
 
#define sensor_reg_bitset(hal,...)   bus_reg_bitset( & (hal)->bus, __VA_ARGS__)
 
#define sensor_reg_fieldget(hal,...)
 
#define sensor_reg_fieldset(hal,...)
 

#define AXIS_NONE   {SENSOR_AXIS_NONE, SENSOR_SIGN_NONE}
#define AXIS_X_NEG   {SENSOR_AXIS_X, SENSOR_SIGN_NEG}
#define AXIS_X_POS   {SENSOR_AXIS_X, SENSOR_SIGN_POS}
#define AXIS_Y_NEG   {SENSOR_AXIS_Y, SENSOR_SIGN_NEG}
#define AXIS_Y_POS   {SENSOR_AXIS_Y, SENSOR_SIGN_POS}
#define AXIS_Z_NEG   {SENSOR_AXIS_Z, SENSOR_SIGN_NEG}
#define AXIS_Z_POS   {SENSOR_AXIS_Z, SENSOR_SIGN_POS}
#define sensor_bus_init   bus_init

Referenced by sensor_platform_init().

#define sensor_bus_probe (   hal,
  ... 
)    bus_probe( & (hal)->bus, __VA_ARGS__)
#define sensor_bus_write (   hal,
  ... 
)    bus_write( & (hal)->bus, __VA_ARGS__)
#define SENSOR_CHANNEL_ALL   (-1)

Sensor Channel Constants - used to select channel within device.

Select all channels in device

Referenced by sfh7770_get_threshold(), sfh7770_set_current(), and sfh7770_set_threshold().

#define sensor_get_pitch (   sensor,
  data 
)    (sensor_get_angle(sensor, data, 0))
#define sensor_get_roll (   sensor,
  data 
)    (sensor_get_angle(sensor, data, 1))
#define sensor_get_x (   sensor,
  data 
)    (sensor_get_axis(sensor, data, 0))
#define sensor_get_y (   sensor,
  data 
)    (sensor_get_axis(sensor, data, 1))
#define sensor_get_yaw (   sensor,
  data 
)    (sensor_get_angle(sensor, data, 2))
#define sensor_get_z (   sensor,
  data 
)    (sensor_get_axis(sensor, data, 2))
#define sensor_reg_bitclear (   hal,
  ... 
)
Value:
bus_reg_bitclear( & (hal)->bus, \
__VA_ARGS__)
static void bus_reg_bitclear(bus_desc_t *bus, uint8_t addr, uint8_t mask)
Clear a bit at a bus device register or memory address.
Definition: sensor_bus.h:171

Referenced by bma150_selftest(), bma150_set_state(), bma220_sleep_en(), imu3000_event(), imu3000_set_state(), itg3200_event(), and itg3200_set_state().

#define sensor_reg_bitset (   hal,
  ... 
)    bus_reg_bitset( & (hal)->bus, __VA_ARGS__)
#define sensor_reg_fieldget (   hal,
  ... 
)
Value:
bus_reg_fieldget( & (hal)->bus, \
__VA_ARGS__)
uint8_t bus_reg_fieldget(bus_desc_t *bus, uint8_t addr, uint8_t mask)
Read a field stored at a device register or memory address.
Definition: sensor_bus.c:63

Referenced by bma222_get_threshold(), and bma250_get_threshold().

#define sensor_reg_fieldset (   hal,
  ... 
)
Value:
bus_reg_fieldset( & (hal)->bus, \
__VA_ARGS__)
void bus_reg_fieldset(bus_desc_t *bus, uint8_t addr, uint8_t mask, uint8_t value)
Write a field stored at a device register or memory address.
Definition: sensor_bus.c:84

Referenced by bma220_set_bandwidth(), bma220_set_range(), bma220_set_threshold(), bma222_set_threshold(), and bma250_set_threshold().

typedef bool(* sensor_enum_callback)(const sensor_hal_t *, void *)
typedef void(* sensor_event_callback)(volatile sensor_event_data_t *, volatile void *)
typedef struct sensor_hal sensor_hal_t

Sensor Hardware Abstraction Descriptor.

typedef struct sensor_desc sensor_t

Generic Sensor API Descriptor.

Sensor Sample Data Format.

Enumerator
SAMPLE_FORMAT_COUNTS 

Unscaled raw sample counts.

SAMPLE_FORMAT_SCALED 

Scaled engineering units.

Sensor Axis Name Constants.

Enumerator
SENSOR_AXIS_X 
SENSOR_AXIS_Y 
SENSOR_AXIS_Z 
SENSOR_AXIS_NONE 

Sensor Calibration Type Constants.

Enumerator
AUTO_CALIBRATE 

Auto-calibration.

MANUAL_CALIBRATE 

Manual calibration.

HARD_IRON_CALIBRATE 

Hard-iron calibration.

SOFT_IRON_CALIBRATE 

Soft-iron calibration.

FIELD_CALIBRATE 

Field calibration.

PROXIMITY_CALIBRATE 

Proximity calibration.

Sensor Command Constants - used for sensor ioctl operations.

Enumerator
SENSOR_INFO_QUERY 

Sensor information query.

SENSOR_STATUS_RUNNING 

Test for a running sensor.

SENSOR_STATUS_SLEEPING 

Test for a sleeping sensor.

SENSOR_STATUS_SUSPENDED 

Test for a suspended sensor.

SENSOR_EXEC_SLEEP 

Execute sensor sleep state.

SENSOR_EXEC_WAKE 

Execute sensor wake state.

SENSOR_EXEC_SUSPEND 

Execute sensor suspend state.

SENSOR_EXEC_RESET 

Execute sensor soft-reset function.

SENSOR_EXEC_SELFTEST 

Execute sensor self-test function.

SENSOR_GET_RANGE 

Get device-specific operational range.

SENSOR_GET_BANDWIDTH 

Get bandwidth (Hertz)

SENSOR_GET_POWER 

Get power requirement (milliamps)

SENSOR_GET_RESOLUTION 

Get sample resolution (bits)

SENSOR_GET_SAMPLE_RATE 

Get device-specific sample rate.

SENSOR_GET_THRESHOLD 

Get sensor threshold value.

SENSOR_GET_SLEEP_TIME 

Get sleep time (milliseconds)

SENSOR_SET_STATE 

Set device operational state/mode.

SENSOR_SET_RANGE 

set device-specific operational range

SENSOR_SET_BANDWIDTH 

Set bandwidth (Hertz)

SENSOR_SET_POWER 

Set power requirement (milliamps)

SENSOR_SET_CURRENT 

Set current level (milliamps)

SENSOR_SET_RESOLUTION 

Set sample resolution (bits)

SENSOR_SET_SAMPLE_RATE 

Set device-specific sample rate.

SENSOR_SET_THRESHOLD 

Set sensor threshold value.

SENSOR_SET_SLEEP_TIME 

Set sleep time (milliseconds)

SENSOR_SET_TAP 

Set sensor tap detection values.

SENSOR_ENABLE_EVENT 

Enable sensor event.

SENSOR_DISABLE_EVENT 

Disable sensor event.

SENSOR_READ_SCALAR 

Read generic single-value data.

SENSOR_READ_VECTOR 

Read generic 3-axis vector data.

Sensor Driver and API Error Constants.

Enumerator
SENSOR_ERR_NONE 
SENSOR_ERR_CALDATA 
SENSOR_ERR_RAWDATA 
SENSOR_ERR_COMPDATA 
SENSOR_ERR_HARDWARE 
SENSOR_ERR_SOFTWARE 
SENSOR_ERR_PARAMS 
SENSOR_ERR_CONFIG 
SENSOR_ERR_SELFTEST 
SENSOR_ERR_IO 
SENSOR_ERR_DRIVER 
SENSOR_ERR_UNSUPPORTED 
SENSOR_ERR_FUNCTION 
SENSOR_ERR_IOCTL 

Sensor Event Types.

Enumerator
SENSOR_EVENT_UNKNOWN 

Unknown sensor event.

SENSOR_EVENT_NEW_DATA 

New data available.

SENSOR_EVENT_MOTION 

Motion detected.

SENSOR_EVENT_LOW_G 

Inertial low-G detected.

SENSOR_EVENT_HIGH_G 

Inertial high-G detected.

SENSOR_EVENT_TILT 

Inertial tilt detected.

SENSOR_EVENT_TAP 

Tap detected.

SENSOR_EVENT_S_TAP 

Single tap detected.

SENSOR_EVENT_D_TAP 

Double tap detected.

SENSOR_EVENT_DROP 

Drop detected.

SENSOR_EVENT_NEAR_PROXIMITY 

Near proximity detected.

SENSOR_EVENT_MED_PROXIMITY 

Medium proximity detected.

SENSOR_EVENT_FAR_PROXIMITY 

Far proximity detected.

SENSOR_EVENT_LOW_LIGHT 

Low light level detected.

SENSOR_EVENT_HIGH_LIGHT 

High light level detected.

Sensor Feature Constants.

Enumerator
SENSOR_CAPS_UNKNOWN 
SENSOR_CAPS_1_AXIS 
SENSOR_CAPS_2_AXIS 
SENSOR_CAPS_3_AXIS 
SENSOR_CAPS_SELFTEST 
SENSOR_CAPS_AUX_TEMP 
SENSOR_CAPS_HI_G_EVENT 
SENSOR_CAPS_LO_G_EVENT 
SENSOR_CAPS_TAP_EVENT 
SENSOR_CAPS_S_TAP_EVENT 
SENSOR_CAPS_D_TAP_EVENT 
SENSOR_CAPS_TILT_EVENT 
SENSOR_CAPS_DROP_EVENT 
SENSOR_CAPS_AUTO_CAL 
SENSOR_CAPS_AUX_ACCEL 

Sensor Proximity Indicator Constants.

Enumerator
PROXIMITY_NONE 

No proximity detected.

PROXIMITY_FAR 

Far proximity detected.

PROXIMITY_MEDIUM 

Medium proximity detected.

PROXIMITY_NEAR 

Near proximity detected (default if 1 level)

Sensor Data Read Operations.

Enumerator
SENSOR_READ_ACCELERATION 

Read acceleration data.

SENSOR_READ_FIELD 

Read field strength data.

SENSOR_READ_HEADING 

Read heading data.

SENSOR_READ_ID 

Read sensor device ID.

SENSOR_READ_INTENSITY 

Read intensity data.

SENSOR_READ_LIGHT 

Read light level data.

SENSOR_READ_PRESSURE 

Read pressure data.

SENSOR_READ_PROXIMITY 

Read proximity data.

SENSOR_READ_ROTATION 

Read rotation data.

SENSOR_READ_TEMPERATURE 

Read temperature data.

Sensor Sample Unit Scale.

Enumerator
SENSOR_SCALE_micro 

Log 0.000001.

SENSOR_SCALE_milli 

Log 0.001.

SENSOR_SCALE_centi 

Log 0.01.

SENSOR_SCALE_deci 

Log 0.1.

SENSOR_SCALE_one 

Log 1.

SENSOR_SCALE_deca 

Log 10.

SENSOR_SCALE_hecto 

Log 100.

SENSOR_SCALE_kilo 

Log 1000.

Sensor Axis Sign Constants.

Enumerator
SENSOR_SIGN_POS 
SENSOR_SIGN_NEG 
SENSOR_SIGN_NONE 

Sensor Operational State Type Constants.

Enumerator
SENSOR_STATE_UNKNOWN 

Unknown state.

SENSOR_STATE_NORMAL 

Normal state.

SENSOR_STATE_SLEEP 

Sleep state.

SENSOR_STATE_SUSPEND 

Suspend state.

SENSOR_STATE_LOWEST_POWER 

Lowest power state.

SENSOR_STATE_LOW_POWER 

Low-power state.

SENSOR_STATE_HIGH_POWER 

High-power state.

SENSOR_STATE_HIGHEST_POWER 

Highest power state.

SENSOR_STATE_X_AXIS_STANDBY 

x-axis low power standby

SENSOR_STATE_Y_AXIS_STANDBY 

y-axis low power standby

SENSOR_STATE_Z_AXIS_STANDBY 

z-axis low power standby

SENSOR_STATE_RESET 

Reset state (run soft-reset)

SENSOR_STATE_POWER_DOWN 

Power-down state.

SENSOR_STATE_SINGLE 

Single measurement mode.

SENSOR_STATE_CONTINUOUS 

Continuous measurement mode.

Sensor Tap Event.

Enumerator
SENSOR_TAP_AXIS_UNKNOWN 

Unknown tap detect axis.

SENSOR_TAP_AXIS_X 

Tap detected on X axis.

SENSOR_TAP_AXIS_Y 

Tap detected on Y axis.

SENSOR_TAP_AXIS_Z 

Tap detected on Z axis.

Sensor Tap Event (event direction)

Enumerator
SENSOR_TAP_DIRECTION_UNKNOWN 

Unknown tap direction.

SENSOR_TAP_DIRECTION_POS 

Tap in positive direction.

SENSOR_TAP_DIRECTION_NEG 

Tap in negative direction.

Sensor Self Test Types.

Enumerator
SENSOR_TEST_DEFAULT 

Default test type for device.

SENSOR_TEST_BIAS_POS 

Positive bias test.

SENSOR_TEST_BIAS_NEG 

Negative bias test.

SENSOR_TEST_DEFLECTION 

Deflection test (e.g.

accelerometer)

SENSOR_TEST_INTERRUPT 

Interrupt test.

Sensor Self-Test Error Constants.

Enumerator
SENSOR_TEST_ERR_NONE 
SENSOR_TEST_ERR_FUNCTION 

No such self-test function.

SENSOR_TEST_ERR_READ 

Read error.

SENSOR_TEST_ERR_WRITE 

Write error.

SENSOR_TEST_ERR_RANGE 

Results out of range.

Sensor Threshold Type Constants.

Enumerator
SENSOR_THRESHOLD_MOTION 

Inertial motion (slope) threshold.

SENSOR_THRESHOLD_LOW_G 

Inertial low-G threshold.

SENSOR_THRESHOLD_HIGH_G 

Inertial high-G threshold.

SENSOR_THRESHOLD_TAP 

Inertial tap threshold.

SENSOR_THRESHOLD_S_TAP 

Inertial single tap threshold.

SENSOR_THRESHOLD_D_TAP 

Inertial double tap threshold.

SENSOR_THRESHOLD_TILT 

Inertial tilt threshold.

SENSOR_THRESHOLD_DURATION 

Event duration.

SENSOR_THRESHOLD_LOW_LIGHT 

Low light level threshold.

SENSOR_THRESHOLD_HIGH_LIGHT 

High light level threshold.

SENSOR_THRESHOLD_NEAR_PROXIMITY 

Near proximity threshold.

SENSOR_THRESHOLD_MED_PROXIMITY 

Medium proximity threshold.

SENSOR_THRESHOLD_FAR_PROXIMITY 

Far proximity threshold.

Sensor Type Constants.

Enumerator
SENSOR_TYPE_UNKNOWN 

Unknown or unspecified sensor.

SENSOR_TYPE_ACCELEROMETER 

Single- or multi-axis accelerometer.

SENSOR_TYPE_BAROMETER 

Atmospheric air pressure.

SENSOR_TYPE_COMPASS 

Single- or multi-axis compass.

SENSOR_TYPE_GYROSCOPE 

Single- or multi-axis gyroscope.

SENSOR_TYPE_HUMIDITY 

Moisture or humidity sensor.

SENSOR_TYPE_LIGHT 

Ambient light sensor.

SENSOR_TYPE_MAGNETIC 

Magnetic sensor.

SENSOR_TYPE_PRESSURE 

Pressure sensor.

SENSOR_TYPE_PROXIMITY 

Proximity sensor.

SENSOR_TYPE_TEMPERATURE 

Single-function temperature.

SENSOR_TYPE_VOLTAGE 

Single-function voltage.

Sensor Sample Units.

Enumerator
SENSOR_UNITS_NONE 

Unscaled data (raw counts)

SENSOR_UNITS_g0 

Standard gravity (g0)

SENSOR_UNITS_gauss 

Gauss (G)

SENSOR_UNITS_lux 

Lux (lx)

SENSOR_UNITS_lumen 

Lumen (lm)

SENSOR_UNITS_pascal 

Pascal (Pa)

SENSOR_UNITS_deg_per_sec 

Degrees-per-second (dps)

SENSOR_UNITS_deg_Celcius 

Degrees-Celcius.

SENSOR_UNITS_tesla 

Tesla (T)

SENSOR_UNITS_volt_DC 

Volts DC.

SENSOR_UNITS_volt_AC 

Volts AC.

Sensor Vendor Constants.

Enumerator
SENSOR_VENDOR_UNKNOWN 

Unknown sensor vendor.

SENSOR_VENDOR_ADI 

Analog Devices, Inc.

SENSOR_VENDOR_AKM 

Asahi Kasei Microdevices.

SENSOR_VENDOR_AVAGO 

Avago Technologies.

SENSOR_VENDOR_BOSCH 

Bosch Sensortec GmbH.

SENSOR_VENDOR_HONEYWELL 

Honeywell International, Inc.

SENSOR_VENDOR_INTERSIL 

Intersil Corporation.

SENSOR_VENDOR_INVENSENSE 

InvenSense.

SENSOR_VENDOR_KIONIX 

Kionix, Inc.

(ROHM)

SENSOR_VENDOR_OSRAM 

OSRAM Opto Semiconductors.

SENSOR_VENDOR_STM 

STMicroelectronics.

SENSOR_VENDOR_TAOS 

Texas Advanced Optoelectronic Solutions.

SENSOR_VENDOR_FREESCALE 

Freescale Semiconductor.

void default_event_handler ( volatile sensor_event_data_t data,
volatile void *  arg 
)

Default sensor event callback handler.

The default event callback handler returns immediately.

Parameters
dataSensor event data descriptor
argOptional user-specified callback argument
Returns
nothing

The default event callback handler returns immediately.

Parameters
dataSensor event data descriptor
argOptional user-specified callback argument
Returns
nothing

Referenced by sensor_add_event().

static int32_t raw_to_scaled ( const sensor_hal_t hal,
int32_t  counts 
)
inlinestatic

Convert raw sensor data to scaled engineering units.

This routine converts a sensor sample, counts, to a linearly scaled integer value in engineering units using device-specific range in standard engineering units and full scale resolution parameters in hal.

Parameters
halAn initialized hardware interface descriptor.
countsAn unscaled raw sensor sample value.
Returns
Scaled signed sensor data in standard engineering units.

References sensor_hal::range, and sensor_hal::resolution.

Referenced by bma222_get_threshold(), bma250_get_threshold(), and kxtf9_get_accel().

static int32_t scaled_to_raw ( const sensor_hal_t hal,
int32_t  value 
)
inlinestatic

Convert scaled sensor data to raw counts.

This routine converts a linearly scaled integer value in engineering units to the corresponding "raw" reading value for the device, using the device-specific range in standard engineering units and full scale resolution parameters in "opts".

Parameters
halAn initialized hardware interface descriptor.
valueA scaled sensor sample value.
Returns
Scaled signed sensor data in standard engineering units.

References sensor_hal::range, and sensor_hal::resolution.

Referenced by bma222_set_threshold(), bma250_set_threshold(), and kxtf9_set_tap().