PWM HALY

group nrfy_pwm

Hardware access layer with cache and barrier support for managing the PWM peripheral.

Functions

NRFY_STATIC_INLINE void nrfy_pwm_periph_configure(NRF_PWM_Type *p_reg, nrfy_pwm_config_t const *p_config)

Function for configuring the PWM.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_config[in] Pointer to the peripheral configuration structure.

NRFY_STATIC_INLINE void nrfy_pwm_int_init(NRF_PWM_Type *p_reg, uint32_t mask, uint8_t irq_priority, bool enable)

Function for initializing the specified PWM interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be initialized.

  • irq_priority[in] Interrupt priority.

  • enable[in] True if interrupts are to be enabled, false otherwise.

NRFY_STATIC_INLINE void nrfy_pwm_int_uninit(NRF_PWM_Type *p_reg)

Function for uninitializing the PWM interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE uint32_t nrfy_pwm_events_process(NRF_PWM_Type *p_reg, uint32_t mask)

Function for processing the specified PWM events.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of events to be processed, created by NRFY_EVENT_TO_INT_BITMASK.

Returns:

Mask of events that were generated and processed. To be checked against the result of NRFY_EVENT_TO_INT_BITMASK().

NRFY_STATIC_INLINE void nrfy_pwm_start(NRF_PWM_Type *p_reg, uint8_t seq_id, bool wait)

Function for starting the PWM sequence.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • seq_id[in] Sequence index.

  • wait[in] True if the sequence is to be blocking, false otherwise.

NRFY_STATIC_INLINE void nrfy_pwm_abort(NRF_PWM_Type *p_reg, bool wait)

Function for aborting the ongoing PWM sequence.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • wait[in] True if the abort is to be blocking, false otherwise.

NRFY_STATIC_INLINE void nrfy_pwm_task_trigger(NRF_PWM_Type *p_reg, nrf_pwm_task_t task)

See also

nrf_pwm_task_trigger Function for activating the specified PWM task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task to be activated.

NRFY_STATIC_INLINE uint32_t nrfy_pwm_task_address_get(NRF_PWM_Type const *p_reg, nrf_pwm_task_t task)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] PWM task.

Returns:

Address of the specified task register.

NRFY_STATIC_INLINE void nrfy_pwm_event_clear(NRF_PWM_Type *p_reg, nrf_pwm_event_t event)

See also

nrf_pwm_event_clear Function for clearing the specified PWM event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to clear.

NRFY_STATIC_INLINE bool nrfy_pwm_event_check(NRF_PWM_Type const *p_reg, nrf_pwm_event_t event)

See also

nrf_pwm_event_check Function for retrieving the state of the PWM event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to be checked.

Return values:
  • true – The event has been generated.

  • false – The event has not been generated.

NRFY_STATIC_INLINE uint32_t nrfy_pwm_event_address_get(NRF_PWM_Type const *p_reg, nrf_pwm_event_t event)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] PWM event.

Returns:

Address of the specified event register.

NRFY_STATIC_INLINE void nrfy_pwm_shorts_enable(NRF_PWM_Type *p_reg, uint32_t mask)

See also

nrf_pwm_shorts_enable Function for enabling the specified shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of shortcuts to be enabled.

NRFY_STATIC_INLINE void nrfy_pwm_shorts_disable(NRF_PWM_Type *p_reg, uint32_t mask)

See also

nrf_pwm_shorts_disable Function for disabling the specified shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of shortcuts to be disabled.

NRFY_STATIC_INLINE void nrfy_pwm_shorts_set(NRF_PWM_Type *p_reg, uint32_t mask)

See also

nrf_pwm_shorts_set Function for setting the configuration of PWM shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Shortcuts configuration to be set.

NRFY_STATIC_INLINE void nrfy_pwm_int_enable(NRF_PWM_Type *p_reg, uint32_t mask)

See also

nrf_pwm_int_enable Function for enabling specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be enabled. Use nrf_pwm_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_pwm_int_disable(NRF_PWM_Type *p_reg, uint32_t mask)

See also

nrf_pwm_int_disable Function for disabling specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be disabled. Use nrf_pwm_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_pwm_int_set(NRF_PWM_Type *p_reg, uint32_t mask)

See also

nrf_pwm_int_set Function for setting the configuration of PWM interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be set. Use nrf_pwm_int_mask_t values for bit masking.

NRFY_STATIC_INLINE uint32_t nrfy_pwm_int_enable_check(NRF_PWM_Type const *p_reg, uint32_t mask)

See also

nrf_pwm_int_enable_check Function for checking if the specified interrupts are enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be checked. Use nrf_pwm_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRFY_STATIC_INLINE void nrfy_pwm_subscribe_set(NRF_PWM_Type *p_reg, nrf_pwm_task_t task, uint8_t channel)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task for which to set the configuration.

  • channel[in] Channel through which to subscribe events.

