nrfx 4.5.0
Loading...
Searching...
No Matches
PWM HAL

Hardware access layer for managing the Pulse Width Modulation (PWM) peripheral. More...

Data Structures

struct  nrf_pwm_values_grouped_t
 Structure for defining duty cycle values for a sequence loaded in NRF_PWM_LOAD_GROUPED mode. More...
 
struct  nrf_pwm_values_individual_t
 Structure for defining duty cycle values for a sequence loaded in NRF_PWM_LOAD_INDIVIDUAL mode. More...
 
struct  nrf_pwm_values_wave_form_t
 Structure for defining duty cycle values for a sequence loaded in NRF_PWM_LOAD_WAVE_FORM mode. More...
 
union  nrf_pwm_values_t
 Union grouping pointers to arrays of duty cycle values applicable to various loading modes. More...
 
struct  nrf_pwm_sequence_t
 Structure for defining a sequence of PWM duty cycles. More...
 

Macros

#define NRF_PWM_HAS_DMA_REG   1
 Symbol indicating whether dedicated DMA register is present.
 
#define NRF_PWM_HAS_SHORT_LOOPSDONE_SEQSTART   1
 Symbol indicating whether shorting SEQSTART task with LOOPSDONE event is available.
 
#define NRF_PWM_HAS_DMA_TASKS_EVENTS   1
 Symbol indicating whether PWM DMA tasks and events are present.
 
#define NRF_PWM_HAS_SEQ_CNT   1
 Symbol indicating whether setting the number of duty cycle values for a sequence is available.
 
#define NRF_PWM_HAS_IDLEOUT   1
 Symbol indicating whether PWM has IDLEOUT register.
 
#define NRF_PWM_HAS_COMPAREMATCH   1
 Symbol indicating whether PWM has COMPAREMATCH events.
 
#define NRF_PWM_INST_GET(idx)
 Macro getting pointer to the structure of registers of the PWM peripheral.
 
#define NRF_PWM_PIN_NOT_CONNECTED   0xFFFFFFFF
 This value can be provided as a parameter for the nrf_pwm_pins_set function call to specify that a given output channel shall not be connected to a physical pin.
 
#define NRF_PWM_CHANNEL_COUNT   4
 Number of channels in each PWM instance.
 
#define NRF_PWM_VALUES_LENGTH(array)
 Helper macro for calculating the number of 16-bit values in the specified array of duty cycle values.
 

Typedefs

typedef uint16_t nrf_pwm_values_common_t
 Type used for defining duty cycle values for a sequence loaded in NRF_PWM_LOAD_COMMON mode.
 

Enumerations

enum  nrf_pwm_task_t {
  NRF_PWM_TASK_STOP = offsetof(NRF_PWM_Type, TASKS_STOP) ,
  NRF_PWM_TASK_SEQSTART0 = offsetof(NRF_PWM_Type, TASKS_DMA.SEQ[0].START) ,
  NRF_PWM_TASK_SEQSTART1 = offsetof(NRF_PWM_Type, TASKS_DMA.SEQ[1].START) ,
  NRF_PWM_TASK_NEXTSTEP = offsetof(NRF_PWM_Type, TASKS_NEXTSTEP)
}
 PWM tasks. More...
 
enum  nrf_pwm_event_t {
  NRF_PWM_EVENT_STOPPED = offsetof(NRF_PWM_Type, EVENTS_STOPPED) ,
  NRF_PWM_EVENT_SEQSTARTED0 = offsetof(NRF_PWM_Type, EVENTS_SEQSTARTED[0]) ,
  NRF_PWM_EVENT_SEQSTARTED1 = offsetof(NRF_PWM_Type, EVENTS_SEQSTARTED[1]) ,
  NRF_PWM_EVENT_SEQEND0 = offsetof(NRF_PWM_Type, EVENTS_SEQEND[0]) ,
  NRF_PWM_EVENT_SEQEND1 = offsetof(NRF_PWM_Type, EVENTS_SEQEND[1]) ,
  NRF_PWM_EVENT_PWMPERIODEND = offsetof(NRF_PWM_Type, EVENTS_PWMPERIODEND) ,
  NRF_PWM_EVENT_LOOPSDONE = offsetof(NRF_PWM_Type, EVENTS_LOOPSDONE) ,
  NRF_PWM_EVENT_COMPAREMATCH0 = offsetof(NRF_PWM_Type, EVENTS_COMPAREMATCH[0]) ,
  NRF_PWM_EVENT_COMPAREMATCH1 = offsetof(NRF_PWM_Type, EVENTS_COMPAREMATCH[1]) ,
  NRF_PWM_EVENT_COMPAREMATCH2 = offsetof(NRF_PWM_Type, EVENTS_COMPAREMATCH[2]) ,
  NRF_PWM_EVENT_COMPAREMATCH3 = offsetof(NRF_PWM_Type, EVENTS_COMPAREMATCH[3])
}
 PWM events. More...
 
