rt_drv_pwm.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * File : rt_drv_pwm.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2018, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2018-05-07 aozima the first version
  23. */
  24. #ifndef __DRV_PWM_H_INCLUDE__
  25. #define __DRV_PWM_H_INCLUDE__
  26. #define PWM_CMD_ENABLE (128 + 0)
  27. #define PWM_CMD_DISABLE (128 + 1)
  28. #define PWM_CMD_SET (128 + 2)
  29. #define PWM_CMD_GET (128 + 3)
  30. struct rt_pwm_configuration
  31. {
  32. rt_uint32_t channel; /* 0-n */
  33. rt_uint32_t period; /* unit:ns 1ns~4.29s:1Ghz~0.23hz */
  34. rt_uint32_t pulse; /* unit:ns (pulse<=period) */
  35. };
  36. struct rt_device_pwm;
  37. struct rt_pwm_ops
  38. {
  39. rt_err_t (*control)(struct rt_device_pwm *device, int cmd, void *arg);
  40. };
  41. struct rt_device_pwm
  42. {
  43. struct rt_device parent;
  44. const struct rt_pwm_ops *ops;
  45. };
  46. extern rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data);
  47. #endif /* __DRV_PWM_H_INCLUDE__ */