NRFY_STATIC_INLINE void nrfy_pwm_subscribe_clear(NRF_PWM_Type *p_reg, nrf_pwm_task_t task)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task for which to clear the configuration.

NRFY_STATIC_INLINE void nrfy_pwm_publish_set(NRF_PWM_Type *p_reg, nrf_pwm_event_t event, uint8_t channel)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event for which to set the configuration.

  • channel[in] Channel through which to publish the event.

NRFY_STATIC_INLINE void nrfy_pwm_publish_clear(NRF_PWM_Type *p_reg, nrf_pwm_event_t event)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event for which to clear the configuration.

NRFY_STATIC_INLINE void nrfy_pwm_enable(NRF_PWM_Type *p_reg)

See also

nrf_pwm_enable Function for enabling the PWM peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE void nrfy_pwm_disable(NRF_PWM_Type *p_reg)

See also

nrf_pwm_disable Function for disabling the PWM peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE bool nrfy_pwm_enable_check(NRF_PWM_Type *p_reg)

See also

nrf_pwm_enable_check Function for checking if the PWM peripheral is enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – The PWM is enabled.

  • false – The PWM is not enabled.

NRFY_STATIC_INLINE void nrfy_pwm_pins_set(NRF_PWM_Type *p_reg, uint32_t out_pins[NRF_PWM_CHANNEL_COUNT])

See also

nrf_pwm_pins_set 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:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • out_pins[in] Array with pin numbers for individual PWM output channels.

NRFY_STATIC_INLINE uint32_t nrfy_pwm_pin_get(NRF_PWM_Type const *p_reg, uint8_t channel)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • channel[in] PWM output channel.

Returns:

Pin selection associated with specified PWM output channel.

NRFY_STATIC_INLINE void nrfy_pwm_configure(NRF_PWM_Type *p_reg, nrf_pwm_clk_t base_clock, nrf_pwm_mode_t mode, uint16_t top_value)

See also

nrf_pwm_configure Function for configuring the PWM peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • base_clock[in] Base clock frequency.

  • mode[in] Operating mode of the pulse generator counter.

  • top_value[in] Value up to which the pulse generator counter counts.

NRFY_STATIC_INLINE void nrfy_pwm_sequence_set(NRF_PWM_Type *p_reg, uint8_t seq_id, nrf_pwm_sequence_t const *p_seq)

See also

nrf_pwm_sequence_set Function for defining a sequence of PWM duty cycles.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • seq_id[in] Identifier of the sequence (0 or 1).

  • p_seq[in] Pointer to the sequence definition.

NRFY_STATIC_INLINE void nrfy_pwm_decoder_set(NRF_PWM_Type *p_reg, nrf_pwm_dec_load_t dec_load, nrf_pwm_dec_step_t dec_step)

See also

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

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • dec_load[in] Mode of loading sequence data from RAM.

  • dec_step[in] Mode of advancing the active sequence.

NRFY_STATIC_INLINE void nrfy_pwm_loop_set(NRF_PWM_Type *p_reg, uint16_t loop_count)

See also

nrf_pwm_loop_set 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:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • loop_count[in] Number of times to perform the sequence playback.

NRFY_STATIC_INLINE nrf_pwm_task_t nrfy_pwm_seqstart_task_get(uint8_t seq_id)

See also

nrf_pwm_seqstart_task_get Function for getting the specified PWM SEQSTART task.

Parameters:
  • seq_id[in] Sequence index.

Returns:

The specified PWM SEQSTART task.

NRFY_STATIC_INLINE nrf_pwm_event_t nrfy_pwm_seqend_event_get(uint8_t seq_id)

See also

nrf_pwm_seqend_event_get Function for getting the specified PWM SEQEND event.

Parameters:
  • seq_id[in] Sequence index.

Returns:

The specified PWM SEQEND event.

struct nrfy_pwm_config_t
#include <nrfy_pwm.h>

PWM configuration structure.

Public Members

uint32_t output_pins[NRF_PWM_CHANNEL_COUNT]

Pin numbers for individual output channels (optional).

Use NRF_PWM_PIN_NOT_CONNECTED if a given output channel is not needed.

uint16_t top_value

Value up to which the pulse generator counter counts.

nrf_pwm_clk_t base_clock

Base clock frequency.

nrf_pwm_mode_t count_mode

Operating mode of the pulse generator counter.

nrf_pwm_dec_load_t load_mode

Mode of loading sequence data from RAM.

nrf_pwm_dec_step_t step_mode

Mode of advancing the active sequence.

bool skip_psel_cfg

Skip pin selection configuration.

When set to true, the driver does not modify pin select registers in the peripheral. Those registers are supposed to be set up externally before the driver is initialized.

Note

When both GPIO configuration and pin selection are to be skipped, the structure fields that specify pins can be omitted, as they are ignored anyway.