core_ck802.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. * File : core_ck802.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2017, 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. * 2017-01-01 Urey first version
  23. */
  24. #ifndef __CORE_CK802_H_GENERIC
  25. #define __CORE_CK802_H_GENERIC
  26. #include <stdint.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /*******************************************************************************
  31. * CSI definitions
  32. ******************************************************************************/
  33. /**
  34. \ingroup Ck802
  35. @{
  36. */
  37. /* CSI CK802 definitions */
  38. #define __CK802_CSI_VERSION_MAIN (0x04U) /*!< [31:16] CSI HAL main version */
  39. #define __CK802_CSI_VERSION_SUB (0x1EU) /*!< [15:0] CSI HAL sub version */
  40. #define __CK802_CSI_VERSION ((__CK802_CSI_VERSION_MAIN << 16U) | \
  41. __CK802_CSI_VERSION_SUB ) /*!< CSI HAL version number */
  42. #define __CK80X (0x02U) /*!< CK80X Core */
  43. /** __FPU_USED indicates whether an FPU is used or not.
  44. This core does not support an FPU at all
  45. */
  46. #define __FPU_USED 0U
  47. #if defined ( __GNUC__ )
  48. #if defined (__VFP_FP__) && !defined(__SOFTFP__)
  49. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  50. #endif
  51. #endif
  52. #include "csi_gcc.h"
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif /* __CORE_CK802_H_GENERIC */
  57. #ifndef __CSI_GENERIC
  58. #ifndef __CORE_CK802_H_DEPENDANT
  59. #define __CORE_CK802_H_DEPENDANT
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63. /* check device defines and use defaults */
  64. //#if defined __CHECK_DEVICE_DEFINES
  65. #ifndef __CK802_REV
  66. #define __CK802_REV 0x0000U
  67. //#warning "__CK802_REV not defined in device header file; using default!"
  68. #endif
  69. #ifndef __NVIC_PRIO_BITS
  70. #define __NVIC_PRIO_BITS 2U
  71. //#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
  72. #endif
  73. #ifndef __Vendor_SysTickConfig
  74. #define __Vendor_SysTickConfig 0U
  75. //#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
  76. #endif
  77. #ifndef __GSR_GCR_PRESENT
  78. #define __GSR_GCR_PRESENT 0U
  79. //#warning "__GSR_GCR_PRESENT not defined in device header file; using default!"
  80. #endif
  81. #ifndef __MGU_PRESENT
  82. #define __MGU_PRESENT 0U
  83. //#warning "__MGU_PRESENT not defined in device header file; using default!"
  84. #endif
  85. //#endif
  86. /* IO definitions (access restrictions to peripheral registers) */
  87. /**
  88. \defgroup CSI_glob_defs CSI Global Defines
  89. <strong>IO Type Qualifiers</strong> are used
  90. \li to specify the access to peripheral variables.
  91. \li for automatic generation of peripheral register debug information.
  92. */
  93. #ifdef __cplusplus
  94. #define __I volatile /*!< Defines 'read only' permissions */
  95. #else
  96. #define __I volatile const /*!< Defines 'read only' permissions */
  97. #endif
  98. #define __O volatile /*!< Defines 'write only' permissions */
  99. #define __IO volatile /*!< Defines 'read / write' permissions */
  100. /* following defines should be used for structure members */
  101. #define __IM volatile const /*! Defines 'read only' structure member permissions */
  102. #define __OM volatile /*! Defines 'write only' structure member permissions */
  103. #define __IOM volatile /*! Defines 'read / write' structure member permissions */
  104. /*@} end of group CK802 */
  105. /*******************************************************************************
  106. * Register Abstraction
  107. Core Register contain:
  108. - Core Register
  109. - Core NVIC Register
  110. - Core SCB Register
  111. - Core SysTick Register
  112. ******************************************************************************/
  113. /**
  114. \defgroup CSI_core_register Defines and Type Definitions
  115. \brief Type definitions and defines for CK80X processor based devices.
  116. */
  117. /**
  118. \ingroup CSI_core_register
  119. \defgroup CSI_CORE Status and Control Registers
  120. \brief Core Register type definitions.
  121. @{
  122. */
  123. /**
  124. \brief 访问处理器状态寄存器(PSR)的联合体定义.
  125. */
  126. typedef union
  127. {
  128. struct
  129. {
  130. uint32_t C: 1; /*!< bit: 0 条件码/进位位 */
  131. uint32_t _reserved0: 5; /*!< bit: 2.. 5 保留 */
  132. uint32_t IE: 1; /*!< bit: 6 中断有效控制位 */
  133. uint32_t IC: 1; /*!< bit: 7 中断控制位 */
  134. uint32_t EE: 1; /*!< bit: 8 异常有效控制位 */
  135. uint32_t MM: 1; /*!< bit: 9 不对齐异常掩盖位 */
  136. uint32_t _reserved1: 6; /*!< bit: 10..15 保留 */
  137. uint32_t VEC: 8; /*!< bit: 16..23 异常事件向量值 */
  138. uint32_t _reserved2: 7; /*!< bit: 24..30 保留 */
  139. uint32_t S: 1; /*!< bit: 31 超级用户模式设置位 */
  140. } b; /*!< Structure 用来按位访问 */
  141. uint32_t w; /*!< Type 整个寄存器访问 */
  142. } PSR_Type;
  143. /* PSR Register Definitions */
  144. #define PSR_S_Pos 31U /*!< PSR: S Position */
  145. #define PSR_S_Msk (1UL << PSR_S_Pos) /*!< PSR: S Mask */
  146. #define PSR_VEC_Pos 16U /*!< PSR: VEC Position */
  147. #define PSR_VEC_Msk (0x7FUL << PSR_VEC_Pos) /*!< PSR: VEC Mask */
  148. #define PSR_MM_Pos 9U /*!< PSR: MM Position */
  149. #define PSR_MM_Msk (1UL << PSR_MM_Pos) /*!< PSR: MM Mask */
  150. #define PSR_EE_Pos 8U /*!< PSR: EE Position */
  151. #define PSR_EE_Msk (1UL << PSR_EE_Pos) /*!< PSR: EE Mask */
  152. #define PSR_IC_Pos 7U /*!< PSR: IC Position */
  153. #define PSR_IC_Msk (1UL << PSR_IC_Pos) /*!< PSR: IC Mask */
  154. #define PSR_IE_Pos 6U /*!< PSR: IE Position */
  155. #define PSR_IE_Msk (1UL << PSR_IE_Pos) /*!< PSR: IE Mask */
  156. #define PSR_C_Pos 0U /*!< PSR: C Position */
  157. #define PSR_C_Msk (1UL << PSR_C_Pos) /*!< PSR: C Mask */
  158. /**
  159. \brief 访问高速缓存配置寄存器(CCR, CR<18, 0>)的联合体定义.
  160. */
  161. typedef union
  162. {
  163. struct
  164. {
  165. uint32_t MP: 1; /*!< bit: 0 内存保护设置位 */
  166. uint32_t _reserved0: 6; /*!< bit: 1.. 6 保留 */
  167. uint32_t BE: 1; /*!< bit: 7 Endian模式 */
  168. uint32_t SCK: 3; /*!< bit: 8..10 系统和处理器的时钟比 */
  169. uint32_t _reserved1: 2; /*!< bit: 11..12 保留 */
  170. uint32_t BE_V2: 1; /*!< bit: 13 V2版本大小端 */
  171. uint32_t _reserved2: 18; /*!< bit: 14..31 保留 */
  172. } b; /*!< Structure 用来按位访问 */
  173. uint32_t w; /*!< Type 整个寄存器访问 */
  174. } CCR_Type;
  175. /* CCR Register Definitions */
  176. #define CCR_BE_V2_Pos 13U /*!< CCR: BE_V2 Position */
  177. #define CCR_BE_V2_Msk (0x1UL << CCR_ISR_Pos) /*!< CCR: BE_V2 Mask */
  178. #define CCR_SCK_Pos 8U /*!< CCR: SCK Position */
  179. #define CCR_SCK_Msk (0x3UL << CCR_SCK_Pos) /*!< CCR: SCK Mask */
  180. #define CCR_BE_Pos 7U /*!< CCR: BE Position */
  181. #define CCR_BE_Msk (0x1UL << CCR_BE_Pos) /*!< CCR: BE Mask */
  182. #define CCR_MP_Pos 0U /*!< CCR: MP Position */
  183. #define CCR_MP_Msk (0x1UL << CCR_MP_Pos) /*!< CCR: MP Mask */
  184. /**
  185. \brief 访问可高缓和访问权限配置寄存器(CAPR, CR<19,0>)的联合体定义..
  186. */
  187. typedef union
  188. {
  189. struct
  190. {
  191. uint32_t X0: 1; /*!< bit: 0 不可执行属性设置位 */
  192. uint32_t X1: 1; /*!< bit: 1 不可执行属性设置位 */
  193. uint32_t X2: 1; /*!< bit: 2 不可执行属性设置位 */
  194. uint32_t X3: 1; /*!< bit: 3 不可执行属性设置位 */
  195. uint32_t X4: 1; /*!< bit: 4 不可执行属性设置位 */
  196. uint32_t X5: 1; /*!< bit: 5 不可执行属性设置位 */
  197. uint32_t X6: 1; /*!< bit: 6 不可执行属性设置位 */
  198. uint32_t X7: 1; /*!< bit: 7 不可执行属性设置位 */
  199. uint32_t AP0: 2; /*!< bit: 8.. 9 访问权限设置位 */
  200. uint32_t AP1: 2; /*!< bit: 10..11 访问权限设置位 */
  201. uint32_t AP2: 2; /*!< bit: 12..13 访问权限设置位 */
  202. uint32_t AP3: 2; /*!< bit: 14..15 访问权限设置位 */
  203. uint32_t AP4: 2; /*!< bit: 16..17 访问权限设置位 */
  204. uint32_t AP5: 2; /*!< bit: 18..19 访问权限设置位 */
  205. uint32_t AP6: 2; /*!< bit: 20..21 访问权限设置位 */
  206. uint32_t AP7: 2; /*!< bit: 22..23 访问权限设置位 */
  207. uint32_t S0: 1; /*!< bit: 24 安全属性设置位 */
  208. uint32_t S1: 1; /*!< bit: 25 安全属性设置位 */
  209. uint32_t S2: 1; /*!< bit: 26 安全属性设置位 */
  210. uint32_t S3: 1; /*!< bit: 27 安全属性设置位 */
  211. uint32_t S4: 1; /*!< bit: 28 安全属性设置位 */
  212. uint32_t S5: 1; /*!< bit: 29 安全属性设置位 */
  213. uint32_t S6: 1; /*!< bit: 30 安全属性设置位 */
  214. uint32_t S7: 1; /*!< bit: 31 安全属性设置位 */
  215. } b; /*!< Structure 用来按位访问 */
  216. uint32_t w; /*!< Type 整个寄存器访问 */
  217. } CAPR_Type;
  218. /* CAPR Register Definitions */
  219. #define CAPR_S7_Pos 31U /*!< CAPR: S7 Position */
  220. #define CAPR_S7_Msk (1UL << CAPR_S7_Pos) /*!< CAPR: S7 Mask */
  221. #define CAPR_S6_Pos 30U /*!< CAPR: S6 Position */
  222. #define CAPR_S6_Msk (1UL << CAPR_S6_Pos) /*!< CAPR: S6 Mask */
  223. #define CAPR_S5_Pos 29U /*!< CAPR: S5 Position */
  224. #define CAPR_S5_Msk (1UL << CAPR_S5_Pos) /*!< CAPR: S5 Mask */
  225. #define CAPR_S4_Pos 28U /*!< CAPR: S4 Position */
  226. #define CAPR_S4_Msk (1UL << CAPR_S4_Pos) /*!< CAPR: S4 Mask */
  227. #define CAPR_S3_Pos 27U /*!< CAPR: S3 Position */
  228. #define CAPR_S3_Msk (1UL << CAPR_S3_Pos) /*!< CAPR: S3 Mask */
  229. #define CAPR_S2_Pos 26U /*!< CAPR: S2 Position */
  230. #define CAPR_S2_Msk (1UL << CAPR_S2_Pos) /*!< CAPR: S2 Mask */
  231. #define CAPR_S1_Pos 25U /*!< CAPR: S1 Position */
  232. #define CAPR_S1_Msk (1UL << CAPR_S1_Pos) /*!< CAPR: S1 Mask */
  233. #define CAPR_S0_Pos 24U /*!< CAPR: S0 Position */
  234. #define CAPR_S0_Msk (1UL << CAPR_S0_Pos) /*!< CAPR: S0 Mask */
  235. #define CAPR_AP7_Pos 22U /*!< CAPR: AP7 Position */
  236. #define CAPR_AP7_Msk (0x3UL << CAPR_AP7_Pos) /*!< CAPR: AP7 Mask */
  237. #define CAPR_AP6_Pos 20U /*!< CAPR: AP6 Position */
  238. #define CAPR_AP6_Msk (0x3UL << CAPR_AP6_Pos) /*!< CAPR: AP6 Mask */
  239. #define CAPR_AP5_Pos 18U /*!< CAPR: AP5 Position */
  240. #define CAPR_AP5_Msk (0x3UL << CAPR_AP5_Pos) /*!< CAPR: AP5 Mask */
  241. #define CAPR_AP4_Pos 16U /*!< CAPR: AP4 Position */
  242. #define CAPR_AP4_Msk (0x3UL << CAPR_AP4_Pos) /*!< CAPR: AP4 Mask */
  243. #define CAPR_AP3_Pos 14U /*!< CAPR: AP3 Position */
  244. #define CAPR_AP3_Msk (0x3UL << CAPR_AP3_Pos) /*!< CAPR: AP3 Mask */
  245. #define CAPR_AP2_Pos 12U /*!< CAPR: AP2 Position */
  246. #define CAPR_AP2_Msk (0x3UL << CAPR_AP2_Pos) /*!< CAPR: AP2 Mask */
  247. #define CAPR_AP1_Pos 10U /*!< CAPR: AP1 Position */
  248. #define CAPR_AP1_Msk (0x3UL << CAPR_AP1_Pos) /*!< CAPR: AP1 Mask */
  249. #define CAPR_AP0_Pos 8U /*!< CAPR: AP0 Position */
  250. #define CAPR_AP0_Msk (0x3UL << CAPR_AP0_Pos) /*!< CAPR: AP0 Mask */
  251. #define CAPR_X7_Pos 7U /*!< CAPR: X7 Position */
  252. #define CAPR_X7_Msk (0x1UL << CAPR_X7_Pos) /*!< CAPR: X7 Mask */
  253. #define CAPR_X6_Pos 6U /*!< CAPR: X6 Position */
  254. #define CAPR_X6_Msk (0x1UL << CAPR_X6_Pos) /*!< CAPR: X6 Mask */
  255. #define CAPR_X5_Pos 5U /*!< CAPR: X5 Position */
  256. #define CAPR_X5_Msk (0x1UL << CAPR_X5_Pos) /*!< CAPR: X5 Mask */
  257. #define CAPR_X4_Pos 4U /*!< CAPR: X4 Position */
  258. #define CAPR_X4_Msk (0x1UL << CAPR_X4_Pos) /*!< CAPR: X4 Mask */
  259. #define CAPR_X3_Pos 3U /*!< CAPR: X3 Position */
  260. #define CAPR_X3_Msk (0x1UL << CAPR_X3_Pos) /*!< CAPR: X3 Mask */
  261. #define CAPR_X2_Pos 2U /*!< CAPR: X2 Position */
  262. #define CAPR_X2_Msk (0x1UL << CAPR_X2_Pos) /*!< CAPR: X2 Mask */
  263. #define CAPR_X1_Pos 1U /*!< CAPR: X1 Position */
  264. #define CAPR_X1_Msk (0x1UL << CAPR_X1_Pos) /*!< CAPR: X1 Mask */
  265. #define CAPR_X0_Pos 0U /*!< CAPR: X0 Position */
  266. #define CAPR_X0_Msk (0x1UL << CAPR_X0_Pos) /*!< CAPR: X0 Mask */
  267. /**
  268. \brief 访问保护区控制寄存器(PACR, CR<20,0>)的联合体定义.
  269. */
  270. typedef union
  271. {
  272. struct
  273. {
  274. uint32_t E: 1; /*!< bit: 0 保护区有效设置 */
  275. uint32_t Size: 5; /*!< bit: 1.. 5 保护区大小 */
  276. uint32_t _reserved0: 4; /*!< bit: 6.. 9 保留 */
  277. uint32_t base_addr: 22; /*!< bit: 10..31 保护区地址的高位 */
  278. } b; /*!< Structure 用来按位访问 */
  279. uint32_t w; /*!< Type 整个寄存器访问 */
  280. } PACR_Type;
  281. /* PACR Register Definitions */
  282. #define PACR_BASE_ADDR_Pos 10U /*!< PACR: base_addr Position */
  283. #define PACK_BASE_ADDR_Msk (0x3FFFFFUL << PACR_BASE_ADDR_Pos) /*!< PACR: base_addr Mask */
  284. #define PACR_SIZE_Pos 1U /*!< PACR: Size Position */
  285. #define PACK_SIZE_Msk (0x1FUL << PACR_SIZE_Pos) /*!< PACR: Size Mask */
  286. #define PACR_E_Pos 0U /*!< PACR: E Position */
  287. #define PACK_E_Msk (0x1UL << PACR_E_Pos) /*!< PACR: E Mask */
  288. /**
  289. \brief 访问保护区选择寄存器(PRSR,CR<21,0>)的联合体定义.
  290. */
  291. typedef union
  292. {
  293. struct
  294. {
  295. uint32_t RID: 3; /*!< bit: 0.. 2 保护区索引值 */
  296. uint32_t _reserved0: 30; /*!< bit: 3..31 保留 */
  297. } b; /*!< Structure 用来按位访问 */
  298. uint32_t w; /*!< Type 整个寄存器访问 */
  299. } PRSR_Type;
  300. /* PRSR Register Definitions */
  301. #define PRSR_RID_Pos 0U /*!< PRSR: RID Position */
  302. #define PRSR_RID_Msk (0x7UL << PRSR_RID_Pos) /*!< PRSR: RID Mask */
  303. /*@} end of group CSI_CORE */
  304. /**
  305. \ingroup CSI_core_register
  306. \defgroup CSI_NVIC Vectored Interrupt Controller (NVIC)
  307. \brief Type definitions for the NVIC Registers
  308. @{
  309. */
  310. /**
  311. \brief 访问矢量中断控制器的结构体.
  312. */
  313. typedef struct
  314. {
  315. __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) 中断使能设置寄存器 */
  316. uint32_t RESERVED0[15U];
  317. __IOM uint32_t IWER[1U]; /*!< Offset: 0x040 (R/W) 中断低功耗唤醒设置寄存器 */
  318. uint32_t RESERVED1[15U];
  319. __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) 中断使能清除寄存器 */
  320. uint32_t RESERVED2[15U];
  321. __IOM uint32_t IWDR[1U]; /*!< Offset: 0x0c0 (R/W) 中断低功耗唤醒清除寄存器 */
  322. uint32_t RESERVED3[15U];
  323. __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) 中断等待设置寄存器 */
  324. uint32_t RESERVED4[15U];
  325. __IOM uint32_t ISSR[1U]; /*!< Offset: 0x140 (R/W) 安全中断使能设置寄存器 */
  326. uint32_t RESERVED5[15U];
  327. __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) 中断等待清除寄存器 */
  328. uint32_t RESERVED6[31U];
  329. __IOM uint32_t IABR[1U]; /*!< Offset: 0x200 (R/W) 中断响应状态寄存器 */
  330. uint32_t RESERVED7[63U];
  331. __IOM uint32_t IPR[8U]; /*!< Offset: 0x300 (R/W) 中断优先级设置寄存器 */
  332. uint32_t RESERVED8[504U];
  333. __IM uint32_t ISR; /*!< Offset: 0xB00 (R/ ) 中断状态寄存器 */
  334. __IOM uint32_t IPTR; /*!< Offset: 0xB04 (R/W) 中断优先级阈值寄存器 */
  335. } NVIC_Type;
  336. /*@} end of group CSI_NVIC */
  337. /**
  338. \ingroup CSI_core_register
  339. \defgroup CSI_SysTick System Tick Timer (CORET)
  340. \brief Type definitions for the System Timer Registers.
  341. @{
  342. */
  343. /**
  344. \brief 访问系统计时器的数据结构.
  345. */
  346. typedef struct
  347. {
  348. __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) 控制状态寄存器 */
  349. __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) 回填值寄存器 */
  350. __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) 当前值寄存器 */
  351. __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) 校准寄存器 */
  352. } CORET_Type;
  353. /* CORET Control / Status Register Definitions */
  354. #define CORET_CTRL_COUNTFLAG_Pos 16U /*!< CORET CTRL: COUNTFLAG Position */
  355. #define CORET_CTRL_COUNTFLAG_Msk (1UL << CORET_CTRL_COUNTFLAG_Pos) /*!< CORET CTRL: COUNTFLAG Mask */
  356. #define CORET_CTRL_CLKSOURCE_Pos 2U /*!< CORET CTRL: CLKSOURCE Position */
  357. #define CORET_CTRL_CLKSOURCE_Msk (1UL << CORET_CTRL_CLKSOURCE_Pos) /*!< CORET CTRL: CLKSOURCE Mask */
  358. #define CORET_CTRL_TICKINT_Pos 1U /*!< CORET CTRL: TICKINT Position */
  359. #define CORET_CTRL_TICKINT_Msk (1UL << CORET_CTRL_TICKINT_Pos) /*!< CORET CTRL: TICKINT Mask */
  360. #define CORET_CTRL_ENABLE_Pos 0U /*!< CORET CTRL: ENABLE Position */
  361. #define CORET_CTRL_ENABLE_Msk (1UL /*<< CORET_CTRL_ENABLE_Pos*/) /*!< CORET CTRL: ENABLE Mask */
  362. /* CORET Reload Register Definitions */
  363. #define CORET_LOAD_RELOAD_Pos 0U /*!< CORET LOAD: RELOAD Position */
  364. #define CORET_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< CORET_LOAD_RELOAD_Pos*/) /*!< CORET LOAD: RELOAD Mask */
  365. /* CORET Current Register Definitions */
  366. #define CORET_VAL_CURRENT_Pos 0U /*!< CORET VAL: CURRENT Position */
  367. #define CORET_VAL_CURRENT_Msk (0xFFFFFFUL /*<< CORET_VAL_CURRENT_Pos*/) /*!< CORET VAL: CURRENT Mask */
  368. /* CORET Calibration Register Definitions */
  369. #define CORET_CALIB_NOREF_Pos 31U /*!< CORET CALIB: NOREF Position */
  370. #define CORET_CALIB_NOREF_Msk (1UL << CORET_CALIB_NOREF_Pos) /*!< CORET CALIB: NOREF Mask */
  371. #define CORET_CALIB_SKEW_Pos 30U /*!< CORET CALIB: SKEW Position */
  372. #define CORET_CALIB_SKEW_Msk (1UL << CORET_CALIB_SKEW_Pos) /*!< CORET CALIB: SKEW Mask */
  373. #define CORET_CALIB_TENMS_Pos 0U /*!< CORET CALIB: TENMS Position */
  374. #define CORET_CALIB_TENMS_Msk (0xFFFFFFUL /*<< CORET_CALIB_TENMS_Pos*/) /*!< CORET CALIB: TENMS Mask */
  375. /*@} end of group CSI_SysTick */
  376. /**
  377. \ingroup CSI_core_register
  378. \defgroup CSI_DCC
  379. \brief Type definitions for the DCC.
  380. @{
  381. */
  382. /**
  383. \brief 访问DCC的数据结构.
  384. */
  385. typedef struct
  386. {
  387. uint32_t RESERVED0[13U];
  388. __IOM uint32_t HCR; /*!< Offset: 0x034 (R/W) */
  389. __IM uint32_t EHSR; /*!< Offset: 0x03C (R/ ) */
  390. uint32_t RESERVED1[6U];
  391. union
  392. {
  393. __IM uint32_t DERJW; /*!< Offset: 0x058 (R/ ) 数据交换寄存器 CPU读*/
  394. __OM uint32_t DERJR; /*!< Offset: 0x058 ( /W) 数据交换寄存器 CPU写*/
  395. };
  396. } DCC_Type;
  397. #define DCC_HCR_JW_Pos 18U /*!< DCC HCR: jw_int_en Position */
  398. #define DCC_HCR_JW_Msk (1UL << DCC_HCR_JW_Pos) /*!< DCC HCR: jw_int_en Mask */
  399. #define DCC_HCR_JR_Pos 19U /*!< DCC HCR: jr_int_en Position */
  400. #define DCC_HCR_JR_Msk (1UL << DCC_HCR_JR_Pos) /*!< DCC HCR: jr_int_en Mask */
  401. #define DCC_EHSR_JW_Pos 1U /*!< DCC EHSR: jw_vld Position */
  402. #define DCC_EHSR_JW_Msk (1UL << DCC_EHSR_JW_Pos) /*!< DCC EHSR: jw_vld Mask */
  403. #define DCC_EHSR_JR_Pos 2U /*!< DCC EHSR: jr_vld Position */
  404. #define DCC_EHSR_JR_Msk (1UL << DCC_EHSR_JR_Pos) /*!< DCC EHSR: jr_vld Mask */
  405. /*@} end of group CSI_DCC */
  406. /**
  407. \ingroup CSI_core_register
  408. \defgroup CSI_core_bitfield Core register bit field macros
  409. \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
  410. @{
  411. */
  412. /**
  413. \brief Mask and shift a bit field value for use in a register bit range.
  414. \param[in] field Name of the register bit field.
  415. \param[in] value Value of the bit field.
  416. \return Masked and shifted value.
  417. */
  418. #define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk)
  419. /**
  420. \brief Mask and shift a register value to extract a bit filed value.
  421. \param[in] field Name of the register bit field.
  422. \param[in] value Value of register.
  423. \return Masked and shifted bit field value.
  424. */
  425. #define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos)
  426. /*@} end of group CSI_core_bitfield */
  427. /**
  428. \ingroup CSI_core_register
  429. \defgroup CSI_core_base Core Definitions
  430. \brief Definitions for base addresses, unions, and structures.
  431. @{
  432. */
  433. /* Memory mapping of CK802 Hardware */
  434. #define TCIP_BASE (0xE000E000UL) /*!< Titly Coupled IP Base Address */
  435. #define CORET_BASE (TCIP_BASE + 0x0010UL) /*!< CORET Base Address */
  436. #define NVIC_BASE (TCIP_BASE + 0x0100UL) /*!< NVIC Base Address */
  437. #define DCC_BASE (0xE0011000UL) /*!< DCC Base Address */
  438. #define CORET ((CORET_Type *) CORET_BASE ) /*!< SysTick configuration struct */
  439. #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
  440. #define DCC ((DCC_Type *) DCC_BASE ) /*!< DCC configuration struct */
  441. /*@} */
  442. #ifdef __cplusplus
  443. }
  444. #endif
  445. #endif /* __CORE_CK802_H_DEPENDANT */
  446. #endif /* __CSI_GENERIC */