PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
Ambient light sensor drivers

Interface for ambient light sensor drivers. More...

Data Structures

struct  pbl_als_ops
 Ambient light sensor driver operations, called with the device lock held. More...
 
struct  pbl_als_state
 Ambient light sensor runtime state. More...
 
struct  pbl_als
 Ambient light sensor. More...
 

Macros

#define PBL_ALS_STATE_DEFINE(sym)
 Define the class state of an ambient light sensor.
 
#define PBL_ALS_INIT(sym, _name, _parent, _ops, _scale)
 Initialize a struct pbl_als.
 

Detailed Description

Interface for ambient light sensor drivers.

A driver embeds a struct pbl_als in its instance, sets it up with PBL_ALS_STATE_DEFINE() and PBL_ALS_INIT(), and implements the struct pbl_als_ops the class calls.


Data Structure Documentation

◆ pbl_als_state

struct pbl_als_state

Ambient light sensor runtime state.

Data Fields
struct pbl_mutex lock Device lock.
uint16_t prime_count Prime references.
uint16_t suspend_count Suspend references.

◆ pbl_als

struct pbl_als

Ambient light sensor.

Data Fields
struct pbl_device dev Device.
const struct pbl_als_ops * ops Driver operations.
const struct pbl_als_scale * scale Lux calibration, or NULL if uncalibrated.
struct pbl_als_state * state Runtime state.

Macro Definition Documentation

◆ PBL_ALS_INIT

#define PBL_ALS_INIT (   sym,
  _name,
  _parent,
  _ops,
  _scale 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_als_dev_init, _parent, &pbl_als_class), \
.ops = (_ops), \
.state = &sym##_als_state, \
.scale = (_scale), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153

Initialize a struct pbl_als.

Parameters
symSymbol of the instance, as passed to PBL_ALS_STATE_DEFINE().
_nameDevice name.
_parentParent device.
_opsDriver operations.
_scaleLux calibration, or NULL.

◆ PBL_ALS_STATE_DEFINE

#define PBL_ALS_STATE_DEFINE (   sym)
Value:
static struct pbl_als_state sym##_als_state = {.lock = PBL_MUTEX_INITIALIZER}
struct pbl_mutex lock
Device lock.
Definition driver.h:40
Ambient light sensor runtime state.
Definition driver.h:38
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50

Define the class state of an ambient light sensor.

Parameters
symSymbol of the instance.