enum  nrf_pwm_int_mask_t {
  NRF_PWM_INT_STOPPED_MASK = PWM_INTENSET_STOPPED_Msk ,
  NRF_PWM_INT_SEQSTARTED0_MASK = PWM_INTENSET_SEQSTARTED0_Msk ,
  NRF_PWM_INT_SEQSTARTED1_MASK = PWM_INTENSET_SEQSTARTED1_Msk ,
  NRF_PWM_INT_SEQEND0_MASK = PWM_INTENSET_SEQEND0_Msk ,
  NRF_PWM_INT_SEQEND1_MASK = PWM_INTENSET_SEQEND1_Msk ,
  NRF_PWM_INT_PWMPERIODEND_MASK = PWM_INTENSET_PWMPERIODEND_Msk ,
  NRF_PWM_INT_LOOPSDONE_MASK = PWM_INTENSET_LOOPSDONE_Msk ,
  NRF_PWM_INT_COMPAREMATCH0_MASK = PWM_INTENSET_COMPAREMATCH0_Msk ,
  NRF_PWM_INT_COMPAREMATCH1_MASK = PWM_INTENSET_COMPAREMATCH1_Msk ,
  NRF_PWM_INT_COMPAREMATCH2_MASK = PWM_INTENSET_COMPAREMATCH2_Msk ,
  NRF_PWM_INT_COMPAREMATCH3_MASK = PWM_INTENSET_COMPAREMATCH3_Msk
}
 PWM interrupts. More...
 
enum  nrf_pwm_short_mask_t {
  NRF_PWM_SHORT_SEQEND0_STOP_MASK = PWM_SHORTS_SEQEND0_STOP_Msk ,
  NRF_PWM_SHORT_SEQEND1_STOP_MASK = PWM_SHORTS_SEQEND1_STOP_Msk ,
  NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK = PWM_SHORTS_LOOPSDONE_SEQSTART0_Msk ,
  NRF_PWM_SHORT_LOOPSDONE_SEQSTART1_MASK = PWM_SHORTS_LOOPSDONE_SEQSTART1_Msk ,
  NRF_PWM_SHORT_LOOPSDONE_STOP_MASK = PWM_SHORTS_LOOPSDONE_STOP_Msk
}
 PWM shortcuts. More...
 
enum  nrf_pwm_mode_t {
  NRF_PWM_MODE_UP = PWM_MODE_UPDOWN_Up ,
  NRF_PWM_MODE_UP_AND_DOWN = PWM_MODE_UPDOWN_UpAndDown
}
 PWM modes of operation. More...
 
enum  nrf_pwm_clk_t {
  NRF_PWM_CLK_16MHz = PWM_PRESCALER_PRESCALER_DIV_1 ,
  NRF_PWM_CLK_8MHz = PWM_PRESCALER_PRESCALER_DIV_2 ,
  NRF_PWM_CLK_4MHz = PWM_PRESCALER_PRESCALER_DIV_4 ,
  NRF_PWM_CLK_2MHz = PWM_PRESCALER_PRESCALER_DIV_8 ,
  NRF_PWM_CLK_1MHz = PWM_PRESCALER_PRESCALER_DIV_16 ,
  NRF_PWM_CLK_500kHz = PWM_PRESCALER_PRESCALER_DIV_32 ,
  NRF_PWM_CLK_250kHz = PWM_PRESCALER_PRESCALER_DIV_64 ,
  NRF_PWM_CLK_125kHz = PWM_PRESCALER_PRESCALER_DIV_128
}
 PWM base clock frequencies. More...
 
enum  nrf_pwm_dec_load_t {
  NRF_PWM_LOAD_COMMON = PWM_DECODER_LOAD_Common ,
  NRF_PWM_LOAD_GROUPED = PWM_DECODER_LOAD_Grouped ,
  NRF_PWM_LOAD_INDIVIDUAL = PWM_DECODER_LOAD_Individual ,
  NRF_PWM_LOAD_WAVE_FORM = PWM_DECODER_LOAD_WaveForm
}
 PWM decoder load modes. More...
 
