hpm_sysctl_drv.h 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  1. /**
  2. * Copyright (c) 2022-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_SYSCTL_DRV_H
  8. #define HPM_SYSCTL_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_sysctl_regs.h"
  11. /**
  12. *
  13. * @brief SYSCTL driver APIs
  14. * @defgroup sysctl_interface SYSCTL driver APIs
  15. * @ingroup io_interfaces
  16. * @{
  17. */
  18. /**
  19. * @brief Retention domains
  20. */typedef enum {
  21. sysctl_retention_domain_sys = 0,
  22. sysctl_retention_domain_cpu0 = 2,
  23. sysctl_retention_domain_cpu1 = 4,
  24. sysctl_retention_domain_xtal24m = 6,
  25. sysctl_retention_domain_pll0 = 7,
  26. sysctl_retention_domain_pll1 = 8,
  27. sysctl_retention_domain_pll2 = 9,
  28. } sysctl_retention_domain_t;
  29. /**
  30. * @brief Clock presets
  31. */
  32. typedef enum {
  33. sysctl_preset_0 = 1 << 0,
  34. sysctl_preset_1 = 1 << 1,
  35. sysctl_preset_2 = 1 << 2,
  36. sysctl_preset_3 = 1 << 3,
  37. } sysctl_preset_t;
  38. /**
  39. * @brief Reset domains
  40. */
  41. typedef enum {
  42. sysctl_reset_domain_soc = 0,
  43. sysctl_reset_domain_cpu0,
  44. sysctl_reset_domain_cpu1,
  45. } sysctl_reset_domain_t;
  46. /**
  47. * @brief Resource
  48. */
  49. typedef enum {
  50. sysctl_resource_cpu0 = SYSCTL_RESOURCE_CPU0,
  51. sysctl_resource_cpx0 = SYSCTL_RESOURCE_CPX0,
  52. sysctl_resource_cpu1 = SYSCTL_RESOURCE_CPU1,
  53. sysctl_resource_cpx1 = SYSCTL_RESOURCE_CPX1,
  54. sysctl_resource_pow_cpu0 = SYSCTL_RESOURCE_POW_CPU0,
  55. sysctl_resource_pow_cpu1 = SYSCTL_RESOURCE_POW_CPU1,
  56. sysctl_resource_rst_soc = SYSCTL_RESOURCE_RST_SOC,
  57. sysctl_resource_rst_cpu0 = SYSCTL_RESOURCE_RST_CPU0,
  58. sysctl_resource_rst_cpu1 = SYSCTL_RESOURCE_RST_CPU1,
  59. sysctl_resource_xtal = SYSCTL_RESOURCE_CLK_SRC_XTAL,
  60. sysctl_resource_pll0 = SYSCTL_RESOURCE_CLK_SRC_PLL0,
  61. sysctl_resource_clk0_pll0 = SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL0,
  62. sysctl_resource_clk1_pll0 = SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL0,
  63. sysctl_resource_clk2_pll0 = SYSCTL_RESOURCE_CLK_SRC_CLK2_PLL0,
  64. sysctl_resource_pll1 = SYSCTL_RESOURCE_CLK_SRC_PLL1,
  65. sysctl_resource_clk0_pll1 = SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL1,
  66. sysctl_resource_clk1_pll1 = SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL1,
  67. sysctl_resource_pll2 = SYSCTL_RESOURCE_CLK_SRC_PLL2,
  68. sysctl_resource_clk0_pll2 = SYSCTL_RESOURCE_CLK_SRC_CLK0_PLL2,
  69. sysctl_resource_clk1_pll2 = SYSCTL_RESOURCE_CLK_SRC_CLK1_PLL2,
  70. sysctl_resource_pll0_ref = SYSCTL_RESOURCE_CLK_SRC_PLL0_REF,
  71. sysctl_resource_pll1_ref = SYSCTL_RESOURCE_CLK_SRC_PLL1_REF,
  72. sysctl_resource_pll2_ref = SYSCTL_RESOURCE_CLK_SRC_PLL2_REF,
  73. sysctl_resource_clk_top_cpu0 = SYSCTL_RESOURCE_CLK_TOP_CPU0,
  74. sysctl_resource_clk_top_mchtmr0 = SYSCTL_RESOURCE_CLK_TOP_MCT0,
  75. sysctl_resource_clk_top_mchtmr1 = SYSCTL_RESOURCE_CLK_TOP_MCT1,
  76. sysctl_resource_clk_top_xpi0 = SYSCTL_RESOURCE_CLK_TOP_XPI0,
  77. sysctl_resource_clk_top_gptmr0 = SYSCTL_RESOURCE_CLK_TOP_TMR0,
  78. sysctl_resource_clk_top_gptmr1 = SYSCTL_RESOURCE_CLK_TOP_TMR1,
  79. sysctl_resource_clk_top_gptmr2 = SYSCTL_RESOURCE_CLK_TOP_TMR2,
  80. sysctl_resource_clk_top_gptmr3 = SYSCTL_RESOURCE_CLK_TOP_TMR3,
  81. sysctl_resource_clk_top_uart0 = SYSCTL_RESOURCE_CLK_TOP_URT0,
  82. sysctl_resource_clk_top_uart1 = SYSCTL_RESOURCE_CLK_TOP_URT1,
  83. sysctl_resource_clk_top_uart2 = SYSCTL_RESOURCE_CLK_TOP_URT2,
  84. sysctl_resource_clk_top_uart3 = SYSCTL_RESOURCE_CLK_TOP_URT3,
  85. sysctl_resource_clk_top_uart4 = SYSCTL_RESOURCE_CLK_TOP_URT4,
  86. sysctl_resource_clk_top_uart5 = SYSCTL_RESOURCE_CLK_TOP_URT5,
  87. sysctl_resource_clk_top_uart6 = SYSCTL_RESOURCE_CLK_TOP_URT6,
  88. sysctl_resource_clk_top_uart7 = SYSCTL_RESOURCE_CLK_TOP_URT7,
  89. sysctl_resource_clk_top_i2c0 = SYSCTL_RESOURCE_CLK_TOP_I2C0,
  90. sysctl_resource_clk_top_i2c1 = SYSCTL_RESOURCE_CLK_TOP_I2C1,
  91. sysctl_resource_clk_top_i2c2 = SYSCTL_RESOURCE_CLK_TOP_I2C2,
  92. sysctl_resource_clk_top_i2c3 = SYSCTL_RESOURCE_CLK_TOP_I2C3,
  93. sysctl_resource_clk_top_spi0 = SYSCTL_RESOURCE_CLK_TOP_SPI0,
  94. sysctl_resource_clk_top_spi1 = SYSCTL_RESOURCE_CLK_TOP_SPI1,
  95. sysctl_resource_clk_top_spi2 = SYSCTL_RESOURCE_CLK_TOP_SPI2,
  96. sysctl_resource_clk_top_spi3 = SYSCTL_RESOURCE_CLK_TOP_SPI3,
  97. sysctl_resource_clk_top_can0 = SYSCTL_RESOURCE_CLK_TOP_CAN0,
  98. sysctl_resource_clk_top_can1 = SYSCTL_RESOURCE_CLK_TOP_CAN1,
  99. sysctl_resource_clk_top_can2 = SYSCTL_RESOURCE_CLK_TOP_CAN2,
  100. sysctl_resource_clk_top_can3 = SYSCTL_RESOURCE_CLK_TOP_CAN3,
  101. sysctl_resource_clk_top_ptpc = SYSCTL_RESOURCE_CLK_TOP_PTPC,
  102. sysctl_resource_clk_top_ana0 = SYSCTL_RESOURCE_CLK_TOP_ANA0,
  103. sysctl_resource_clk_top_ana1 = SYSCTL_RESOURCE_CLK_TOP_ANA1,
  104. sysctl_resource_clk_top_ana2 = SYSCTL_RESOURCE_CLK_TOP_ANA2,
  105. sysctl_resource_clk_top_ana3 = SYSCTL_RESOURCE_CLK_TOP_ANA3,
  106. sysctl_resource_clk_top_ana4 = SYSCTL_RESOURCE_CLK_TOP_ANA4,
  107. sysctl_resource_clk_top_ref0 = SYSCTL_RESOURCE_CLK_TOP_REF0,
  108. sysctl_resource_clk_top_ref1 = SYSCTL_RESOURCE_CLK_TOP_REF1,
  109. sysctl_resource_clk_top_lin0 = SYSCTL_RESOURCE_CLK_TOP_LIN0,
  110. sysctl_resource_clk_top_lin1 = SYSCTL_RESOURCE_CLK_TOP_LIN1,
  111. sysctl_resource_clk_top_lin2 = SYSCTL_RESOURCE_CLK_TOP_LIN2,
  112. sysctl_resource_clk_top_lin3 = SYSCTL_RESOURCE_CLK_TOP_LIN3,
  113. sysctl_resource_clk_top_adc0 = SYSCTL_RESOURCE_CLK_TOP_ADC0,
  114. sysctl_resource_clk_top_adc1 = SYSCTL_RESOURCE_CLK_TOP_ADC1,
  115. sysctl_resource_clk_top_adc2 = SYSCTL_RESOURCE_CLK_TOP_ADC2,
  116. sysctl_resource_clk_top_dac0 = SYSCTL_RESOURCE_CLK_TOP_DAC0,
  117. sysctl_resource_clk_top_dac1 = SYSCTL_RESOURCE_CLK_TOP_DAC1,
  118. sysctl_resource_linkable_start = 256,
  119. sysctl_resource_ahbp = SYSCTL_RESOURCE_AHBP,
  120. sysctl_resource_axis = SYSCTL_RESOURCE_AXIS,
  121. sysctl_resource_axic = SYSCTL_RESOURCE_AXIC,
  122. sysctl_resource_lmm0 = SYSCTL_RESOURCE_LMM0,
  123. sysctl_resource_mchtmr0 = SYSCTL_RESOURCE_MCT0,
  124. sysctl_resource_lmm1 = SYSCTL_RESOURCE_LMM1,
  125. sysctl_resource_mchtmr1 = SYSCTL_RESOURCE_MCT1,
  126. sysctl_resource_rom0 = SYSCTL_RESOURCE_ROM0,
  127. sysctl_resource_ram0 = SYSCTL_RESOURCE_RAM0,
  128. sysctl_resource_i2c0 = SYSCTL_RESOURCE_I2C0,
  129. sysctl_resource_i2c1 = SYSCTL_RESOURCE_I2C1,
  130. sysctl_resource_i2c2 = SYSCTL_RESOURCE_I2C2,
  131. sysctl_resource_i2c3 = SYSCTL_RESOURCE_I2C3,
  132. sysctl_resource_gptmr0 = SYSCTL_RESOURCE_TMR0,
  133. sysctl_resource_gptmr1 = SYSCTL_RESOURCE_TMR1,
  134. sysctl_resource_gptmr2 = SYSCTL_RESOURCE_TMR2,
  135. sysctl_resource_gptmr3 = SYSCTL_RESOURCE_TMR3,
  136. sysctl_resource_gpio = SYSCTL_RESOURCE_GPIO,
  137. sysctl_resource_adc0 = SYSCTL_RESOURCE_ADC0,
  138. sysctl_resource_adc1 = SYSCTL_RESOURCE_ADC1,
  139. sysctl_resource_adc2 = SYSCTL_RESOURCE_ADC2,
  140. sysctl_resource_dac0 = SYSCTL_RESOURCE_DAC0,
  141. sysctl_resource_dac1 = SYSCTL_RESOURCE_DAC1,
  142. sysctl_resource_acmp = SYSCTL_RESOURCE_ACMP,
  143. sysctl_resource_spi0 = SYSCTL_RESOURCE_SPI0,
  144. sysctl_resource_spi1 = SYSCTL_RESOURCE_SPI1,
  145. sysctl_resource_spi2 = SYSCTL_RESOURCE_SPI2,
  146. sysctl_resource_spi3 = SYSCTL_RESOURCE_SPI3,
  147. sysctl_resource_sdm0 = SYSCTL_RESOURCE_SDM0,
  148. sysctl_resource_uart0 = SYSCTL_RESOURCE_URT0,
  149. sysctl_resource_uart1 = SYSCTL_RESOURCE_URT1,
  150. sysctl_resource_uart2 = SYSCTL_RESOURCE_URT2,
  151. sysctl_resource_uart3 = SYSCTL_RESOURCE_URT3,
  152. sysctl_resource_uart4 = SYSCTL_RESOURCE_URT4,
  153. sysctl_resource_uart5 = SYSCTL_RESOURCE_URT5,
  154. sysctl_resource_uart6 = SYSCTL_RESOURCE_URT6,
  155. sysctl_resource_uart7 = SYSCTL_RESOURCE_URT7,
  156. sysctl_resource_lin0 = SYSCTL_RESOURCE_LIN0,
  157. sysctl_resource_lin1 = SYSCTL_RESOURCE_LIN1,
  158. sysctl_resource_lin2 = SYSCTL_RESOURCE_LIN2,
  159. sysctl_resource_lin3 = SYSCTL_RESOURCE_LIN3,
  160. sysctl_resource_ptpc = SYSCTL_RESOURCE_PTPC,
  161. sysctl_resource_can0 = SYSCTL_RESOURCE_CAN0,
  162. sysctl_resource_can1 = SYSCTL_RESOURCE_CAN1,
  163. sysctl_resource_can2 = SYSCTL_RESOURCE_CAN2,
  164. sysctl_resource_can3 = SYSCTL_RESOURCE_CAN3,
  165. sysctl_resource_wdg0 = SYSCTL_RESOURCE_WDG0,
  166. sysctl_resource_wdg1 = SYSCTL_RESOURCE_WDG1,
  167. sysctl_resource_mbx0 = SYSCTL_RESOURCE_MBX0,
  168. sysctl_resource_mbx1 = SYSCTL_RESOURCE_MBX1,
  169. sysctl_resource_crc0 = SYSCTL_RESOURCE_CRC0,
  170. sysctl_resource_mot0 = SYSCTL_RESOURCE_MOT0,
  171. sysctl_resource_mot1 = SYSCTL_RESOURCE_MOT1,
  172. sysctl_resource_mot2 = SYSCTL_RESOURCE_MOT2,
  173. sysctl_resource_mot3 = SYSCTL_RESOURCE_MOT3,
  174. sysctl_resource_msyn = SYSCTL_RESOURCE_MSYN,
  175. sysctl_resource_xpi0 = SYSCTL_RESOURCE_XPI0,
  176. sysctl_resource_dma0 = SYSCTL_RESOURCE_HDMA,
  177. sysctl_resource_dma1 = SYSCTL_RESOURCE_XDMA,
  178. sysctl_resource_kman = SYSCTL_RESOURCE_KMAN,
  179. sysctl_resource_sdp0 = SYSCTL_RESOURCE_SDP0,
  180. sysctl_resource_rng0 = SYSCTL_RESOURCE_RNG0,
  181. sysctl_resource_tsns = SYSCTL_RESOURCE_TSNS,
  182. sysctl_resource_usb0 = SYSCTL_RESOURCE_USB0,
  183. sysctl_resource_ref0 = SYSCTL_RESOURCE_REF0,
  184. sysctl_resource_ref1 = SYSCTL_RESOURCE_REF1,
  185. sysctl_resource_linkable_end,
  186. sysctl_resource_end = sysctl_resource_linkable_end,
  187. } sysctl_resource_t;
  188. /**
  189. * @brief Resource modes
  190. */
  191. typedef enum {
  192. sysctl_resource_mode_auto = 0, /*!< Resource clock is automatically managed by system request */
  193. sysctl_resource_mode_force_on, /*!< Force the resource clock on */
  194. sysctl_resource_mode_force_off, /*!< Force the resource clock off */
  195. } sysctl_resource_mode_t;
  196. /**
  197. * @brief Clock nodes
  198. */
  199. typedef enum {
  200. clock_node_mchtmr0 = SYSCTL_CLOCK_CLK_TOP_MCT0,
  201. clock_node_mchtmr1 = SYSCTL_CLOCK_CLK_TOP_MCT1,
  202. clock_node_xpi0 = SYSCTL_CLOCK_CLK_TOP_XPI0,
  203. clock_node_gptmr0 = SYSCTL_CLOCK_CLK_TOP_TMR0,
  204. clock_node_gptmr1 = SYSCTL_CLOCK_CLK_TOP_TMR1,
  205. clock_node_gptmr2 = SYSCTL_CLOCK_CLK_TOP_TMR2,
  206. clock_node_gptmr3 = SYSCTL_CLOCK_CLK_TOP_TMR3,
  207. clock_node_uart0 = SYSCTL_CLOCK_CLK_TOP_URT0,
  208. clock_node_uart1 = SYSCTL_CLOCK_CLK_TOP_URT1,
  209. clock_node_uart2 = SYSCTL_CLOCK_CLK_TOP_URT2,
  210. clock_node_uart3 = SYSCTL_CLOCK_CLK_TOP_URT3,
  211. clock_node_uart4 = SYSCTL_CLOCK_CLK_TOP_URT4,
  212. clock_node_uart5 = SYSCTL_CLOCK_CLK_TOP_URT5,
  213. clock_node_uart6 = SYSCTL_CLOCK_CLK_TOP_URT6,
  214. clock_node_uart7 = SYSCTL_CLOCK_CLK_TOP_URT7,
  215. clock_node_i2c0 = SYSCTL_CLOCK_CLK_TOP_I2C0,
  216. clock_node_i2c1 = SYSCTL_CLOCK_CLK_TOP_I2C1,
  217. clock_node_i2c2 = SYSCTL_CLOCK_CLK_TOP_I2C2,
  218. clock_node_i2c3 = SYSCTL_CLOCK_CLK_TOP_I2C3,
  219. clock_node_spi0 = SYSCTL_CLOCK_CLK_TOP_SPI0,
  220. clock_node_spi1 = SYSCTL_CLOCK_CLK_TOP_SPI1,
  221. clock_node_spi2 = SYSCTL_CLOCK_CLK_TOP_SPI2,
  222. clock_node_spi3 = SYSCTL_CLOCK_CLK_TOP_SPI3,
  223. clock_node_can0 = SYSCTL_CLOCK_CLK_TOP_CAN0,
  224. clock_node_can1 = SYSCTL_CLOCK_CLK_TOP_CAN1,
  225. clock_node_can2 = SYSCTL_CLOCK_CLK_TOP_CAN2,
  226. clock_node_can3 = SYSCTL_CLOCK_CLK_TOP_CAN3,
  227. clock_node_ptpc = SYSCTL_CLOCK_CLK_TOP_PTPC,
  228. clock_node_ana0 = SYSCTL_CLOCK_CLK_TOP_ANA0,
  229. clock_node_ana1 = SYSCTL_CLOCK_CLK_TOP_ANA1,
  230. clock_node_ana2 = SYSCTL_CLOCK_CLK_TOP_ANA2,
  231. clock_node_ana3 = SYSCTL_CLOCK_CLK_TOP_ANA3,
  232. clock_node_ana4 = SYSCTL_CLOCK_CLK_TOP_ANA4,
  233. clock_node_ref0 = SYSCTL_CLOCK_CLK_TOP_REF0,
  234. clock_node_ref1 = SYSCTL_CLOCK_CLK_TOP_REF1,
  235. clock_node_lin0 = SYSCTL_CLOCK_CLK_TOP_LIN0,
  236. clock_node_lin1 = SYSCTL_CLOCK_CLK_TOP_LIN1,
  237. clock_node_lin2 = SYSCTL_CLOCK_CLK_TOP_LIN2,
  238. clock_node_lin3 = SYSCTL_CLOCK_CLK_TOP_LIN3,
  239. clock_node_adc_start,
  240. clock_node_adc0 = clock_node_adc_start,
  241. clock_node_adc1,
  242. clock_node_adc2,
  243. clock_node_adc3,
  244. clock_node_dac_start,
  245. clock_node_dac0 = clock_node_dac_start,
  246. clock_node_dac1,
  247. clock_node_end,
  248. clock_node_core_start = 0xfc,
  249. clock_node_cpu0 = clock_node_core_start,
  250. clock_node_cpu1 = clock_node_cpu0,
  251. clock_node_axi,
  252. clock_node_ahb,
  253. } clock_node_t;
  254. /**
  255. * @brief General clock sources
  256. */
  257. typedef enum {
  258. clock_source_osc0_clk0 = 0,
  259. clock_source_pll0_clk0 = 1,
  260. clock_source_pll0_clk1 = 2,
  261. clock_source_pll0_clk2 = 3,
  262. clock_source_pll1_clk0 = 4,
  263. clock_source_pll1_clk1 = 5,
  264. clock_source_pll2_clk0 = 6,
  265. clock_source_pll2_clk1 = 7,
  266. clock_source_general_source_end,
  267. } clock_source_t;
  268. /**
  269. * @brief ADC clock sources
  270. */
  271. typedef enum {
  272. clock_source_adc_ana_clock = 0,
  273. clock_source_adc_ahb_clock = 1,
  274. clock_source_adc_clk_end,
  275. } clock_source_adc_t;
  276. /**
  277. * @brief DAC clock sources
  278. */
  279. typedef enum {
  280. clock_source_dac_ana_clock = 0,
  281. clock_source_dac_ahb_clock = 1,
  282. clock_source_dac_clk_end,
  283. } clock_source_dac_t;
  284. /**
  285. * @brief CPU low power mode
  286. */
  287. typedef enum {
  288. cpu_lp_mode_gate_cpu_clock = 0,
  289. cpu_lp_mode_trigger_system_lp = 0x1,
  290. cpu_lp_mode_ungate_cpu_clock = 0x2,
  291. } cpu_lp_mode_t;
  292. /**
  293. * @brief Monitor targets
  294. */
  295. /* Monitor Target types */
  296. typedef enum {
  297. monitor_target_clk_32k = 0,
  298. monitor_target_clk_irc24m = 1,
  299. monitor_target_clk_xtal_24m = 2,
  300. monitor_target_clk_usb0_phy = 3,
  301. monitor_target_clk_usb1_phy = 4,
  302. monitor_target_clk0_osc0 = 8,
  303. monitor_target_clk0_pll0 = 9,
  304. monitor_target_clk1_pll0 = 10,
  305. monitor_target_clk2_pll0 = 11,
  306. monitor_target_clk0_pll1 = 12,
  307. monitor_target_clk1_pll1 = 13,
  308. monitor_target_clk0_pll2 = 14,
  309. monitor_target_clk1_pll2 = 15,
  310. monitor_target_clk_top_cpu0 = 128,
  311. monitor_target_clk_top_mchtmr0 = 129,
  312. monitor_target_clk_top_mchtmr1 = 130,
  313. monitor_target_clk_top_xpi0 = 131,
  314. monitor_target_clk_top_gptmr0 = 132,
  315. monitor_target_clk_top_gptmr1 = 133,
  316. monitor_target_clk_top_gptmr2 = 134,
  317. monitor_target_clk_top_gptmr3 = 135,
  318. monitor_target_clk_top_uart0 = 136,
  319. monitor_target_clk_top_uart1 = 137,
  320. monitor_target_clk_top_uart2 = 138,
  321. monitor_target_clk_top_uart3 = 139,
  322. monitor_target_clk_top_uart4 = 140,
  323. monitor_target_clk_top_uart5 = 141,
  324. monitor_target_clk_top_uart6 = 142,
  325. monitor_target_clk_top_uart7 = 143,
  326. monitor_target_clk_top_i2c0 = 144,
  327. monitor_target_clk_top_i2c1 = 145,
  328. monitor_target_clk_top_i2c2 = 146,
  329. monitor_target_clk_top_i2c3 = 147,
  330. monitor_target_clk_top_spi0 = 148,
  331. monitor_target_clk_top_spi1 = 149,
  332. monitor_target_clk_top_spi2 = 150,
  333. monitor_target_clk_top_spi3 = 151,
  334. monitor_target_clk_top_can0 = 152,
  335. monitor_target_clk_top_can1 = 153,
  336. monitor_target_clk_top_can2 = 154,
  337. monitor_target_clk_top_can3 = 155,
  338. monitor_target_clk_top_ptpc = 156,
  339. monitor_target_clk_top_ana0 = 157,
  340. monitor_target_clk_top_ana1 = 158,
  341. monitor_target_clk_top_ana2 = 159,
  342. monitor_target_clk_top_ana3 = 160,
  343. monitor_target_clk_top_ana4 = 161,
  344. monitor_target_clk_top_ref0 = 162,
  345. monitor_target_clk_top_ref1 = 163,
  346. monitor_target_clk_top_lin0 = 164,
  347. monitor_target_clk_top_lin1 = 165,
  348. monitor_target_clk_top_lin2 = 166,
  349. monitor_target_clk_top_lin3 = 167,
  350. } monitor_target_t;
  351. /**
  352. * @brief Monitor work mode
  353. */
  354. typedef enum {
  355. monitor_work_mode_compare = 0,
  356. monitor_work_mode_record = 1,
  357. } monitor_work_mode_t;
  358. /**
  359. * @brief Monitor accuracy
  360. */
  361. typedef enum {
  362. monitor_accuracy_1khz = 0,
  363. monitor_accuracy_1hz = 1,
  364. } monitor_accuracy_t;
  365. /**
  366. * @brief Monitor reference clock source
  367. */
  368. typedef enum {
  369. monitor_reference_32khz = 0,
  370. monitor_reference_24mhz = 1,
  371. } monitor_reference_t;
  372. typedef enum {
  373. cpu_event_flag_mask_reset = SYSCTL_CPU_LP_RESET_FLAG_MASK,
  374. cpu_event_flag_mask_sleep = SYSCTL_CPU_LP_SLEEP_FLAG_MASK,
  375. cpu_event_flag_mask_wake = SYSCTL_CPU_LP_WAKE_FLAG_MASK,
  376. cpu_event_flag_mask_all = SYSCTL_CPU_LP_RESET_FLAG_MASK | SYSCTL_CPU_LP_SLEEP_FLAG_MASK | SYSCTL_CPU_LP_WAKE_FLAG_MASK,
  377. } cpu_event_flag_mask_t;
  378. /**
  379. * @brief Monitor config
  380. */
  381. typedef struct monitor_config {
  382. uint8_t divide_by; /**< Divider to be used for OBS output to pads */
  383. monitor_work_mode_t mode; /**< Monitor work mode */
  384. monitor_accuracy_t accuracy; /**< Monitor reference accuracy */
  385. monitor_reference_t reference; /**< Monitor reference clock source */
  386. monitor_target_t target; /**< Monitor target */
  387. bool start_measure; /**< Start flag */
  388. bool enable_output; /**< Enable output to pads if true */
  389. uint32_t high_limit; /**< Maximum frequency at compare mode */
  390. uint32_t low_limit; /**< Minimum frequency at compare mode */
  391. } monitor_config_t;
  392. #ifdef __cplusplus
  393. extern "C" {
  394. #endif
  395. /**
  396. * @brief Check if monitor result is valid
  397. *
  398. * @param[in] ptr SYSCTL_Type base address
  399. * @param[in] monitor_index specific monitor instance to be used
  400. *
  401. * @return true if it is valid
  402. */
  403. static inline bool sysctl_monitor_result_is_valid(SYSCTL_Type *ptr, uint8_t monitor_index)
  404. {
  405. return SYSCTL_MONITOR_CONTROL_VALID_GET(ptr->MONITOR[monitor_index].CONTROL);
  406. }
  407. /**
  408. * @brief Get target monitor instance result
  409. *
  410. * @param[in] ptr SYSCTL_Type base address
  411. * @param[in] monitor_index specific monitor instance to be used
  412. * @return value of monitor result measured
  413. */
  414. static inline uint32_t sysctl_monitor_get_current_result(SYSCTL_Type *ptr, uint8_t monitor_index)
  415. {
  416. while (!sysctl_monitor_result_is_valid(ptr, monitor_index)) {
  417. }
  418. return ptr->MONITOR[monitor_index].CURRENT;
  419. }
  420. /**
  421. * @brief Set work mode for target monitor instance
  422. *
  423. * @param[in] ptr SYSCTL_Type base address
  424. * @param[in] monitor_index specific monitor instance to be used
  425. * @param[in] mode monitor_work_mode_compare, monitor_work_mode_record
  426. */
  427. static inline void sysctl_monitor_set_work_mode(SYSCTL_Type *ptr, uint8_t monitor_index, monitor_work_mode_t mode)
  428. {
  429. ptr->MONITOR[monitor_index].CONTROL = (ptr->MONITOR[monitor_index].CONTROL & ~SYSCTL_MONITOR_CONTROL_MODE_MASK) |
  430. (SYSCTL_MONITOR_CONTROL_MODE_SET(mode));
  431. }
  432. /**
  433. * @brief Set minimum frequency for target monitor instance
  434. *
  435. * @param[in] ptr SYSCTL_Type base address
  436. * @param[in] monitor_index specific monitor instance to be used
  437. * @param[in] limit measurement low limit
  438. */
  439. static inline hpm_stat_t sysctl_monitor_set_limit_low(SYSCTL_Type *ptr, uint8_t monitor_index, uint32_t limit)
  440. {
  441. if (ptr->MONITOR[monitor_index].CONTROL & SYSCTL_MONITOR_CONTROL_MODE_MASK) {
  442. return status_invalid_argument;
  443. }
  444. ptr->MONITOR[monitor_index].LOW_LIMIT = SYSCTL_MONITOR_LOW_LIMIT_FREQUENCY_SET(limit);
  445. return status_success;
  446. }
  447. /**
  448. * @brief Set maximum frequency for target monitor instance
  449. *
  450. * @param[in] ptr SYSCTL_Type base address
  451. * @param[in] monitor_index specific monitor instance to be used
  452. * @param[in] limit measurement high limit
  453. */
  454. static inline hpm_stat_t sysctl_monitor_set_limit_high(SYSCTL_Type *ptr, uint8_t monitor_index, uint32_t limit)
  455. {
  456. if (ptr->MONITOR[monitor_index].CONTROL & SYSCTL_MONITOR_CONTROL_MODE_MASK) {
  457. return status_invalid_argument;
  458. }
  459. ptr->MONITOR[monitor_index].HIGH_LIMIT = SYSCTL_MONITOR_HIGH_LIMIT_FREQUENCY_SET(limit);
  460. return status_success;
  461. }
  462. /**
  463. * @brief Set frequency limit for target monitor instance
  464. *
  465. * @param[in] ptr SYSCTL_Type base address
  466. * @param[in] monitor_index specific monitor instance to be used
  467. * @param[in] limit_high measurement high limit
  468. * @param[in] limit_low measurement low limit
  469. */
  470. static inline hpm_stat_t sysctl_monitor_set_limit(SYSCTL_Type *ptr,
  471. uint8_t monitor_index,
  472. uint32_t limit_high,
  473. uint32_t limit_low)
  474. {
  475. if (ptr->MONITOR[monitor_index].CONTROL & SYSCTL_MONITOR_CONTROL_MODE_MASK) {
  476. return status_invalid_argument;
  477. }
  478. ptr->MONITOR[monitor_index].HIGH_LIMIT = SYSCTL_MONITOR_HIGH_LIMIT_FREQUENCY_SET(limit_high);
  479. ptr->MONITOR[monitor_index].LOW_LIMIT = SYSCTL_MONITOR_LOW_LIMIT_FREQUENCY_SET(limit_low);
  480. return status_success;
  481. }
  482. /**
  483. * @brief Get maximum frequency for target monitor instance
  484. *
  485. * @param[in] ptr SYSCTL_Type base address
  486. * @param[in] monitor_index specific monitor instance to be used
  487. * @return current high limit value
  488. */
  489. static inline uint32_t sysctl_monitor_get_limit_high(SYSCTL_Type *ptr, uint32_t monitor_index)
  490. {
  491. return SYSCTL_MONITOR_HIGH_LIMIT_FREQUENCY_GET(ptr->MONITOR[monitor_index].HIGH_LIMIT);
  492. }
  493. /**
  494. * @brief Get minimum frequency for target monitor instance
  495. *
  496. * @param[in] ptr SYSCTL_Type base address
  497. * @param[in] monitor_index specific monitor instance to be used
  498. * @return current low limit value
  499. */
  500. static inline uint32_t sysctl_monitor_get_limit_low(SYSCTL_Type *ptr, uint32_t monitor_index)
  501. {
  502. return SYSCTL_MONITOR_LOW_LIMIT_FREQUENCY_SET(ptr->MONITOR[monitor_index].LOW_LIMIT);
  503. }
  504. /**
  505. * @brief Measure specific target frequency
  506. *
  507. * @param[in] ptr SYSCTL_Type base address
  508. * @param[in] monitor_index specific monitor instance to be used
  509. * @param[in] target monitor target to be measured
  510. * @param[in] enable_output enable clock obs output
  511. * @return frequency of monitor target measured
  512. */
  513. uint32_t sysctl_monitor_measure_frequency(SYSCTL_Type *ptr,
  514. uint8_t monitor_index,
  515. monitor_target_t target,
  516. bool enable_output);
  517. /**
  518. * @brief Link current CPU core its own group
  519. *
  520. * Once it is linked, peripherals state in that group will keep on as long as this core is not in low power mode
  521. *
  522. * @param[in] ptr SYSCTL_Type base address
  523. * @param[in] cpu_index cpu index to enable its own affiliated group
  524. */
  525. static inline void sysctl_set_enable_cpu_affiliate(SYSCTL_Type *ptr, uint8_t cpu_index)
  526. {
  527. ptr->AFFILIATE[cpu_index].SET = 1 << cpu_index;
  528. }
  529. /**
  530. * @brief Unlink current CPU core with its own group
  531. *
  532. * @param[in] ptr SYSCTL_Type base address
  533. * @param[in] cpu_index cpu index to enable its own affiliated group
  534. */
  535. static inline void sysctl_set_disable_cpu_affiliate(SYSCTL_Type *ptr, uint8_t cpu_index)
  536. {
  537. ptr->AFFILIATE[cpu_index].CLEAR = 1 << cpu_index;
  538. }
  539. /**
  540. * @brief Check if any resource is busy
  541. *
  542. * @param[in] ptr SYSCTL_Type base address
  543. * @return true if any resource is busy
  544. */
  545. static inline bool sysctl_resource_any_is_busy(SYSCTL_Type *ptr)
  546. {
  547. return ptr->RESOURCE[0] & SYSCTL_RESOURCE_GLB_BUSY_MASK;
  548. }
  549. /**
  550. * @brief Check if specific target is busy
  551. *
  552. * @param[in] ptr SYSCTL_Type base address
  553. * @param[in] resource target resource index
  554. * @return true if target resource is busy
  555. */
  556. static inline bool sysctl_resource_target_is_busy(SYSCTL_Type *ptr, sysctl_resource_t resource)
  557. {
  558. return ptr->RESOURCE[resource] & SYSCTL_RESOURCE_LOC_BUSY_MASK;
  559. }
  560. /**
  561. * @brief Set target mode
  562. *
  563. * @param[in] ptr SYSCTL_Type base address
  564. * @param[in] resource target resource index
  565. * @param[in] mode target resource mode
  566. */
  567. static inline void sysctl_resource_target_set_mode(SYSCTL_Type *ptr,
  568. sysctl_resource_t resource,
  569. sysctl_resource_mode_t mode)
  570. {
  571. ptr->RESOURCE[resource] =
  572. (ptr->RESOURCE[resource] & ~SYSCTL_RESOURCE_MODE_MASK) |
  573. SYSCTL_RESOURCE_MODE_SET(mode);
  574. }
  575. /**
  576. * @brief Disable resource retention when specific CPU enters stop mode
  577. *
  578. * @param[in] ptr SYSCTL_Type base address
  579. * @param[in] cpu_index cpu index
  580. * @param[in] mask bit mask to clear
  581. */
  582. static inline void sysctl_clear_cpu_lp_retention_with_mask(SYSCTL_Type *ptr, uint8_t cpu_index, uint32_t mask)
  583. {
  584. ptr->RETENTION[cpu_index].CLEAR = mask;
  585. }
  586. /**
  587. * @brief Disable resource retention when CPU0 enters stop mode
  588. *
  589. * @param[in] ptr SYSCTL_Type base address
  590. * @param[in] mask bit mask to clear
  591. */
  592. static inline void sysctl_clear_cpu0_lp_retention_with_mask(SYSCTL_Type *ptr, uint32_t mask)
  593. {
  594. sysctl_clear_cpu_lp_retention_with_mask(ptr, 0, mask);
  595. }
  596. /**
  597. * @brief Disable resource retention when CPU1 enters stop mode
  598. *
  599. * @param[in] ptr SYSCTL_Type base address
  600. * @param[in] mask bit mask to clear
  601. */
  602. static inline void sysctl_clear_cpu1_lp_retention_with_mask(SYSCTL_Type *ptr, uint32_t mask)
  603. {
  604. sysctl_clear_cpu_lp_retention_with_mask(ptr, 1, mask);
  605. }
  606. /**
  607. * @brief Enable resource retention when specific CPU enters stop mode
  608. *
  609. * @param[in] ptr SYSCTL_Type base address
  610. * @param[in] cpu_index cpu index
  611. * @param[in] mask bit mask to set
  612. */
  613. static inline void sysctl_set_cpu_lp_retention_with_mask(SYSCTL_Type *ptr, uint8_t cpu_index, uint32_t mask)
  614. {
  615. ptr->RETENTION[cpu_index].SET = mask;
  616. }
  617. /**
  618. * @brief Enable resource retention when CPU0 enters stop mode
  619. *
  620. * @param[in] ptr SYSCTL_Type base address
  621. * @param[in] mask bit mask to set
  622. */
  623. static inline void sysctl_set_cpu0_lp_retention_with_mask(SYSCTL_Type *ptr, uint32_t mask)
  624. {
  625. sysctl_set_cpu_lp_retention_with_mask(ptr, 0, mask);
  626. }
  627. /**
  628. * @brief Enable resource retention when CPU1 enters stop mode
  629. *
  630. * @param[in] ptr SYSCTL_Type base address
  631. * @param[in] mask bit mask to set
  632. */
  633. static inline void sysctl_set_cpu1_lp_retention_with_mask(SYSCTL_Type *ptr, uint32_t mask)
  634. {
  635. sysctl_set_cpu_lp_retention_with_mask(ptr, 1, mask);
  636. }
  637. /**
  638. * @brief Enable resource retention when specific CPU enters stop mode
  639. *
  640. * @param[in] ptr SYSCTL_Type base address
  641. * @param[in] cpu_index cpu index
  642. * @param[in] value value to be set
  643. */
  644. static inline void sysctl_set_cpu_lp_retention(SYSCTL_Type *ptr, uint8_t cpu_index, uint32_t value)
  645. {
  646. ptr->RETENTION[cpu_index].VALUE = value;
  647. }
  648. /**
  649. * @brief Enable resource retention when CPU0 enters stop mode
  650. *
  651. * @param[in] ptr SYSCTL_Type base address
  652. * @param[in] value value to be set
  653. */
  654. static inline void sysctl_set_cpu0_lp_retention(SYSCTL_Type *ptr, uint32_t value)
  655. {
  656. sysctl_set_cpu_lp_retention(ptr, 0, value);
  657. }
  658. /**
  659. * @brief Enable resource retention when CPU1 enters stop mode
  660. *
  661. * @param[in] ptr SYSCTL_Type base address
  662. * @param[in] value value to be set
  663. */
  664. static inline void sysctl_set_cpu1_lp_retention(SYSCTL_Type *ptr, uint32_t value)
  665. {
  666. sysctl_set_cpu_lp_retention(ptr, 1, value);
  667. }
  668. /**
  669. * @brief Retain target domain for specific CPU
  670. *
  671. * @param[in] ptr SYSCTL_Type base address
  672. * @param[in] cpu_index CPU index
  673. * @param[in] domain target domain power to be retained
  674. * @param[in] retain_mem set true to retain memory/register of target domain
  675. */
  676. static inline void sysctl_set_cpu_lp_retain_domain(SYSCTL_Type *ptr,
  677. uint8_t cpu_index,
  678. sysctl_retention_domain_t domain,
  679. bool retain_mem)
  680. {
  681. uint8_t set_mask = 0x1;
  682. if (domain < sysctl_retention_domain_xtal24m) {
  683. set_mask = retain_mem ? 0x3 : 0x1;
  684. }
  685. ptr->RETENTION[cpu_index].SET = (set_mask << domain);
  686. }
  687. /**
  688. * @brief Retain target domain for specific CPU0
  689. *
  690. * @param[in] ptr SYSCTL_Type base address
  691. * @param[in] domain target domain power to be retained
  692. * @param[in] retain_mem set true to retain memory/register of target domain
  693. */
  694. static inline void sysctl_set_cpu0_lp_retain_domain(SYSCTL_Type *ptr,
  695. sysctl_retention_domain_t domain,
  696. bool retain_mem)
  697. {
  698. sysctl_set_cpu_lp_retain_domain(ptr, 0, domain, retain_mem);
  699. }
  700. /**
  701. * @brief Retain target domain for specific CPU
  702. *
  703. * @param[in] ptr SYSCTL_Type base address
  704. * @param[in] domain target domain power to be retained
  705. * @param[in] retain_mem set true to retain memory/register of target domain
  706. */
  707. static inline void sysctl_set_cpu1_lp_retain_domain(SYSCTL_Type *ptr,
  708. sysctl_retention_domain_t domain,
  709. bool retain_mem)
  710. {
  711. sysctl_set_cpu_lp_retain_domain(ptr, 1, domain, retain_mem);
  712. }
  713. /**
  714. * @brief Check if cpu clock is busy
  715. *
  716. * @param[in] ptr SYSCTL_Type base address
  717. * @return true if any clock is busy
  718. */
  719. static inline bool sysctl_cpu_clock_any_is_busy(SYSCTL_Type *ptr)
  720. {
  721. return ptr->CLOCK_CPU[0] & SYSCTL_CLOCK_CPU_GLB_BUSY_MASK;
  722. }
  723. /**
  724. * @brief Check if any clock is busy
  725. *
  726. * @param[in] ptr SYSCTL_Type base address
  727. * @return true if any clock is busy
  728. */
  729. static inline bool sysctl_clock_any_is_busy(SYSCTL_Type *ptr)
  730. {
  731. return ptr->CLOCK[0] & SYSCTL_CLOCK_GLB_BUSY_MASK;
  732. }
  733. /**
  734. * @brief Check if target clock is busy
  735. *
  736. * @param[in] ptr SYSCTL_Type base address
  737. * @param[in] clock target clock
  738. * @return true if target clock is busy
  739. */
  740. static inline bool sysctl_clock_target_is_busy(SYSCTL_Type *ptr, uint32_t clock)
  741. {
  742. return ptr->CLOCK[clock] & SYSCTL_CLOCK_LOC_BUSY_MASK;
  743. }
  744. /**
  745. * @brief Set clock preset
  746. *
  747. * @param[in] ptr SYSCTL_Type base address
  748. * @param[in] preset preset
  749. */
  750. static inline void sysctl_clock_set_preset(SYSCTL_Type *ptr, sysctl_preset_t preset)
  751. {
  752. ptr->GLOBAL00 = (ptr->GLOBAL00 & ~SYSCTL_GLOBAL00_MUX_MASK) | SYSCTL_GLOBAL00_MUX_SET(preset);
  753. }
  754. /**
  755. * @brief Check if target reset domain wakeup status
  756. *
  757. * @param[in] ptr SYSCTL_Type base address
  758. * @param[in] domain target domain to be checked
  759. * @return true if target domain was taken wakeup reset
  760. */
  761. static inline bool sysctl_reset_check_target_domain_wakeup_flag(SYSCTL_Type *ptr, sysctl_reset_domain_t domain)
  762. {
  763. return ptr->RESET[domain].CONTROL & SYSCTL_RESET_CONTROL_FLAG_WAKE_MASK;
  764. }
  765. /**
  766. * @brief Clear target reset domain wakeup status
  767. *
  768. * @param[in] ptr SYSCTL_Type base address
  769. * @param[in] domain target domain to be checked
  770. */
  771. static inline void sysctl_reset_clear_target_domain_wakeup_flag(SYSCTL_Type *ptr, sysctl_reset_domain_t domain)
  772. {
  773. ptr->RESET[domain].CONTROL |= SYSCTL_RESET_CONTROL_FLAG_WAKE_MASK;
  774. }
  775. /**
  776. * @brief Clear target reset domain reset status
  777. *
  778. * @param[in] ptr SYSCTL_Type base address
  779. * @param[in] domain target domain to be checked
  780. * @return true if target domain was taken reset
  781. */
  782. static inline bool sysctl_reset_check_target_domain_flag(SYSCTL_Type *ptr, sysctl_reset_domain_t domain)
  783. {
  784. return ptr->RESET[domain].CONTROL & SYSCTL_RESET_CONTROL_FLAG_MASK;
  785. }
  786. /**
  787. * @brief Clear target reset domain reset status
  788. *
  789. * @param[in] ptr SYSCTL_Type base address
  790. * @param[in] domain target domain to be checked
  791. */
  792. static inline void sysctl_reset_clear_target_domain_flag(SYSCTL_Type *ptr, sysctl_reset_domain_t domain)
  793. {
  794. ptr->RESET[domain].CONTROL |= SYSCTL_RESET_CONTROL_FLAG_MASK;
  795. }
  796. /**
  797. * @brief Clear target reset domain for all reset status
  798. *
  799. * @param[in] ptr SYSCTL_Type base address
  800. * @param[in] domain target domain to be checked
  801. */
  802. static inline void sysctl_reset_clear_target_domain_all_flags(SYSCTL_Type *ptr, sysctl_reset_domain_t domain)
  803. {
  804. ptr->RESET[domain].CONTROL |= SYSCTL_RESET_CONTROL_FLAG_MASK | SYSCTL_RESET_CONTROL_FLAG_WAKE_MASK;
  805. }
  806. /**
  807. * @brief Get target CPU wakeup source status
  808. *
  809. * @param[in] ptr SYSCTL_Type base address
  810. * @param[in] cpu_index CPU index
  811. * @param[in] status_index wakeup status index 0 - 7
  812. * @return wakeup source status mask
  813. */
  814. static inline uint32_t sysctl_get_wakeup_source_status(SYSCTL_Type *ptr, uint8_t cpu_index, uint8_t status_index)
  815. {
  816. return ptr->CPU[cpu_index].WAKEUP_STATUS[status_index];
  817. }
  818. /**
  819. * @brief Get target CPU0 wakeup source status
  820. *
  821. * @param[in] ptr SYSCTL_Type base address
  822. * @param[in] status_index wakeup status index 0 - 7
  823. * @return wakeup source status mask
  824. */
  825. static inline uint32_t sysctl_get_cpu0_wakeup_source_status(SYSCTL_Type *ptr, uint8_t status_index)
  826. {
  827. return sysctl_get_wakeup_source_status(ptr, 0, status_index);
  828. }
  829. /**
  830. * @brief Get target CPU1 wakeup source status
  831. *
  832. * @param[in] ptr SYSCTL_Type base address
  833. * @param[in] status_index wakeup status index 0 - 7
  834. * @return wakeup source status mask
  835. */
  836. static inline uint32_t sysctl_get_cpu1_wakeup_source_status(SYSCTL_Type *ptr, uint8_t status_index)
  837. {
  838. return sysctl_get_wakeup_source_status(ptr, 1, status_index);
  839. }
  840. /**
  841. * @brief Check wakeup source status with mask
  842. *
  843. * @param[in] ptr SYSCTL_Type base address
  844. * @param[in] cpu_index CPU index
  845. * @param[in] status_index wakeup status index 0 - 7
  846. * @param[in] mask expected status mask
  847. * @return wakeup status according to given bit mask
  848. */
  849. static inline uint32_t sysctl_check_wakeup_source_status_with_mask(SYSCTL_Type *ptr,
  850. uint8_t cpu_index,
  851. uint8_t status_index,
  852. uint32_t mask)
  853. {
  854. return ptr->CPU[cpu_index].WAKEUP_STATUS[status_index] & mask;
  855. }
  856. /**
  857. * @brief Check CPU0 wakeup source status with mask
  858. *
  859. * @param[in] ptr SYSCTL_Type base address
  860. * @param[in] status_index wakeup status index 0 - 7
  861. * @param[in] mask expected status mask
  862. * @return wakeup status according to given bit mask
  863. */
  864. static inline uint32_t sysctl_check_cpu0_wakeup_source_status_with_mask(SYSCTL_Type *ptr,
  865. uint8_t status_index,
  866. uint32_t mask)
  867. {
  868. return sysctl_check_wakeup_source_status_with_mask(ptr, 0, status_index, mask);
  869. }
  870. /**
  871. * @brief Check CPU1 wakeup source status with mask
  872. *
  873. * @param[in] ptr SYSCTL_Type base address
  874. * @param[in] status_index wakeup status index 0 - 7
  875. * @param[in] mask expected status mask
  876. * @return wakeup status according to given bit mask
  877. */
  878. static inline uint32_t sysctl_check_cpu1_wakeup_source_status_with_mask(SYSCTL_Type *ptr,
  879. uint8_t status_index,
  880. uint32_t mask)
  881. {
  882. return sysctl_check_wakeup_source_status_with_mask(ptr, 1, status_index, mask);
  883. }
  884. /**
  885. * @brief Enable wakeup source status with mask
  886. *
  887. * @param[in] ptr SYSCTL_Type base address
  888. * @param[in] cpu_index CPU index
  889. * @param[in] enable_index wakeup enable index 0 - 7
  890. * @param[in] mask expected status mask
  891. */
  892. static inline void sysctl_enable_wakeup_source_with_mask(SYSCTL_Type *ptr,
  893. uint8_t cpu_index,
  894. uint8_t enable_index,
  895. uint32_t mask)
  896. {
  897. ptr->CPU[cpu_index].WAKEUP_ENABLE[enable_index] |= mask;
  898. }
  899. /**
  900. * @brief Enable CPU0 wakeup source status with mask
  901. *
  902. * @param[in] ptr SYSCTL_Type base address
  903. * @param[in] enable_index wakeup enable index 0 - 7
  904. * @param[in] mask expected status mask
  905. */
  906. static inline void sysctl_enable_cpu0_wakeup_source_with_mask(SYSCTL_Type *ptr,
  907. uint8_t enable_index,
  908. uint32_t mask)
  909. {
  910. ptr->CPU[0].WAKEUP_ENABLE[enable_index] |= mask;
  911. }
  912. /**
  913. * @brief Enable CPU1 wakeup source status with mask
  914. *
  915. * @param[in] ptr SYSCTL_Type base address
  916. * @param[in] enable_index wakeup enable index 0 - 7
  917. * @param[in] mask expected status mask
  918. */
  919. static inline void sysctl_enable_cpu1_wakeup_source_with_mask(SYSCTL_Type *ptr,
  920. uint8_t enable_index,
  921. uint32_t mask)
  922. {
  923. ptr->CPU[1].WAKEUP_ENABLE[enable_index] |= mask;
  924. }
  925. /**
  926. * @brief Disable wakeup source status with mask
  927. *
  928. * @param[in] ptr SYSCTL_Type base address
  929. * @param[in] cpu_index CPU index
  930. * @param[in] enable_index wakeup enable index 0 - 7
  931. * @param[in] mask expected status mask
  932. */
  933. static inline void sysctl_disable_wakeup_source_with_mask(SYSCTL_Type *ptr,
  934. uint8_t cpu_index,
  935. uint8_t enable_index,
  936. uint32_t mask)
  937. {
  938. ptr->CPU[cpu_index].WAKEUP_ENABLE[enable_index] &= ~mask;
  939. }
  940. /**
  941. * @brief Disable CPU0 wakeup source status with mask
  942. *
  943. * @param[in] ptr SYSCTL_Type base address
  944. * @param[in] enable_index wakeup enable index 0 - 7
  945. * @param[in] mask expected status mask
  946. */
  947. static inline void sysctl_disable_cpu0_wakeup_source_with_mask(SYSCTL_Type *ptr,
  948. uint8_t enable_index,
  949. uint32_t mask)
  950. {
  951. sysctl_disable_wakeup_source_with_mask(ptr, 0, enable_index, mask);
  952. }
  953. /**
  954. * @brief Disable CPU1 wakeup source status with mask
  955. *
  956. * @param[in] ptr SYSCTL_Type base address
  957. * @param[in] enable_index wakeup enable index 0 - 7
  958. * @param[in] mask expected status mask
  959. */
  960. static inline void sysctl_disable_cpu1_wakeup_source_with_mask(SYSCTL_Type *ptr,
  961. uint8_t enable_index,
  962. uint32_t mask)
  963. {
  964. sysctl_disable_wakeup_source_with_mask(ptr, 1, enable_index, mask);
  965. }
  966. /**
  967. * @brief Disable wakeup source status with irq
  968. *
  969. * @param[in] ptr SYSCTL_Type base address
  970. * @param[in] cpu_index CPU index
  971. * @param[in] irq_num irq number to be disabled as wakeup source
  972. */
  973. static inline void sysctl_disable_wakeup_source_with_irq(SYSCTL_Type *ptr,
  974. uint8_t cpu_index,
  975. uint16_t irq_num)
  976. {
  977. ptr->CPU[cpu_index].WAKEUP_ENABLE[irq_num >> 2] &= ~(1UL << (irq_num % 32));
  978. }
  979. /**
  980. * @brief Disable CPU0 wakeup source status with irq
  981. *
  982. * @param[in] ptr SYSCTL_Type base address
  983. * @param[in] irq_num irq number to be disabled as wakeup source
  984. */
  985. static inline void sysctl_disable_cpu0_wakeup_source_with_irq(SYSCTL_Type *ptr, uint16_t irq_num)
  986. {
  987. sysctl_disable_wakeup_source_with_irq(ptr, 0, irq_num);
  988. }
  989. /**
  990. * @brief Disable CPU1 wakeup source status with irq
  991. *
  992. * @param[in] ptr SYSCTL_Type base address
  993. * @param[in] irq_num irq number to be disabled as wakeup source
  994. */
  995. static inline void sysctl_disable_cpu1_wakeup_source_with_irq(SYSCTL_Type *ptr, uint16_t irq_num)
  996. {
  997. sysctl_disable_wakeup_source_with_irq(ptr, 1, irq_num);
  998. }
  999. /**
  1000. * @brief Enable wakeup source status with irq
  1001. *
  1002. * @param[in] ptr SYSCTL_Type base address
  1003. * @param[in] cpu_index CPU index
  1004. * @param[in] irq_num irq number to be set as wakeup source
  1005. */
  1006. static inline void sysctl_enable_wakeup_source_with_irq(SYSCTL_Type *ptr, uint8_t cpu_index, uint16_t irq_num)
  1007. {
  1008. ptr->CPU[cpu_index].WAKEUP_ENABLE[irq_num / 32] |= 1UL << (irq_num & 0x1F);
  1009. }
  1010. /**
  1011. * @brief Enable CPU0 wakeup source status with irq
  1012. *
  1013. * @param[in] ptr SYSCTL_Type base address
  1014. * @param[in] irq_num irq number to be set as wakeup source
  1015. */
  1016. static inline void sysctl_enable_cpu0_wakeup_source_with_irq(SYSCTL_Type *ptr, uint16_t irq_num)
  1017. {
  1018. sysctl_enable_wakeup_source_with_irq(ptr, 0, irq_num);
  1019. }
  1020. /**
  1021. * @brief Enable CPU1 wakeup source status with irq
  1022. *
  1023. * @param[in] ptr SYSCTL_Type base address
  1024. * @param[in] irq_num irq number to be set as wakeup source
  1025. */
  1026. static inline void sysctl_enable_cpu1_wakeup_source_with_irq(SYSCTL_Type *ptr, uint16_t irq_num)
  1027. {
  1028. sysctl_enable_wakeup_source_with_irq(ptr, 1, irq_num);
  1029. }
  1030. /**
  1031. * @brief Lock CPU gpr with mask
  1032. *
  1033. * @param[in] ptr SYSCTL_Type base address
  1034. * @param[in] cpu_index CPU index
  1035. * @param[in] gpr_mask bit mask of gpr registers to be locked
  1036. */
  1037. static inline void sysctl_cpu_lock_gpr_with_mask(SYSCTL_Type *ptr, uint8_t cpu_index, uint16_t gpr_mask)
  1038. {
  1039. ptr->CPU[cpu_index].LOCK |= SYSCTL_CPU_LOCK_GPR_SET(gpr_mask);
  1040. }
  1041. /**
  1042. * @brief Lock CPU0 gpr with mask
  1043. *
  1044. * @param[in] ptr SYSCTL_Type base address
  1045. * @param[in] gpr_mask bit mask of gpr registers to be locked
  1046. */
  1047. static inline void sysctl_cpu0_lock_gpr_with_mask(SYSCTL_Type *ptr, uint16_t gpr_mask)
  1048. {
  1049. sysctl_cpu_lock_gpr_with_mask(ptr, 0, gpr_mask);
  1050. }
  1051. /**
  1052. * @brief Lock CPU1 gpr with mask
  1053. *
  1054. * @param[in] ptr SYSCTL_Type base address
  1055. * @param[in] gpr_mask bit mask of gpr registers to be locked
  1056. */
  1057. static inline void sysctl_cpu1_lock_gpr_with_mask(SYSCTL_Type *ptr, uint16_t gpr_mask)
  1058. {
  1059. sysctl_cpu_lock_gpr_with_mask(ptr, 1, gpr_mask);
  1060. }
  1061. /**
  1062. * @brief Lock CPU lock
  1063. *
  1064. * @param[in] ptr SYSCTL_Type base address
  1065. * @param[in] cpu_index CPU index
  1066. */
  1067. static inline void sysctl_cpu_lock(SYSCTL_Type *ptr, uint8_t cpu_index)
  1068. {
  1069. ptr->CPU[cpu_index].LOCK |= SYSCTL_CPU_LOCK_LOCK_MASK;
  1070. }
  1071. /**
  1072. * @brief Lock CPU0 lock
  1073. *
  1074. * @param[in] ptr SYSCTL_Type base address
  1075. */
  1076. static inline void sysctl_cpu0_lock(SYSCTL_Type *ptr)
  1077. {
  1078. sysctl_cpu_lock(ptr, 0);
  1079. }
  1080. /**
  1081. * @brief Lock CPU1 lock
  1082. *
  1083. * @param[in] ptr SYSCTL_Type base address
  1084. */
  1085. static inline void sysctl_cpu1_lock(SYSCTL_Type *ptr)
  1086. {
  1087. sysctl_cpu_lock(ptr, 1);
  1088. }
  1089. /**
  1090. * @brief Set CPU low power mode
  1091. *
  1092. * @param[in] ptr SYSCTL_Type base address
  1093. * @param[in] cpu_index CPU index
  1094. * @param[in] mode target mode to set
  1095. */
  1096. static inline void sysctl_set_cpu_lp_mode(SYSCTL_Type *ptr, uint8_t cpu_index, cpu_lp_mode_t mode)
  1097. {
  1098. ptr->CPU[cpu_index].LP = (ptr->CPU[cpu_index].LP & ~(SYSCTL_CPU_LP_MODE_MASK)) | (mode);
  1099. }
  1100. /**
  1101. * @brief Set CPU0 low power mode
  1102. *
  1103. * @param[in] ptr SYSCTL_Type base address
  1104. * @param[in] mode target mode to set
  1105. */
  1106. static inline void sysctl_set_cpu0_lp_mode(SYSCTL_Type *ptr, cpu_lp_mode_t mode)
  1107. {
  1108. sysctl_set_cpu_lp_mode(ptr, 0, mode);
  1109. }
  1110. /**
  1111. * @brief Set CPU1 low power mode
  1112. *
  1113. * @param[in] ptr SYSCTL_Type base address
  1114. * @param[in] mode target mode to set
  1115. */
  1116. static inline void sysctl_set_cpu1_lp_mode(SYSCTL_Type *ptr, cpu_lp_mode_t mode)
  1117. {
  1118. sysctl_set_cpu_lp_mode(ptr, 1, mode);
  1119. }
  1120. /**
  1121. * @brief Clear CPU event flags
  1122. *
  1123. * @param[in] ptr SYSCTL_Type base address
  1124. * @param[in] cpu_index CPU index
  1125. * @param[in] flags flag mask to be cleared
  1126. */
  1127. static inline void sysctl_clear_cpu_flags(SYSCTL_Type *ptr, uint8_t cpu_index, cpu_event_flag_mask_t flags)
  1128. {
  1129. ptr->CPU[cpu_index].LP |=
  1130. ((SYSCTL_CPU_LP_SLEEP_FLAG_MASK | SYSCTL_CPU_LP_WAKE_FLAG_MASK | SYSCTL_CPU_LP_RESET_FLAG_MASK) & flags);
  1131. }
  1132. /**
  1133. * @brief Clear CPU0 event flags
  1134. *
  1135. * @param[in] ptr SYSCTL_Type base address
  1136. * @param[in] flags flag mask to be cleared
  1137. */
  1138. static inline void sysctl_clear_cpu0_flags(SYSCTL_Type *ptr, cpu_event_flag_mask_t flags)
  1139. {
  1140. sysctl_clear_cpu_flags(ptr, 0, flags);
  1141. }
  1142. /**
  1143. * @brief Clear CPU1 event flags
  1144. *
  1145. * @param[in] ptr SYSCTL_Type base address
  1146. * @param[in] flags flag mask to be cleared
  1147. */
  1148. static inline void sysctl_clear_cpu1_flags(SYSCTL_Type *ptr, cpu_event_flag_mask_t flags)
  1149. {
  1150. sysctl_clear_cpu_flags(ptr, 1, flags);
  1151. }
  1152. /**
  1153. * @brief Get CPU event flags
  1154. *
  1155. * @param[in] ptr SYSCTL_Type base address
  1156. * @param[in] cpu_index CPU index
  1157. * @retval event flag mask
  1158. */
  1159. static inline uint32_t sysctl_get_cpu_flags(SYSCTL_Type *ptr, uint8_t cpu_index)
  1160. {
  1161. return ptr->CPU[cpu_index].LP &
  1162. (SYSCTL_CPU_LP_SLEEP_FLAG_MASK | SYSCTL_CPU_LP_WAKE_FLAG_MASK | SYSCTL_CPU_LP_RESET_FLAG_MASK);
  1163. }
  1164. /**
  1165. * @brief Get CPU0 event flags
  1166. *
  1167. * @param[in] ptr SYSCTL_Type base address
  1168. * @retval event flag mask
  1169. */
  1170. static inline uint32_t sysctl_get_cpu0_flags(SYSCTL_Type *ptr)
  1171. {
  1172. return sysctl_get_cpu_flags(ptr, 0);
  1173. }
  1174. /**
  1175. * @brief Get CPU1 event flags
  1176. *
  1177. * @param[in] ptr SYSCTL_Type base address
  1178. * @retval event flag mask
  1179. */
  1180. static inline uint32_t sysctl_get_cpu1_flags(SYSCTL_Type *ptr)
  1181. {
  1182. return sysctl_get_cpu_flags(ptr, 1);
  1183. }
  1184. /**
  1185. * @brief Release cpu
  1186. *
  1187. * @param[in] ptr SYSCTL_Type base address
  1188. * @param[in] cpu_index CPU index
  1189. */
  1190. static inline void sysctl_release_cpu(SYSCTL_Type *ptr, uint8_t cpu_index)
  1191. {
  1192. ptr->CPU[cpu_index].LP &= ~SYSCTL_CPU_LP_HALT_MASK;
  1193. }
  1194. /**
  1195. * @brief Release cpu1
  1196. *
  1197. * @param[in] ptr SYSCTL_Type base address
  1198. */
  1199. static inline void sysctl_release_cpu1(SYSCTL_Type *ptr)
  1200. {
  1201. sysctl_release_cpu(ptr, 1);
  1202. }
  1203. /**
  1204. * @brief Check whether CPU is released or not
  1205. *
  1206. * @param [in] ptr SYSCTL_Type base address
  1207. * @param[in] cpu_index CPU index
  1208. * @retval true CPU is released
  1209. * @retval false CPU is on-hold
  1210. */
  1211. static inline bool sysctl_is_cpu_released(SYSCTL_Type *ptr, uint8_t cpu_index)
  1212. {
  1213. return ((ptr->CPU[cpu_index].LP & SYSCTL_CPU_LP_HALT_MASK) == 0U);
  1214. }
  1215. /**
  1216. * @brief Check whether CPU1 is released or not
  1217. *
  1218. * @param [in] ptr SYSCTL_Type base address
  1219. * @retval true CPU1 is released
  1220. * @retval false CPU1 is on-hold
  1221. */
  1222. static inline bool sysctl_is_cpu1_released(SYSCTL_Type *ptr)
  1223. {
  1224. return sysctl_is_cpu_released(ptr, 1);
  1225. }
  1226. /**
  1227. * @brief Config lock
  1228. *
  1229. * @param[in] ptr SYSCTL_Type base address
  1230. * @param[in] node clock node to be configured
  1231. * @param[in] source clock source to be used
  1232. * @param[in] divide_by clock frequency divider
  1233. * @return status_success if everything is okay
  1234. */
  1235. hpm_stat_t sysctl_config_clock(SYSCTL_Type *ptr, clock_node_t node, clock_source_t source, uint32_t divide_by);
  1236. /**
  1237. * @brief Configure CPU domain clock
  1238. * @param ptr SYSCTL base address
  1239. * @param source clock source to be used
  1240. * @param cpu_div CPU divider
  1241. * @param axi_sub_div AXI BUS divider based on divided CPU clock
  1242. * @param ahb_sub_div AHB BUS divider based on divided CPU clock
  1243. * @return status_success if everything is okay
  1244. */
  1245. hpm_stat_t sysctl_config_cpu0_domain_clock(SYSCTL_Type *ptr,
  1246. clock_source_t source,
  1247. uint32_t cpu_div,
  1248. uint32_t axi_sub_div,
  1249. uint32_t ahb_sub_div);
  1250. /**
  1251. * @brief Set ADC clock mux
  1252. *
  1253. * @param[in] ptr SYSCTL_Type base address
  1254. * @param[in] node clock node to be configured
  1255. * @param[in] source clock source to be used
  1256. * @return status_success if everything is okay
  1257. */
  1258. hpm_stat_t sysctl_set_adc_clock_mux(SYSCTL_Type *ptr, clock_node_t node, clock_source_adc_t source);
  1259. /**
  1260. * @brief Set DAC clock mux
  1261. *
  1262. * @param[in] ptr SYSCTL_Type base address
  1263. * @param[in] node clock node to be configured
  1264. * @param[in] source clock source to be used
  1265. * @return status_success if everything is okay
  1266. */
  1267. hpm_stat_t sysctl_set_dac_clock_mux(SYSCTL_Type *ptr, clock_node_t node, clock_source_dac_t source);
  1268. /**
  1269. * @brief Enable group resource
  1270. *
  1271. * @param[in] ptr SYSCTL_Type base address
  1272. * @param[in] group target group to be modified
  1273. * @param[in] resource target resource to be added/removed from group
  1274. * @param[in] enable set true to add resource, remove otherwise
  1275. * @return status_success if everything is okay
  1276. */
  1277. hpm_stat_t sysctl_enable_group_resource(SYSCTL_Type *ptr,
  1278. uint8_t group,
  1279. sysctl_resource_t resource,
  1280. bool enable);
  1281. /**
  1282. * @brief Add resource to CPU0
  1283. *
  1284. * @param[in] ptr SYSCTL_Type base address
  1285. * @param[in] resource resource to be added to CPU0
  1286. * @return status_success if everything is okay
  1287. */
  1288. hpm_stat_t sysctl_add_resource_to_cpu0(SYSCTL_Type *ptr, sysctl_resource_t resource);
  1289. /**
  1290. * @brief Remove resource from CPU0
  1291. *
  1292. * @param[in] ptr SYSCTL_Type base address
  1293. * @param[in] resource Resource to be removed to CPU0
  1294. * @return status_success if everything is okay
  1295. */
  1296. hpm_stat_t sysctl_remove_resource_from_cpu0(SYSCTL_Type *ptr, sysctl_resource_t resource);
  1297. /**
  1298. * @brief Add resource to CPU1
  1299. *
  1300. * @param[in] ptr SYSCTL_Type base address
  1301. * @param[in] resource Resource to be added to CPU1
  1302. * @return status_success if everything is okay
  1303. */
  1304. hpm_stat_t sysctl_add_resource_to_cpu1(SYSCTL_Type *ptr, sysctl_resource_t resource);
  1305. /**
  1306. * @brief Remove resource from CPU1
  1307. *
  1308. * @param[in] ptr SYSCTL_Type base address
  1309. * @param[in] resource Resource to be removed to CPU1
  1310. * @return status_success if everything is okay
  1311. */
  1312. hpm_stat_t sysctl_remove_resource_from_cpu1(SYSCTL_Type *ptr, sysctl_resource_t resource);
  1313. /**
  1314. * @brief Get default monitor config
  1315. *
  1316. * @param[in] ptr SYSCTL_Type base address
  1317. * @param[in] config Monitor config structure pointer
  1318. */
  1319. void sysctl_monitor_get_default_config(SYSCTL_Type *ptr, monitor_config_t *config);
  1320. /**
  1321. * @brief Initialize Monitor
  1322. *
  1323. * @param[in] ptr SYSCTL_Type base address
  1324. * @param[in] monitor_index Monitor instance to be initialized
  1325. * @param[in] config Monitor config structure pointer
  1326. */
  1327. void sysctl_monitor_init(SYSCTL_Type *ptr, uint8_t monitor_index, monitor_config_t *config);
  1328. /**
  1329. * @brief Save data to GPU0 GPR starting from given index
  1330. *
  1331. * @param[in] ptr SYSCTL_Type base address
  1332. * @param[in] start Starting GPR index
  1333. * @param[in] count Number of GPR registers to set
  1334. * @param[in] data Pointer to data buffer
  1335. * @param[in] lock Set true to lock written GPR registers after setting
  1336. * @return status_success if everything is okay
  1337. */
  1338. hpm_stat_t sysctl_cpu0_set_gpr(SYSCTL_Type *ptr, uint8_t start, uint8_t count, uint32_t *data, bool lock);
  1339. /**
  1340. * @brief Get data saved from GPU0 GPR starting from given index
  1341. *
  1342. * @param[in] ptr SYSCTL_Type base address
  1343. * @param[in] start Starting GPR index
  1344. * @param[in] count Number of GPR registers to set
  1345. * @param[out] data Pointer of buffer to save data
  1346. * @return status_success if everything is okay
  1347. */
  1348. hpm_stat_t sysctl_cpu0_get_gpr(SYSCTL_Type *ptr, uint8_t start, uint8_t count, uint32_t *data);
  1349. /**
  1350. * @brief Set data to CPU1 GPR starting from given index
  1351. *
  1352. * @param[in] ptr SYSCTL_Type base address
  1353. * @param[in] start Starting GPR index
  1354. * @param[in] count Number of GPR registers to set
  1355. * @param[in] data Pointer to data buffer
  1356. * @param[in] lock Set true to lock written GPR registers after setting
  1357. * @return status_success if everything is okay
  1358. */
  1359. hpm_stat_t sysctl_cpu1_set_gpr(SYSCTL_Type *ptr, uint8_t start, uint8_t count, uint32_t *data, bool lock);
  1360. /**
  1361. * @brief Get data saved in CPU1 GPR starting from given index
  1362. *
  1363. * @param[in] ptr SYSCTL_Type base address
  1364. * @param[in] start Starting GPR index
  1365. * @param[in] count Number of GPR registers to set
  1366. * @param[out] data Pointer of buffer to save data
  1367. * @return status_success if everything is okay
  1368. */
  1369. hpm_stat_t sysctl_get_cpu1_gpr(SYSCTL_Type *ptr, uint8_t start, uint8_t count, uint32_t *data);
  1370. /**
  1371. * @brief Set entry point on CPU boot or wakeup
  1372. *
  1373. * @param[in] ptr SYSCTL_Type base address
  1374. * @param[in] cpu CPU index
  1375. * @param[in] entry Entry address for CPU
  1376. * @return status_success if everything is okay
  1377. */
  1378. hpm_stat_t sysctl_set_cpu_entry(SYSCTL_Type *ptr, uint8_t cpu, uint32_t entry);
  1379. /**
  1380. * @brief Set entry point on CPU0 wakeup
  1381. *
  1382. * @param[in] ptr SYSCTL_Type base address
  1383. * @param[in] entry Entry address for CPU0 on its wakeup
  1384. * @return status_success if everything is okay
  1385. */
  1386. hpm_stat_t sysctl_set_cpu0_wakeup_entry(SYSCTL_Type *ptr, uint32_t entry);
  1387. /**
  1388. * @brief Set entry point on either CPU1 boot or wakeup
  1389. *
  1390. * @param[in] ptr SYSCTL_Type base address
  1391. * @param[in] entry Entry address for CPU1
  1392. * @return status_success if everything is okay
  1393. */
  1394. hpm_stat_t sysctl_set_cpu1_entry(SYSCTL_Type *ptr, uint32_t entry);
  1395. #ifdef __cplusplus
  1396. }
  1397. #endif
  1398. /**
  1399. * @}
  1400. */
  1401. #endif /* HPM_SYSCTL_DRV_H */