Microchip® Advanced Software Framework

pwm4.h File Reference
#include <avr32/io.h>
#include "compiler.h"

Data Structures

struct  pwm_compare_opt_t
 
struct  pwm_opt_t
 Input parameters when initializing a PWM channel. More...
 
struct  pwm_output_override_opt_t
 

Macros

#define AVR32_PWM_LINES_MSB   4
 Local Definition for the number of PWM Lines. More...
 
#define PWM_CKSEL_GCLK   1
 PWM Clock Input is Generic Clock. More...
 
#define PWM_CKSEL_MCK   0
 PWM Clock Input is Master Clock. More...
 
#define PWM_COMPARE_MODE_DOWN   1
 PWM Compare DOWN. More...
 
#define PWM_COMPARE_MODE_UP   0
 PWM Compare UP. More...
 
#define PWM_COMPARE_OFF   0
 PWM Compare OFF. More...
 
#define PWM_COMPARE_ON   1
 PWM Compare ON. More...
 
#define PWM_EVENT_LINE0   (1<<AVR32_PWM_EL0MR_CSEL0_OFFSET)
 
#define PWM_EVENT_LINE1   (1<<AVR32_PWM_EL0MR_CSEL1_OFFSET)
 
#define PWM_EVENT_LINE2   (1<<AVR32_PWM_EL0MR_CSEL2_OFFSET)
 
#define PWM_EVENT_LINE3   (1<<AVR32_PWM_EL0MR_CSEL3_OFFSET)
 
#define PWM_EVENT_LINE4   (1<<AVR32_PWM_EL0MR_CSEL4_OFFSET)
 
#define PWM_EVENT_LINE5   (1<<AVR32_PWM_EL0MR_CSEL5_OFFSET)
 
#define PWM_EVENT_LINE6   (1<<AVR32_PWM_EL0MR_CSEL6_OFFSET)
 
#define PWM_EVENT_LINE7   (1<<AVR32_PWM_EL0MR_CSEL7_OFFSET)
 
#define PWM_FAILURE   -1
 Value returned by function when it was unable to complete successfully for some unspecified reason. More...
 
#define PWM_FAULT_INPUT_ACTIVE_HIGH   1
 PWM Fault Input Active High State. More...
 
#define PWM_FAULT_INPUT_ACTIVE_LOW   0
 PWM Fault Input Active Low State. More...
 
#define PWM_FAULT_INPUT_FILTER_OFF   0
 PWM Fault Input Filtering Option OFF. More...
 
#define PWM_FAULT_INPUT_FILTER_ON   1
 PWM Fault Input Filtering Option ON. More...
 
#define PWM_FAULT_INPUT_NOT_USED   0
 PWM Fault Input Not Used. More...
 
#define PWM_FAULT_INPUT_USED   1
 PWM Fault Input Used. More...
 
#define PWM_FAULT_LINES   8
 PWM Number of Fault Lines. More...
 
#define PWM_FAULT_MODE_LEVEL   0
 PWM Fault Mode Level. More...
 
#define PWM_FAULT_MODE_TGL   1
 PWM Fault Mode Toggle. More...
 
#define PWM_FAULT_OUTPUT   4
 PWM Fault Output Lines: PWM0,1,2,3 => 4. More...
 
#define PWM_INVALID_ARGUMENT   1
 Value returned by function when the channel number is invalid. More...
 
#define PWM_INVALID_INPUT   1
 Value returned by function when the input parameters are out of range. More...
 
#define PWM_MODE_CENTER_ALIGNED   1
 Operate PWM channel in center aligned mode. More...
 
#define PWM_MODE_LEFT_ALIGNED   0
 Operate PWM channel in left aligned mode. More...
 
#define PWM_NO_WRITE_PROTECT_VIOLATION   0xFFFFFFFF
 PWM No Write To Protected Register Status. More...
 
#define PWM_OOV_CTRL_OFF   0
 PWM Output Override Control OFF. More...
 
#define PWM_OOV_CTRL_ON   1
 PWM Output Override Control ON. More...
 
#define PWM_OOV_LINES   4
 PWM Ouptut Override Number of Lines: PWM0,1,2,3 => 4. More...
 
#define PWM_OOV_VALUE_HIGH   1
 PWM Output Override Value High Level. More...
 
#define PWM_OOV_VALUE_LOW   0
 PWM Output Override Value Low Level. More...
 
#define PWM_OUTPUT_HIGH_WHEN_FAULT_DETECTION   1
 PWM Output High Level when fault detection. More...
 
#define PWM_OUTPUT_LOW_WHEN_FAULT_DETECTION   0
 PWM Output Low Level when fault detection. More...
 
#define PWM_POLARITY_HIGH   1
 PWM channel starts output high level. More...
 
#define PWM_POLARITY_LOW   0
 PWM channel starts output low level. More...
 
#define PWM_SUCCESS   0
 Value returned by function when it completed successfully. More...
 
#define PWM_SYNC_CHANNEL_OFF   1
 PWM Sync channel OFF. More...
 
#define PWM_SYNC_CHANNEL_ON   1
 PWM Sync channel ON. More...
 