enum  nrf_pwm_dec_step_t {
  NRF_PWM_STEP_AUTO = PWM_DECODER_MODE_RefreshCount ,
  NRF_PWM_STEP_TRIGGERED = PWM_DECODER_MODE_NextStep
}
 PWM decoder next step modes. More...
 

Functions

NRF_STATIC_INLINE void nrf_pwm_task_trigger (NRF_PWM_Type *p_reg, nrf_pwm_task_t task)
 Function for activating the specified PWM task.
 
NRF_STATIC_INLINE uint32_t nrf_pwm_task_address_get (NRF_PWM_Type const *p_reg, nrf_pwm_task_t task)
 Function for getting the address of the specified PWM task register.
 
NRF_STATIC_INLINE void nrf_pwm_event_clear (NRF_PWM_Type *p_reg, nrf_pwm_event_t event)
 Function for clearing the specified PWM event.
 
NRF_STATIC_INLINE bool nrf_pwm_event_check (NRF_PWM_Type const *p_reg, nrf_pwm_event_t event)
 Function for retrieving the state of the PWM event.
 
NRF_STATIC_INLINE uint32_t nrf_pwm_event_address_get (NRF_PWM_Type const *p_reg, nrf_pwm_event_t event)
 Function for getting the address of the specified PWM event register.
 
NRF_STATIC_INLINE void nrf_pwm_shorts_enable (NRF_PWM_Type *p_reg, uint32_t mask)
 Function for enabling the specified shortcuts.
 
NRF_STATIC_INLINE void nrf_pwm_shorts_disable (NRF_PWM_Type *p_reg, uint32_t mask)
 Function for disabling the specified shortcuts.
 
NRF_STATIC_INLINE void nrf_pwm_shorts_set (NRF_PWM_Type *p_reg, uint32_t mask)
 Function for setting the configuration of PWM shortcuts.
 
NRF_STATIC_INLINE void nrf_pwm_int_enable (NRF_PWM_Type *p_reg, uint32_t mask)
 Function for enabling specified interrupts.
 
NRF_STATIC_INLINE void nrf_pwm_int_disable (NRF_PWM_Type *p_reg, uint32_t mask)
 Function for disabling specified interrupts.
 
NRF_STATIC_INLINE void nrf_pwm_int_set (NRF_PWM_Type *p_reg, uint32_t mask)
 Function for setting the configuration of PWM interrupts.
 
NRF_STATIC_INLINE uint32_t nrf_pwm_int_enable_check (NRF_PWM_Type const *p_reg, uint32_t mask)
 Function for checking if the specified interrupts are enabled.
 
NRF_STATIC_INLINE void nrf_pwm_subscribe_set (NRF_PWM_Type *p_reg, nrf_pwm_task_t task, uint8_t channel)
 Function for setting the subscribe configuration for a given PWM task.
 
NRF_STATIC_INLINE void nrf_pwm_subscribe_clear (NRF_PWM_Type *p_reg, nrf_pwm_task_t task)
 Function for clearing the subscribe configuration for a given PWM task.
 
NRF_STATIC_INLINE uint32_t nrf_pwm_subscribe_get (NRF_PWM_Type const *p_reg, nrf_pwm_task_t task)
 Function for getting the subscribe configuration for a given PWM task.
 
NRF_STATIC_INLINE void nrf_pwm_publish_set (NRF_PWM_Type *p_reg, nrf_pwm_event_t event, uint8_t channel)
 Function for setting the publish configuration for a given PWM event.
 
NRF_STATIC_INLINE void nrf_pwm_publish_clear (NRF_PWM_Type *p_reg, nrf_pwm_event_t event)
 Function for clearing the publish configuration for a given PWM event.
 
NRF_STATIC_INLINE uint32_t nrf_pwm_publish_get (NRF_PWM_Type const *p_reg, nrf_pwm_event_t event)
 Function for getting the publish configuration for a given PWM event.
 
NRF_STATIC_INLINE void nrf_pwm_enable (NRF_PWM_Type *p_reg)
 Function for enabling the PWM peripheral.
 
NRF_STATIC_INLINE void nrf_pwm_disable (NRF_PWM_Type *p_reg)
 Function for disabling the PWM peripheral.
 
