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

Virtual Temperature Sensor Interface with Callback Support. More...

#include <temperature_sensor.h>

Public Attributes

bool(* readTemperature )(int16_t *const temperature)
 Get the current temperature in °C. More...
 
void(* registerNewSampleCb )(const NewTemperatureSampleCb callback)
 Register a NewTemperatureSampleCb function. More...
 
void(* unregisterNewSampleCb )(const NewTemperatureSampleCb callback)
 Remove a registered NewTemperatureSampleCb function. More...
 
void(* registerErrorCb )(const TemperatureErrorCb callback)
 Register a TemperatureErrorCb function. More...
 
void(* unregisterErrorCb )(const TemperatureErrorCb callback)
 Remove a registered TemperatureErrorCb function. More...
 

Detailed Description

Virtual Temperature Sensor Interface with Callback Support.

A standard interface for a device which can measure temperature. Interested parties can receive callbacks when new samples are available.

This device measures temperature in °C.

Fundamental Assumptions

Undesired event assumptions

Implementation Notes

Definition at line 144 of file temperature_sensor.h.

Member Data Documentation

◆ readTemperature

bool(* TemperatureSensor_withCb::readTemperature) (int16_t *const temperature)

Get the current temperature in °C.

Precondition
The sensor has been properly initialized by the system.
Postcondition
If the measurement is valid and the temperature 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 temperature 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]temperaturePointer which will be used for storing the latest temperature reading.

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

Temperature readings will be provided as a signed 16-bit fixed point integer in format Q7.8

Returns
True if the sample is valid, false if invalid (e.g., an error occured)
Parameters
[in,out]Currenttemperature in °C. Temperature readings will be provided as a signed 16-bit fixed point integer in format Q7.8
Returns
True if the sample is valid, false if invalid (e.g., an error occured)

Definition at line 173 of file temperature_sensor.h.

◆ registerErrorCb

void(* TemperatureSensor_withCb::registerErrorCb) (const TemperatureErrorCb callback)

Register a TemperatureErrorCb function.

This function will add the callback input to a list of functions to execute when a temperature 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 212 of file temperature_sensor.h.

◆ registerNewSampleCb

void(* TemperatureSensor_withCb::registerNewSampleCb) (const NewTemperatureSampleCb callback)

Register a NewTemperatureSampleCb 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 186 of file temperature_sensor.h.

◆ unregisterErrorCb

void(* TemperatureSensor_withCb::unregisterErrorCb) (const TemperatureErrorCb callback)

Remove a registered TemperatureErrorCb 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 225 of file temperature_sensor.h.

◆ unregisterNewSampleCb

void(* TemperatureSensor_withCb::unregisterNewSampleCb) (const NewTemperatureSampleCb callback)

Remove a registered NewTemperatureSampleCb 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 199 of file temperature_sensor.h.


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