19 #ifndef CODEBASE_HAL_HAL_PWM_H_ 20 #define CODEBASE_HAL_HAL_PWM_H_ 36 #error "nRF51 series SoCs don't have a PWM peripheral" 39 #if SYS_CFG_PRESENT == 1 40 #include "sys_config.h" 42 #ifndef HAL_PWM_PERIPH_USED 43 #define HAL_PWM_PERIPH_USED 0 48 #define PWM_USED HAL_PWM_PERIPH_USED 51 #define HAL_PWM_MAX_PIN_NUM 4 56 HAL_PWM_FREQ_16MHz = PWM_PRESCALER_PRESCALER_DIV_1,
Each channel has its own 16 bit value.
uint32_t shorts_mask
Select the shortcuts that need to be enabled. OR the values in hal_pwm_short_mask_t to enable them.
Short between LOOPSDONE event and SEQSTART[0] task.
Interrupt on SEQSTARTED[0] event.
hal_pwm_irq_mask_t
PWM interrupts.
uint32_t repeats
Number of times a particular value should be played. Only for HAL_PWM_STEP_INTERNAL mode.
hal_pwm_freq_t
Select the PWM frequency to operate at.
uint32_t * pins
Pointer to array containing the pins number used by hal pwm.
uint32_t interrupt_masks
Select the interrupts that need to be enabled OR the values in hal_pwm_irq_mask_t to enable them.
uint16_t len
Number of 16-bit values in the buffer pointed by seq_values.
After the loaded value is repeated for the number of times in REFRESH register.
uint32_t countertop
Maximum count of the counter. This and oper_freq decide the frequency of the resulting PWM waveform.
hal_pwm_decoder_load_t decoder_load
Select the way in which the data pointed in seq_config is loaded into to the various channels.
hal_pwm_decoder_load_t
PWM decoder's data load modes. This mode selects how the different channels' next value is loaded fro...
hal_pwm_dec_trigger_t
PWM decoder's next load trigger modes. This selects when the next value is loaded from RAM.
Short between LOOPSDONE event and STOP task.
A 16-bit value is used in all four (0-3) PWM channels.
Short between LOOPSDONE event and SEQSTART[1] task.
uint32_t irq_priority
IRQ priority with which the irq_handler in hal_pwm_start_t is called.
void hal_pwm_start(hal_pwm_start_t *start_config)
Start the PWM generation based on the configuration provided.
Up counter, reset to 0 on incrementing to CounterTop.
uint16_t * seq_values
Pointer to an array containing the PWM duty cycle values. This array present in the data RAM should p...
Interrupt on PWMPERIODEND event.
hal_pwm_freq_t oper_freq
Select the operating frequency of the hal pwm module.
Interrupt on SEQEND[1] event.
uint32_t loop
The number of times the pattern of both seq_config must be repeated.
When the Next Step task is set.
Short between SEQEND[1] event and STOP task.
hal_pwm_dec_trigger_t decoder_trigger
Select when the next data is loaded to the PWM.
bool * pin_idle_state
Pointer to array having the state of pins when PWM generation isn't on.
uint32_t pin_num
Number of pins to be used by hal pwm. Maximum is HAL_PWM_MAX_PIN_NUM.
hal_pwm_mode_t
Select the operating mode of the PWM wave counter.
void hal_pwm_stop(void)
Stop the PWM generation.
Short between SEQEND[0] event and STOP task.
Interrupt on SEQEND[0] event.
Interrupt on SEQSTARTED[1] event.
hal_pwm_mode_t oper_mode
Select the operating mode (Up or Up&Down) of the module's counter.
Interrupt on STOPPED event.
Struct for initializing the hal pwm module.
hal_pwm_short_mask_t
Bit masks for the PWM shortcuts. Or the appropriate ones for the required shortcuts.
Up & down counter, decrement back to 0 on reaching CounterTop.
void hal_pwm_init(hal_pwm_init_t *init_config)
Initialize the HAL PWM module. Can be called again to change the initialization configuration.
1st 16-bit value used in channels 0 and 1; 2nd one in channels 2 and 3.
Interrupt on LOOPSDONE event.
uint32_t end_delay
Additional number of cycles that the last PWM value is to be played after the end....
Struct containing the configuration for starting the hal pwm module.
1st three channels have their own 16 bit values, 4th one is the wave counter.
Configuration for a sequence of PWM values. Note that the buffer pointed to in this structure needs t...