--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * SAM Software Package License\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2015, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \par Purpose\r
+ *\r
+ * Interface for configuration the Pulse Width Modulation Controller (PWM) peripheral.\r
+ *\r
+ * \par Usage\r
+ *\r
+ * -# Configures PWM clocks A & B to run at the given frequencies using\r
+ * pwmc_configure_clocks().\r
+ * -# Configure PWMC channel using pwmc_configure_channel(), pwmc_set_period()\r
+ * and pwmc_set_duty_cycle().\r
+ * -# Enable & disable channel using pwmc_enable_channel() and pwmc_disable_channel().\r
+ * -# Enable & disable the period interrupt for the given PWM channel using\r
+ * pwmc_enable_channel_it() and pwmc_disable_channel_it().\r
+ *\r
+ */\r
+\r
+#ifndef _PWMC_\r
+#define _PWMC_\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Headers\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include "chip.h"\r
+\r
+#include <stdint.h>\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Exported functions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * \brief Configures PWM clocks\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param mode PWM clock source selection and divide factor.\r
+ */\r
+extern void pwmc_configure_clocks(Pwm * p_pwm, uint32_t mode);\r
+\r
+/**\r
+ * \brief Enables the given PWM channel.\r
+ *\r
+ * This does NOT enable the corresponding pin; this must be done in the user\r
+ * code.\r
+ *\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ */\r
+extern void pwmc_enable_channel(Pwm * p_pwm, uint8_t channel);\r
+\r
+/**\r
+ * \brief Disables the given PWM channel.\r
+ *\r
+ * Beware, the channel will be effectively disabled at the end of the current\r
+ * period.\r
+ * Applications may check whether the channel is disabled using the following\r
+ * wait loop:\r
+ * while ((PWM->PWM_SR & (1 << channel)) != 0) {};\r
+ *\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ */\r
+extern void pwmc_disable_channel(Pwm * p_pwm, uint8_t channel);\r
+\r
+/**\r
+ * \brief Enables the selected interrupts sources on a PWMC peripheral.\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ */\r
+extern void pwmc_enable_channel_it(Pwm * p_pwm, uint8_t channel);\r
+\r
+/**\r
+ * \brief Disables the selected interrupts sources on a PWMC peripheral.\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ */\r
+extern void pwmc_disable_channel_it(Pwm * p_pwm, uint8_t channel);\r
+\r
+/**\r
+ * \brief Configures a PWM channel with the given parameters, basic configure\r
+ * function.\r
+ *\r
+ * The PWM controller must have been clocked in the PMC prior to calling this\r
+ * function.\r
+ * Beware: this function disables the channel. It will wait until the channel is\r
+ * effectively disabled.\r
+ *\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ * \param mode Channel mode.\r
+ */\r
+extern void pwmc_configure_channel(Pwm * p_pwm, uint8_t channel, uint32_t mode);\r
+\r
+/**\r
+ * \brief Sets the period value used by a PWM channel.\r
+ *\r
+ * This function writes directly to the CPRD register if the channel is\r
+ * disabled. Otherwise it sets the update register CPRDUPD.\r
+ *\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ * \param period Period value.\r
+ */\r
+extern void pwmc_set_period(Pwm * p_pwm, uint8_t channel, uint16_t period);\r
+\r
+/**\r
+ * \brief Sets the duty cycle used by a PWM channel.\r
+ * This function writes directly to the CDTY register if the channel is\r
+ * disabled. Otherwise it sets the update register CDTYUPD.\r
+ * Note that the duty cycle must always be inferior or equal to the channel\r
+ * period.\r
+ *\r
+ * \param p_pwm Pointer to a Pwm instance\r
+ * \param channel Channel number.\r
+ * \param duty Duty cycle value.\r
+ */\r
+extern void pwmc_set_duty_cycle(Pwm * p_pwm, uint8_t channel, uint16_t duty);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /* #ifndef _PWMC_ */\r