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... | |
static bool | sensor_driver_unimpl (sensor_t *sensor) |
Unimplemented driver function handler. 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... | |
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.
This routine installs a sensor event handler that will be called when the specified sensor events occur. Function parameters specify the specific sensor event to be reported, the address of the handler function to be called, an optional parameter that will be passed to the handler, and whether the event handler should initially be enabled or disabled.
The event handler can subsequently be enabled and disabled using the sensor_event_enable() and sensor_event_disable() routines.
sensor | Specifies an initialized sensor descriptor |
sensor_event | Specifies the sensor event type |
handler | Specifies an application-defined callback |
arg | Specifies an optional callback argument |
enable | Specifies whether or not the event should be enabled |
This routine installs a sensor event handler that will be called when the specified sensor events occur. Function parameters specify the specific sensor event to be reported, the address of the handler function to be called, an optional parameter that will be passed to the handler, and whether the event handler should initially be enabled or disabled.
The event handler can subsequently be enabled and disabled using the sensor_event_enable() and sensor_event_disable() routines.
sensor | Specifies an initialized sensor descriptor |
sensor_event | Specifies the sensor event type |
handler | Specifies an application-defined callback |
arg | Specifies an optional callback argument |
enable | Specifies whether or not the event should be enabled |
References sensor_event_callback_t::arg, default_event_handler(), sensor_event_callback_t::handler, and SENSOR_DRV_CALL.
Referenced by main().
const char* sensor_api_version | ( | void | ) |
Atmel Software Framework Common Sensor API version.
This routine Gets the Sensor API version number and release date.
This routine Gets the Sensor API version number and release date.
bool sensor_attach | ( | sensor_t * | sensor, |
sensor_type_t | type, | ||
int | num, | ||
void * | aux | ||
) |
Attach a specified sensor descriptor to a sensor device.
Applications invoke this routine to attach a sensor_t
instance to an existing sensor device of a specified type
. Assuming the attach call is successful, the sensor_t
instance can then be used with other sensor API functions to perform operations on the device.
sensor | Specifies a descriptor to attach to the sensor device. |
type | Specifies the sensor type to attach. |
num | Driver instance number; currently ignored. |
aux | API Reserved value; should always be set to zero. |
Applications invoke this routine to attach a sensor_t
instance to an existing sensor device of a specified type
. Assuming the attach call is successful, the sensor_t
instance can then be used with other sensor API functions to perform operations on the device.
sensor | Specifies a descriptor to attach to the sensor device. |
type | Specifies the sensor type to attach. |
num | Driver instance number; currently ignored. |
aux | API Reserved value; should always be set to zero. |
References sensor_desc::aux, sensor_desc::err, sensor_desc::hal, sensor_desc::mod, SENSOR_ERR_DRIVER, SENSOR_ERR_NONE, sensor_find(), sensor_hal::sensor_init, SENSOR_STATE_NORMAL, and sensor_desc::type.
Referenced by main(), run_sensor_accel_test(), run_sensor_compass_test(), run_sensor_gyro_test(), run_sensor_init_test(), and run_sensor_temp_test().
bool sensor_calibrate | ( | sensor_t * | sensor, |
sensor_calibration_t | caltype, | ||
int | code, | ||
void * | caldata | ||
) |
Calibrate a sensor device.
sensor | The address of an initialized sensor descriptor. |
caltype | The type of calibration to perform. |
code | Device-specific calibration code or step parameter. |
info | Unimplemented (ignored) parameter. |
sensor | The address of an initialized sensor descriptor. |
caltype | The type of calibration to perform. |
References SENSOR_DRV_CALL.
Referenced by main().
bool sensor_device_enum | ( | sensor_type_t | type, |
sensor_enum_callback | func, | ||
void * | arg | ||
) |
Enumerate sensor devices.
This routine is a sensor device enumeration function that will call a user-defined callback func
for each sensor of a specified type
configured into the system. The user-callback function will be passed the address of a sensor_hal_t HAL
descriptor corresponding to the sensor type along with a user-specified address arg
storing any additional function arguments.
If the specified sensor type
is SENSOR_TYPE_UNKNOWN
, then the user func
will be called for every sensor device in the system.
Once called, the user-callback function must return a boolean true value to continue iterating the list, else false to cease device list iteration. This routine returns when there are not more sensors of the requested type
in the device list, or when the user function returns zero (false).
Note that this function will not be included in the API by default. Build a sensor system with INCLUDE_SENSOR_ENUM
defined to include this routine.
type | Specifies the sensor type to enumerate. |
func | Specifies the address of a user callback function. |
arg | Specifies the address of a callback function argument. |
This routine is a sensor device enumeration function that will call a user-defined callback func
for each sensor of a specified type
configured into the system. The user-callback function will be passed the address of a sensor_hal_t HAL
descriptor corresponding to the sensor type along with a user-specified address arg
storing any additional function arguments.
If the specified sensor type
is SENSOR_TYPE_UNKNOWN
, then the user func
will be called for every sensor device in the system.
Once called, the user-callback function must return a boolean true value to continue iterating the list, else false to cease device list iteration. This routine returns when there are not more sensors of the requested type
in the device list, or when the user function returns zero (false).
Note that this function will not be included in the API by default. Build a sensor system with INCLUDE_SENSOR_ENUM
defined to include this routine.
type | Specifies the sensor type to enumerate. |
func | Specifies the address of a user callback function. |
arg | Specifies the address of a callback function argument. |
References sensor_hal::dev_type, sensor_list(), and SENSOR_TYPE_UNKNOWN.
Get sensor hardware device ID.
This routine returns device-specific sensor hardware identification and, optionally, version values. Unimplemented values will be set to zero. For example, devices supporting a dedicated ID register, but not a version register, will set "id" to the ID value and "ver" to zero.
sensor | The address of an initialized sensor descriptor. |
id | An address where the device ID is returned. |
ver | An address where the device version is returned. |
This routine returns device-specific sensor hardware identification and, optionally, version values. Unimplemented values will be set to zero. For example, devices supporting a dedicated ID register, but not a version register, will set "id" to the ID value and "ver" to zero.
sensor | The address of an initialized sensor descriptor. |
id | An address where the device ID is returned. |
ver | An address where the device version is returned. |
References sensor_data_t::device, sensor_read(), SENSOR_READ_ID, and status.
Referenced by main().
|
inlinestatic |
Disable a sensor event handler.
This routine disables the handler for a sensor event. The event handler must have already been defined using sensor_add_event(). To enable the event, see sensor_enable_event().
sensor | Specifies an initialized sensor descriptor |
sensor_event | Specifies the sensor event type |
References SENSOR_DISABLE_EVENT, and sensor_ioctl().
Referenced by main().
Unimplemented driver function handler.
This routine is called in the API to set the sensor error status and return a status indicating a function call failure when a driver has been invoked to run an interface that's not implemented in the driver.
sensor | The address of an initialized sensor descriptor. |
false
. References sensor_desc::err, and SENSOR_ERR_FUNCTION.
|
inlinestatic |
Enable a sensor event handler.
This routine enables the handler for a sensor event. The event handler must have already been defined using sensor_add_event(). To disable the event, see sensor_disable_event().
sensor | Specifies an initialized sensor descriptor |
sensor_event | Specifies the sensor event type |
References SENSOR_ENABLE_EVENT, and sensor_ioctl().
Referenced by main().
bool sensor_enum_bandwidth | ( | sensor_t * | sensor, |
const sensor_band_t ** | table, | ||
size_t * | count | ||
) |
Enumerate sensor bandwidth settings.
This routine returns the address of a table, if any, holding device-specific sensor bandwidth settings. The use and context of the settings are specific to the device and typically documented in the manufacturer's data sheets for the device.
sensor | The address of a sensor descriptor. |
table | Location where the table address is returned. |
count | Location where the number of table elements is returned. |
This routine returns the address of a table, if any, holding device-specific sensor bandwidth settings. The use and context of the settings are specific to the device and typically documented in the manufacturer's data sheets for the device.
sensor | The address of a sensor descriptor. |
table | Location where the table address is returned. |
count | Location where the number of table elements is returned. |
References sensor_caps_t::band_count, sensor_caps_t::band_table, sensor_device_t::caps, and sensor_desc::drv.
bool sensor_enum_range | ( | sensor_t * | sensor, |
const sensor_range_t ** | table, | ||
size_t * | count | ||
) |
Enumerate sensor range settings.
This routine returns the address of a table, if any, holding device-specific sensor range settings. The units of the settings are specific to the device and typically documented in the manufacturer's data sheets for the device.
sensor | The address of a sensor descriptor. |
table | Location where the table address is returned. |
count | Location where the number of table elements is returned. |
This routine returns the address of a table, if any, holding device-specific sensor range settings. The units of the settings are specific to the device and typically documented in the manufacturer's data sheets for the device.
sensor | The address of a sensor descriptor. |
table | Location where the table address is returned. |
count | Location where the number of table elements is returned. |
References sensor_device_t::caps, sensor_desc::drv, sensor_caps_t::range_count, and sensor_caps_t::range_table.
sensor_hal_t* sensor_find | ( | sensor_type_t | type | ) |
Find a sensor hardware descriptor.
This routine returns the address of a sensor hardware descriptor, based on the sensor type specified in the type
parameter. The first hardware entry with the correct type will be used.
This utility is currently used to abstract the details of the device list implementation from the rest of the API. However, it will not be retained in future versions of the API. As a result applications and library code should not use this routine. If list iteration is required in API clients, use the sensor_device_enum() function.
type | The type of sensor to find in hardware descriptor list |
References sensor_list().
Referenced by sensor_attach().
|
inlinestatic |
Get acceleration sensor data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_ACCELERATION.
Referenced by main(), and run_sensor_accel_test().
|
inlinestatic |
Read angular rate sensor data.
This routine returns a data sample for an angle
of a specified angular rate sensor
device such as a gyroscope.
In the event of a false return from this routine, the contents stored at the location specified by data
are undefined.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
angle | Specifies the angle (pitch = 0, roll = 1, yaw = 2) |
References sensor_read(), SENSOR_READ_ROTATION, and sensor_data_t::value.
Get the sensor operational bandwidth.
sensor | The address of an initialized sensor descriptor. |
bandwidth_Hz | The current sensor operational bandwidth in Hertz. |
References SENSOR_GET_BANDWIDTH, and sensor_ioctl().
Referenced by main().
Get sensor channel.
This routine obtains the individual channel that is currently selected within a multi-channel sensor device.
sensor | The address of an initialized sensor descriptor. |
channel | The address where the current channel is to be returned. |
References sensor_desc::channel.
|
inlinestatic |
Get sensor field strength data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_FIELD.
Referenced by main().
|
inlinestatic |
Get sensor heading data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_HEADING.
Referenced by main(), and run_sensor_compass_test().
|
inlinestatic |
Get sensor intensity data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_INTENSITY.
|
inlinestatic |
Get sensor light level data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_LIGHT.
Referenced by main().
|
inlinestatic |
Get pressure sensor data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_PRESSURE.
Referenced by main().
|
inlinestatic |
Get sensor proximity data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_PROXIMITY.
Referenced by main().
Get the sensor operational range.
sensor | The address of an initialized sensor descriptor. |
range | The current sensor operational range. |
References SENSOR_GET_RANGE, and sensor_ioctl().
Referenced by main().
|
inlinestatic |
Get rotation sensor data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_ROTATION.
Referenced by main(), and run_sensor_gyro_test().
Get the sensor operational sample interval.
sensor | The address of an initialized sensor descriptor. |
interval_ms | Address where sample interval to be returned. |
References SENSOR_GET_SAMPLE_RATE, sensor_ioctl(), and status.
Get the sensor operational sample rate.
sensor | The address of an initialized sensor descriptor. |
sample_Hz | The current sensor sample rate in Hertz. |
References SENSOR_GET_SAMPLE_RATE, and sensor_ioctl().
bool sensor_get_state | ( | sensor_t * | sensor, |
sensor_state_t * | mode | ||
) |
Get a sensor mode.
This routine gets the current sensor execution state which may be one of the following values:
- 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_RESET
These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent.
sensor | The address of an initialized sensor descriptor. |
mode | The current sensor mode is returned to this location. |
This routine gets the current sensor execution state which may be one of the following values:
These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent.
sensor | The address of an initialized sensor descriptor. |
mode | The current sensor mode is returned to this location. |
References sensor_desc::mod.
|
inlinestatic |
Get temperature sensor data.
sensor | The address of an initialized sensor descriptor. |
data | Specifies an address where sensor data is stored. |
References sensor_read(), and SENSOR_READ_TEMPERATURE.
Referenced by main(), and run_sensor_temp_test().
bool sensor_get_threshold | ( | sensor_t * | sensor, |
sensor_threshold_t | type, | ||
int16_t * | value | ||
) |
Get a sensor operational threshold.
sensor | The address of an initialized sensor descriptor. |
threshold | A specified sensor operational threshold. |
value | Address of location to return threshold value |
sensor | The address of an initialized sensor descriptor. |
type | A specified sensor operational threshold type. |
value | Address of location to return threshold value |
References SENSOR_DRV_CALL, SENSOR_GET_THRESHOLD, status, sensor_threshold_desc_t::type, and sensor_threshold_desc_t::value.
Referenced by main().
Get vector sensor data.
This routine reads a specified sensor and returns the data stored in in a vector3_t data format for use with API routines that operate on that format.
In the event of a false return from this routine, the contents stored at the location specified by "data" are undefined.
sensor | The address of an initialized sensor descriptor. |
vector | Specifies an address where sensor data is stored. |
References sensor_ioctl(), and SENSOR_READ_VECTOR.
bool sensor_ioctl | ( | sensor_t * | sensor, |
sensor_command_t | cmd, | ||
void * | arg | ||
) |
Execute a sensor device control function.
sensor | The address of an initialized sensor descriptor. |
cmd | Specifies the IOCTL command. |
arg | Specifies command parameters (varies by command). |
sensor | The address of an initialized sensor descriptor. |
cmd | Specifies the IOCTL command. |
arg | Specifies command parameters (varies by command). |
References sensor_hal::bandwidth, sensor_device_t::caps, sensor_desc::drv, sensor_desc::err, sensor_desc::hal, sensor_hal::range, sensor_hal::sample_rate, sensor_band_index(), SENSOR_DRV_CALL, SENSOR_ERR_FUNCTION, SENSOR_ERR_PARAMS, SENSOR_GET_BANDWIDTH, SENSOR_GET_RANGE, SENSOR_GET_SAMPLE_RATE, sensor_range_index(), SENSOR_SET_BANDWIDTH, SENSOR_SET_RANGE, and SENSOR_SET_SAMPLE_RATE.
Referenced by sensor_disable_event(), sensor_enable_event(), sensor_get_bandwidth(), sensor_get_range(), sensor_get_sample_interval(), sensor_get_sample_rate(), sensor_get_vector(), sensor_set_bandwidth(), sensor_set_current(), sensor_set_range(), sensor_set_sample_interval(), and sensor_set_sample_rate().
bool sensor_irq_connect | ( | uint32_t | intr_pin, |
void(*)(volatile void *) | handler, | ||
void * | arg | ||
) |
Install a sensor device interrupt handler.
This routine will enable interrupts on the pin specified by the intr_pin
parameter and call a user-defined callback handler
when an interrupt is detected. The arg
parameter is used to pass the address of user-defined input and output storage for the callback handler. Calling the routine with the handler
parameter set to 0 (the NULL pointer) will cause interrupts to be disabled for the specified GPIO pin.
intr_pin | Board-specific interrupt / GPIO pin interface to the MCU. |
handler | The address of a user-defined interrupt handler. |
arg | An optional address passed to the interrupt handler. |
true
if the call succeeds, else false
. References sensor_board_irq_connect(), and status.
Referenced by bma150_init(), bma220_init(), bma222_init(), bma250_init(), itg3200_init(), kxtf9_init(), and sfh7770_init().
sensor_hal_t* sensor_list | ( | size_t * | dev_count | ) |
Fetch the sensor hardware descriptor list.
This routine returns the system address of a table of sensor hardware descriptors along with the number of descriptors in the dev_count
parameter. This utility is currently used to abstract the details of the device list implementation from the rest of the API. However, it will not be retained in future versions of the API. As a result applications and library code should not use this routine. If list iteration is required in API clients, use the sensor_device_enum() function.
dev_count | The list descriptor count is returned here. |
Sensor Device List
When a new driver is added to the API a HAL descriptor indicating the sensor type, xxx_init() function prefix, bus address (where applicable), and I/O Pin assignment (where applicable) should be conditionally allocated in this table.
References ARRAYSIZE, SENSOR_HAL_DESC, SENSOR_TYPE_ACCELEROMETER, SENSOR_TYPE_BAROMETER, SENSOR_TYPE_COMPASS, SENSOR_TYPE_GYROSCOPE, SENSOR_TYPE_LIGHT, and SENSOR_TYPE_PROXIMITY.
Referenced by sensor_device_enum(), and sensor_find().
bool sensor_platform_init | ( | void | ) |
Initialize the Sensor Platform Hardware.
This function initializes the Atmel Xplained
platform hardware and must be called once from the client application before any of the Sensors Xplained API routines can be used.
After the platform board initialization (i.e. board_init()) configures GPIO pins, interrupts, etc., this routine initializes the microcontroller hardware abstraction layer (HAL) for the Xplained Sensor API.
This function initializes the Atmel Xplained
platform hardware and must be called once from the client application before any of the Sensors Xplained API routines can be used.
After the platform board initialization (i.e. board_init()) configures GPIO pins, interrupts, etc., this routine initializes the AVR and AVR32 hardware abstraction layer (HAL) for the Xplained Sensor API.
References usart_rs232_options::baudrate, board_init(), BUS_TYPE_UNKNOWN, BUSIO_IF, BUSIO_SPEED, BUSIO_TYPE, CONFIG_USART_BAUDRATE, CONFIG_USART_CHAR_LENGTH, CONFIG_USART_IF, CONFIG_USART_PARITY, CONFIG_USART_STOP_BIT, delay_ms, sensor_bus_init, SENSOR_START_DELAY_MSEC, stdio_serial_init(), and sysclk_init().
Referenced by configure_sensor_platform(), and main().
bool sensor_read | ( | sensor_t * | sensor, |
sensor_read_t | type, | ||
sensor_data_t * | data | ||
) |
Read sensor data.
This is a generic routine that will call a specified sensor function returning \c vector sensor data. It is used primarily by API routines but may be called by special-case application or library code where needed to extend the API semantics. As an example, consider a multiple-axis gyroscope driver implementing the sensor_funcs_t.get_rotation() interface. An application will usually call the sensor_get_rotation() routine in this case, but the angular rate might be obtained from the device as follows:
In the event of a false return from this routine, the contents stored at the location specified by "data" are undefined.
sensor | The address of an initialized sensor descriptor. |
type | Type of read operation to perform. |
data | Specifies an address where sensor data is stored. |
This is a generic routine that will call a specified sensor function returning sensor data. It is used primarily by API routines but may be called by special-case application or library code where needed to extend the API semantics.
As an example, consider a multiple-axis gyroscope driver implementing the sensor_funcs_t.get_rotation() interface. An application will usually call the sensor_get_rotation() routine in this case, but the angular rate might be obtained from the device as follows:
In the event of a false return from this routine, the contents stored at the location specified by "data" are undefined.
sensor | The address of an initialized sensor descriptor. |
type | Type of sample to read from sensor |
data | Specifies an address where sensor data is stored. |
References read, SENSOR_DRV_CALL, sensor_timestamp(), and sensor_data_t::timestamp.
Referenced by sensor_device_id(), sensor_get_acceleration(), sensor_get_angle(), sensor_get_field(), sensor_get_heading(), sensor_get_intensity(), sensor_get_light(), sensor_get_pressure(), sensor_get_proximity(), sensor_get_rotation(), and sensor_get_temperature().
Initiate a sensor device software reset.
sensor | The address of an initialized sensor descriptor. |
arg | Device-specific argument options. |
sensor | The address of an initialized sensor descriptor. |
References sensor_set_state(), and SENSOR_STATE_RESET.
Activate a sensor self-test function.
sensor | Address of an initialized sensor device descriptor. |
test_code | Address of a device-specific numeric test code. |
arg | Device-specific self-test argument options. |
sensor | Address of an initialized sensor device descriptor. |
test_code | Address of a device-specific numeric test code. |
arg | Device-specific self-test argument options. |
References sensor_desc::err, SENSOR_DRV_CALL, SENSOR_ERR_FUNCTION, and SENSOR_ERR_SELFTEST.
Set the sensor operational bandwidth.
sensor | The address of an initialized sensor descriptor. |
bandwidth_Hz | The new sensor operational bandwidth in Hertz. |
References sensor_ioctl(), and SENSOR_SET_BANDWIDTH.
Set sensor channel.
This routine selects the individual channel within a multi-channel sensor device. This selection is then used is subsequent function calls that control the sensor.
Specifying a value of -1 (SENSOR_CHANNEL_ALL) for the sensor channel indicates that all channels are to be affected by the subsequent function calls.
sensor | The address of an initialized sensor descriptor. |
channel | The number of the channel to be selected, or -1 for all. |
References sensor_desc::channel.
Referenced by main().
Set the sensor operational current.
sensor | The address of an initialized sensor descriptor. |
current_mA | The new sensor operational current in mA |
References sensor_ioctl(), and SENSOR_SET_CURRENT.
Referenced by main().
Set the sensor operational range.
sensor | The address of an initialized sensor descriptor. |
range | The new sensor operational range. |
References sensor_ioctl(), and SENSOR_SET_RANGE.
Set the sensor operational sample interval.
sensor | The address of an initialized sensor descriptor. |
interval_ms | The new sensor sample interval in milliseconds. |
References sensor_ioctl(), and SENSOR_SET_SAMPLE_RATE.
Set the sensor operational sample rate.
sensor | The address of an initialized sensor descriptor. |
sample_Hz | The new sensor operational sample rate in Hertz. |
References sensor_ioctl(), and SENSOR_SET_SAMPLE_RATE.
Referenced by main().
bool sensor_set_state | ( | sensor_t * | sensor, |
sensor_state_t | mode | ||
) |
Set a sensor mode.
This routine sets a specified sensor execution state to one of the following values:
- 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_RESET
These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent.
sensor | The address of an initialized sensor descriptor. |
mode | A specified sensor operational mode. |
This routine sets a specified sensor execution state to one of the following values:
These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent.
sensor | The address of an initialized sensor descriptor. |
mode | A specified sensor operational mode. |
References sensor_desc::mod, SENSOR_DRV_CALL, SENSOR_SET_STATE, SENSOR_STATE_NORMAL, and SENSOR_STATE_RESET.
Referenced by main(), sensor_reset(), and sensor_sleep().
bool sensor_set_tap | ( | sensor_t * | sensor, |
sensor_tap_params_t * | params | ||
) |
Set tap event parameters.
sensor | Address of an initialized sensor device descriptor. |
params | Address of a tap parameter structure. |
sensor | Address of an initialized sensor device descriptor. |
params | Address of a tap parameter structure. |
References SENSOR_DRV_CALL, and SENSOR_SET_TAP.
bool sensor_set_threshold | ( | sensor_t * | sensor, |
sensor_threshold_t | type, | ||
int16_t | value | ||
) |
Set a sensor operational threshold.
sensor | The address of an initialized sensor descriptor. |
threshold | A specified sensor operational threshold. |
value | The value of the specified threshold. |
sensor | The address of an initialized sensor descriptor. |
type | A specified sensor operational threshold type. |
value | The value of the specified threshold. |
References SENSOR_DRV_CALL, SENSOR_SET_THRESHOLD, sensor_threshold_desc_t::type, and sensor_threshold_desc_t::value.
Referenced by main().
Set a sensor device to low-power or standby mode.
sensor | The address of an initialized sensor descriptor. |
arg | Device-specific argument options. |
sensor | The address of an initialized sensor descriptor. |
References sensor_set_state(), and SENSOR_STATE_SLEEP.
uint32_t sensor_timestamp | ( | void | ) |
This function returns the current timestamp counter value.
The timestamp facility is implemented in terms of the XMEGA or UC3 timer and clock function APIs.
References Get_system_register, and sysclk_get_cpu_hz().
Referenced by bma150_isr(), bma220_isr(), bma222_isr(), bma250_isr(), imu3000_isr(), itg3200_isr(), kxtf9_isr(), sensor_read(), and sfh7770_isr().