drv_pwm.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File : drv_pwm.h
  3. * This file is part of GK710X BSP for RT-Thread distribution.
  4. *
  5. * Copyright (c) 2017 GOKE Microelectronics Co., Ltd.
  6. * All rights reserved
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * Visit http://www.goke.com to get contact with Goke.
  23. *
  24. * Change Logs:
  25. * Date Author Notes
  26. */
  27. #ifndef PWM_H_
  28. #define PWM_H_
  29. #include <rtthread.h>
  30. #include <rtdef.h>
  31. #define ENABLE_PWM (0x10)
  32. #define DISABLE_PWM (0x11)
  33. #define SET_PWM_DUTY_CYCLE (0x12)
  34. #define GET_PWM_DUTY_CYCLE (0x13)
  35. #define SET_PWM_VSYNC_MODE (0x14)
  36. #define GET_PWM_VSYNC_MODE (0x15)
  37. #define SET_PWM_CLOCK_DIV (0x16)
  38. #define SET_PWM_ACT_CHANNEL (0x17)
  39. #define PWM_MAX_CHANNEL 8
  40. struct pwm_param_vsync_mode
  41. {
  42. rt_uint16_t speed;
  43. rt_uint32_t highLevelCnt;
  44. rt_uint32_t lowLevelCnt;
  45. };
  46. struct pwm_device
  47. {
  48. rt_uint32_t freq;
  49. rt_uint32_t range;
  50. rt_uint32_t duty;
  51. };
  52. struct gk_pwm_obj
  53. {
  54. int id;
  55. rt_uint32_t gpio_id;
  56. };
  57. struct pwm_driver
  58. {
  59. struct gk_pwm_obj pwm[PWM_MAX_CHANNEL];
  60. };
  61. void rt_hw_pwm_init(void);
  62. #endif /* PWM_H_ */