SAM4SD32 (SAM4S-EK2)
Loading...
Searching...
No Matches
pwm.c File Reference

Pulse Width Modulation (PWM) driver for SAM. More...

#include "pwm.h"

Go to the source code of this file.

Macros

#define PWM_CLOCK_DIV_MAX   256
#define PWM_CLOCK_PRE_MAX   11
#define PWM_WPCR_WPCMD_DISABLE_SW_PROT   (PWM_WPCR_WPCMD(0))
#define PWM_WPCR_WPCMD_ENABLE_HW_PROT   (PWM_WPCR_WPCMD(2))
#define PWM_WPCR_WPCMD_ENABLE_SW_PROT   (PWM_WPCR_WPCMD(1))
#define PWM_WPCR_WPKEY_PASSWD   0x50574D00

Functions

void pwm_channel_disable (Pwm *p_pwm, uint32_t ul_channel)
 Disable the PWM channel.
void pwm_channel_disable_interrupt (Pwm *p_pwm, uint32_t ul_event, uint32_t ul_fault)
 Disable the interrupt of a channel counter event and fault protection.
void pwm_channel_enable (Pwm *p_pwm, uint32_t ul_channel)
 Enable the PWM channel.
void pwm_channel_enable_interrupt (Pwm *p_pwm, uint32_t ul_event, uint32_t ul_fault)
 Enable the interrupt of a channel counter event and fault protection.
uint32_t pwm_channel_get_counter (Pwm *p_pwm, pwm_channel_t *p_channel)
 Return channel counter value.
uint32_t pwm_channel_get_interrupt_mask (Pwm *p_pwm)
 Get channel counter event and fault protection trigger interrupt mask.
uint32_t pwm_channel_get_interrupt_status (Pwm *p_pwm)
 Get channel counter event and fault protection trigger interrupt status.
uint32_t pwm_channel_get_status (Pwm *p_pwm)
 Check which PWM channel is enabled.
uint32_t pwm_channel_init (Pwm *p_pwm, pwm_channel_t *p_channel)
 Initialize one PWM channel.
void pwm_channel_update_dead_time (Pwm *p_pwm, pwm_channel_t *p_channel, uint16_t us_deadtime_pwmh, uint16_t us_deadtime_pwml)
 Change dead-time value for PWM outputs.
uint32_t pwm_channel_update_duty (Pwm *p_pwm, pwm_channel_t *p_channel, uint32_t ul_duty)
 Change the duty cycle of the PWM channel.
void pwm_channel_update_output (Pwm *p_pwm, pwm_channel_t *p_channel, pwm_output_t *p_output, bool b_sync)
 Change output selection of the PWM channel.
uint32_t pwm_channel_update_period (Pwm *p_pwm, pwm_channel_t *p_channel, uint32_t ul_period)
 Change the period of the PWM channel.
static uint32_t pwm_clocks_generate (uint32_t ul_frequency, uint32_t ul_mck)
 Find a prescaler/divisor couple to generate the desired ul_frequency from ul_mck.
uint32_t pwm_cmp_change_setting (Pwm *p_pwm, pwm_cmp_t *p_cmp)
 Change the setting of PWM comparison.
void pwm_cmp_disable_interrupt (Pwm *p_pwm, uint32_t ul_sources, pwm_cmp_interrupt_t type)
 Disable the interrupt of comparison.
void pwm_cmp_enable_interrupt (Pwm *p_pwm, uint32_t ul_sources, pwm_cmp_interrupt_t type)
 Enable the interrupt of comparison.
uint32_t pwm_cmp_get_period_counter (Pwm *p_pwm, uint32_t ul_cmp_unit)
 Report the value of the comparison period counter.
uint32_t pwm_cmp_get_update_counter (Pwm *p_pwm, uint32_t ul_cmp_unit)
 Report the value of the comparison update period counter.
uint32_t pwm_cmp_init (Pwm *p_pwm, pwm_cmp_t *p_cmp)
 Initialize PWM comparison unit.
void pwm_disable_protect (Pwm *p_pwm, uint32_t ul_group)
 Disable PWM write protect.
void pwm_enable_protect (Pwm *p_pwm, uint32_t ul_group, bool b_sw)
 Enable PWM write protect.
void pwm_fault_clear_status (Pwm *p_pwm, pwm_fault_id_t id)
 Clear a fault input.
pwm_level_t pwm_fault_get_input_level (Pwm *p_pwm, pwm_fault_id_t id)
 Get the level of a fault input.
uint32_t pwm_fault_get_status (Pwm *p_pwm)
 Get fault status.
uint32_t pwm_fault_init (Pwm *p_pwm, pwm_fault_t *p_fault)
 Initialize the behavior of a fault input.
uint32_t pwm_get_interrupt_mask (Pwm *p_pwm)
 Get interrupt mask of PDC transfer, synchronous channels and comparison.
uint32_t pwm_get_interrupt_status (Pwm *p_pwm)
 Get interrupt status of PDC transfer, synchronous channels and comparison.
bool pwm_get_protect_status (Pwm *p_pwm, pwm_protect_t *p_protect)
 Get PWM write protect status.
uint32_t pwm_init (Pwm *p_pwm, pwm_clock_t *clock_config)
 Initialize the PWM source clock (clock A and clock B).
void pwm_pdc_disable_interrupt (Pwm *p_pwm, uint32_t ul_sources)
 Disable the interrupt of PDC transfer.
void pwm_pdc_enable_interrupt (Pwm *p_pwm, uint32_t ul_sources)
 Enable the interrupt of PDC transfer.
void pwm_pdc_set_request_mode (Pwm *p_pwm, pwm_pdc_request_mode_t request_mode, uint32_t ul_cmp_unit)
 Set PDC transfer request mode.
void pwm_stepper_motor_init (Pwm *p_pwm, pwm_stepper_motor_pair_t pair, bool b_enable_gray, bool b_down)
 Initialize PWM stepper motor mode.
void pwm_sync_change_period (Pwm *p_pwm, uint32_t ul_update_period)
 Change the wanted time between each update of the synchronous channels.
void pwm_sync_disable_interrupt (Pwm *p_pwm, uint32_t ul_sources)
 Disable the interrupt of synchronous channels.
void pwm_sync_enable_interrupt (Pwm *p_pwm, uint32_t ul_sources)
 Enable the interrupt of synchronous channel.
uint32_t pwm_sync_get_period_counter (Pwm *p_pwm)
 Get the value of the synchronization update period counter.
uint32_t pwm_sync_init (Pwm *p_pwm, pwm_sync_update_mode_t mode, uint32_t ul_update_period)
 Initialize synchronous channels update mode and period.
void pwm_sync_unlock_update (Pwm *p_pwm)
 Unlock the update of synchronous channels.

Detailed Description

Pulse Width Modulation (PWM) driver for SAM.

Copyright (c) 2011-2019 Microchip Technology Inc. and its subsidiaries.

\cond ASF_LICENSE

Definition in file pwm.c.