NRF_STATIC_INLINE bool nrf_pwm_enable_check (NRF_PWM_Type const *p_reg)
 Function for checking if the PWM peripheral is enabled.
 
NRF_STATIC_INLINE void nrf_pwm_pins_set (NRF_PWM_Type *p_reg, uint32_t const out_pins[4])
 Function for assigning pins to PWM output channels.
 
NRF_STATIC_INLINE void nrf_pwm_pin_set (NRF_PWM_Type *p_reg, uint8_t channel, uint32_t pin)
 Function for setting pin associated with specified PWM output channel.
 
NRF_STATIC_INLINE uint32_t nrf_pwm_pin_get (NRF_PWM_Type const *p_reg, uint8_t channel)
 Function for getting pin selection associated with specified PWM output channel.
 
NRF_STATIC_INLINE void nrf_pwm_configure (NRF_PWM_Type *p_reg, nrf_pwm_clk_t base_clock, nrf_pwm_mode_t mode, uint16_t top_value)
 Function for configuring the PWM peripheral.
 
NRF_STATIC_INLINE void nrf_pwm_sequence_set (NRF_PWM_Type *p_reg, uint8_t seq_id, nrf_pwm_sequence_t const *p_seq)
 Function for defining a sequence of PWM duty cycles.
 
NRF_STATIC_INLINE void nrf_pwm_seq_ptr_set (NRF_PWM_Type *p_reg, uint8_t seq_id, uint16_t const *p_values)
 Function for modifying the pointer to the duty cycle values in the specified sequence.
 
NRF_STATIC_INLINE void nrf_pwm_seq_cnt_set (NRF_PWM_Type *p_reg, uint8_t seq_id, uint16_t length)
 Function for modifying the total number of duty cycle values in the specified sequence.
 
NRF_STATIC_INLINE void nrf_pwm_seq_refresh_set (NRF_PWM_Type *p_reg, uint8_t seq_id, uint32_t refresh)
 Function for modifying the additional number of PWM periods spent on each duty cycle value in the specified sequence.
 
NRF_STATIC_INLINE void nrf_pwm_seq_end_delay_set (NRF_PWM_Type *p_reg, uint8_t seq_id, uint32_t end_delay)
 Function for modifying the additional time added after the sequence is played.
 
NRF_STATIC_INLINE void nrf_pwm_decoder_set (NRF_PWM_Type *p_reg, nrf_pwm_dec_load_t dec_load, nrf_pwm_dec_step_t dec_step)
 Function for setting the mode of loading sequence data from RAM and advancing the sequence.
 
NRF_STATIC_INLINE void nrf_pwm_loop_set (NRF_PWM_Type *p_reg, uint16_t loop_count)
 Function for setting the number of times the sequence playback should be performed.
 
NRF_STATIC_INLINE nrf_pwm_task_t nrf_pwm_seqstart_task_get (uint8_t seq_id)
 Function for getting the specified PWM SEQSTART task.
 
NRF_STATIC_INLINE nrf_pwm_event_t nrf_pwm_seqend_event_get (uint8_t seq_id)
 Function for getting the specified PWM SEQEND event.
 
NRF_STATIC_INLINE void nrf_pwm_channel_idle_set (NRF_PWM_Type *p_reg, uint8_t channel, bool value)
 Function for setting the output value of specified channel while PDM is idle.
 
NRF_STATIC_INLINE bool nrf_pwm_channel_idle_get (NRF_PWM_Type const *p_reg, uint8_t channel)
 Function for getting the output value of specified channel while PDM is idle.
 

Detailed Description

Hardware access layer for managing the Pulse Width Modulation (PWM) peripheral.

Macro Definition Documentation

◆ NRF_PWM_INST_GET

#define NRF_PWM_INST_GET ( idx)
Value:
NRFX_CONCAT(NRF_, PWM, idx)
#define NRFX_CONCAT(...)
Macro for concatenating multiple arguments.
Definition nrfx_utils.h:777

Macro getting pointer to the structure of registers of the PWM peripheral.

Parameters
[in]idxPWM instance index.
Returns
Pointer to the structure of registers of the PWM peripheral.

◆ NRF_PWM_VALUES_LENGTH

#define NRF_PWM_VALUES_LENGTH ( array)
Value:
(sizeof(array) / 2UL)

Helper macro for calculating the number of 16-bit values in the specified array of duty cycle values.

