Atmel Software Framework Common Sensor API.
The sensor device service provides high-level interfaces and binary driver libraries for sensor devices on systems built around UC3, XMEGA, and SAM microcontrollers.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
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... | |
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... | |
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,...) |
Typedefs | |
typedef struct sensor_hal | sensor_hal_t |
Sensor Hardware Abstraction Descriptor. More... | |
typedef struct sensor_desc | sensor_t |
Generic Sensor API Descriptor. More... | |
Functions | |
bool | sensor_add_event (sensor_t *sensor, sensor_event_t sensor_event, sensor_event_callback handler, volatile void *arg, bool enable) |
Install a sensor event handler. More... | |
bool | sensor_attach (sensor_t *sensor, sensor_type_t type, int num, void *aux) |
Attach a specified sensor descriptor to a sensor device. More... | |
bool | sensor_calibrate (sensor_t *sensor, sensor_calibration_t caltype, int code, void *info) |
Calibrate a sensor device. More... | |
bool | sensor_device_enum (sensor_type_t type, sensor_enum_callback func, void *arg) |
Enumerate sensor devices. More... | |
bool | sensor_device_id (sensor_t *sensor, uint32_t *id, uint8_t *ver) |
Get sensor hardware device ID. More... | |
static bool | sensor_disable_event (sensor_t *sensor, sensor_event_t sensor_event) |
Disable a sensor event handler. More... | |
static bool | sensor_enable_event (sensor_t *sensor, sensor_event_t sensor_event) |
Enable a sensor event handler. More... | |
bool | sensor_enum_bandwidth (sensor_t *sensor, const sensor_band_t **table, size_t *count) |
Enumerate sensor bandwidth settings. More... | |
bool | sensor_enum_range (sensor_t *sensor, const sensor_range_t **table, size_t *count) |
Enumerate sensor range settings. More... | |
static bool | sensor_get_acceleration (sensor_t *sensor, sensor_data_t *data) |
Get acceleration sensor data. More... | |
static bool | sensor_get_angle (sensor_t *sensor, sensor_data_t *data, int angle) |
Read angular rate sensor data. More... | |
static bool | sensor_get_bandwidth (sensor_t *sensor, int16_t *bandwidth_Hz) |
Get the sensor operational bandwidth. More... | |
static bool | sensor_get_channel (sensor_t *sensor, uint16_t *channel) |
Get sensor channel. More... | |
static bool | sensor_get_field (sensor_t *sensor, sensor_data_t *data) |
Get sensor field strength data. More... | |
static bool | sensor_get_heading (sensor_t *sensor, sensor_data_t *data) |
Get sensor heading data. More... | |
static bool | sensor_get_intensity (sensor_t *sensor, sensor_data_t *data) |
Get sensor intensity data. More... | |
static bool | sensor_get_light (sensor_t *sensor, sensor_data_t *data) |
Get sensor light level data. More... | |
static bool | sensor_get_pressure (sensor_t *sensor, sensor_data_t *data) |
Get pressure sensor data. More... | |
static bool | sensor_get_proximity (sensor_t *sensor, sensor_data_t *data) |
Get sensor proximity data. More... | |
static bool | sensor_get_range (sensor_t *sensor, int16_t *range) |
Get the sensor operational range. More... | |
static bool | sensor_get_rotation (sensor_t *sensor, sensor_data_t *data) |
Get rotation sensor data. More... | |
static bool | sensor_get_sample_interval (sensor_t *sensor, int16_t *interval_ms) |
Get the sensor operational sample interval. More... | |
static bool | sensor_get_sample_rate (sensor_t *sensor, int16_t *sample_Hz) |
Get the sensor operational sample rate. More... | |
bool | sensor_get_state (sensor_t *sensor, sensor_state_t *mode) |
Get a sensor mode. More... | |
static bool | sensor_get_temperature (sensor_t *sensor, sensor_data_t *data) |
Get temperature sensor data. More... | |
bool | sensor_get_threshold (sensor_t *sensor, sensor_threshold_t threshold, int16_t *value) |
Get a sensor operational threshold. More... | |
static bool | sensor_get_vector (sensor_t *sensor, vector3_t *vector) |
Get vector sensor data. More... | |
bool | sensor_ioctl (sensor_t *sensor, sensor_command_t cmd, void *arg) |
Execute a sensor device control function. More... | |
bool | sensor_read (sensor_t *sensor, sensor_read_t type, sensor_data_t *data) |
Read sensor data. More... | |
bool | sensor_reset (sensor_t *sensor, int arg) |
Initiate a sensor device software reset. More... | |
bool | sensor_selftest (sensor_t *sensor, int *test_code, void *arg) |
Activate a sensor self-test function. More... | |
static bool | sensor_set_bandwidth (sensor_t *sensor, int16_t bandwidth_Hz) |
Set the sensor operational bandwidth. More... | |
static bool | sensor_set_channel (sensor_t *sensor, int16_t channel) |
Set sensor channel. More... | |
static bool | sensor_set_current (sensor_t *sensor, int16_t current_mA) |
Set the sensor operational current. More... | |
static bool | sensor_set_range (sensor_t *sensor, int16_t range) |
Set the sensor operational range. More... | |
static bool | sensor_set_sample_interval (sensor_t *sensor, int16_t interval_ms) |
Set the sensor operational sample interval. More... | |
static bool | sensor_set_sample_rate (sensor_t *sensor, int16_t sample_Hz) |
Set the sensor operational sample rate. More... | |
bool | sensor_set_state (sensor_t *sensor, sensor_state_t mode) |
Set a sensor mode. More... | |
bool | sensor_set_tap (sensor_t *sensor, sensor_tap_params_t *params) |
Set tap event parameters. More... | |
bool | sensor_set_threshold (sensor_t *sensor, sensor_threshold_t threshold, int16_t value) |
Set a sensor operational threshold. More... | |
bool | sensor_sleep (sensor_t *sensor, int arg) |
Set a sensor device to low-power or standby mode. More... | |
Platform Interfaces | |
const char * | sensor_api_version (void) |
Atmel Software Framework Common Sensor API version. More... | |
sensor_hal_t * | sensor_find (sensor_type_t type) |
Find a sensor hardware descriptor. More... | |
bool | sensor_irq_connect (uint32_t intr_pin, void(*handler)(volatile void *), void *arg) |
Install a sensor device interrupt handler. More... | |
sensor_hal_t * | sensor_list (size_t *dev_count) |
Fetch the sensor hardware descriptor list. More... | |
bool | sensor_platform_init (void) |
Initialize the Sensor Platform Hardware. More... | |
uint32_t | sensor_timestamp (void) |
This function returns the current timestamp counter value. More... | |
Sensor Physical Axis Definitions | |
#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} |
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... | |
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 | |
#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)) |
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... | |