ck_pwm.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 ck_pwm.h
  18. * @brief header file for pwm driver
  19. * @version V1.0
  20. * @date 02. June 2017
  21. ******************************************************************************/
  22. #ifndef __CK_PWM_H
  23. #define __CK_PWM_H
  24. #include <stdio.h>
  25. #include "soc.h"
  26. typedef enum {
  27. CKENUM_PWM_CH0 = 0,
  28. CKENUM_PWM_CH1 = 1,
  29. CKENUM_PWM_CH2 = 2,
  30. CKENUM_PWM_CH3 = 3,
  31. CKENUM_PWM_CH4 = 4,
  32. CKENUM_PWM_CH5 = 5,
  33. CKENUM_PWM_CH6 = 6,
  34. CKENUM_PWM_CH7 = 7,
  35. CKENUM_PWM_CH8 = 8,
  36. CKENUM_PWM_CH9 = 9,
  37. CKENUM_PWM_CH10 = 10,
  38. CKENUM_PWM_CH11 = 11
  39. } CKENUM_PWM_CHANNEL;
  40. typedef enum {
  41. CKENUM_PWM_COUNT_UP = 0,
  42. CKENUM_PWM_COUNT_UP_DOWN = 1
  43. } CKENUM_PWM_COUNTER_MODE;
  44. typedef struct {
  45. __IOM uint32_t PWMCFG; /* Offset: 0x000 (R/W) PWM configure register */
  46. __IOM uint32_t PWMINVERTTRIG; /* Offset: 0x004 (R/W) PWM signal is inverted register */
  47. __IOM uint32_t PWM01TRIG; /* Offset: 0x008 (R/W) contain the trigger generate compare value */
  48. __IOM uint32_t PWM23TRIG; /* Offset: 0x00C (R/W) contain the trigger generate compare value */
  49. __IOM uint32_t PWM45TRIG; /* Offset: 0x010 (N/A) contain the trigger generate compare value */
  50. __IOM uint32_t PWMINTEN1; /* Offset: 0x014 (R/W) interrupt enable */
  51. __IM uint32_t PWMINTEN2; /* Offset: 0x018 (N/A) interrupt enable */
  52. __IOM uint32_t PWMRIS1; /* Offset: 0x01C (R/ ) raw interrupt status */
  53. __IOM uint32_t PWMRIS2; /* Offset: 0x020 (N/A) raw interrupt status */
  54. __IOM uint32_t PWMIC1; /* Offset: 0x024 (R/W) interrupt clear */
  55. __IOM uint32_t PWMIC2; /* Offset: 0x028 (R/W) interrupt clear */
  56. __IOM uint32_t PWMIS1; /* Offset: 0x02C (R/W) interrupt status */
  57. __IOM uint32_t PWMIS2; /* Offset: 0x030 (R/W) interrupt status */
  58. __IOM uint32_t PWMCTL; /* Offset: 0x034 (R/W) configure the pwm generation blocks */
  59. __IOM uint32_t PWM01LOAD; /* Offset: 0x038 (R/W) contain the load value of the PWM count */
  60. __IOM uint32_t PWM23LOAD; /* Offset: 0x03C (R/W) contain the load value of the PWM count */
  61. __IOM uint32_t PWM45LOAD; /* Offset: 0x040 (N/A) contain the load value of the PWM count */
  62. __IM uint32_t PWM01COUNT; /* Offset: 0x044 (R/ ) contain the current value of the PWM count */
  63. __IM uint32_t PWM23COUNT; /* Offset: 0x048 (R/ ) contain the current value of the PWM count */
  64. __IOM uint32_t PWM45COUNT; /* Offset: 0x04C (N/A) contain the current value of the PWM count */
  65. __IOM uint32_t PWM0CMP; /* Offset: 0x050 (R/W) contain a value to be compared against the counter */
  66. __IOM uint32_t PWM1CMP; /* Offset: 0x054 (R/W) contain a value to be compared against the counter */
  67. __IOM uint32_t PWM2CMP; /* Offset: 0x058 (R/W) contain a value to be compared against the counter */
  68. __IOM uint32_t PWM3CMP; /* Offset: 0x05C (N/A) contain a value to be compared against the counter */
  69. __IOM uint32_t PWM4CMP; /* Offset: 0x060 (N/A) contain a value to be compared against the counter */
  70. __IOM uint32_t PWM5CMP; /* Offset: 0x064 (N/A) contain a value to be compared against the counter */
  71. __IOM uint32_t PWM01DB; /* Offset: 0x068 (R/W) contain the number of clock ticks to delay */
  72. __IOM uint32_t PWM23DB; /* Offset: 0x06C (R/W) contain the number of clock ticks to delayr */
  73. __IOM uint32_t PWM45DB; /* Offset: 0x070 (N/A) contain the number of clock ticks to delay */
  74. __IOM uint32_t CAPCTL; /* Offset: 0x074 (R/W) input capture control */
  75. __IOM uint32_t CAPINTEN; /* Offset: 0x078 (R/W) input capture interrupt enable */
  76. __IM uint32_t CAPRIS; /* Offset: 0x07C (R/ ) input capture raw interrupt status */
  77. __IOM uint32_t CAPIC; /* Offset: 0x080 (R/W) input capture interrupt clear */
  78. __IM uint32_t CAPIS; /* Offset: 0x084 (R/ ) input capture interrupt status */
  79. __IM uint32_t CAP01T; /* Offset: 0x088 (R/ ) input capture count value */
  80. __IM uint32_t CAP23T; /* Offset: 0x08C (R/ ) input capture count value */
  81. __IOM uint32_t CAP45T; /* Offset: 0x090 (N/A) input capture count value */
  82. __IOM uint32_t CAP01MATCH; /* Offset: 0x094 (R/W) input capture match value */
  83. __IOM uint32_t CAP23MATCH; /* Offset: 0x098 (R/W) input capture match value */
  84. __IOM uint32_t CAP45MATCH; /* Offset: 0x09C (N/A) input capture match value */
  85. __IOM uint32_t TIMINTEN; /* Offset: 0x0A0 (R/W) time interrupt enable */
  86. __IM uint32_t TIMRIS; /* Offset: 0x0A4 (R/ ) time raw interrupt stats */
  87. __IOM uint32_t TIMIC; /* Offset: 0x0A8 (R/W) time interrupt clear */
  88. __IM uint32_t TIMIS; /* Offset: 0x0AC (R/ ) time interrupt status */
  89. __IOM uint32_t TIM01LOAD; /* Offset: 0x0B0 (R/W) time load value */
  90. __IOM uint32_t TIM23LOAD; /* Offset: 0x0B4 (R/W) time load value */
  91. __IOM uint32_t TIM45LOAD; /* Offset: 0x0B8 (N/A) time load value */
  92. __IOM uint32_t TIM01COUNT; /* Offset: 0x0BC (R/W) time current count time */
  93. __IOM uint32_t TIM23COUNT; /* Offset: 0x0C0 (R/W) time current count time */
  94. __IOM uint32_t TIM45COUNT; /* Offset: 0x0C4 (R/W) time current count time */
  95. } ck_pwm_reg_t;
  96. #endif /* __CK_PWM_H */