Enumeration Type Documentation

◆ nrf_pwm_clk_t

PWM base clock frequencies.

Enumerator
NRF_PWM_CLK_16MHz 

16 MHz / 1 = 16 MHz.

NRF_PWM_CLK_8MHz 

16 MHz / 2 = 8 MHz.

NRF_PWM_CLK_4MHz 

16 MHz / 4 = 4 MHz.

NRF_PWM_CLK_2MHz 

16 MHz / 8 = 2 MHz.

NRF_PWM_CLK_1MHz 

16 MHz / 16 = 1 MHz.

NRF_PWM_CLK_500kHz 

16 MHz / 32 = 500 kHz.

NRF_PWM_CLK_250kHz 

16 MHz / 64 = 250 kHz.

NRF_PWM_CLK_125kHz 

16 MHz / 128 = 125 kHz.

◆ nrf_pwm_dec_load_t

PWM decoder load modes.

The selected mode determines how the sequence data is read from RAM and spread to the compare registers.

Enumerator
NRF_PWM_LOAD_COMMON 

1st half word (16-bit) used in all PWM channels (0-3).

NRF_PWM_LOAD_GROUPED 

1st half word (16-bit) used in channels 0 and 1; 2nd word in channels 2 and 3.

NRF_PWM_LOAD_INDIVIDUAL 

1st half word (16-bit) used in channel 0; 2nd in channel 1; 3rd in channel 2; 4th in channel 3.

NRF_PWM_LOAD_WAVE_FORM 

1st half word (16-bit) used in channel 0; 2nd in channel 1; ... ; 4th as the top value for the pulse generator counter.

◆ nrf_pwm_dec_step_t

PWM decoder next step modes.

The selected mode determines when the next value from the active sequence is loaded.

Enumerator
NRF_PWM_STEP_AUTO 

Automatically after the current value is played and repeated the requested number of times.

NRF_PWM_STEP_TRIGGERED 

When the NRF_PWM_TASK_NEXTSTEP task is triggered.

◆ nrf_pwm_event_t

PWM events.

Enumerator
NRF_PWM_EVENT_STOPPED 

Response to STOP task, emitted when PWM pulses are no longer generated.

NRF_PWM_EVENT_SEQSTARTED0 

First PWM period started on sequence 0.

NRF_PWM_EVENT_SEQSTARTED1 

First PWM period started on sequence 1.

NRF_PWM_EVENT_SEQEND0 

Emitted at the end of every sequence 0 when its last value has been read from RAM.

NRF_PWM_EVENT_SEQEND1 

Emitted at the end of every sequence 1 when its last value has been read from RAM.

NRF_PWM_EVENT_PWMPERIODEND 

Emitted at the end of each PWM period.

NRF_PWM_EVENT_LOOPSDONE 

Concatenated sequences have been played the specified number of times.

NRF_PWM_EVENT_COMPAREMATCH0 

Compare matched for channel 0.

NRF_PWM_EVENT_COMPAREMATCH1 

Compare matched for channel 1.

NRF_PWM_EVENT_COMPAREMATCH2 

Compare matched for channel 2.

NRF_PWM_EVENT_COMPAREMATCH3 

Compare matched for channel 3.

◆ nrf_pwm_int_mask_t

PWM interrupts.

Enumerator
NRF_PWM_INT_STOPPED_MASK 

Interrupt on STOPPED event.

NRF_PWM_INT_SEQSTARTED0_MASK 

Interrupt on SEQSTARTED[0] event.

NRF_PWM_INT_SEQSTARTED1_MASK 

Interrupt on SEQSTARTED[1] event.

NRF_PWM_INT_SEQEND0_MASK 

Interrupt on SEQEND[0] event.

NRF_PWM_INT_SEQEND1_MASK 

Interrupt on SEQEND[1] event.

NRF_PWM_INT_PWMPERIODEND_MASK 

Interrupt on PWMPERIODEND event.

NRF_PWM_INT_LOOPSDONE_MASK 

Interrupt on LOOPSDONE event.

NRF_PWM_INT_COMPAREMATCH0_MASK 

Interrupt on COMPAREMATCH[0] event.

NRF_PWM_INT_COMPAREMATCH1_MASK 

Interrupt on COMPAREMATCH[1] event.

NRF_PWM_INT_COMPAREMATCH2_MASK 

Interrupt on COMPAREMATCH[2] event.

