High Level Sensor functions
.
More...
Overview
The sensor API implements a generic abstraction for the sensors that are supported by µracoli. The low level drivers are documented in section
Sensor Drivers.
Sensor API in liburacoli_<board>.a
The sensors of a board are defined in file
board.cfg
in the key
sensors:
<sensors1> <sensor2> ...
- Usage
uint8_t nb_sensors;
for (i = 0; i < nb_sensors; i++)
{
PRINTF(
" %d : id=%d name=%s type=%s data_sz=%d\n",
}
while (1)
{
sensor_getALL_SENSORS, buf);
}
- Examples
uint8_t create_board_sensors |
( |
void |
| ) |
|
This function creates the data structure for all sensors that are defined per board.
- Examples:
- xmpl_sensor.c.
char* sensor_decode |
( |
uint8_t * |
buf, |
|
|
char * |
line, |
|
|
uint16_t |
size |
|
) |
| |
Decode sensor data buffer to string.
- Parameters
-
buf | sensor data buffer |
line | line buffer for decoded text. |
size | maximum size of the line buffer |
- Returns
- a string pointer to line or NULL.
- Examples:
- xmpl_sensor.c.
uint8_t sensor_get |
( |
int |
idx, |
|
|
uint8_t * |
pdata |
|
) |
| |
Query sensor values
- Parameters
-
idx | number of the sensor or ALL_SENSORS (-1) for all |
pdata | databuffer to store the sensor data. |
- Returns
- size in bytes of the queried data block (size depends on data availability, e.g. if the sensor has data).
Note: To estimate the max. size for pdata, call sensor_get(-1, NULL). This retrieves the max. block length for all sensors.
- Examples:
- xmpl_sensor.c.
uint8_t sensor_get_error |
( |
uint8_t |
idx | ) |
|
Get last error code of the addressed sensor.
- Parameters
-
uint8_t sensor_get_id |
( |
uint8_t |
idx | ) |
|
Get sensor ID value for the sensor indexed by idx.
- Parameters
-
- Examples:
- xmpl_sensor.c.
char* sensor_get_name |
( |
uint8_t |
idx | ) |
|
get sensor type for the addressed sensor.
- Parameters
-
- Examples:
- xmpl_sensor.c.
uint8_t sensor_get_number |
( |
void |
| ) |
|
Return the number of sensors for this board.
- Examples:
- xmpl_sensor.c.
char* sensor_get_type |
( |
uint8_t |
idx | ) |
|
Get sensor type for the adressed sensor.
- Parameters
-
- Examples:
- xmpl_sensor.c.
void sensor_sleep |
( |
int |
idx | ) |
|
Set sensor into sleep mode.
- Parameters
-
idx | number of the sensor or ALL_SENSORS (-1) for all |
- Examples:
- xmpl_sensor.c.
void sensor_trigger |
( |
int |
idx, |
|
|
bool |
one_shot |
|
) |
| |
Trigger a sensor measurment.
- Parameters
-
idx | number of the sensor or ALL_SENSORS (-1) for all. |
one_shot | if one_shot is true, a single measurement is triggered, otherwise a continous measurement. It depends on the sensor if this parameter is really supported in hardware. |
- Examples:
- xmpl_sensor.c.
struct board_sensor_ctx_t |
board defined sensor data structure
Definition at line 76 of file sensor.h.