Christina Quast | 637ace9 | 2014-11-28 13:28:37 +0100 | [diff] [blame] | 1 | /* ----------------------------------------------------------------------------
|
| 2 | * ATMEL Microcontroller Software Support
|
| 3 | * ----------------------------------------------------------------------------
|
| 4 | * Copyright (c) 2009, Atmel Corporation
|
| 5 | *
|
| 6 | * All rights reserved.
|
| 7 | *
|
| 8 | * Redistribution and use in source and binary forms, with or without
|
| 9 | * modification, are permitted provided that the following conditions are met:
|
| 10 | *
|
| 11 | * - Redistributions of source code must retain the above copyright notice,
|
| 12 | * this list of conditions and the disclaimer below.
|
| 13 | *
|
| 14 | * Atmel's name may not be used to endorse or promote products derived from
|
| 15 | * this software without specific prior written permission.
|
| 16 | *
|
| 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
| 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
| 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
| 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
| 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 27 | * ----------------------------------------------------------------------------
|
| 28 | */
|
| 29 |
|
| 30 | /**
|
| 31 | * \file
|
| 32 | *
|
| 33 | * \par Purpose
|
| 34 | *
|
| 35 | * Interface for configuration the Pulse Width Modulation Controller (PWM) peripheral.
|
| 36 | *
|
| 37 | * \par Usage
|
| 38 | *
|
| 39 | * -# Configures PWM clocks A & B to run at the given frequencies using
|
| 40 | * \ref PWMC_ConfigureClocks().
|
| 41 | * -# Configure PWMC channel using \ref PWMC_ConfigureChannel(), \ref PWMC_ConfigureChannelExt()
|
| 42 | * \ref PWMC_SetPeriod(), \ref PWMC_SetDutyCycle() and \ref PWMC_SetDeadTime().
|
| 43 | * -# Enable & disable channel using \ref PWMC_EnableChannel() and
|
| 44 | * \ref PWMC_DisableChannel().
|
| 45 | * -# Enable & disable the period interrupt for the given PWM channel using
|
| 46 | * \ref PWMC_EnableChannelIt() and \ref PWMC_DisableChannelIt().
|
| 47 | * -# Enable & disable the selected interrupts sources on a PWMC peripheral
|
| 48 | * using \ref PWMC_EnableIt() and \ref PWMC_DisableIt().
|
| 49 | * -# Control syncronous channel using \ref PWMC_ConfigureSyncChannel(),
|
| 50 | * \ref PWMC_SetSyncChannelUpdatePeriod() and \ref PWMC_SetSyncChannelUpdateUnlock().
|
| 51 | * -# Control PWM override output using \ref PWMC_SetOverrideValue(),
|
| 52 | * \ref PWMC_EnableOverrideOutput() and \ref PWMC_DisableOverrideOutput().
|
| 53 | * -# Send data through the transmitter using \ref PWMC_WriteBuffer().
|
| 54 | *
|
| 55 | */
|
| 56 |
|
| 57 | #ifndef _PWMC_
|
| 58 | #define _PWMC_
|
| 59 |
|
| 60 | /*----------------------------------------------------------------------------
|
| 61 | * Headers
|
| 62 | *----------------------------------------------------------------------------*/
|
| 63 |
|
| 64 | #include "chip.h"
|
| 65 |
|
| 66 | #include <stdint.h>
|
| 67 |
|
| 68 | #ifdef __cplusplus
|
| 69 | extern "C" {
|
| 70 | #endif
|
| 71 |
|
| 72 | /*----------------------------------------------------------------------------
|
| 73 | * Exported functions
|
| 74 | *----------------------------------------------------------------------------*/
|
| 75 |
|
| 76 | extern void PWMC_ConfigureChannel(
|
| 77 | Pwm* pPwm,
|
| 78 | uint8_t channel,
|
| 79 | uint32_t prescaler,
|
| 80 | uint32_t alignment,
|
| 81 | uint32_t polarity);
|
| 82 | extern void PWMC_ConfigureChannelExt(
|
| 83 | Pwm* pPwm,
|
| 84 | uint8_t channel,
|
| 85 | uint32_t prescaler,
|
| 86 | uint32_t alignment,
|
| 87 | uint32_t polarity,
|
| 88 | uint32_t countEventSelect,
|
| 89 | uint32_t DTEnable,
|
| 90 | uint32_t DTHInverte,
|
| 91 | uint32_t DTLInverte);
|
| 92 | extern void PWMC_ConfigureClocks(uint32_t clka, uint32_t clkb, uint32_t mck);
|
| 93 | extern void PWMC_SetPeriod( Pwm* pPwm, uint8_t channel, uint16_t period);
|
| 94 | extern void PWMC_SetDutyCycle( Pwm* pPwm, uint8_t channel, uint16_t duty);
|
| 95 | extern void PWMC_SetDeadTime( Pwm* pPwm, uint8_t channel, uint16_t timeH, uint16_t timeL);
|
| 96 | extern void PWMC_ConfigureSyncChannel( Pwm* pPwm,
|
| 97 | uint32_t channels,
|
| 98 | uint32_t updateMode,
|
| 99 | uint32_t requestMode,
|
| 100 | uint32_t requestComparisonSelect);
|
| 101 | extern void PWMC_SetSyncChannelUpdatePeriod( Pwm* pPwm, uint8_t period);
|
| 102 | extern void PWMC_SetSyncChannelUpdateUnlock( Pwm* pPwm );
|
| 103 | extern void PWMC_EnableChannel( Pwm* pPwm, uint8_t channel);
|
| 104 | extern void PWMC_DisableChannel( Pwm* pPwm, uint8_t channel);
|
| 105 | extern void PWMC_EnableChannelIt( Pwm* pPwm, uint8_t channel);
|
| 106 | extern void PWMC_DisableChannelIt( Pwm* pPwm, uint8_t channel);
|
| 107 | extern void PWMC_EnableIt( Pwm* pPwm, uint32_t sources1, uint32_t sources2);
|
| 108 | extern void PWMC_DisableIt( Pwm* pPwm, uint32_t sources1, uint32_t sources2);
|
| 109 | extern uint8_t PWMC_WriteBuffer(Pwm *pwmc,
|
| 110 | void *buffer,
|
| 111 | uint32_t length);
|
| 112 | extern void PWMC_SetOverrideValue( Pwm* pPwm, uint32_t value);
|
| 113 | extern void PWMC_EnableOverrideOutput( Pwm* pPwm, uint32_t value, uint32_t sync);
|
| 114 | extern void PWMC_DisableOverrideOutput( Pwm* pPwm, uint32_t value, uint32_t sync);
|
| 115 | extern void PWMC_SetFaultMode( Pwm* pPwm, uint32_t mode);
|
| 116 | extern void PWMC_FaultClear( Pwm* pPwm, uint32_t fault);
|
| 117 | extern void PWMC_SetFaultProtectionValue( Pwm* pPwm, uint32_t value);
|
| 118 | extern void PWMC_EnableFaultProtection( Pwm* pPwm, uint32_t value);
|
| 119 | extern void PWMC_ConfigureComparisonUnit( Pwm* pPwm, uint32_t x, uint32_t value, uint32_t mode);
|
| 120 | extern void PWMC_ConfigureEventLineMode( Pwm* pPwm, uint32_t x, uint32_t mode);
|
| 121 |
|
| 122 | #ifdef __cplusplus
|
| 123 | }
|
| 124 | #endif
|
| 125 |
|
| 126 | #endif /* #ifndef _PWMC_ */
|
| 127 |
|