[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_0_eng / packages / ti / platform_org / evmk2g / platform_lib / include / evmc66x_pwm.h
1 /*
2 * Copyright (c) 2015, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
34 /**
35 *
36 * \file evmc66x_pwm.h
37 *
38 * \brief This is the header file for pwm driver
39 *
40 ******************************************************************************/
42 #ifndef _EVMC66X_PWM_H_
43 #define _EVMC66X_PWM_H_
45 /** Handle to access ECAP registers */
46 typedef CSL_EcapRegs *hEcapHandle;
48 /** Handle to access PWMSS registers */
49 typedef CSL_PwmssRegs *hPwmssHandle;
52 /*ECAP register offsets*/
53 #define ECAP_TSCTR (0x00U)
54 #define ECAP_CTRPHS (0x04U)
55 #define ECAP_CAP1 (0x08U)
56 #define ECAP_CAP2 (0x0CU)
57 #define ECAP_CAP3 (0x10U)
58 #define ECAP_CAP4 (0x14U)
59 #define ECAP_ECCTL1 (0x28U)
60 #define ECAP_ECCTL2 (0x2AU)
61 #define ECAP_ECEINT (0x2CU)
62 #define ECAP_ECFLG (0x2EU)
63 #define ECAP_ECCLR (0x30U)
64 #define ECAP_ECFRC (0x32U)
65 #define ECAP_REVID (0x5CU)
68 /**************************************************************************
69 ** Macro Definitions
70 **************************************************************************/
72 #define ECAP_ECCTL2_APWM_MODE (0x1U)
73 #define ECAP_ECCTL2_APWM_MODE_DISABLE (0x0U)
74 #define ECAP_TSCTR_COUNT (0x10000U)
75 #define ECAP_ECCTL2_APWM_POLARITY (0x1U)
76 #define ECAP_ECCTL2_FREERUN_ENABLE (0x1U)
77 #define ECAP_CAP1_APRD_VALUE (0x1000U)
78 #define ECAP_CAP2_ACMP_VALUE (0x500U)
79 #define ECAP_ECCTL2_SYNCO_SEL_DISABLE (0x3U)
81 /** Macros definitons for error and success */
82 #define ECAP_ERR (-1)
83 #define ECAP_SUCCESS (0)
85 #define PWM_ECAP_CLK_EN (0x01)
86 #define ECAP_PRESCALE_6 (0x03)
89 /**************************************************************************
90 ** API function Prototypes
91 **************************************************************************/
93 /**
94 *
95 * \brief This function initializes the ECAP module and PWM driver.
96 * It also enables the backlight with 50% duty cycle.
97 *
98 * No parameters.
99 *
100 * \return ECAP_SUCCESS - On Success
101 * ECAP_ERR - On Failure
102 *
103 */
104 int8_t pwmInit(void);
106 /**
107 *
108 * \brief This function is used to set the duty cycle of the PWM waveform.
109 *
110 * \param dutyCycle [IN] : Value of the duty cycle to be set.
111 * 50 : 50% duty cycle.
112 * 75 : 75% duty cycle.
113 *
114 * \return ECAP SUCESS - On Success.
115 * ECAP_ERR - On Failure.
116 *
117 */
118 int8_t pwmSetDutyCycle(uint8_t dutyCycle);
120 #endif /* _EVMC66X_PWM_H_ */