gd_pwm.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gd_pwm.h
  5. **
  6. ** \brief pwm driver.
  7. **
  8. ** The driver provides functions to use the GK7101's PWM
  9. ** interface.
  10. **
  11. ** Copyright: 2012 - 2013 (C) GoKe Microelectronics ShangHai Branch
  12. **
  13. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  14. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  15. ** OMMISSIONS.
  16. **
  17. ** \version
  18. **
  19. ******************************************************************************/
  20. #ifndef _GD_PWM_H_
  21. #define _GD_PWM_H_
  22. #endif
  23. #include <gtypes.h>
  24. #include <gmodids.h>
  25. /*---------------------------------------------------------------------------*/
  26. /* types, enums and structures */
  27. /*---------------------------------------------------------------------------*/
  28. /*!
  29. *******************************************************************************
  30. **
  31. ** \brief PWM channel number.
  32. **
  33. **
  34. ******************************************************************************/
  35. #define GD_PWM_COUNT 8
  36. /*!
  37. *******************************************************************************
  38. **
  39. ** \brief PWM operition modes.
  40. **
  41. ** \sa GD_PWM_INIT_PARAMS_S
  42. **
  43. ******************************************************************************/
  44. typedef enum
  45. {
  46. GD_NORMAL_SPEED,
  47. GD_SYNC_SPEED,
  48. }GD_PWM_MODE_E;
  49. typedef struct
  50. {
  51. U8 channel; /* 0 ~ 3 */
  52. U16 xon; /* 0x00 ~ 0xffff */
  53. U16 xoff; /* 0x00 ~ 0xffff */
  54. }GD_PWM_DUTY_S;
  55. typedef enum
  56. {
  57. GD_PWM_NO_ERR = 0,
  58. GD_PWM_ERR_NOT_SUPPORTED_CHANNEL,
  59. GD_PWM_ERR_NOT_SUPPORTED_FREQUENCY,
  60. GD_PWM_ERR_NOT_SUPPORTED_RANGE,
  61. GD_PWM_ERR_WRONG_DUTY_CONFIGURATION,
  62. GD_PWM_ERR_RANGE_EXCEED_LIMIT,
  63. }GD_PWM_ERROR_CODE_E;
  64. GERR GD_PWM_Init();
  65. GERR GD_PWM_Cycle(U8 channel, U32 highLevelCnt, U32 lowLevelCnt);
  66. GERR GD_PWM_Set_Mode(U8 channel, U8 mode);
  67. GERR GD_PWM_Get_Mode(U8 channel, GD_PWM_MODE_E *mode);
  68. GERR GD_PwmOnOff(U8 channel,U32 on);
  69. GERR GD_PWM_Open(U8 channel,U32 iomode);
  70. GERR GD_PWM_Close(U8 channel);
  71. GD_PWM_ERROR_CODE_E GD_PWM_Set_Param(U8 channel, U32 frequency, U32 range, U32 duty);
  72. GERR GD_PWM_Get_Param(U8 channel, U32 *frequency, U32 *duty);
  73. GERR GD_PWM_Get_Status(U8 channel, U32 *status);
  74. GERR GD_PWM_Set_Clock_Divider(U8 channel, U8 divider);