max32660.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. /**
  2. * @file max32660.h
  3. * @brief Device-specific perhiperal header file
  4. */
  5. /*******************************************************************************
  6. * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
  22. * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * Except as contained in this notice, the name of Maxim Integrated
  27. * Products, Inc. shall not be used except as stated in the Maxim Integrated
  28. * Products, Inc. Branding Policy.
  29. *
  30. * The mere transfer of this software does not imply any licenses
  31. * of trade secrets, proprietary technology, copyrights, patents,
  32. * trademarks, maskwork rights, or any other form of intellectual
  33. * property whatsoever. Maxim Integrated Products, Inc. retains all
  34. * ownership rights.
  35. *
  36. * $Date: 2018-12-18 15:37:22 -0600 (Tue, 18 Dec 2018) $
  37. * $Revision: 40072 $
  38. *
  39. ******************************************************************************/
  40. #ifndef _MAX32660_REGS_H_
  41. #define _MAX32660_REGS_H_
  42. #ifndef TARGET_NUM
  43. #define TARGET_NUM 32660
  44. #endif
  45. #include <stdint.h>
  46. #ifndef FALSE
  47. #define FALSE (0)
  48. #endif
  49. #ifndef TRUE
  50. #define TRUE (1)
  51. #endif
  52. #if !defined (__GNUC__)
  53. #define CMSIS_VECTAB_VIRTUAL
  54. #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "nvic_table.h"
  55. #endif /* !__GNUC__ */
  56. /* COMPILER SPECIFIC DEFINES (IAR, ARMCC and GNUC) */
  57. #if defined ( __GNUC__ ) /* GCC */
  58. #define __weak __attribute__((weak))
  59. #elif defined ( __CC_ARM) /* Keil */
  60. #define inline __inline
  61. #pragma anon_unions
  62. #endif
  63. typedef enum {
  64. NonMaskableInt_IRQn = -14,
  65. HardFault_IRQn = -13,
  66. MemoryManagement_IRQn = -12,
  67. BusFault_IRQn = -11,
  68. UsageFault_IRQn = -10,
  69. SVCall_IRQn = -5,
  70. DebugMonitor_IRQn = -4,
  71. PendSV_IRQn = -2,
  72. SysTick_IRQn = -1,
  73. /* Device-specific interrupt sources (external to ARM core) */
  74. /* table entry number */
  75. /* |||| */
  76. /* |||| table offset address */
  77. /* vvvv vvvvvv */
  78. PF_IRQn = 0, /* 0x10 0x0040 16: Power Fail */
  79. WDT0_IRQn, /* 0x11 0x0044 17: Watchdog 0 */
  80. RSV00_IRQn, /* 0x12 0x0048 18: RSV00 */
  81. RTC_IRQn, /* 0x13 0x004C 19: RTC */
  82. RSV1_IRQn, /* 0x14 0x0050 20: RSV1 */
  83. TMR0_IRQn, /* 0x15 0x0054 21: Timer 0 */
  84. TMR1_IRQn, /* 0x16 0x0058 22: Timer 1 */
  85. TMR2_IRQn, /* 0x17 0x005C 23: Timer 2 */
  86. RSV02_IRQn, /* 0x18 0x0060 24: RSV02 */
  87. RSV03_IRQn, /* 0x19 0x0064 25: RSV03 */
  88. RSV04_IRQn, /* 0x1A 0x0068 26: RSV04 */
  89. RSV05_IRQn, /* 0x1B 0x006C 27: RSV05 */
  90. RSV06_IRQn, /* 0x1C 0x0070 28: RSV06 */
  91. I2C0_IRQn, /* 0x1D 0x0074 29: I2C0 */
  92. UART0_IRQn, /* 0x1E 0x0078 30: UART 0 */
  93. UART1_IRQn, /* 0x1F 0x007C 31: UART 1 */
  94. SPI17Y_IRQn, /* 0x20 0x0080 32: SPI17Y */
  95. SPIMSS_IRQn, /* 0x21 0x0084 33: SPIMSS */
  96. RSV07_IRQn, /* 0x22 0x0088 34: RSV07 */
  97. RSV08_IRQn, /* 0x23 0x008C 35: RSV08 */
  98. RSV09_IRQn, /* 0x24 0x0090 36: RSV09 */
  99. RSV10_IRQn, /* 0x25 0x0094 37: RSV10 */
  100. RSV11_IRQn, /* 0x26 0x0098 38: RSV11 */
  101. FLC_IRQn, /* 0x27 0x009C 39: FLC */
  102. GPIO0_IRQn, /* 0x28 0x00A0 40: GPIO0 */
  103. RSV12_IRQn, /* 0x29 0x00A4 41: RSV12 */
  104. RSV13_IRQn, /* 0x2A 0x00A8 42: RSV13 */
  105. RSV14_IRQn, /* 0x2B 0x00AC 43: RSV14 */
  106. DMA0_IRQn, /* 0x2C 0x00B0 44: DMA0 */
  107. DMA1_IRQn, /* 0x2D 0x00B4 45: DMA1 */
  108. DMA2_IRQn, /* 0x2E 0x00B8 46: DMA2 */
  109. DMA3_IRQn, /* 0x2F 0x00BC 47: DMA3 */
  110. RSV15_IRQn, /* 0x30 0x00C0 48: RSV15 */
  111. RSV16_IRQn, /* 0x31 0x00C4 49: RSV16 */
  112. RSV17_IRQn, /* 0x32 0x00C8 50: RSV17 */
  113. RSV18_IRQn, /* 0x33 0x00CC 51: RSV18 */
  114. I2C1_IRQn, /* 0x34 0x00D0 52: I2C1 */
  115. RSV19_IRQn, /* 0x35 0x00D4 53: RSV19 */
  116. RSV20_IRQn, /* 0x36 0x00D8 54: RSV20 */
  117. RSV21_IRQn, /* 0x37 0x00DC 55: RSV21 */
  118. RSV22_IRQn, /* 0x38 0x00E0 56: RSV22 */
  119. RSV23_IRQn, /* 0x39 0x00E4 57: RSV23 */
  120. RSV24_IRQn, /* 0x3A 0x00E8 58: RSV24 */
  121. RSV25_IRQn, /* 0x3B 0x00EC 59: RSV25 */
  122. RSV26_IRQn, /* 0x3C 0x00F0 60: RSV26 */
  123. RSV27_IRQn, /* 0x3D 0x00F4 61: RSV27 */
  124. RSV28_IRQn, /* 0x3E 0x00F8 62: RSV28 */
  125. RSV29_IRQn, /* 0x3F 0x00FC 63: RSV29 */
  126. RSV30_IRQn, /* 0x40 0x0100 64: RSV30 */
  127. RSV31_IRQn, /* 0x41 0x0104 65: RSV31 */
  128. RSV32_IRQn, /* 0x42 0x0108 66: RSV32 */
  129. RSV33_IRQn, /* 0x43 0x010C 67: RSV33 */
  130. RSV34_IRQn, /* 0x44 0x0110 68: RSV34 */
  131. RSV35_IRQn, /* 0x45 0x0114 69: RSV35 */
  132. GPIOWAKE_IRQn, /* 0x46 0x0118 70: GPIO Wakeup */
  133. MXC_IRQ_EXT_COUNT,
  134. } IRQn_Type;
  135. #define MXC_IRQ_COUNT (MXC_IRQ_EXT_COUNT + 16)
  136. /* ================================================================================ */
  137. /* ================ Processor and Core Peripheral Section ================ */
  138. /* ================================================================================ */
  139. /* ---------------------- Configuration of the Cortex-M Processor and Core Peripherals ---------------------- */
  140. #define __CM4_REV 0x0100 /*!< Cortex-M4 Core Revision */
  141. #define __MPU_PRESENT 1 /*!< MPU present or not */
  142. #define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */
  143. #define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
  144. #define __FPU_PRESENT 1 /*!< FPU present or not */
  145. #include <core_cm4.h> /*!< Cortex-M4 processor and core peripherals */
  146. #include "system_max32660.h" /*!< System Header */
  147. /* ================================================================================ */
  148. /* ================== Device Specific Memory Section ================== */
  149. /* ================================================================================ */
  150. #define MXC_FLASH_MEM_BASE 0x00000000UL
  151. #define MXC_FLASH_PAGE_SIZE 0x00002000UL
  152. #define MXC_FLASH_MEM_SIZE 0x00040000UL
  153. #define MXC_INFO_MEM_BASE 0x00040000UL
  154. #define MXC_INFO_MEM_SIZE 0x00001000UL
  155. #define MXC_SRAM_MEM_BASE 0x20000000UL
  156. #define MXC_SRAM_MEM_SIZE 0x00018000UL
  157. /* ================================================================================ */
  158. /* ================ Device Specific Peripheral Section ================ */
  159. /* ================================================================================ */
  160. /*
  161. Base addresses and configuration settings for all MAX32660 peripheral modules.
  162. */
  163. /******************************************************************************/
  164. /* Global control */
  165. #define MXC_BASE_GCR ((uint32_t)0x40000000UL)
  166. #define MXC_GCR ((mxc_gcr_regs_t*)MXC_BASE_GCR)
  167. /******************************************************************************/
  168. /* Non-battery backed SI Registers */
  169. #define MXC_BASE_SIR ((uint32_t)0x40000400UL)
  170. #define MXC_SIR ((mxc_sir_regs_t*)MXC_BASE_SIR)
  171. /******************************************************************************/
  172. /* Watchdog */
  173. #define MXC_BASE_WDT0 ((uint32_t)0x40003000UL)
  174. #define MXC_WDT0 ((mxc_wdt_regs_t*)MXC_BASE_WDT0)
  175. /******************************************************************************/
  176. /* Real Time Clock */
  177. #define MXC_BASE_RTC ((uint32_t)0x40006000UL)
  178. #define MXC_RTC ((mxc_rtc_regs_t*)MXC_BASE_RTC)
  179. /******************************************************************************/
  180. /* Power Sequencer */
  181. #define MXC_BASE_PWRSEQ ((uint32_t)0x40006800UL)
  182. #define MXC_PWRSEQ ((mxc_pwrseq_regs_t*)MXC_BASE_PWRSEQ)
  183. /******************************************************************************/
  184. /* GPIO */
  185. #define MXC_CFG_GPIO_INSTANCES (1)
  186. #define MXC_CFG_GPIO_PINS_PORT (14)
  187. #define MXC_BASE_GPIO0 ((uint32_t)0x40008000UL)
  188. #define MXC_GPIO0 ((mxc_gpio_regs_t*)MXC_BASE_GPIO0)
  189. #define MXC_GPIO_GET_IDX(p) ((p) == MXC_GPIO0 ? 0 :-1)
  190. #define MXC_GPIO_GET_GPIO(i) ((i) == 0 ? MXC_GPIO0 : 0)
  191. #define MXC_GPIO_GET_IRQ(i) ((i) == 0 ? GPIO0_IRQn : 0)
  192. /******************************************************************************/
  193. /* Timer */
  194. #define MXC_CFG_TMR_INSTANCES (3)
  195. #define MXC_BASE_TMR0 ((uint32_t)0x40010000UL)
  196. #define MXC_TMR0 ((mxc_tmr_regs_t*)MXC_BASE_TMR0)
  197. #define MXC_BASE_TMR1 ((uint32_t)0x40011000UL)
  198. #define MXC_TMR1 ((mxc_tmr_regs_t*)MXC_BASE_TMR1)
  199. #define MXC_BASE_TMR2 ((uint32_t)0x40012000UL)
  200. #define MXC_TMR2 ((mxc_tmr_regs_t*)MXC_BASE_TMR2)
  201. #define MXC_TMR_GET_IRQ(i) (IRQn_Type)((i) == 0 ? TMR0_IRQn : \
  202. (i) == 1 ? TMR1_IRQn : \
  203. (i) == 2 ? TMR2_IRQn : 0)
  204. #define MXC_TMR_GET_BASE(i) ((i) == 0 ? MXC_BASE_TMR0 : \
  205. (i) == 1 ? MXC_BASE_TMR1 : \
  206. (i) == 2 ? MXC_BASE_TMR2 : 0)
  207. #define MXC_TMR_GET_TMR(i) ((i) == 0 ? MXC_TMR0 : \
  208. (i) == 1 ? MXC_TMR1 : \
  209. (i) == 2 ? MXC_TMR2 : 0)
  210. #define MXC_TMR_GET_IDX(p) ((p) == MXC_TMR0 ? 0 : \
  211. (p) == MXC_TMR1 ? 1 : \
  212. (p) == MXC_TMR2 ? 2 : -1)
  213. /******************************************************************************/
  214. /* SPIMSS */
  215. #define MXC_SPIMSS_INSTANCES (1)
  216. #define MXC_SPIMSS_FIFO_DEPTH (8)
  217. #define MXC_BASE_SPIMSS ((uint32_t)0x40019000UL)
  218. #define MXC_SPIMSS ((mxc_spimss_regs_t*)MXC_BASE_SPIMSS)
  219. #define MXC_SPIMSS_GET_IDX(p) ((p) == MXC_SPIMSS ? 0 : -1)
  220. #define MXC_SPIMSS_GET_SPI(i) ((i) == 0 ? MXC_SPIMSS : 0)
  221. /******************************************************************************/
  222. /* I2C */
  223. #define MXC_I2C_INSTANCES (2)
  224. #define MXC_I2C_FIFO_DEPTH (8)
  225. #define MXC_BASE_I2C0 ((uint32_t)0x4001D000UL)
  226. #define MXC_I2C0 ((mxc_i2c_regs_t*)MXC_BASE_I2C0)
  227. #define MXC_BASE_I2C1 ((uint32_t)0x4001E000UL)
  228. #define MXC_I2C1 ((mxc_i2c_regs_t*)MXC_BASE_I2C1)
  229. #define MXC_I2C_GET_IRQ(i) (IRQn_Type)((i) == 0 ? I2C0_IRQn : \
  230. (i) == 1 ? I2C1_IRQn : 0)
  231. #define MXC_I2C_GET_BASE(i) ((i) == 0 ? MXC_BASE_I2C0 : \
  232. (i) == 1 ? MXC_BASE_I2C1 : 0)
  233. #define MXC_I2C_GET_I2C(i) ((i) == 0 ? MXC_I2C0 : \
  234. (i) == 1 ? MXC_I2C1 : 0)
  235. #define MXC_I2C_GET_IDX(p) ((p) == MXC_I2C0 ? 0 : \
  236. (p) == MXC_I2C1 ? 1 : -1)
  237. /******************************************************************************/
  238. /* DMA */
  239. #define MXC_DMA_CHANNELS (4)
  240. #define MXC_BASE_DMA ((uint32_t)0x40028000UL)
  241. #define MXC_DMA ((mxc_dma_regs_t*)MXC_BASE_DMA)
  242. /******************************************************************************/
  243. /* FLC */
  244. #define MXC_BASE_FLC ((uint32_t)0x40029000UL)
  245. #define MXC_FLC ((mxc_flc_regs_t*)MXC_BASE_FLC)
  246. /******************************************************************************/
  247. /* Instruction Cache */
  248. #define MXC_BASE_ICC ((uint32_t)0x4002A000UL)
  249. #define MXC_ICC ((mxc_icc_regs_t*)MXC_BASE_ICC)
  250. /******************************************************************************/
  251. /* UART / Serial Port Interface */
  252. #define MXC_UART_INSTANCES (2)
  253. #define MXC_UART_FIFO_DEPTH (8)
  254. #define MXC_BASE_UART0 ((uint32_t)0x40042000UL)
  255. #define MXC_UART0 ((mxc_uart_regs_t*)MXC_BASE_UART0)
  256. #define MXC_BASE_UART1 ((uint32_t)0x40043000UL)
  257. #define MXC_UART1 ((mxc_uart_regs_t*)MXC_BASE_UART1)
  258. #define MXC_UART_GET_IRQ(i) (IRQn_Type)((i) == 0 ? UART0_IRQn : \
  259. (i) == 1 ? UART1_IRQn : 0)
  260. #define MXC_UART_GET_BASE(i) ((i) == 0 ? MXC_BASE_UART0 : \
  261. (i) == 1 ? MXC_BASE_UART1 : 0)
  262. #define MXC_UART_GET_UART(i) ((i) == 0 ? MXC_UART0 : \
  263. (i) == 1 ? MXC_UART1 : 0)
  264. #define MXC_UART_GET_IDX(p) ((p) == MXC_UART0 ? 0 : \
  265. (p) == MXC_UART1 ? 1 : -1)
  266. /******************************************************************************/
  267. /* SPI */
  268. #define MXC_SPI17Y_INSTANCES (4)
  269. #define MXC_SPI17Y_SS_INSTANCES (1)
  270. #define MXC_SPI17Y_FIFO_DEPTH (32)
  271. #define MXC_BASE_SPI17Y ((uint32_t)0x40046000UL)
  272. #define MXC_SPI17Y ((mxc_spi17y_regs_t*)MXC_BASE_SPI17Y)
  273. #define MXC_SPI17Y_GET_IDX(p) ((p) == MXC_SPI17Y ? 0 : -1)
  274. #define MXC_SPI17Y_GET_BASE(i) ((i) == 0 ? MXC_BASE_SPI17Y : 0)
  275. #define MXC_SPI17Y_GET_SPI17Y(i) ((i) == 0 ? MXC_SPI17Y : 0)
  276. /******************************************************************************/
  277. /* Bit Shifting */
  278. #define MXC_F_BIT_0 (1 << 0)
  279. #define MXC_F_BIT_1 (1 << 1)
  280. #define MXC_F_BIT_2 (1 << 2)
  281. #define MXC_F_BIT_3 (1 << 3)
  282. #define MXC_F_BIT_4 (1 << 4)
  283. #define MXC_F_BIT_5 (1 << 5)
  284. #define MXC_F_BIT_6 (1 << 6)
  285. #define MXC_F_BIT_7 (1 << 7)
  286. #define MXC_F_BIT_8 (1 << 8)
  287. #define MXC_F_BIT_9 (1 << 9)
  288. #define MXC_F_BIT_10 (1 << 10)
  289. #define MXC_F_BIT_11 (1 << 11)
  290. #define MXC_F_BIT_12 (1 << 12)
  291. #define MXC_F_BIT_13 (1 << 13)
  292. #define MXC_F_BIT_14 (1 << 14)
  293. #define MXC_F_BIT_15 (1 << 15)
  294. #define MXC_F_BIT_16 (1 << 16)
  295. #define MXC_F_BIT_17 (1 << 17)
  296. #define MXC_F_BIT_18 (1 << 18)
  297. #define MXC_F_BIT_19 (1 << 19)
  298. #define MXC_F_BIT_20 (1 << 20)
  299. #define MXC_F_BIT_21 (1 << 21)
  300. #define MXC_F_BIT_22 (1 << 22)
  301. #define MXC_F_BIT_23 (1 << 23)
  302. #define MXC_F_BIT_24 (1 << 24)
  303. #define MXC_F_BIT_25 (1 << 25)
  304. #define MXC_F_BIT_26 (1 << 26)
  305. #define MXC_F_BIT_27 (1 << 27)
  306. #define MXC_F_BIT_28 (1 << 28)
  307. #define MXC_F_BIT_29 (1 << 29)
  308. #define MXC_F_BIT_30 (1 << 30)
  309. #define MXC_F_BIT_31 (1 << 31)
  310. /******************************************************************************/
  311. /* Bit Banding */
  312. #define BITBAND(reg, bit) ((0xf0000000 & (uint32_t)(reg)) + 0x2000000 + \
  313. (((uint32_t)(reg) & 0x0fffffff) << 5) + ((bit) << 2))
  314. #define MXC_CLRBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit) = 0)
  315. #define MXC_SETBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit) = 1)
  316. #define MXC_GETBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit))
  317. #define MXC_SETFIELD(reg, mask, value) (reg = (reg & ~mask) | (value & mask))
  318. /******************************************************************************/
  319. /* SCB CPACR */
  320. /* Note: Added by Maxim Integrated, as these are missing from CMSIS/Core/Include/core_cm4.h */
  321. #define SCB_CPACR_CP10_Pos 20 /*!< SCB CPACR: Coprocessor 10 Position */
  322. #define SCB_CPACR_CP10_Msk (0x3UL << SCB_CPACR_CP10_Pos) /*!< SCB CPACR: Coprocessor 10 Mask */
  323. #define SCB_CPACR_CP11_Pos 22 /*!< SCB CPACR: Coprocessor 11 Position */
  324. #define SCB_CPACR_CP11_Msk (0x3UL << SCB_CPACR_CP11_Pos) /*!< SCB CPACR: Coprocessor 11 Mask */
  325. #endif /* _MAX32660_REGS_H_ */