Sensor Driver API functions. More...
Typedefs | |
typedef void * | sensorId_t |
Identifier. | |
typedef void(* | sensorEvent_t) (sensorId_t id, uint32_t event) |
Sensor Events callback function type. | |
Functions | |
sensorId_t | sensorGetId (const char *name) |
Get sensor identifier. | |
sensorConfig_t * | sensorGetConfig (sensorId_t id) |
Get sensor configuration. | |
int32_t | sensorRegisterEvents (sensorId_t id, sensorEvent_t event_cb, uint32_t event_mask) |
Register sensor events. | |
int32_t | sensorEnable (sensorId_t id) |
Enable sensor. | |
int32_t | sensorDisable (sensorId_t id) |
Disable sensor. | |
sensorStatus_t | sensorGetStatus (sensorId_t id) |
Get sensor status. | |
uint32_t | sensorReadSamples (sensorId_t id, uint32_t num_samples, void *buf, uint32_t buf_size) |
Read samples from sensor. | |
void * | sensorGetBlockData (sensorId_t id) |
Get block data. | |
Sensor Driver API functions.
sensorEvent_t |
Sensor Events callback function type.
[in] | id | sensorId_t |
[in] | event | events notification mask |
Provides the typedef for the event callback function sensorEvent (sensorId_t id, uint32_t event) to be registered with sensorRegisterEvents.
The parameter id specifies the sensor.
The parameter event indicates the reported event(s) that occurred during driver operation. Each event is encoded in a separate bit so it is possible to signal multiple events within the same call. SENSOR_EVENT_... definitions list the events that can be reported.
Parameter for:
sensorId_t sensorGetId | ( | const char * | name | ) |
Get sensor identifier.
[in] | name | sensor name (pointer to NULL terminated string) |
The function sensorGetId retrieves the sensor identifier, which is then used to specify which sensor is affected by the function call.
The parameter name specifies sensor name.
Possible return values:
sensorConfig_t * sensorGetConfig | ( | sensorId_t | id | ) |
Get sensor configuration.
[in] | id | sensorId_t |
The function sensorGetConfig retrieves sensor configuration.
The parameter id specifies the sensor.
int32_t sensorRegisterEvents | ( | sensorId_t | id, |
sensorEvent_t | event_cb, | ||
uint32_t | event_mask | ||
) |
Register sensor events.
[in] | id | sensorId_t |
[in] | event_cb | pointer to sensorEvent_t |
[in] | event_mask | event mask |
The function sensorRegisterEvents registers sensor events.
The parameter id specifies the sensor.
The parameter event_cb is a pointer to the sensorEvent_t callback function.
The parameter event_mask specifies the event. Each event is encoded in a separate bit. SENSOR_EVENT_... definitions list the events that can be reported.
Possible return values:
int32_t sensorEnable | ( | sensorId_t | id | ) |
Enable sensor.
[in] | id | sensorId_t |
The function sensorEnable enables the specified sensor.
The parameter id specifies the sensor.
Possible return values:
int32_t sensorDisable | ( | sensorId_t | id | ) |
Disable sensor.
[in] | id | sensorId_t |
The function sensorDisable disables the specified sensor.
The parameter id specifies the sensor.
Possible return values:
sensorStatus_t sensorGetStatus | ( | sensorId_t | id | ) |
Get sensor status.
[in] | id | sensorId_t |
The function sensorGetStatus retrieves the current status of the specified sensor.
The parameter id specifies the sensor.
uint32_t sensorReadSamples | ( | sensorId_t | id, |
uint32_t | num_samples, | ||
void * | buf, | ||
uint32_t | buf_size | ||
) |
Read samples from sensor.
[in] | id | sensorId_t |
[in] | num_samples | maximum number of samples to read |
[out] | buf | pointer to buffer for samples |
[in] | buf_size | buffer size in bytes |
The function sensorReadSamples reads requested number of samples from sensor and stores them in the specified buffer. If the requested number of samples is higher than the number of available samples, the available number of samples will be read and stored in the buffer. If the provided buffer size is not big enough, no samples will be read from the sensor.
The parameter id specifies the sensor.
The parameter num_samples specifies the maximum number of samples to be read from the sensor.
The parameter buf points to the sensor sample memory buffer provided by the user.
The parameter buf_size defines the size of user provided sensor sample buffer.
void * sensorGetBlockData | ( | sensorId_t | id | ) |
Get block data.
[in] | id | sensorId_t |
The function sensorGetBlockData gets a pointer to block data.
The parameter id specifies the sensor.