- Main Page
- Related Pages
- Data Structures
- Files

# pwm.h

Go to the documentation of this file.

    00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
    00018 /* Copyright (C) 2006-2008, 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,
    00024  * this 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  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
    00034  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00035  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
    00036  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
    00037  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00038  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00039  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00040  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00041  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    00042  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00043  */
    00044
    00045
    00046 #ifndef _PWM_H_
    00047 #define _PWM_H_
    00048
    00049 #include <avr32/io.h>
    00050
    00051
    00053 #define PWM_SUCCESS 0
    00054
    00057 #define PWM_FAILURE -1
    00058
    00060 #define PWM_INVALID_INPUT 1
    00061
    00063 #define PWM_INVALID_ARGUMENT 1
    00064
    00066 #define PWM_MODE_LEFT_ALIGNED 0
    00067
    00069 #define PWM_MODE_CENTER_ALIGNED 1
    00070
    00072 #define PWM_POLARITY_LOW 0
    00073
    00075 #define PWM_POLARITY_HIGH 1
    00076
    00078 #define PWM_UPDATE_DUTY 0
    00079
    00081 #define PWM_UPDATE_PERIOD 1
    00082
    00083
    00085 typedef struct
    00086 {
    00088   unsigned int divb;
    00089
    00091   unsigned int diva;
    00092
    00094   unsigned int preb;
    00095
    00097   unsigned int prea;
    00098 } pwm_opt_t;
    00099
    00100
    00105 extern int pwm_init(const pwm_opt_t *opt);
    00106
    00112 extern int pwm_channel_init(unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel);
    00113
    00118 extern int pwm_start_channels(unsigned long channels_bitmask);
    00119
    00124 extern int pwm_stop_channels(unsigned long channels_bitmask);
    00125
    00134 extern int pwm_sync_update_channel(unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel);
    00135
    00146 extern int pwm_async_update_channel(unsigned int channel_id, const avr32_pwm_channel_t *pwm_channel);
    00147
    00148
    00149 #endif  // _PWM_H_