#define PWM_SYNC_UPDATE_AUTO_WRITE_AUTO_UPDATE   2
 PWM Automatic Write And Automatic Update Period, Duty Cycle and Event Method. More...
 
#define PWM_SYNC_UPDATE_MANUAL_WRITE_AUTO_UPDATE   1
 PWM Manual Write And Automatic Update Period, Duty Cycle and Event Method. More...
 
#define PWM_SYNC_UPDATE_MANUAL_WRITE_MANUAL_UPDATE   0
 PWM Manual Write And Manual Update Period, Duty Cycle and Event Method. More...
 
#define PWM_UPDATE_DUTY   0
 PWM channel write in CUPDx updates duty cycle at the next period start event. More...
 
#define PWM_UPDATE_PERIOD   1
 PWM channel write in CUPDx updates period at the next period start event. More...
 
#define PWM_UPDLOCK_TRIGGER   1
 PWM Update Lock State. More...
 
#define PWM_WPKEY   0x50574D
 PWM Protection Key. More...
 

Functions

int pwm_channel_init (unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel)
 Initialize a specific PWM channel. More...
 
void pwm_clr_fault_status (void)
 Return Fault Status. More...
 
int pwm_compare_disable (int line)
 Compare Match Disable. More...
 
int pwm_compare_enable (int line)
 Compare Match Enable. More...
 
int pwm_compare_event_disable (int line, int event_line)
 Compare Event Disable. More...
 
int pwm_compare_event_enable (int line, int event_line)
 Compare Event Enable. More...
 
int pwm_compare_match_reload_setup (int line, pwm_compare_opt_t *pwm_compare_t)
 Compare Match Reload Setup. More...
 
int pwm_compare_match_setup (int line, pwm_compare_opt_t *pwm_compare_t)
 Compare Match Setup. More...
 
int pwm_compare_reload_update_period_value (int line, pwm_compare_opt_t *pwm_compare_t)
 Compare Reload Update Period. More...
 
int pwm_compare_update_period_value (int line, pwm_compare_opt_t *pwm_compare_t)
 Fault Lines Enable function. More...
 
int pwm_fault_lines_enable (U8 line, U8 channel)
 Fault Lines Enable function. More...
 
int pwm_fault_lines_level_setup (U8 line, U8 channel_high, U8 channel_low)
 Fault Lines Level Setup Function. More...
 
int pwm_fault_lines_polarity_setup (U8 line, U8 polarity, U8 mode, U8 filter)
 Fault Lines Level Polarity Function. More...
 
int pwm_get_fault_status (void)
 Get Fault Status. More...
 
unsigned int pwm_get_update_period_counter_value (void)
 Return Current Counter of Update Period Value. More...
 
int pwm_init (pwm_opt_t *opt)
 This function initialize the PWM controller (mode register) and disable the interrupt. More...
 
int pwm_interrupt_update_channel (unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel)
 Update channel register CPRDx or CDTYx with the interrupt method. This function uses the CUPDx register as a double buffer for the period or the duty cycle. Only the first 20 bits of cupd are significant. More...
 
int pwm_output_override_setup (pwm_output_override_opt_t *opt)
 Output Override Configuration. This function uses the OS and OOV registers. More...
 
int pwm_output_override_write (pwm_output_override_opt_t *opt)
 Output Override Set. This function uses the OS and OOV registers. More...
 
int pwm_start_channels (unsigned long channels_bitmask)
 Start PWM channels. More...
 
int pwm_stop_channels (unsigned long channels_bitmask)
 Stop PWM channels. More...
 
int pwm_synchronous_prepare_update (unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel)
 Prepare a Synchronous Channel, User should call this function for all the synchronous channel. More...
 
int pwm_update_auto_write_auto_update_check_eot (void)
 Synchronous Update with Manual Write and Auto Update Method. More...
 
int pwm_update_auto_write_auto_update_check_ready (void)
 Synchronous Update with Manual Write and Auto Update Method. More...
 
int pwm_update_channel (unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel)
 Update channel register CPRDx or CDTYx with the polling method. This function uses the CUPDx register as a double buffer for the period or the duty cycle. Only the first 20 bits of cupd are significant. More...
 
int pwm_update_manual_write_auto_update (void)
 Synchronous Update with Manual Write and Auto Update Method. More...
 
int pwm_update_manual_write_manual_update (void)
 Synchronous Update with Manual Write and Manual Update Method. More...
 
int pwm_update_period_value (unsigned int value)
 Define Update Period Value For Update Of Synchronous Channel. More...
 
int pwm_update_period_value_update (unsigned int value)
 Define Update Period Value For Update Of Synchronous Channel after a first init. More...
 
int pwm_write_protect_hw_lock (int group)
 Hardware Write Protect Lock Function. This function uses the WPMR register. More...
 
U32 pwm_write_protect_status (void)
 Write Protect Status Function. This function uses the WPSR register. More...
 
int pwm_write_protect_sw_lock (int group)
 Software Write Protect Lock Function. This function uses the WPMR register. More...
 
int pwm_write_protect_sw_unlock (int group)
 Software Write Protect Unlock Function. This function uses the WPMR register. More...