Embedded Artistry C Interfaces
A reference collection of abstract interfaces in C.
barometric_sensor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2022 Embedded Artistry LLC <contact@embeddedartistry.com>
2// SPDX-License-Identifier: MIT
3
4#include <stdbool.h>
5#include <stdint.h>
6
38#pragma mark - Basic Interface -
39
68typedef struct
69{
88 bool (*readPressure)(uint32_t* const pressure);
89
104 bool (*readAltitude)(int32_t* const altitude);
105
111 void (*setSeaLevelPressure)(uint32_t slp);
113
114#pragma mark - Interface with Callback Support -
115
136typedef void (*NewBarometricSampleCb)(uint32_t pressure, int32_t altitude);
137
151typedef void (*BarometricErrorCb)(void);
152
193typedef struct
194{
218 bool (*readPressure)(uint32_t* const pressure);
219
247 bool (*readAltitude)(int32_t* const altitude);
248
254 void (*setSeaLevelPressure)(uint32_t slp);
255
267 void (*registerNewSampleCb)(const NewBarometricSampleCb callback);
268
280 void (*unregisterNewSampleCb)(const NewBarometricSampleCb callback);
281
293 void (*registerErrorCb)(const BarometricErrorCb callback);
294
306 void (*unregisterErrorCb)(const BarometricErrorCb callback);
308
309#pragma mark - Asynchronous Processing Support -
310
353typedef struct
354{
365 bool (*readSample)(void);
366
372 void (*setSeaLevelPressure)(uint32_t slp);
373
385 void (*registerNewSampleCb)(const NewBarometricSampleCb callback);
386
398 void (*unregisterNewSampleCb)(const NewBarometricSampleCb callback);
399
411 void (*registerErrorCb)(const BarometricErrorCb callback);
412
424 void (*unregisterErrorCb)(const BarometricErrorCb callback);
void(* BarometricErrorCb)(void)
Callback function prototype for barometric sensor errors.
void(* NewBarometricSampleCb)(uint32_t pressure, int32_t altitude)
Callback function prototype for processing new barometric samples.
Virtual Barometric Pressure/Altimeter Interface (asynchronous mode)
Virtual Barometric Pressure/Altimeter Interface (with callback support)
Virtual Barometric Pressure/Altimeter Sensor Interface.