PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
Vibration motor drivers

Interface for vibration motor drivers. More...

Data Structures

struct  pbl_vibe_ops
 Vibration motor driver operations, called with the device lock held. More...
 
struct  pbl_vibe_state
 Vibration motor runtime state. More...
 
struct  pbl_vibe
 Vibration motor. More...
 

Macros

#define PBL_VIBE_STATE_DEFINE(sym)
 Define the class state of a vibration motor.
 
#define PBL_VIBE_INIT(sym, _name, _parent, _ops, _braking_strength)
 Initialize a struct pbl_vibe.
 

Detailed Description

Interface for vibration motor drivers.

A driver embeds a struct pbl_vibe in its instance, sets it up with PBL_VIBE_STATE_DEFINE() and PBL_VIBE_INIT(), and implements the struct pbl_vibe_ops the class calls.


Data Structure Documentation

◆ pbl_vibe_state

struct pbl_vibe_state

Vibration motor runtime state.

Data Fields
struct pbl_mutex lock Device lock.

◆ pbl_vibe

struct pbl_vibe

Vibration motor.

Data Fields
int8_t braking_strength Strength that brakes the motor, VIBE_STRENGTH_OFF if the driver cannot brake.
struct pbl_device dev Device.
const struct pbl_vibe_ops * ops Driver operations.
struct pbl_vibe_state * state Runtime state.

Macro Definition Documentation

◆ PBL_VIBE_INIT

#define PBL_VIBE_INIT (   sym,
  _name,
  _parent,
  _ops,
  _braking_strength 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_vibe_dev_init, _parent, &pbl_vibe_class), \
.ops = (_ops), \
.state = &sym##_vibe_state, \
.braking_strength = (_braking_strength), \
}
#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_vibe.

Parameters
symSymbol of the instance, as passed to PBL_VIBE_STATE_DEFINE().
_nameDevice name.
_parentParent device.
_opsDriver operations.
_braking_strengthStrength that brakes the motor, or VIBE_STRENGTH_OFF.

◆ PBL_VIBE_STATE_DEFINE

#define PBL_VIBE_STATE_DEFINE (   sym)
Value:
static struct pbl_vibe_state sym##_vibe_state = {.lock = PBL_MUTEX_INITIALIZER}
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
struct pbl_mutex lock
Device lock.
Definition driver.h:40
Vibration motor runtime state.
Definition driver.h:38
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50

Define the class state of a vibration motor.

Parameters
symSymbol of the instance.