1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup IotHardware 18 * @{ 19 * 20 * @brief Provides APIs for operating devices, 21 * including flash, GPIO, I2C, PWM, UART, and watchdog APIs. 22 * 23 * 24 * 25 * @since 2.2 26 * @version 2.2 27 */ 28 29 /** 30 * @file iot_pwm.h 31 * 32 * @brief Declares functions for operating PWM devices, 33 * including initializing and deinitializing a PWM device and starting and stopping PWM signal output. 34 * 35 * 36 * 37 * @since 2.2 38 * @version 2.2 39 */ 40 41 #ifndef IOT_PWM_H 42 #define IOT_PWM_H 43 44 /** 45 * @brief Initializes a PWM device. 46 * 47 * @param port Indicates the port number of the PWM device. 48 * @return Returns {@link IOT_SUCCESS} if the PWM device is initialized; 49 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 50 * @since 2.2 51 * @version 2.2 52 */ 53 unsigned int IoTPwmInit(unsigned int port); 54 55 /** 56 * @brief Deinitializes a PWM device. 57 * 58 * @param port Indicates the port number of the PWM device. 59 * @return Returns {@link IOT_SUCCESS} if the PWM device is deinitialized; 60 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 61 * @since 2.2 62 * @version 2.2 63 */ 64 unsigned int IoTPwmDeinit(unsigned int port); 65 66 /** 67 * @brief Starts PWM signal output from a specified port based on the given output frequency and duty cycle. 68 * 69 * 70 * 71 * @param port Indicates the port number of the PWM device. 72 * @param duty Indicates the duty cycle for PWM signal output. The value ranges from 1 to 99. 73 * @param freq Indicates the frequency for PWM signal output. 74 * @return Returns {@link IOT_SUCCESS} if the PWM signal output is started; 75 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 76 * @since 2.2 77 * @version 2.2 78 */ 79 unsigned int IoTPwmStart(unsigned int port, unsigned short duty, unsigned int freq); 80 81 /** 82 * @brief Stops PWM signal output from a specified port. 83 * 84 * @param port Indicates the port number of the PWM device. 85 * @return Returns {@link IOT_SUCCESS} if the PWM signal output is stopped; 86 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 87 * @since 2.2 88 * @version 2.2 89 */ 90 unsigned int IoTPwmStop(unsigned int port); 91 92 #endif // IOT_PWM_H 93 /** @} */ 94