OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2009 NVIDIA Corporation. |
| 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 are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 #ifndef INCLUDED_nvrm_pwm_H |
| 34 #define INCLUDED_nvrm_pwm_H |
| 35 |
| 36 |
| 37 #if defined(__cplusplus) |
| 38 extern "C" |
| 39 { |
| 40 #endif |
| 41 |
| 42 #include "nvrm_pinmux.h" |
| 43 #include "nvrm_module.h" |
| 44 #include "nvrm_init.h" |
| 45 |
| 46 #include "nvos.h" |
| 47 #include "nvcommon.h" |
| 48 |
| 49 /** |
| 50 * NvRmPwmHandle is an opaque handle to the NvRmPwmStructRec interface |
| 51 */ |
| 52 |
| 53 typedef struct NvRmPwmRec *NvRmPwmHandle; |
| 54 |
| 55 /** |
| 56 * Defines possible PWM modes. |
| 57 */ |
| 58 |
| 59 typedef enum |
| 60 { |
| 61 |
| 62 /// Specifies Pwm disable mode |
| 63 NvRmPwmMode_Disable = 1, |
| 64 |
| 65 /// Specifies Pwm enable mode |
| 66 NvRmPwmMode_Enable, |
| 67 |
| 68 /// Specifies Blink LED enabled mode |
| 69 NvRmPwmMode_Blink_LED, |
| 70 |
| 71 /// Specifies Blink output 32KHz clock enable mode |
| 72 NvRmPwmMode_Blink_32KHzClockOutput, |
| 73 |
| 74 /// Specifies Blink disabled mode |
| 75 NvRmPwmMode_Blink_Disable, |
| 76 NvRmPwmMode_Num, |
| 77 NvRmPwmMode_Force32 = 0x7FFFFFFF |
| 78 } NvRmPwmMode; |
| 79 |
| 80 /** |
| 81 * Defines the possible PWM output pin |
| 82 */ |
| 83 |
| 84 typedef enum |
| 85 { |
| 86 |
| 87 /// Specifies PWM Output-0 |
| 88 NvRmPwmOutputId_PWM0 = 1, |
| 89 |
| 90 /// Specifies PWM Output-1 |
| 91 NvRmPwmOutputId_PWM1, |
| 92 |
| 93 /// Specifies PWM Output-2 |
| 94 NvRmPwmOutputId_PWM2, |
| 95 |
| 96 /// Specifies PWM Output-3 |
| 97 NvRmPwmOutputId_PWM3, |
| 98 |
| 99 /// Specifies PMC Blink LED |
| 100 NvRmPwmOutputId_Blink, |
| 101 NvRmPwmOutputId_Num, |
| 102 NvRmPwmOutputId_Force32 = 0x7FFFFFFF |
| 103 } NvRmPwmOutputId; |
| 104 |
| 105 /** |
| 106 * @brief Initializes and opens the pwm channel. This function allocates the |
| 107 * handle for the pwm channel and provides it to the client. |
| 108 * |
| 109 * Assert encountered in debug mode if passed parameter is invalid. |
| 110 * |
| 111 * @param hDevice Handle to the Rm device which is required by Rm to acquire |
| 112 * the resources from RM. |
| 113 * @param phPwm Points to the location where the Pwm handle shall be stored. |
| 114 * |
| 115 * @retval NvSuccess Indicates that the Pwm channel has successfully opened. |
| 116 * @retval NvError_InsufficientMemory Indicates that function fails to allocate |
| 117 * the memory. |
| 118 * @retval NvError_NotInitialized Indicates the Pwm initialization failed. |
| 119 */ |
| 120 |
| 121 NvError NvRmPwmOpen( |
| 122 NvRmDeviceHandle hDevice, |
| 123 NvRmPwmHandle * phPwm ); |
| 124 |
| 125 /** |
| 126 * @brief Closes the Pwm channel. This function frees the memory allocated for |
| 127 * the pwm handle for the pwm channel. |
| 128 * This function de-initializes the pwm channel. This API never fails. |
| 129 * |
| 130 * @param hPwm A handle from NvRmPwmOpen(). If hPwm is NULL, this API does |
| 131 * nothing. |
| 132 */ |
| 133 |
| 134 void NvRmPwmClose( |
| 135 NvRmPwmHandle hPwm ); |
| 136 |
| 137 /** |
| 138 * @brief Configure PWM module as disable/enable. Also, it is used |
| 139 * to set the PWM duty cycle and frequency. Beside that, it is |
| 140 * used to configure PMC' blinking LED if OutputId is NvRmPwmOutputId_Blink |
| 141 * |
| 142 * @param hPwm Handle to the PWM channel. |
| 143 * * @param OutputId The output pin to config. Allowed OutputId values are |
| 144 * defined in ::NvRmPwmOutputId |
| 145 * @param Mode The mode type to config. Allowed mode values are |
| 146 * defined in ::NvRmPwmMode |
| 147 * @param DutyCycle The duty cycle is an unsigned 15.16 fixed point |
| 148 * value that represents PWM duty cycle in percentage range from |
| 149 * 0.00 to 100.00. For example, 10.5 percentage duty cycle would be |
| 150 * represented as 0x000A8000. This parameter is ignored if NvRmPwmMode |
| 151 * is NvRmPwmMode_Blink_32KHzClockOutput or NvRmPwmMode_Blink_Disable |
| 152 * @param RequestedFreqHzOrPeriod The requested frequency in Hz or Period |
| 153 * A requested frequency value beyond the max supported value will be |
| 154 * clamped to the max supported value. |
| 155 * If PMC Blink LED is used, this parameter is represented as |
| 156 * request period time in second unit. This parameter is ignored if |
| 157 * NvRmPwmMode is NvRmPwmMode_Blink_32KHzClockOutput or |
| 158 * NvRmPwmMode_Blink_Disable |
| 159 * |
| 160 * @param pCurrentFreqHzOrPeriod Pointer to the returns frequency of |
| 161 * that mode. If PMC Blink LED is used then it is the pointer to |
| 162 * the returns period time. This parameter is ignored if NvRmPwmMode |
| 163 * is NvRmPwmMode_Blink_32KHzClockOutput or NvRmPwmMode_Blink_Disable |
| 164 * |
| 165 * @retval NvSuccess Indicates the configuration succeeded. |
| 166 */ |
| 167 |
| 168 NvError NvRmPwmConfig( |
| 169 NvRmPwmHandle hPwm, |
| 170 NvRmPwmOutputId OutputId, |
| 171 NvRmPwmMode Mode, |
| 172 NvU32 DutyCycle, |
| 173 NvU32 RequestedFreqHzOrPeriod, |
| 174 NvU32 * pCurrentFreqHzOrPeriod ); |
| 175 |
| 176 #if defined(__cplusplus) |
| 177 } |
| 178 #endif |
| 179 |
| 180 #endif |
OLD | NEW |