NRF_PWM_INT_COMPAREMATCH3_MASK 

Interrupt on COMPAREMATCH[3] event.

◆ nrf_pwm_mode_t

PWM modes of operation.

Enumerator
NRF_PWM_MODE_UP 

Up counter (edge-aligned PWM duty cycle).

NRF_PWM_MODE_UP_AND_DOWN 

Up and down counter (center-aligned PWM duty cycle).

◆ nrf_pwm_short_mask_t

PWM shortcuts.

Enumerator
NRF_PWM_SHORT_SEQEND0_STOP_MASK 

Shortcut between SEQEND[0] event and STOP task.

NRF_PWM_SHORT_SEQEND1_STOP_MASK 

Shortcut between SEQEND[1] event and STOP task.

NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK 

Shortcut between LOOPSDONE event and SEQSTART[0] task.

NRF_PWM_SHORT_LOOPSDONE_SEQSTART1_MASK 

Shortcut between LOOPSDONE event and SEQSTART[1] task.

NRF_PWM_SHORT_LOOPSDONE_STOP_MASK 

Shortcut between LOOPSDONE event and STOP task.

◆ nrf_pwm_task_t

PWM tasks.

Enumerator
NRF_PWM_TASK_STOP 

Stops PWM pulse generation on all channels at the end of the current PWM period, and stops the sequence playback.

NRF_PWM_TASK_SEQSTART0 

Starts playback of sequence 0.

NRF_PWM_TASK_SEQSTART1 

Starts playback of sequence 1.

NRF_PWM_TASK_NEXTSTEP 

Steps by one value in the current sequence if the decoder is set to NRF_PWM_STEP_TRIGGERED mode.

Function Documentation

◆ nrf_pwm_channel_idle_get()

NRF_STATIC_INLINE bool nrf_pwm_channel_idle_get ( NRF_PWM_Type const * p_reg,
uint8_t channel )

Function for getting the output value of specified channel while PDM is idle.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]channelPWM output channel.
Return values
trueIdle output value is high.
falseIdle output value is low.

◆ nrf_pwm_channel_idle_set()

NRF_STATIC_INLINE void nrf_pwm_channel_idle_set ( NRF_PWM_Type * p_reg,
uint8_t channel,
bool value )

Function for setting the output value of specified channel while PDM is idle.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]channelPWM output channel.
[in]valueIf true, idle output will be high. If false, it will be low.

◆ nrf_pwm_configure()

NRF_STATIC_INLINE void nrf_pwm_configure ( NRF_PWM_Type * p_reg,
nrf_pwm_clk_t base_clock,
nrf_pwm_mode_t mode,
uint16_t top_value )

Function for configuring the PWM peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]base_clockBase clock frequency.
[in]modeOperating mode of the pulse generator counter.
[in]top_valueValue up to which the pulse generator counter counts.

◆ nrf_pwm_decoder_set()

NRF_STATIC_INLINE void nrf_pwm_decoder_set ( NRF_PWM_Type * p_reg,
nrf_pwm_dec_load_t dec_load,
nrf_pwm_dec_step_t dec_step )

Function for setting the mode of loading sequence data from RAM and advancing the sequence.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]dec_loadMode of loading sequence data from RAM.
[in]dec_stepMode of advancing the active sequence.

◆ nrf_pwm_disable()

NRF_STATIC_INLINE void nrf_pwm_disable ( NRF_PWM_Type * p_reg)

Function for disabling the PWM peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_pwm_enable()

NRF_STATIC_INLINE void nrf_pwm_enable ( NRF_PWM_Type * p_reg)

Function for enabling the PWM peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_pwm_enable_check()

NRF_STATIC_INLINE bool nrf_pwm_enable_check ( NRF_PWM_Type const * p_reg)

Function for checking if the PWM peripheral is enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Return values
trueThe PWM is enabled.
falseThe PWM is not enabled.

◆ nrf_pwm_event_address_get()

NRF_STATIC_INLINE uint32_t nrf_pwm_event_address_get ( NRF_PWM_Type const * p_reg,
nrf_pwm_event_t event )

Function for getting the address of the specified PWM event register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventPWM event.
Returns
Address of the specified event register.

◆ nrf_pwm_event_check()

NRF_STATIC_INLINE bool nrf_pwm_event_check ( NRF_PWM_Type const * p_reg,
nrf_pwm_event_t event )

Function for retrieving the state of the PWM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.

