00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00018 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions are met: 00022 * 00023 * 1. Redistributions of source code must retain the above copyright notice, this 00024 * list of conditions and the following disclaimer. 00025 * 00026 * 2. Redistributions in binary form must reproduce the above copyright notice, 00027 * this list of conditions and the following disclaimer in the documentation 00028 * and/or other materials provided with the distribution. 00029 * 00030 * 3. The name of Atmel may not be used to endorse or promote products derived 00031 * from this software without specific prior written permission. 00032 * 00033 * 4. This software may only be redistributed and used in connection with an Atmel 00034 * AVR product. 00035 * 00036 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00038 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00039 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00040 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00041 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00042 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00044 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00045 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00046 * 00047 */ 00048 00049 #ifndef _PWM_H_ 00050 #define _PWM_H_ 00051 00052 #include <avr32/io.h> 00053 00054 00056 #define PWM_SUCCESS 0 00057 00060 #define PWM_FAILURE -1 00061 00063 #define PWM_INVALID_INPUT 1 00064 00066 #define PWM_INVALID_ARGUMENT 1 00067 00069 #define PWM_MODE_LEFT_ALIGNED 0 00070 00072 #define PWM_MODE_CENTER_ALIGNED 1 00073 00075 #define PWM_POLARITY_LOW 0 00076 00078 #define PWM_POLARITY_HIGH 1 00079 00081 #define PWM_UPDATE_DUTY 0 00082 00084 #define PWM_UPDATE_PERIOD 1 00085 00086 00088 typedef struct 00089 { 00091 unsigned int divb; 00092 00094 unsigned int diva; 00095 00097 unsigned int preb; 00098 00100 unsigned int prea; 00101 } pwm_opt_t; 00102 00103 00108 extern int pwm_init(const pwm_opt_t *opt); 00109 00115 extern int pwm_channel_init(unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel); 00116 00121 extern int pwm_start_channels(unsigned long channels_bitmask); 00122 00127 extern int pwm_stop_channels(unsigned long channels_bitmask); 00128 00137 extern int pwm_sync_update_channel(unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel); 00138 00149 extern int pwm_async_update_channel(unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel); 00150 00151 00152 #endif // _PWM_H_