drv_pwm.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /******************************************************************************
  17. * @file drv_pwm.h
  18. * @brief header file for pwm driver
  19. * @version V1.0
  20. * @date 02. June 2017
  21. ******************************************************************************/
  22. #ifndef _CSI_PWM_H_
  23. #define _CSI_PWM_H_
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include <stdint.h>
  28. #include <drv_common.h>
  29. /// definition for pwm handle.
  30. typedef void *pwm_handle_t;
  31. /****** PWM specific error codes *****/
  32. typedef enum {
  33. EDRV_PWM_MODE = (EDRV_SPECIFIC + 1), ///< Specified Mode not supported
  34. } drv_pwm_error_e;
  35. /**
  36. \brief Initialize PWM Interface. 1. Initializes the resources needed for the PWM interface 2.registers event callback function
  37. \param[in] pwm_pin pin name of pwm
  38. \return handle pwm handle to operate.
  39. */
  40. pwm_handle_t drv_pwm_initialize(pin_t pwm_pin);
  41. /**
  42. \brief De-initialize PWM Interface. stops operation and releases the software resources used by the interface
  43. \param[in] handle pwm handle to operate.
  44. \return error code
  45. */
  46. int32_t drv_pwm_uninitialize(pwm_handle_t handle);
  47. /**
  48. \brief config pwm mode.
  49. \param[in] handle pwm handle to operate.
  50. \param[in] sysclk configured system clock.
  51. \param[in] period_us the PWM period in us
  52. \param[in] duty the PMW duty. ( 0 - 10000 represents 0% - 100% ,other values are invalid)
  53. \return error code
  54. */
  55. int32_t drv_pwm_config(pwm_handle_t handle,
  56. uint32_t sysclk,
  57. uint32_t period_us,
  58. uint32_t duty);
  59. /**
  60. \brief start generate pwm signal.
  61. \param[in] handle pwm handle to operate.
  62. \return error code
  63. */
  64. int32_t drv_pwm_start(pwm_handle_t handle);
  65. /**
  66. \brief Stop generate pwm signal.
  67. \param[in] handle pwm handle to operate.
  68. \return error code
  69. */
  70. int32_t drv_pwm_stop(pwm_handle_t handle);
  71. /**
  72. \brief Get PWM status.
  73. \param[in] handle pwm handle to operate.
  74. \return PWM status \ref pwm_status_t
  75. pwm_status_t drv_pwm_get_status(pwm_handle_t handle);
  76. */
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* _CSI_PWM_H_ */