◆ nrf_pwm_event_clear()

NRF_STATIC_INLINE void nrf_pwm_event_clear ( NRF_PWM_Type * p_reg,
nrf_pwm_event_t event )

Function for clearing the specified PWM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to clear.

◆ nrf_pwm_int_disable()

NRF_STATIC_INLINE void nrf_pwm_int_disable ( NRF_PWM_Type * p_reg,
uint32_t mask )

Function for disabling specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be disabled. Use nrf_pwm_int_mask_t values for bit masking.

◆ nrf_pwm_int_enable()

NRF_STATIC_INLINE void nrf_pwm_int_enable ( NRF_PWM_Type * p_reg,
uint32_t mask )

Function for enabling specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be enabled. Use nrf_pwm_int_mask_t values for bit masking.

◆ nrf_pwm_int_enable_check()

NRF_STATIC_INLINE uint32_t nrf_pwm_int_enable_check ( NRF_PWM_Type const * p_reg,
uint32_t mask )

Function for checking if the specified interrupts are enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be checked. Use nrf_pwm_int_mask_t values for bit masking.
Returns
Mask of enabled interrupts.

◆ nrf_pwm_int_set()

NRF_STATIC_INLINE void nrf_pwm_int_set ( NRF_PWM_Type * p_reg,
uint32_t mask )

Function for setting the configuration of PWM interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be set. Use nrf_pwm_int_mask_t values for bit masking.

◆ nrf_pwm_loop_set()

NRF_STATIC_INLINE void nrf_pwm_loop_set ( NRF_PWM_Type * p_reg,
uint16_t loop_count )

Function for setting the number of times the sequence playback should be performed.

This function applies to two-sequence playback (concatenated sequence 0 and 1). A single sequence can be played back only once.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]loop_countNumber of times to perform the sequence playback.

◆ nrf_pwm_pin_get()

NRF_STATIC_INLINE uint32_t nrf_pwm_pin_get ( NRF_PWM_Type const * p_reg,
uint8_t channel )

Function for getting pin selection associated with specified PWM output channel.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]channelPWM output channel.
Returns
Pin selection associated with specified PWM output channel.

◆ nrf_pwm_pin_set()

NRF_STATIC_INLINE void nrf_pwm_pin_set ( NRF_PWM_Type * p_reg,
uint8_t channel,
uint32_t pin )

Function for setting pin associated with specified PWM output channel.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]channelPWM output channel.
[in]pinPWM output pin associated with specified PWM output channel.

◆ nrf_pwm_pins_set()

NRF_STATIC_INLINE void nrf_pwm_pins_set ( NRF_PWM_Type * p_reg,
uint32_t const out_pins[4] )

Function for assigning pins to PWM output channels.

Usage of all PWM output channels is optional. If a given channel is not needed, pass the NRF_PWM_PIN_NOT_CONNECTED value instead of its pin number.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]out_pinsArray with pin numbers for individual PWM output channels.

◆ nrf_pwm_publish_clear()

NRF_STATIC_INLINE void nrf_pwm_publish_clear ( NRF_PWM_Type * p_reg,
nrf_pwm_event_t event )

Function for clearing the publish configuration for a given PWM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to clear the configuration.

◆ nrf_pwm_publish_get()

NRF_STATIC_INLINE uint32_t nrf_pwm_publish_get ( NRF_PWM_Type const * p_reg,
nrf_pwm_event_t event )

Function for getting the publish configuration for a given PWM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to read the configuration.
Returns
PWM publish configuration.

◆ nrf_pwm_publish_set()

NRF_STATIC_INLINE void nrf_pwm_publish_set ( NRF_PWM_Type * p_reg,
nrf_pwm_event_t event,
uint8_t channel )

Function for setting the publish configuration for a given PWM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to set the configuration.
[in]channelChannel through which to publish the event.

◆ nrf_pwm_seq_cnt_set()

NRF_STATIC_INLINE void nrf_pwm_seq_cnt_set ( NRF_PWM_Type * p_reg,
uint8_t seq_id,
uint16_t length )

Function for modifying the total number of duty cycle values in the specified sequence.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]seq_idIdentifier of the sequence (0 or 1).
[in]lengthNumber of duty cycle values (in 16-bit half words).

◆ nrf_pwm_seq_end_delay_set()

NRF_STATIC_INLINE void nrf_pwm_seq_end_delay_set ( NRF_PWM_Type * p_reg,
uint8_t seq_id,
uint32_t end_delay )

