timer_group_struct.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _SOC_TIMG_STRUCT_H_
  14. #define _SOC_TIMG_STRUCT_H_
  15. typedef volatile struct {
  16. struct{
  17. union {
  18. struct {
  19. uint32_t reserved0: 10;
  20. uint32_t alarm_en: 1; /*When set alarm is enabled*/
  21. uint32_t level_int_en: 1; /*When set level type interrupt will be generated during alarm*/
  22. uint32_t edge_int_en: 1; /*When set edge type interrupt will be generated during alarm*/
  23. uint32_t divider: 16; /*Timer clock (T0/1_clk) pre-scale value.*/
  24. uint32_t autoreload: 1; /*When set timer 0/1 auto-reload at alarming is enabled*/
  25. uint32_t increase: 1; /*When set timer 0/1 time-base counter increment. When cleared timer 0 time-base counter decrement.*/
  26. uint32_t enable: 1; /*When set timer 0/1 time-base counter is enabled*/
  27. };
  28. uint32_t val;
  29. } config;
  30. uint32_t cnt_low; /*Register to store timer 0/1 time-base counter current value lower 32 bits.*/
  31. uint32_t cnt_high; /*Register to store timer 0 time-base counter current value higher 32 bits.*/
  32. uint32_t update; /*Write any value will trigger a timer 0 time-base counter value update (timer 0 current value will be stored in registers above)*/
  33. uint32_t alarm_low; /*Timer 0 time-base counter value lower 32 bits that will trigger the alarm*/
  34. uint32_t alarm_high; /*Timer 0 time-base counter value higher 32 bits that will trigger the alarm*/
  35. uint32_t load_low; /*Lower 32 bits of the value that will load into timer 0 time-base counter*/
  36. uint32_t load_high; /*higher 32 bits of the value that will load into timer 0 time-base counter*/
  37. uint32_t reload; /*Write any value will trigger timer 0 time-base counter reload*/
  38. } hw_timer[2];
  39. union {
  40. struct {
  41. uint32_t reserved0: 14;
  42. uint32_t flashboot_mod_en: 1; /*When set flash boot protection is enabled*/
  43. uint32_t sys_reset_length: 3; /*length of system reset selection. 0: 100ns 1: 200ns 2: 300ns 3: 400ns 4: 500ns 5: 800ns 6: 1.6us 7: 3.2us*/
  44. uint32_t cpu_reset_length: 3; /*length of CPU reset selection. 0: 100ns 1: 200ns 2: 300ns 3: 400ns 4: 500ns 5: 800ns 6: 1.6us 7: 3.2us*/
  45. uint32_t level_int_en: 1; /*When set level type interrupt generation is enabled*/
  46. uint32_t edge_int_en: 1; /*When set edge type interrupt generation is enabled*/
  47. uint32_t stg3: 2; /*Stage 3 configuration. 0: off 1: interrupt 2: reset CPU 3: reset system*/
  48. uint32_t stg2: 2; /*Stage 2 configuration. 0: off 1: interrupt 2: reset CPU 3: reset system*/
  49. uint32_t stg1: 2; /*Stage 1 configuration. 0: off 1: interrupt 2: reset CPU 3: reset system*/
  50. uint32_t stg0: 2; /*Stage 0 configuration. 0: off 1: interrupt 2: reset CPU 3: reset system*/
  51. uint32_t en: 1; /*When set SWDT is enabled*/
  52. };
  53. uint32_t val;
  54. } wdt_config0;
  55. union {
  56. struct {
  57. uint32_t reserved0: 16;
  58. uint32_t clk_prescale:16; /*SWDT clock prescale value. Period = 12.5ns * value stored in this register*/
  59. };
  60. uint32_t val;
  61. } wdt_config1;
  62. uint32_t wdt_config2; /*Stage 0 timeout value in SWDT clock cycles*/
  63. uint32_t wdt_config3; /*Stage 1 timeout value in SWDT clock cycles*/
  64. uint32_t wdt_config4; /*Stage 2 timeout value in SWDT clock cycles*/
  65. uint32_t wdt_config5; /*Stage 3 timeout value in SWDT clock cycles*/
  66. uint32_t wdt_feed; /*Write any value will feed SWDT*/
  67. uint32_t wdt_wprotect; /*If change its value from default then write protection is on.*/
  68. union {
  69. struct {
  70. uint32_t reserved0: 12;
  71. uint32_t start_cycling: 1;
  72. uint32_t clk_sel: 2;
  73. uint32_t rdy: 1;
  74. uint32_t max: 15;
  75. uint32_t start: 1;
  76. };
  77. uint32_t val;
  78. } rtc_cali_cfg;
  79. union {
  80. struct {
  81. uint32_t reserved0: 7;
  82. uint32_t value:25;
  83. };
  84. uint32_t val;
  85. } rtc_cali_cfg1;
  86. union {
  87. struct {
  88. uint32_t reserved0: 7;
  89. uint32_t rtc_only: 1;
  90. uint32_t cpst_en: 1;
  91. uint32_t lac_en: 1;
  92. uint32_t alarm_en: 1;
  93. uint32_t level_int_en: 1;
  94. uint32_t edge_int_en: 1;
  95. uint32_t divider: 16;
  96. uint32_t autoreload: 1;
  97. uint32_t increase: 1;
  98. uint32_t en: 1;
  99. };
  100. uint32_t val;
  101. } lactconfig;
  102. union {
  103. struct {
  104. uint32_t reserved0: 6;
  105. uint32_t step_len:26;
  106. };
  107. uint32_t val;
  108. } lactrtc;
  109. uint32_t lactlo; /**/
  110. uint32_t lacthi; /**/
  111. uint32_t lactupdate; /**/
  112. uint32_t lactalarmlo; /**/
  113. uint32_t lactalarmhi; /**/
  114. uint32_t lactloadlo; /**/
  115. uint32_t lactloadhi; /**/
  116. uint32_t lactload; /**/
  117. union {
  118. struct {
  119. uint32_t t0: 1; /*interrupt when timer0 alarm*/
  120. uint32_t t1: 1; /*interrupt when timer1 alarm*/
  121. uint32_t wdt: 1; /*Interrupt when an interrupt stage timeout*/
  122. uint32_t lact: 1;
  123. uint32_t reserved4: 28;
  124. };
  125. uint32_t val;
  126. } int_ena;
  127. union {
  128. struct {
  129. uint32_t t0: 1; /*interrupt when timer0 alarm*/
  130. uint32_t t1: 1; /*interrupt when timer1 alarm*/
  131. uint32_t wdt: 1; /*Interrupt when an interrupt stage timeout*/
  132. uint32_t lact: 1;
  133. uint32_t reserved4:28;
  134. };
  135. uint32_t val;
  136. } int_raw;
  137. union {
  138. struct {
  139. uint32_t t0: 1; /*interrupt when timer0 alarm*/
  140. uint32_t t1: 1; /*interrupt when timer1 alarm*/
  141. uint32_t wdt: 1; /*Interrupt when an interrupt stage timeout*/
  142. uint32_t lact: 1;
  143. uint32_t reserved4: 28;
  144. };
  145. uint32_t val;
  146. } int_st_timers;
  147. union {
  148. struct {
  149. uint32_t t0: 1; /*interrupt when timer0 alarm*/
  150. uint32_t t1: 1; /*interrupt when timer1 alarm*/
  151. uint32_t wdt: 1; /*Interrupt when an interrupt stage timeout*/
  152. uint32_t lact: 1;
  153. uint32_t reserved4: 28;
  154. };
  155. uint32_t val;
  156. } int_clr_timers;
  157. uint32_t reserved_a8;
  158. uint32_t reserved_ac;
  159. uint32_t reserved_b0;
  160. uint32_t reserved_b4;
  161. uint32_t reserved_b8;
  162. uint32_t reserved_bc;
  163. uint32_t reserved_c0;
  164. uint32_t reserved_c4;
  165. uint32_t reserved_c8;
  166. uint32_t reserved_cc;
  167. uint32_t reserved_d0;
  168. uint32_t reserved_d4;
  169. uint32_t reserved_d8;
  170. uint32_t reserved_dc;
  171. uint32_t reserved_e0;
  172. uint32_t reserved_e4;
  173. uint32_t reserved_e8;
  174. uint32_t reserved_ec;
  175. uint32_t reserved_f0;
  176. uint32_t reserved_f4;
  177. union {
  178. struct {
  179. uint32_t date:28; /*Version of this regfile*/
  180. uint32_t reserved28: 4;
  181. };
  182. uint32_t val;
  183. } timg_date;
  184. union {
  185. struct {
  186. uint32_t reserved0: 31;
  187. uint32_t en: 1; /*Force clock enable for this regfile*/
  188. };
  189. uint32_t val;
  190. } clk;
  191. } timg_dev_t;
  192. extern timg_dev_t TIMERG0;
  193. extern timg_dev_t TIMERG1;
  194. #endif /* _SOC_TIMG_STRUCT_H_ */