PebbleOS v4.43.0-108-gde23235b2
Loading...
Searching...
No Matches
nRF5 PWM

PWM controller driver for the nRF5 PWM peripheral. More...

Data Structures

struct  pbl_pwm_nrf5
 nRF5 PWM controller. More...
 

Macros

#define PBL_PWM_NRF5_DEFINE(sym, _name, _idx, _deps, ...)
 Define an nRF5 PWM controller.
 

Detailed Description

PWM controller driver for the nRF5 PWM peripheral.

Four channels share one counter, so channels running at the same time have the same period; applying another period fails with -EBUSY. The counter runs from the 16 MHz clock with the smallest prescaler that fits the period, at most 32767 counts. The outputs are GPIOs driven to their inactive level while the PWM is stopped.

PBL_PWM_NRF5_DEFINE(s_pwm0, "pwm0", 0, NULL, PBL_GPIO(NRF5_GPIO_P0, 26, 0));
#define NRF5_GPIO_P0
Port P0.
Definition nrf5.h:40
#define PBL_GPIO(_port, _pin, _flags)
Initializer for a struct pbl_gpio.
Definition gpio.h:148
#define PBL_PWM_NRF5_DEFINE(sym, _name, _idx, _deps,...)
Define an nRF5 PWM controller.
Definition nrf5.h:63

Data Structure Documentation

◆ pbl_pwm_nrf5

struct pbl_pwm_nrf5

nRF5 PWM controller.

Data Fields
struct pbl_pwm_controller ctrl PWM controller.
uint8_t index Peripheral instance, from 0.
struct pbl_gpio out[4] Output of each channel; unconnected channels cannot be used.
struct pbl_pwm_nrf5_state * state Driver runtime state.

Macro Definition Documentation

◆ PBL_PWM_NRF5_DEFINE

#define PBL_PWM_NRF5_DEFINE (   sym,
  _name,
  _idx,
  _deps,
  ... 
)
Value:
static struct pbl_pwm_nrf5_state sym##_nrf5_state; \
const struct pbl_pwm_nrf5 sym = { \
.ctrl = PBL_PWM_CONTROLLER_INIT(sym, _name, pbl_pwm_nrf5_init, _deps, &pbl_pwm_nrf5_ops), \
.state = &sym##_nrf5_state, \
.out = {__VA_ARGS__}, \
.index = (_idx), \
}; \
PBL_DEVICE_REGISTER(sym, &sym.ctrl.dev)
struct pbl_gpio out[4]
Output of each channel; unconnected channels cannot be used.
Definition nrf5.h:44
struct pbl_pwm_controller ctrl
PWM controller.
Definition nrf5.h:40
nRF5 PWM controller.
Definition nrf5.h:38
struct pbl_device dev
Device.
Definition pwm.h:112
#define PBL_PWM_CONTROLLER_INIT(sym, _name, _init, _deps, _ops)
Initializer for the struct pbl_pwm_controller of controller sym.
Definition pwm.h:141
#define PBL_PWM_CONTROLLER_STATE_DEFINE(sym, _num_channels)
Define the class state of PWM controller sym, for the driver's define macro.
Definition pwm.h:127

Define an nRF5 PWM controller.

Parameters
symSymbol of the controller.
_nameName.
_idxPeripheral instance, 0 to 3.
_depsDependencies from PBL_DEVICE_DEPS(), or NULL.
...Outputs of channels 0 to 3, from PBL_GPIO().