Function for modifying the additional time added after the sequence is played.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]seq_idIdentifier of the sequence (0 or 1).
[in]end_delayNumber of PWM periods added at the end of the sequence.

◆ nrf_pwm_seq_ptr_set()

NRF_STATIC_INLINE void nrf_pwm_seq_ptr_set ( NRF_PWM_Type * p_reg,
uint8_t seq_id,
uint16_t const * p_values )

Function for modifying the pointer to the duty cycle values in the specified sequence.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]seq_idIdentifier of the sequence (0 or 1).
[in]p_valuesPointer to an array with duty cycle values.

◆ nrf_pwm_seq_refresh_set()

NRF_STATIC_INLINE void nrf_pwm_seq_refresh_set ( NRF_PWM_Type * p_reg,
uint8_t seq_id,
uint32_t refresh )

Function for modifying the additional number of PWM periods spent on each duty cycle value in the specified sequence.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]seq_idIdentifier of the sequence (0 or 1).
[in]refreshNumber of additional PWM periods for each duty cycle value.

◆ nrf_pwm_seqend_event_get()

NRF_STATIC_INLINE nrf_pwm_event_t nrf_pwm_seqend_event_get ( uint8_t seq_id)

Function for getting the specified PWM SEQEND event.

Parameters
[in]seq_idSequence index.
Returns
The specified PWM SEQEND event.

◆ nrf_pwm_seqstart_task_get()

NRF_STATIC_INLINE nrf_pwm_task_t nrf_pwm_seqstart_task_get ( uint8_t seq_id)

Function for getting the specified PWM SEQSTART task.

Parameters
[in]seq_idSequence index.
Returns
The specified PWM SEQSTART task.

◆ nrf_pwm_sequence_set()

NRF_STATIC_INLINE void nrf_pwm_sequence_set ( NRF_PWM_Type * p_reg,
uint8_t seq_id,
nrf_pwm_sequence_t const * p_seq )

Function for defining a sequence of PWM duty cycles.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]seq_idIdentifier of the sequence (0 or 1).
[in]p_seqPointer to the sequence definition.

◆ nrf_pwm_shorts_disable()

NRF_STATIC_INLINE void nrf_pwm_shorts_disable ( NRF_PWM_Type * p_reg,
uint32_t mask )

Function for disabling the specified shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of shortcuts to be disabled.

◆ nrf_pwm_shorts_enable()

NRF_STATIC_INLINE void nrf_pwm_shorts_enable ( NRF_PWM_Type * p_reg,
uint32_t mask )

Function for enabling the specified shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of shortcuts to be enabled.

◆ nrf_pwm_shorts_set()

NRF_STATIC_INLINE void nrf_pwm_shorts_set ( NRF_PWM_Type * p_reg,
uint32_t mask )

Function for setting the configuration of PWM shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskShortcuts configuration to be set.

◆ nrf_pwm_subscribe_clear()

NRF_STATIC_INLINE void nrf_pwm_subscribe_clear ( NRF_PWM_Type * p_reg,
nrf_pwm_task_t task )

Function for clearing the subscribe configuration for a given PWM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to clear the configuration.

◆ nrf_pwm_subscribe_get()

NRF_STATIC_INLINE uint32_t nrf_pwm_subscribe_get ( NRF_PWM_Type const * p_reg,
nrf_pwm_task_t task )

Function for getting the subscribe configuration for a given PWM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to read the configuration.
Returns
PWM subscribe configuration.

◆ nrf_pwm_subscribe_set()

NRF_STATIC_INLINE void nrf_pwm_subscribe_set ( NRF_PWM_Type * p_reg,
nrf_pwm_task_t task,
uint8_t channel )

Function for setting the subscribe configuration for a given PWM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to set the configuration.
[in]channelChannel through which to subscribe events.

◆ nrf_pwm_task_address_get()

NRF_STATIC_INLINE uint32_t nrf_pwm_task_address_get ( NRF_PWM_Type const * p_reg,
nrf_pwm_task_t task )

Function for getting the address of the specified PWM task register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskPWM task.
Returns
Address of the specified task register.

◆ nrf_pwm_task_trigger()

NRF_STATIC_INLINE void nrf_pwm_task_trigger ( NRF_PWM_Type * p_reg,
nrf_pwm_task_t task )

Function for activating the specified PWM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask to be activated.