Virtual Hardware  Version 1.3.1 - beta
AVH FVP Models
 
Loading...
Searching...
No Matches

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_tsensorGetConfig (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.
 

Description

Sensor Driver API functions.

Typedef Documentation

◆ sensorEvent_t

sensorEvent_t

Sensor Events callback function type.

Parameters
[in]idsensorId_t
[in]eventevents notification mask
Returns
none

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:

Function Documentation

◆ sensorGetId()

sensorId_t sensorGetId ( const char *  name)

Get sensor identifier.

Parameters
[in]namesensor name (pointer to NULL terminated string)
Returns
sensorId_t

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:

  • sensorId_t
  • NULL : sensor name was not specified.

◆ sensorGetConfig()

sensorConfig_t * sensorGetConfig ( sensorId_t  id)

Get sensor configuration.

Parameters
[in]idsensorId_t
Returns
pointer to sensorConfig_t

The function sensorGetConfig retrieves sensor configuration.

The parameter id specifies the sensor.

◆ sensorRegisterEvents()

int32_t sensorRegisterEvents ( sensorId_t  id,
sensorEvent_t  event_cb,
uint32_t  event_mask 
)

Register sensor events.

Parameters
[in]idsensorId_t
[in]event_cbpointer to sensorEvent_t
[in]event_maskevent mask
Returns
return code

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:

  • SENSOR_OK : events registered.
  • SENSOR_ERROR : returned in the following cases:
    • sensor id is invalid.
    • event_cb is NULL.
    • event_mask is 0.

◆ sensorEnable()

int32_t sensorEnable ( sensorId_t  id)

Enable sensor.

Parameters
[in]idsensorId_t
Returns
return code

The function sensorEnable enables the specified sensor.

The parameter id specifies the sensor.

Possible return values:

  • SENSOR_OK : sensor enabled.
  • SENSOR_ERROR : returned in the following cases:
    • sensor id is invalid.
    • sensor is already active.

◆ sensorDisable()

int32_t sensorDisable ( sensorId_t  id)

Disable sensor.

Parameters
[in]idsensorId_t
Returns
return code

The function sensorDisable disables the specified sensor.

The parameter id specifies the sensor.

Possible return values:

  • SENSOR_OK : sensor disabled.
  • SENSOR_ERROR : returned in the following cases:
    • sensor id is invalid.
    • sensor is already disabled.

◆ sensorGetStatus()

sensorStatus_t sensorGetStatus ( sensorId_t  id)

Get sensor status.

Parameters
[in]idsensorId_t
Returns
sensorStatus_t

The function sensorGetStatus retrieves the current status of the specified sensor.

The parameter id specifies the sensor.

◆ sensorReadSamples()

uint32_t sensorReadSamples ( sensorId_t  id,
uint32_t  num_samples,
void *  buf,
uint32_t  buf_size 
)

Read samples from sensor.

Parameters
[in]idsensorId_t
[in]num_samplesmaximum number of samples to read
[out]bufpointer to buffer for samples
[in]buf_sizebuffer size in bytes
Returns
number of samples read

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.

◆ sensorGetBlockData()

void * sensorGetBlockData ( sensorId_t  id)

Get block data.

Parameters
[in]idsensorId_t
Returns
pointer to block data

The function sensorGetBlockData gets a pointer to block data.

The parameter id specifies the sensor.