Embedded Artistry C Interfaces
A reference collection of abstract interfaces in C.
Public Attributes | List of all members
BarometricSensor_withCb Struct Reference

Virtual Barometric Pressure/Altimeter Interface (with callback support) More...

#include <barometric_sensor.h>

Public Attributes

bool(* readPressure )(uint32_t *const pressure)
 Request an pressure sample from the device. More...
 
bool(* readAltitude )(int32_t *const altitude)
 Request an altitude sample from the device. More...
 
void(* setSeaLevelPressure )(uint32_t slp)
 Set the sea level pressure. More...
 
void(* registerNewSampleCb )(const NewBarometricSampleCb callback)
 Register a NewBarometricSampleCb function. More...
 
void(* unregisterNewSampleCb )(const NewBarometricSampleCb callback)
 Remove a registered NewBarometricSampleCb function. More...
 
void(* registerErrorCb )(const BarometricErrorCb callback)
 Register a BarometricErrorCb function. More...
 
void(* unregisterErrorCb )(const BarometricErrorCb callback)
 Remove a registered BarometricErrorCb function. More...
 

Detailed Description

Virtual Barometric Pressure/Altimeter Interface (with callback support)

A standard interface for a device which can measure barometric pressure. In this variant, the readPressure() and readAltitude() functions can be used in the following ways:

Fundamental Assumptions

Undesired event assumptions

Implementation Notes

Definition at line 193 of file barometric_sensor.h.

Member Data Documentation

◆ readAltitude

bool(* BarometricSensor_withCb::readAltitude) (int32_t *const altitude)

Request an altitude sample from the device.

Altitude will be corrected for Sea Level Pressure. If no value for SLP has been supplied, calculations will assume 1013.25 hPa.

Precondition
The altitude sensor has been properly initialized by the system.
Postcondition
If the measurement is valid and the altitude parameter is not NULL, the data pointed to will be updated with the latest reading
If the measurement is invalid, the data pointed to by the altitude parameter will remain unchanged.
If the measurement is valid, registered New Sample callbacks will be invoked or dispatched with the new measurement.
If the measurement is not valid, registered Error callbacks will be invoked or dispatched.
Parameters
[in,out]altitudePointer which will be used for storing the latest altitude reading.

If altitude is NULL, the function will only supply the altitude sample to registered callback functions.

Altitude is specified as a signed 32-bit fixed-point number in format Q21.10

Altitude will be corrected for Sea Level Pressure.

Returns
True if the sample is valid, false if invalid (e.g., an error occured)

Definition at line 247 of file barometric_sensor.h.

◆ readPressure

bool(* BarometricSensor_withCb::readPressure) (uint32_t *const pressure)

Request an pressure sample from the device.

Precondition
The pressure sensor has been properly initialized by the system.
Postcondition
If the measurement is valid and pressure is not NULL, the data pointed to by the pressure parameter will be updated with the latest reading
If the measurement is invalid, the data pointed to by the pressure parameter will remain unchanged.
If the measurement is valid, registered New Sample callbacks will be invoked or dispatched with the new measurement.
If the measurement is not valid, registered Error callbacks will be invoked or dispatched.
Parameters
[in,out]pressurePointer which will be used for storing the latest pressure reading.

If pressure is NULL, the function will only supply the pressure sample to registered callback functions. I

Pressure will be formatted as a 32-bit fixed-point integer with format UQ22.10, giving a resolution of 0.001 hPa.

Returns
True if the sample is valid, false if invalid (e.g., an error occured)

Definition at line 218 of file barometric_sensor.h.

◆ registerErrorCb

void(* BarometricSensor_withCb::registerErrorCb) (const BarometricErrorCb callback)

Register a BarometricErrorCb function.

This function will add the callback input to a list of functions to execute when a pressure sensor error occurs.

Precondition
callback is not NULL
Postcondition
callback is added to the list of error callbacks.
Parameters
[in]callbackThe callback function pointer to register on the "error" callback list.

Definition at line 293 of file barometric_sensor.h.

◆ registerNewSampleCb

void(* BarometricSensor_withCb::registerNewSampleCb) (const NewBarometricSampleCb callback)

Register a NewBarometricSampleCb function.

This function will add the callback input to a list of functions to execute when a new and valid sample is available.

Precondition
callback is not NULL
Postcondition
callback is added to the list of "new sample" callbacks.
Parameters
[in]callbackThe callback function pointer to register on the "new sample" callback list.

Definition at line 267 of file barometric_sensor.h.

◆ setSeaLevelPressure

void(* BarometricSensor_withCb::setSeaLevelPressure) (uint32_t slp)

Set the sea level pressure.

Parameters
[in]slpThe current sea level pressure in hPa. slp should be specified as an unsigned 32-bit fixed-point number in format UQ22.10.

Definition at line 254 of file barometric_sensor.h.

◆ unregisterErrorCb

void(* BarometricSensor_withCb::unregisterErrorCb) (const BarometricErrorCb callback)

Remove a registered BarometricErrorCb function.

This function will remove a callback function from the registered list of "error" callbacks. If the function has not been previously registered, the parameter will be ignored and the list will be unchanged.

Postcondition
callback function pointer is not present on the list of "error" callbacks.
Parameters
[in]callbackThe callback function pointer to remove from the "error" callback list.

Definition at line 306 of file barometric_sensor.h.

◆ unregisterNewSampleCb

void(* BarometricSensor_withCb::unregisterNewSampleCb) (const NewBarometricSampleCb callback)

Remove a registered NewBarometricSampleCb function.

This function will remove a callback function from the registered list of "new sample" callbacks. If the function has not been previously registered, the parameter will be ignored and the list will be unchanged.

Postcondition
callback function pointer is not present on the list of "new sample" callbacks.
Parameters
[in]callbackThe callback function pointer to remove from the "new sample" callback list.

Definition at line 280 of file barometric_sensor.h.


The documentation for this struct was generated from the following file: