t_bk3231sf.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. #ifndef _USER_BK3231SF_H_
  2. #define _USER_BK3231SF_H_
  3. #include "t_define.h"
  4. /********************************
  5. * reg base addr
  6. ********************************/
  7. #define ADDR_ROM_START 0x00000000ul
  8. #define ADDR_RAM_START 0x00400000ul
  9. #define REG_ICU_BASE 0x00800000ul
  10. #define REG_BK24_BASE 0x00810000ul
  11. #define REG_FLASH_BASE 0x00820000ul
  12. #define REG_AHB2APB_BASE 0x00F00000ul
  13. #define REG_WDT_BASE 0x00F00000ul
  14. #define REG_PWM_BASE 0x00F00100ul
  15. #define REG_SPI_BASE 0x00F00200ul
  16. #define REG_UART_BASE 0x00F00300ul
  17. #define REG_I2C_BASE 0x00F00400ul
  18. #define REG_GPIO_BASE 0x00F00500ul
  19. #define REG_RTC_BASE 0x00F00600ul
  20. #define REG_ADC_BASE 0x00F00700ul
  21. #define REG_3DS_BASE 0x00F00800ul
  22. #define REG_I2C1_BASE 0x00F00900ul
  23. #define REG_TIMER_BASE 0x00F00A00ul
  24. #define REG_XVER_BASE 0x00F10000ul
  25. #define REG_CEVA_BASE 0x00F20000ul
  26. /********************************
  27. * ICU - reg bitoffset bitmask
  28. ********************************/
  29. #define REG_ICU_MCU_CLKSRC_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x00ul)))
  30. #define REG_ICU_CORE_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x04ul)))
  31. #define REG_ICU_ADC_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x08ul)))
  32. #define REG_ICU_UART_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x0cul)))
  33. #define REG_ICU_I2C_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x10ul)))
  34. #define REG_ICU_SPI_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x14ul)))
  35. #define REG_ICU_CEVA_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x18ul)))
  36. #define REG_ICU_WD_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x1cul)))
  37. #define REG_ICU_BK24_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x20ul)))
  38. #define REG_ICU_LPO_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x24ul)))
  39. #define REG_ICU_RTC_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x28ul)))
  40. #define REG_ICU_PWM0_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x2Cul)))
  41. #define REG_ICU_PWM1_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x30ul)))
  42. #define REG_ICU_PWM2_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x34ul)))
  43. #define REG_ICU_PWM3_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x38ul)))
  44. #define REG_ICU_PWM4_CLK_CFG (*((volatile uint32 *) (REG_ICU_BASE + 0x3Cul)))
  45. #define REG_ICU_PPH_INT_EN (*((volatile uint32 *) (REG_ICU_BASE + 0x40ul)))
  46. #define REG_ICU_FIQ_IRQ_EN (*((volatile uint32 *) (REG_ICU_BASE + 0x44ul)))
  47. #define REG_ICU_PPH_INT_STA (*((volatile uint32 *) (REG_ICU_BASE + 0x48ul)))
  48. //#define REG_ICU_PERI_2ND_EN (*((volatile uint32 *) (REG_ICU_BASE + 0x4cul)))
  49. //#define REG_ICU_ANALOG_MODE (*((volatile uint32 *) (REG_ICU_BASE + 0x50ul)))
  50. //#define REG_ICU_ANALOG0_PWD (*((volatile uint32 *) (REG_ICU_BASE + 0x54ul)))
  51. //#define REG_ICU_ANALOG1_PWD (*((volatile uint32 *) (REG_ICU_BASE + 0x58ul)))
  52. //#define REG_ICU_DIGITAL_PWD (*((volatile uint32 *) (REG_ICU_BASE + 0x5cul)))
  53. #define REG_ICU_GPIO0T3_DEEP_WAKEUP_EN (*((volatile uint32 *) (REG_ICU_BASE + 0x60ul)))
  54. #define REG_ICU_GPIO4_DEEP_WAKEUP_EN (*((volatile uint32 *) (REG_ICU_BASE + 0x64ul)))
  55. //#define REG_ICU_RC32K_CONFG (*((volatile uint32 *) (REG_ICU_BASE + 0x68ul)))
  56. //#define REG_ICU_SLEEP_TIME (*((volatile uint32 *) (REG_ICU_BASE + 0x6Cul)))
  57. //#define REG_ICU_BOOST_READY_DLY (*((volatile uint32 *) (REG_ICU_BASE + 0x70ul)))
  58. //#define REG_ICU_RSTNREG_LATCH (*((volatile uint32 *) (REG_ICU_BASE + 0x74ul)))
  59. //#define REG_ICU_EXT_TIMER_CTRL (*((volatile uint32 *) (REG_ICU_BASE + 0x78ul)))
  60. #define REG_ICU_PPH_INT_FIQ_PRIORITY_EN (*((volatile uint32 *) (REG_ICU_BASE + 0x7Cul)))
  61. //#define REG_ICU_DCO16M_PWD (*((volatile uint32 *) (REG_ICU_BASE + 0x80ul)))
  62. //#define REG_ICU_OTP_PWD (*((volatile uint32 *) (REG_ICU_BASE + 0x84ul)))
  63. //#define REG_ICU_OTP_CSTM_CFG0 (*((volatile uint32 *) (REG_ICU_BASE + 0x88ul)))
  64. //#define REG_ICU_OTP_CSTM_CFG1 (*((volatile uint32 *) (REG_ICU_BASE + 0x8Cul)))
  65. //#define REG_ICU_OTP_CSTM_CFG2 (*((volatile uint32 *) (REG_ICU_BASE + 0x90ul)))
  66. //#define REG_ICU_OTP_CSTM_CFG3 (*((volatile uint32 *) (REG_ICU_BASE + 0x94ul)))
  67. //#define REG_ICU_JTAG_MODE (*((volatile uint32 *) (REG_ICU_BASE + 0x98ul)))
  68. #define BO_ICU_MCU_CLKSRC_SEL 0
  69. #define BM_ICU_MCU_CLKSRC_SEL (0x03ul<<BO_ICU_MCU_CLKSRC_SEL)
  70. #define BO_ICU_CORE_CLK_DISEN 0
  71. #define BM_ICU_CORE_CLK_DISEN (0x01ul<<BO_ICU_CORE_CLK_DISEN)
  72. #define BO_ICU_CORE_CLK_DIV 1
  73. #define BM_ICU_CORE_CLK_DIV (0x03ul<<BO_ICU_CORE_CLK_DIV)
  74. #define BO_ICU_ADC_CLK_DISEN 0
  75. #define BM_ICU_ADC_CLK_DISEN (0x01ul<<BO_ICU_ADC_CLK_DISEN)
  76. #define BO_ICU_ADC_CLK_DIV 1
  77. #define BM_ICU_ADC_CLK_DIV (0x7Ful<<BO_ICU_ADC_CLK_DIV)
  78. #define BO_ICU_UART_CLK_DISEN 0
  79. #define BM_ICU_UART_CLK_DISEN (0x01ul<<BO_ICU_UART_CLK_DISEN)
  80. #define BO_ICU_I2C0_CLK_DISEN 0
  81. #define BM_ICU_I2C0_CLK_DISEN (0x01ul<<BO_ICU_I2C0_CLK_DISEN)
  82. #define BO_ICU_I2C1_CLK_DISEN 16
  83. #define BM_ICU_I2C1_CLK_DISEN (0x01ul<<BO_ICU_I2C1_CLK_DISEN)
  84. #define BO_ICU_SPI_CLK_DISEN 0
  85. #define BM_ICU_SPI_CLK_DISEN (0x01ul<<BO_ICU_SPI_CLK_DISEN)
  86. #define BO_ICU_CEVA_CLK_DISEN 0
  87. #define BM_ICU_CEVA_CLK_DISEN (0x01ul<<BO_ICU_CEVA_CLK_DISEN)
  88. #define BO_ICU_WD_CLK_DISEN 0
  89. #define BM_ICU_WD_CLK_DISEN (0x01ul<<BO_ICU_WD_CLK_DISEN)
  90. #define BO_ICU_BK24_CLK_DISEN 0
  91. #define BM_ICU_BK24_CLK_DISEN (0x01ul<<BO_ICU_BK24_CLK_DISEN)
  92. #define BO_ICU_LPO_CLK_DISEN 0
  93. #define BM_ICU_LPO_CLK_DISEN (0x01ul<<BO_ICU_LPO_CLK_DISEN)
  94. #define BO_ICU_LPO_CLK_32SRC_SEL 1
  95. #define BM_ICU_LPO_CLK_32SRC_SEL (0x01ul<<BO_ICU_LPO_CLK_32SRC_SEL)
  96. #define BO_ICU_RTC_CLK_DISEN 0
  97. #define BM_ICU_RTC_CLK_DISEN (0x01ul<<BO_ICU_RTC_CLK_DISEN)
  98. #define BO_ICU_PWM0_CLK_DISEN 0
  99. #define BM_ICU_PWM0_CLK_DISEN (0x01ul<<BO_ICU_PWM0_CLK_DISEN)
  100. #define BO_ICU_PWM0_CLK_SEL 1
  101. #define BM_ICU_PWM0_CLK_SEL (0x03ul<<BO_ICU_PWM0_CLK_SEL)
  102. #define BO_ICU_PWM1_CLK_DISEN 0
  103. #define BM_ICU_PWM1_CLK_DISEN (0x01ul<<BO_ICU_PWM1_CLK_DISEN)
  104. #define BO_ICU_PWM1_CLK_SEL 1
  105. #define BM_ICU_PWM1_CLK_SEL (0x03ul<<BO_ICU_PWM1_CLK_SEL)
  106. #define BO_ICU_PWM2_CLK_DISEN 0
  107. #define BM_ICU_PWM2_CLK_DISEN (0x01ul<<BO_ICU_PWM2_CLK_DISEN)
  108. #define BO_ICU_PWM2_CLK_SEL 1
  109. #define BM_ICU_PWM2_CLK_SEL (0x03ul<<BO_ICU_PWM2_CLK_SEL)
  110. #define BO_ICU_PWM3_CLK_DISEN 0
  111. #define BM_ICU_PWM3_CLK_DISEN (0x01ul<<BO_ICU_PWM3_CLK_DISEN)
  112. #define BO_ICU_PWM3_CLK_SEL 1
  113. #define BM_ICU_PWM3_CLK_SEL (0x03ul<<BO_ICU_PWM3_CLK_SEL)
  114. #define BO_ICU_PWM4_CLK_DISEN 0
  115. #define BM_ICU_PWM4_CLK_DISEN (0x01ul<<BO_ICU_PWM4_CLK_DISEN)
  116. #define BO_ICU_PWM4_CLK_SEL 1
  117. #define BM_ICU_PWM4_CLK_SEL (0x03ul<<BO_ICU_PWM4_CLK_SEL)
  118. #define BO_ICU_PWM5_CLK_DISEN 4
  119. #define BM_ICU_PWM5_CLK_DISEN (0x01ul<<BO_ICU_PWM5_CLK_DISEN)
  120. #define BO_ICU_PWM5_CLK_SEL 5
  121. #define BM_ICU_PWM5_CLK_SEL (0x03ul<<BO_ICU_PWM5_CLK_SEL)
  122. #define BO_ICU_TIMER_CLK_DISEN 8
  123. #define BM_ICU_TIMER_CLK_DISEN (0x01ul<<BO_ICU_TIMER_CLK_DISEN)
  124. #define BO_ICU_TIMER_CLK_SEL 9
  125. #define BM_ICU_TIMER_CLK_SEL (0x01ul<<BO_ICU_TIMER_CLK_SEL)
  126. #define BO_ICU_INT_CEVA 0
  127. #define BO_ICU_INT_GPIO 1
  128. #define BO_ICU_INT_BK24 2
  129. #define BO_ICU_INT_PWM 3
  130. #define BO_ICU_INT_UART 4
  131. #define BO_ICU_INT_RTC 5
  132. #define BO_ICU_INT_ADC 6
  133. #define BO_ICU_INT_SPI 7
  134. #define BO_ICU_INT_I2C0 8
  135. #define BO_ICU_INT_3DS 9
  136. #define BO_ICU_INT_EXT_TIME 10
  137. #define BO_ICU_INT_I2C1 11
  138. #define BO_ICU_INT_TIMER 12
  139. #define BO_ICU_INT_CEVA_WAKEUP 16
  140. #define BO_ICU_INT_GPIO_WAKEUP 17
  141. #define BO_ICU_INT_BK24_WAKEUP 18
  142. #define BO_ICU_INT_PWM_WAKEUP 19
  143. #define BO_ICU_INT_UART_WAKEUP 20
  144. #define BO_ICU_INT_RTC_WAKEUP 21
  145. #define BO_ICU_INT_ADC_WAKEUP 22
  146. #define BO_ICU_INT_SPI_WAKEUP 23
  147. #define BO_ICU_INT_I2C0_WAKEUP 24
  148. #define BO_ICU_INT_3DS_WAKEUP 25
  149. #define BO_ICU_INT_EXT_TIME_WAKEUP 26
  150. #define BO_ICU_INT_I2C1_WAKEUP 27
  151. #define BO_ICU_INT_TIMER_WAKEUP 28
  152. #define BM_ICU_INT_CEVA (0x01ul<<BO_ICU_INT_CEVA)
  153. #define BM_ICU_INT_GPIO (0x01ul<<BO_ICU_INT_GPIO)
  154. #define BM_ICU_INT_BK24 (0x01ul<<BO_ICU_INT_BK24)
  155. #define BM_ICU_INT_PWM (0x01ul<<BO_ICU_INT_PWM)
  156. #define BM_ICU_INT_UART (0x01ul<<BO_ICU_INT_UART)
  157. #define BM_ICU_INT_RTC (0x01ul<<BO_ICU_INT_RTC)
  158. #define BM_ICU_INT_ADC (0x01ul<<BO_ICU_INT_ADC)
  159. #define BM_ICU_INT_SPI (0x01ul<<BO_ICU_INT_SPI)
  160. #define BM_ICU_INT_I2C0 (0x01ul<<BO_ICU_INT_I2C0)
  161. #define BM_ICU_INT_3DS (0x01ul<<BO_ICU_INT_3DS)
  162. #define BM_ICU_INT_EXT_TIME (0x01ul<<BO_ICU_INT_EXT_TIME)
  163. #define BM_ICU_INT_I2C1 (0x01ul<<BO_ICU_INT_I2C1)
  164. #define BM_ICU_INT_TIMER (0x01ul<<BO_ICU_INT_TIMER)
  165. #define BM_ICU_INT_CEVA_WAKEUP (0x01ul<<BO_ICU_INT_CEVA_WAKEUP)
  166. #define BM_ICU_INT_GPIO_WAKEUP (0x01ul<<BO_ICU_INT_GPIO_WAKEUP)
  167. #define BM_ICU_INT_BK24_WAKEUP (0x01ul<<BO_ICU_INT_BK24_WAKEUP)
  168. #define BM_ICU_INT_PWM_WAKEUP (0x01ul<<BO_ICU_INT_PWM_WAKEUP)
  169. #define BM_ICU_INT_UART_WAKEUP (0x01ul<<BO_ICU_INT_UART_WAKEUP)
  170. #define BM_ICU_INT_RTC_WAKEUP (0x01ul<<BO_ICU_INT_RTC_WAKEUP)
  171. #define BM_ICU_INT_ADC_WAKEUP (0x01ul<<BO_ICU_INT_ADC_WAKEUP)
  172. #define BM_ICU_INT_SPI_WAKEUP (0x01ul<<BO_ICU_INT_SPI_WAKEUP)
  173. #define BM_ICU_INT_I2C0_WAKEUP (0x01ul<<BO_ICU_INT_I2C0_WAKEUP)
  174. #define BM_ICU_INT_3DS_WAKEUP (0x01ul<<BO_ICU_INT_3DS_WAKEUP)
  175. #define BM_ICU_INT_EXT_TIME_WAKEUP (0x01ul<<BO_ICU_INT_EXT_TIME_WAKEUP)
  176. #define BM_ICU_INT_I2C1_WAKEUP (0x01ul<<BO_ICU_INT_I2C1_WAKEUP)
  177. #define BM_ICU_INT_TIMER_WAKEUP (0x01ul<<BO_ICU_INT_TIMER_WAKEUP)
  178. #define BO_ICU_INT_IRQ_EN 0
  179. #define BM_ICU_INT_IRQ_EN (0x01<<BO_ICU_INT_IRQ_EN)
  180. #define BO_ICU_INT_FIQ_EN 1
  181. #define BM_ICU_INT_FIQ_EN (0x01<<BO_ICU_INT_FIQ_EN)
  182. #define BO_ICU_DEEP_SLEEP_CTRL_WORD 16
  183. #define BM_ICU_DEEP_SLEEP_CTRL_WORD (0xFFFFuL<<BO_ICU_DEEP_SLEEP_CTRL_WORD)
  184. /********************************
  185. * GPIO - reg bitoffset bitmask
  186. ********************************/
  187. #define REG_GPIO0_CFG (*((volatile uint32 *) (REG_GPIO_BASE + 0x00ul) ))
  188. #define REG_GPIO0_DATA (*((volatile uint32 *) (REG_GPIO_BASE + 0x04ul) ))
  189. #define REG_GPIO1_CFG (*((volatile uint32 *) (REG_GPIO_BASE + 0x08ul) ))
  190. #define REG_GPIO1_DATA (*((volatile uint32 *) (REG_GPIO_BASE + 0x0Cul) ))
  191. #define REG_GPIO2_CFG (*((volatile uint32 *) (REG_GPIO_BASE + 0x10ul) ))
  192. #define REG_GPIO2_DATA (*((volatile uint32 *) (REG_GPIO_BASE + 0x14ul) ))
  193. #define REG_GPIO3_CFG (*((volatile uint32 *) (REG_GPIO_BASE + 0x18ul) ))
  194. #define REG_GPIO3_DATA (*((volatile uint32 *) (REG_GPIO_BASE + 0x1Cul) ))
  195. #define REG_GPIO4_CFG (*((volatile uint32 *) (REG_GPIO_BASE + 0x20ul) ))
  196. #define REG_GPIO4_DATA (*((volatile uint32 *) (REG_GPIO_BASE + 0x24ul) ))
  197. #define REG_GPIO0T3_INT_EDGE (*((volatile uint32 *) (REG_GPIO_BASE + 0x40ul) ))
  198. #define REG_GPIO0T3_INT_EN (*((volatile uint32 *) (REG_GPIO_BASE + 0x48ul) ))
  199. #define REG_GPIO0T3_INT_STA (*((volatile uint32 *) (REG_GPIO_BASE + 0x50ul) ))
  200. #define REG_GPIO4_INT_EDGE (*((volatile uint32 *) (REG_GPIO_BASE + 0x44ul) ))
  201. #define REG_GPIO4_INT_EN (*((volatile uint32 *) (REG_GPIO_BASE + 0x4Cul) ))
  202. #define REG_GPIO4_INT_STA (*((volatile uint32 *) (REG_GPIO_BASE + 0x54ul) ))
  203. #define BO_GPIO_MODE 0
  204. #define BO_GPIO_IO_OUT_NOR 8
  205. #define BO_GPIO_PULL_UP 16
  206. #define BO_GPIO_PULL_DOWN 24
  207. #define BO_GPIO_OUT_DATA 0
  208. #define BO_GPIO_IN_DATA 8
  209. #define BO_GPIO_IO_IN 16
  210. #define BM_GPIO_MODE (0x01ul<<BO_GPIO_MODE)
  211. #define BM_GPIO_IO_OUT_NOR (0x01ul<<BO_GPIO_IO_OUT_NOR)
  212. #define BM_GPIO_PULL_UP (0x01ul<<BO_GPIO_PULL_UP)
  213. #define BM_GPIO_PULL_DOWN (0x01ul<<BO_GPIO_PULL_DOWN)
  214. #define BM_GPIO_OUT_DATA (0x01ul<<BO_GPIO_OUT_DATA)
  215. #define BM_GPIO_IN_DATA (0x01ul<<BO_GPIO_IN_DATA)
  216. #define BM_GPIO_IO_IN (0x01ul<<BO_GPIO_IO_IN)
  217. #define BO_GPIO0_INT 0
  218. #define BO_GPIO1_INT 8
  219. #define BO_GPIO2_INT 16
  220. #define BO_GPIO3_INT 24
  221. #define BO_GPIO4_INT 0
  222. #define BM_GPIO0_INT (0x01ul<<BO_GPIO0_INT)
  223. #define BM_GPIO1_INT (0x01ul<<BO_GPIO1_INT)
  224. #define BM_GPIO2_INT (0x01ul<<BO_GPIO2_INT)
  225. #define BM_GPIO3_INT (0x01ul<<BO_GPIO3_INT)
  226. #define BM_GPIO4_INT (0x01ul<<BO_GPIO4_INT)
  227. /********************************
  228. * UART - reg bitoffset bitmask
  229. ********************************/
  230. #define REG_UART_CFG (*((volatile uint32 *) (REG_UART_BASE + 0x00ul) ))
  231. #define REG_UART_FIFO_CFG (*((volatile uint32 *) (REG_UART_BASE + 0x04ul) ))
  232. #define REG_UART_FIFO_STA (*((volatile uint32 *) (REG_UART_BASE + 0x08ul) ))
  233. #define REG_UART_DATA (*((volatile uint32 *) (REG_UART_BASE + 0x0Cul) ))
  234. #define REG_UART_INT_EN (*((volatile uint32 *) (REG_UART_BASE + 0x10ul) ))
  235. #define REG_UART_INT_STA (*((volatile uint32 *) (REG_UART_BASE + 0x14ul) ))
  236. #define REG_UART_FLOW_CTRL (*((volatile uint32 *) (REG_UART_BASE + 0x18ul) ))
  237. #define REG_UART_WAKEUP_CFG (*((volatile uint32 *) (REG_UART_BASE + 0x1cul) ))
  238. //gen cfg
  239. #define BO_UART_TX_EN 0
  240. #define BO_UART_RX_EN 1
  241. #define BO_UART_IRDA_MODE 2
  242. #define BO_UART_DATA_LEN 3
  243. #define BO_UART_PARITY_EN 5
  244. #define BO_UART_PARITY_MODE 6
  245. #define BO_UART_STOP_LEN 7
  246. #define BO_UART_CLK_DIV 8
  247. #define BM_UART_TX_EN (0x01ul<<BO_UART_TX_EN)
  248. #define BM_UART_RX_EN (0x01ul<<BO_UART_RX_EN)
  249. #define BM_UART_IRDA_MODE (0x01ul<<BO_UART_IRDA_MODE)
  250. #define BM_UART_DATA_LEN (0x03ul<<BO_UART_DATA_LEN)
  251. #define BM_UART_PARITY_EN (0x01ul<<BO_UART_PARITY_EN)
  252. #define BM_UART_PARITY_MODE (0x01ul<<BO_UART_PARITY_MODE)
  253. #define BM_UART_STOP_LEN (0x01ul<<BO_UART_STOP_LEN)
  254. #define BM_UART_CLK_DIV (0x1FFFul<<BO_UART_CLK_DIV)
  255. //fifo cfg
  256. #define BO_UART_TX_FIFO_THRESHOLD 0
  257. #define BO_UART_RX_FIFO_THRESHOLD 8
  258. #define BO_UART_RX_STOP_DETECT_TIME 16
  259. #define BM_UART_TX_FIFO_THRESHOLD (0xFFul<<BO_UART_TX_FIFO_THRESHOLD)
  260. #define BM_UART_RX_FIFO_THRESHOLD (0xFFul<<BO_UART_RX_FIFO_THRESHOLD)
  261. #define BM_UART_RX_STOP_DETECT_TIME (0x03ul<<BO_UART_RX_STOP_DETECT_TIME)
  262. //fifo sta
  263. #define BO_UART_TX_FIFO_CNT 0
  264. #define BO_UART_RX_FIFO_CNT 8
  265. #define BO_UART_TX_FIFO_FULL 16
  266. #define BO_UART_TX_FIFO_EMPTY 17
  267. #define BO_UART_RX_FIFO_FULL 18
  268. #define BO_UART_RX_FIFO_EMPTY 19
  269. #define BO_UART_TX_FIFO_WR_READY 20
  270. #define BO_UART_RX_FIFO_RD_READY 21
  271. #define BM_UART_TX_FIFO_CNT (0xFFul<<BO_UART_TX_FIFO_CNT)
  272. #define BM_UART_RX_FIFO_CNT (0xFFul<<BO_UART_RX_FIFO_CNT)
  273. #define BM_UART_TX_FIFO_FULL (0x01ul<<BO_UART_TX_FIFO_FULL)
  274. #define BM_UART_TX_FIFO_EMPTY (0x01ul<<BO_UART_TX_FIFO_EMPTY)
  275. #define BM_UART_RX_FIFO_FULL (0x01ul<<BO_UART_RX_FIFO_FULL)
  276. #define BM_UART_RX_FIFO_EMPTY (0x01ul<<BO_UART_RX_FIFO_EMPTY)
  277. #define BM_UART_TX_FIFO_WR_READY (0x01ul<<BO_UART_TX_FIFO_WR_READY)
  278. #define BM_UART_RX_FIFO_RD_READY (0x01ul<<BO_UART_RX_FIFO_RD_READY)
  279. //uart data
  280. #define BO_UART_DATA_TX_RNTRY 0
  281. #define BO_UART_DATA_RX_ENTRY 8
  282. #define BM_UART_DATA_TX_RNTRY (0xFFul<<BO_UART_DATA_TX_RNTRY)
  283. #define BM_UART_DATA_RX_ENTRY (0xFFul<<BO_UART_DATA_RX_ENTRY)
  284. //int en
  285. #define BO_UART_TX_FIFO_NEED_WRITE_EN 0
  286. #define BO_UART_RX_FIFO_NEED_READ_EN 1
  287. #define BO_UART_RX_FIFO_OVER_FLOW_EN 2
  288. #define BO_UART_RX_PARITY_ERR_EN 3
  289. #define BO_UART_RX_STOP_ERR_EN 4
  290. #define BO_UART_TX_STOP_END_EN 5
  291. #define BO_UART_RX_STOP_END_EN 6
  292. #define BO_UART_RX_WAKEUP_EN 7
  293. #define BM_UART_TX_FIFO_NEED_WRITE_EN (0x01ul<<BO_UART_TX_FIFO_NEED_WRITE_EN)
  294. #define BM_UART_RX_FIFO_NEED_READ_EN (0x01ul<<BO_UART_RX_FIFO_NEED_READ_EN)
  295. #define BM_UART_RX_FIFO_OVER_FLOW_EN (0x01ul<<BO_UART_RX_FIFO_OVER_FLOW_EN)
  296. #define BM_UART_RX_PARITY_ERR_EN (0x01ul<<BO_UART_RX_PARITY_ERR_EN)
  297. #define BM_UART_RX_STOP_ERR_EN (0x01ul<<BO_UART_RX_STOP_ERR_EN)
  298. #define BM_UART_TX_STOP_END_EN (0x01ul<<BO_UART_TX_STOP_END_EN)
  299. #define BM_UART_RX_STOP_END_EN (0x01ul<<BO_UART_RX_STOP_END_EN)
  300. #define BM_UART_RX_WAKEUP_EN (0x01ul<<BO_UART_RX_WAKEUP_EN)
  301. //int sta
  302. #define BO_UART_TX_FIFO_NEED_WRITE 0
  303. #define BO_UART_RX_FIFO_NEED_READ 1
  304. #define BO_UART_RX_FIFO_OVER_FLOW 2
  305. #define BO_UART_RX_PARITY_ERR 3
  306. #define BO_UART_RX_STOP_ERR 4
  307. #define BO_UART_TX_STOP_END 5
  308. #define BO_UART_RX_STOP_END 6
  309. #define BO_UART_RX_WAKEUP 7
  310. #define BM_UART_TX_FIFO_NEED_WRITE (0x01ul<<BO_UART_TX_FIFO_NEED_WRITE)
  311. #define BM_UART_RX_FIFO_NEED_READ (0x01ul<<BO_UART_RX_FIFO_NEED_READ)
  312. #define BM_UART_RX_FIFO_OVER_FLOW (0x01ul<<BO_UART_RX_FIFO_OVER_FLOW)
  313. #define BM_UART_RX_PARITY_ERR (0x01ul<<BO_UART_RX_PARITY_ERR)
  314. #define BM_UART_RX_STOP_ERR (0x01ul<<BO_UART_RX_STOP_ERR)
  315. #define BM_UART_TX_STOP_END (0x01ul<<BO_UART_TX_STOP_END)
  316. #define BM_UART_RX_STOP_END (0x01ul<<BO_UART_RX_STOP_END)
  317. #define BM_UART_RX_WAKEUP (0x01ul<<BO_UART_RX_WAKEUP)
  318. //flow cfg
  319. //wake cfg
  320. /********************************
  321. * ADC - reg bitoffset bitmask
  322. ********************************/
  323. #define REG_ADC_CFG (*((volatile uint32 *) (REG_ADC_BASE + 0x00ul)))
  324. #define REG_ADC_DATA (*((volatile uint32 *) (REG_ADC_BASE + 0x04ul)))
  325. #define BO_ADC_MODE 0
  326. #define BO_ADC_EN 2
  327. #define BO_ADC_CHNL 3
  328. #define BO_ADC_FIFO_EMPTY 6
  329. #define BO_ADC_BUSY 7
  330. #define BO_ADC_SAMP_RATE 8
  331. #define BO_ADC_START_WAIT 10
  332. #define BO_ADC_VALID_MODE 11
  333. #define BO_ADC_INT_CLEAR 15
  334. #define BO_ADC_CLK_DIV 16
  335. #define BM_ADC_MODE (0x03ul << BO_ADC_MODE)
  336. #define BM_ADC_EN (0x01ul << BO_ADC_EN)
  337. #define BM_ADC_CHNL (0x07ul << BO_ADC_CHNL)
  338. #define BM_ADC_FIFO_EMPTY (0x01ul << BO_ADC_FIFO_EMPTY)
  339. #define BM_ADC_BUSY (0x01ul << BO_ADC_BUSY)
  340. #define BM_ADC_SAMPLE_RATE (0x03ul << BO_ADC_SAMP_RATE)
  341. #define BM_ADC_WAIT_CLK_SET (0x01ul << BO_ADC_START_WAIT)
  342. #define BM_ADC_VALID_MODE (0x03ul << BO_ADC_VALID_MODE)
  343. #define BM_ADC_INT_CLEAR (0x01ul << BO_ADC_INT_CLEAR)
  344. #define BM_ADC_CLK_RATE (0x07ul << BO_ADC_CLK_DIV)
  345. #define BO_ADC_DATA 2
  346. #define BM_ADC_DATA (0xFFul << BO_ADC_DATA)
  347. /********************************
  348. * PWM - reg bitoffset bitmask
  349. ********************************/
  350. #define REG_PWM_CFG (*( (volatile uint32 *) (REG_PWM_BASE + (0x00ul)) ))
  351. #define REG_PWM_INT_STA (*( (volatile uint32 *) (REG_PWM_BASE + (0x04ul)) ))
  352. #define REG_PWM0_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x08ul)) ))
  353. #define REG_PWM0_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x0Cul)) ))
  354. #define REG_PWM1_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x10ul)) ))
  355. #define REG_PWM1_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x14ul)) ))
  356. #define REG_PWM2_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x18ul)) ))
  357. #define REG_PWM2_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x1Cul)) ))
  358. #define REG_PWM3_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x20ul)) ))
  359. #define REG_PWM3_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x24ul)) ))
  360. #define REG_PWM4_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x28ul)) ))
  361. #define REG_PWM4_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x2Cul)) ))
  362. #define REG_PWM5_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x30ul)) ))
  363. #define REG_PWM5_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x34ul)) ))
  364. #define REG_PWM6_CNT (*( (volatile uint32 *) (REG_PWM_BASE + (0x38ul)) ))
  365. #define REG_PWM6_CAP (*( (volatile uint32 *) (REG_PWM_BASE + (0x3Cul)) ))
  366. #define BO_PWM_EN 0
  367. #define BO_PWM_INT_EN 1
  368. #define BO_PWM_MODE 2
  369. #define BM_PWM_EN (0x01ul<<BO_PWM_EN)
  370. #define BM_PWM_INT_EN (0x01ul<<BO_PWM_INT_EN)
  371. #define BM_PWM_MODE (0x03ul<<BO_PWM_MODE)
  372. #define BO_PWM0_INT_STA 0
  373. #define BO_PWM1_INT_STA 1
  374. #define BO_PWM2_INT_STA 2
  375. #define BO_PWM3_INT_STA 3
  376. #define BO_PWM4_INT_STA 4
  377. #define BO_PWM5_INT_STA 5
  378. #define BM_PWM0_INT_STA (0x01ul<<BO_PWM0_INT_STA)
  379. #define BM_PWM1_INT_STA (0x01ul<<BO_PWM1_INT_STA)
  380. #define BM_PWM2_INT_STA (0x01ul<<BO_PWM2_INT_STA)
  381. #define BM_PWM3_INT_STA (0x01ul<<BO_PWM3_INT_STA)
  382. #define BM_PWM4_INT_STA (0x01ul<<BO_PWM4_INT_STA)
  383. #define BM_PWM5_INT_STA (0x01ul<<BO_PWM5_INT_STA)
  384. #define BO_PWM_CNT_PERIOD 0
  385. #define BO_PWM_CNT_DUTY 16
  386. #define BM_PWM_CNT_PERIOD (0xFFFFul<<BO_PWM_CNT_PERIOD)
  387. #define BM_PWM_CNT_DUTY (0xFFFFul<<BO_PWM_CNT_DUTY)
  388. #define BO_PWM_CNT_CAP 0
  389. #define BM_PWM_CNT_CAP (0xFFFFul<<BO_PWM_CNT_CAP)
  390. /********************************
  391. * TIMER - reg bitoffset bitmask
  392. ********************************/
  393. #define REG_TIMER_CFG (*( (volatile uint32 *) (REG_TIMER_BASE + 0x00ul) ))
  394. #define REG_TIMER_INT_STA (*( (volatile uint32 *) (REG_TIMER_BASE + 0x04ul) ))
  395. #define REG_TIMER0_PERIOD_CNT (*( (volatile uint32 *) (REG_TIMER_BASE + 0x08ul) ))
  396. #define REG_TIMER0_CNT (*( (volatile uint32 *) (REG_TIMER_BASE + 0x0Cul) ))
  397. #define REG_TIMER1_PERIOD_CNT (*( (volatile uint32 *) (REG_TIMER_BASE + 0x10ul) ))
  398. #define REG_TIMER1_CNT (*( (volatile uint32 *) (REG_TIMER_BASE + 0x14ul) ))
  399. #define BO_TIMER_EN 0
  400. #define BO_TIMER_INT_EN 1
  401. #define BM_TIMER_EN (0x01ul<<BO_TIMER_EN)
  402. #define BM_TIMER_INT_EN (0x01ul<<BO_TIMER_INT_EN)
  403. #define BO_TIMER0_INT_STA 0
  404. #define BO_TIMER1_INT_STA 1
  405. #define BM_TIMER0_INT_STA (0x01ul<<BO_TIMER0_INT_STA)
  406. #define BM_TIMER1_INT_STA (0x01ul<<BO_TIMER1_INT_STA)
  407. #define BO_TIMER_PERIOD_CNT 0
  408. #define BM_TIMER_PERIOD_CNT (0xFFFFul<<BO_TIMER_PERIOD_CNT)
  409. #define BO_TIMER_CNT 0
  410. #define BM_TIMER_CNT (0xFFFFul<<BO_TIMER_CNT)
  411. /********************************
  412. * RTC - reg bitoffset bitmask
  413. ********************************/
  414. #define REG_RTC_CFG (*((volatile uint32 *) (REG_RTC_BASE + 0x00ul) ))
  415. #define REG_RTC_CLK_CFG (*((volatile uint32 *) (REG_RTC_BASE + 0x04ul) ))
  416. #define REG_RTC_TIME (*((volatile uint32 *) (REG_RTC_BASE + 0x08ul) ))
  417. #define REG_RTC_ALM_TIME (*((volatile uint32 *) (REG_RTC_BASE + 0x0Cul) ))
  418. #define REG_RTC_ALM_FLAG (*((volatile uint32 *) (REG_RTC_BASE + 0x10ul) ))
  419. #define BO_RTC_EN 0
  420. #define BO_RTC_REST 1
  421. #define BO_RTC_ALARM_EN 2
  422. #define BO_RTC_ALARM_MODE 3
  423. #define BM_RTC_EN
  424. #define BM_RTC_REST
  425. #define BM_RTC_ALARM_EN
  426. #define BM_RTC_ALARM_MODE
  427. #define BO_RTC_DIV 0
  428. #define BO_RTC_UNIT_MSEC 2
  429. #define BO_RTC_UNIT_SEC 8
  430. #define BM_RTC_DIV
  431. #define BM_RTC_UNIT_MSEC
  432. #define BM_RTC_UNIT_SEC
  433. #define BO_RTC_SECOND 0
  434. #define BO_RTC_MINUTE 6
  435. #define BO_RTC_HOUR 12
  436. #define BO_RTC_WEEK 17
  437. #define BM_RTC_SECOND 0
  438. #define BM_RTC_MINUTE 6
  439. #define BM_RTC_HOUR 12
  440. #define BM_RTC_WEEK 17
  441. #define BO_RTC_ALARM_SECOND 0
  442. #define BO_RTC_ALARM_MINUTE 6
  443. #define BO_RTC_ALARM_HOUR 12
  444. #define BO_RTC_ALARM_MILLISEC 17
  445. #define BM_RTC_ALARM_SECOND 0
  446. #define BM_RTC_ALARM_MINUTE 6
  447. #define BM_RTC_ALARM_HOUR 12
  448. #define BM_RTC_ALARM_MILLISEC 17
  449. /********************************
  450. * 3DS - reg bitoffset bitmask
  451. ********************************/
  452. #endif