Embedded Artistry C Interfaces
A reference collection of abstract interfaces in C.
|
Example relative humidity interface. More...
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
Classes | |
struct | HumiditySensor |
Virtual Relative Humidity Sensor Interface. More... | |
struct | HumiditySensor_withCb |
Virtual Relative Humidity Sensor Interface with Callback Support. More... | |
Typedefs | |
typedef void(* | NewHumiditySampleCb) (uint8_t humidity) |
Callback function prototype for processing new humidity samples. More... | |
typedef void(* | HumidityErrorCb) (void) |
Callback function prototype for humidity sensor errors. More... | |
Example relative humidity interface.
This header defines the core interfaces for a virtual humdity. Two samples are provided:
There are a number of ways you might modify this interface to suit your needs:
For data format, we can consider a few options:
Definition in file humidity_sensor.h.
typedef void(* HumidityErrorCb) (void) |
Callback function prototype for humidity sensor errors.
When an error in the virtual humidity device occurs, this callback function will be invoked. The virtual device itself does not support error handling capabilities, so we recommend using this callback in tightly-coupled system code to take the appropriate recovery action (restart the device, restart the system, etc.).
The callback is not guaranteed to run on its own thread of control. We recommend keeping the implementation small. Your function implementation could take the new sample and perform some dispatching operation (e.g., add the value to a queue), ensuring that any "heavy" processing happens on a new thread.
Definition at line 111 of file humidity_sensor.h.
typedef void(* NewHumiditySampleCb) (uint8_t humidity) |
Callback function prototype for processing new humidity samples.
When a new (and valid) humidity sample is available, this callback function will be invoked.
The callback is not guaranteed to run on its own thread of control. We recommend keeping the implementation small. Your function implementation could take the new sample and perform some dispatching operation (e.g., add the value to a queue), ensuring that any "heavy" processing happens on a new thread.
[in] | humidity | The latest humidity sample. Humidity is specified as an integral perecentage. |
Definition at line 96 of file humidity_sensor.h.