]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Maxim/TARGET_MAX32600/max32600.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_Maxim / TARGET_MAX32600 / max32600.h
1 /*******************************************************************************
2  * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
18  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Except as contained in this notice, the name of Maxim Integrated
23  * Products, Inc. shall not be used except as stated in the Maxim Integrated
24  * Products, Inc. Branding Policy.
25  *
26  * The mere transfer of this software does not imply any licenses
27  * of trade secrets, proprietary technology, copyrights, patents,
28  * trademarks, maskwork rights, or any other form of intellectual
29  * property whatsoever. Maxim Integrated Products, Inc. retains all
30  * ownership rights.
31  *******************************************************************************
32  */
33
34 #ifndef _MAX32600_H_
35 #define _MAX32600_H_
36
37 #include <stdint.h>
38
39 typedef enum IRQn_Type {
40     NonMaskableInt_IRQn = -14,
41     HardFault_IRQn = -13,
42     MemoryManagement_IRQn = -12,
43     BusFault_IRQn = -11,
44     UsageFault_IRQn = -10,
45     SVCall_IRQn = -5,
46     DebugMonitor_IRQn = -4,
47     PendSV_IRQn = -2,
48     SysTick_IRQn = -1,
49
50     /* Externals interrupts */
51     UART0_IRQn = 0,      /* 16:01 UART0 */
52     UART1_IRQn,          /* 17: 2 UART1 */
53     I2CM0_IRQn,          /* 18: 3 I2C Master 0 */
54     I2CS_IRQn,           /* 19: 4 I2C Slave */
55     USB_IRQn,            /* 20: 5 USB */
56     PMU_IRQn,            /* 21: 6 DMA */
57     AFE_IRQn,            /* 22: 7 AFE */
58     MAA_IRQn,            /* 23: 8 MAA */
59     AES_IRQn,            /* 24: 9 AES */
60     SPI0_IRQn,           /* 25:10 SPI0 */
61     SPI1_IRQn,           /* 26:11 SPI1 */
62     SPI2_IRQn,           /* 27:12 SPI2 */
63     TMR0_IRQn,           /* 28:13 Timer32-0 */
64     TMR1_IRQn,           /* 29:14 Timer32-1 */
65     TMR2_IRQn,           /* 30:15 Timer32-1 */
66     TMR3_IRQn,           /* 31:16 Timer32-2 */
67     RSVD0_IRQn,          /* 32:17 RSVD */
68     RSVD1_IRQn,          /* 33:18 RSVD */
69     DAC0_IRQn,           /* 34:19 DAC0  (12-bit DAC) */
70     DAC1_IRQn,           /* 35:20 DAC1  (12-bit DAC) */
71     DAC2_IRQn,           /* 36:21 DAC2  (8-bit DAC) */
72     DAC3_IRQn,           /* 37:22 DAC3  (8-bit DAC) */
73     ADC_IRQn,            /* 38:23 ADC */
74     FLC_IRQn,            /* 39:24 Flash Controller */
75     PWRMAN_IRQn,         /* 40:25 PWRMAN */
76     CLKMAN_IRQn,         /* 41:26 CLKMAN */
77     RTC0_IRQn,           /* 42:27 RTC INT0 */
78     RTC1_IRQn,           /* 43:28 RTC INT1 */
79     RTC2_IRQn,           /* 44:29 RTC INT2 */
80     RTC3_IRQn,           /* 45:30 RTC INT3 */
81     WDT0_IRQn,           /* 46:31 WATCHDOG0 */
82     WDT0_P_IRQn,         /* 47:32 WATCHDOG0 PRE-WINDOW */
83     WDT1_IRQn,           /* 48:33 WATCHDOG1 */
84     WDT1_P_IRQn,         /* 49:34 WATCHDOG1 PRE-WINDOW */
85     GPIO_P0_IRQn,        /* 50:35 GPIO Port 0  */
86     GPIO_P1_IRQn,        /* 51:36 GPIO Port 1  */
87     GPIO_P2_IRQn,        /* 52:37 GPIO Port 2  */
88     GPIO_P3_IRQn,        /* 53:38 GPIO Port 3  */
89     GPIO_P4_IRQn,        /* 54:39 GPIO Port 4  */
90     GPIO_P5_IRQn,        /* 55:40 GPIO Port 5  */
91     GPIO_P6_IRQn,        /* 56:41 GPIO Port 6  */
92     GPIO_P7_IRQn,        /* 57:42 GPIO Port 7  */
93     TMR16_0_IRQn,        /* 58:43 Timer16-s0 */
94     TMR16_1_IRQn,        /* 59:44 Timer16-s1 */
95     TMR16_2_IRQn,        /* 60:45 Timer16-s2 */
96     TMR16_3_IRQn,        /* 61:46 Timer16-s3 */
97     I2CM1_IRQn,          /* 62:47 I2C Master 1 */
98     MXC_IRQ_EXT_COUNT,
99 } IRQn_Type;
100
101 #define MXC_IRQ_COUNT (MXC_IRQ_EXT_COUNT + 16)
102
103 /* ================================================================================ */
104 /* ================      Processor and Core Peripheral Section     ================ */
105 /* ================================================================================ */
106
107 #define __NVIC_PRIO_BITS          3         /*!< Number of Bits used for Priority Levels         */
108
109 #include <core_cm3.h>                       /* Processor and core peripherals */
110 #include "system_max32600.h"                /* System Header */
111
112 /* ================================================================================ */
113 /* ==================       Device Specific Memory Section       ================== */
114 /* ================================================================================ */
115
116 #define MXC_FLASH_MEM_BASE    0x00000000UL
117 #define MXC_FLASH_PAGE_SIZE   0x1000        // 256 x 128b = 4KB
118 #define MXC_FLASH_MEM_SIZE    0x00040000UL
119 #define MXC_SYS_MEM_BASE      0x20000000UL
120
121 /* ================================================================================ */
122 /* ================       Device Specific Peripheral Section       ================ */
123 /* ================================================================================ */
124
125 /*******************************************************************************/
126 /*                                            General Purpose I/O Ports (GPIO) */
127
128 #define MXC_BASE_GPIO                   ((uint32_t)0x40000000UL)
129 #define MXC_GPIO                        ((mxc_gpio_regs_t *)MXC_BASE_GPIO)
130 #define MXC_BASE_GPIO_BITBAND           ((uint32_t)0x42000000UL)
131
132 #define MXC_GPIO_GET_IRQ(i)             (((unsigned int)i) + GPIO_P0_IRQn)
133
134
135 /*******************************************************************************/
136 /*                                                      Pulse Train Generation */
137
138 #define MXC_CFG_PT_INSTANCES             (13)
139
140 #define MXC_BASE_PTG                     ((uint32_t)0x40001000UL)
141 #define MXC_PTG                          ((mxc_ptg_regs_t *)MXC_BASE_PTG)
142 #define MXC_BASE_PT                      ((uint32_t)0x40001008UL)
143 #define MXC_PT                           ((mxc_pt_regs_t *)MXC_BASE_PT)
144 #define MXC_BASE_PT0                     ((uint32_t)0x40001008UL)
145 #define MXC_PT0                          ((mxc_pt_regs_t *)MXC_BASE_PT0)
146 #define MXC_BASE_PT1                     ((uint32_t)0x40001010UL)
147 #define MXC_PT1                          ((mxc_pt_regs_t *)MXC_BASE_PT1)
148 #define MXC_BASE_PT2                     ((uint32_t)0x40001018UL)
149 #define MXC_PT2                          ((mxc_pt_regs_t *)MXC_BASE_PT2)
150 #define MXC_BASE_PT3                     ((uint32_t)0x40001020UL)
151 #define MXC_PT3                          ((mxc_pt_regs_t *)MXC_BASE_PT3)
152 #define MXC_BASE_PT4                     ((uint32_t)0x40001028UL)
153 #define MXC_PT4                          ((mxc_pt_regs_t *)MXC_BASE_PT4)
154 #define MXC_BASE_PT5                     ((uint32_t)0x40001030UL)
155 #define MXC_PT5                          ((mxc_pt_regs_t *)MXC_BASE_PT5)
156 #define MXC_BASE_PT6                     ((uint32_t)0x40001038UL)
157 #define MXC_PT6                          ((mxc_pt_regs_t *)MXC_BASE_PT6)
158 #define MXC_BASE_PT7                     ((uint32_t)0x40001040UL)
159 #define MXC_PT7                          ((mxc_pt_regs_t *)MXC_BASE_PT7)
160 #define MXC_BASE_PT8                     ((uint32_t)0x40001048UL)
161 #define MXC_PT8                          ((mxc_pt_regs_t *)MXC_BASE_PT8)
162 #define MXC_BASE_PT9                     ((uint32_t)0x40001050UL)
163 #define MXC_PT9                          ((mxc_pt_regs_t *)MXC_BASE_PT9)
164 #define MXC_BASE_PT10                    ((uint32_t)0x40001058UL)
165 #define MXC_PT10                         ((mxc_pt_regs_t *)MXC_BASE_PT10)
166 #define MXC_BASE_PT11                    ((uint32_t)0x40001060UL)
167 #define MXC_PT11                         ((mxc_pt_regs_t *)MXC_BASE_PT11)
168
169 /*                                       PT12, PT13, PT14 are not used         */
170
171 /*******************************************************************************/
172 /*                                                        CRC-16/CRC-32 Engine */
173
174 #define MXC_BASE_CRC                    ((uint32_t)0x40010000UL)
175 #define MXC_CRC_REGS                    ((mxc_crc_regs_t *)MXC_BASE_CRC)
176
177 #define MXC_BASE_CRC_DATA               ((uint32_t)0x4010B000UL)
178 #define MXC_CRC_DATA                    ((mxc_crc_data_regs_t *)MXC_BASE_CRC_DATA)
179
180 /*******************************************************************************/
181 /*                                                 Trust Protection Unit (TPU) */
182
183 #define MXC_BASE_TPU                     ((uint32_t)0x40011000UL)
184 #define MXC_TPU                          ((mxc_tpu_regs_t *)MXC_BASE_TPU)
185
186 #define MXC_BASE_TPU_TSR                 ((uint32_t)0x40011C00UL)
187 #define MXC_TPU_TSR                      ((mxc_tpu_tsr_regs_t *)MXC_BASE_TPU_TSR)
188
189 /*******************************************************************************/
190 /*                                                    AES Cryptographic Engine */
191
192 #define MXC_BASE_AES                     ((uint32_t)0x40011400UL)
193 #define MXC_AES                          ((mxc_aes_regs_t *)MXC_BASE_AES)
194
195 #define MXC_BASE_AES_MEM                 ((uint32_t)0x4010A000UL)
196 #define MXC_AES_MEM                      ((mxc_aes_mem_regs_t *)MXC_BASE_AES_MEM)
197
198
199 /*******************************************************************************/
200 /*                                                    MAA Cryptographic Engine */
201
202 #define MXC_BASE_MAA                     ((uint32_t)0x40011800UL)
203 #define MXC_MAA                          ((mxc_maa_regs_t *)MXC_BASE_MAA)
204
205 #define MXC_BASE_MAA_MEM                 ((uint32_t)0x4010A800UL)
206 #define MXC_MAA_MEM                      ((mxc_maa_mem_regs_t *)MXC_BASE_MAA_MEM)
207
208 /*******************************************************************************/
209 /*                                                    32-Bit PWM Timer/Counter */
210
211 #define MXC_CFG_TMR_INSTANCES            (4)
212
213 #define MXC_BASE_TMR0                    ((uint32_t)0x40012000UL)
214 #define MXC_BASE_TMR0_BITBAND            ((uint32_t)0x42240000UL)
215 #define MXC_TMR0                         ((mxc_tmr_regs_t *) MXC_BASE_TMR0)
216
217 #define MXC_BASE_TMR1                    ((uint32_t)0x40013000UL)
218 #define MXC_BASE_TMR1_BITBAND            ((uint32_t)0x42260000UL)
219 #define MXC_TMR1                         ((mxc_tmr_regs_t *) MXC_BASE_TMR1)
220
221 #define MXC_BASE_TMR2                    ((uint32_t)0x40014000UL)
222 #define MXC_BASE_TMR2_BITBAND            ((uint32_t)0x42280000UL)
223 #define MXC_TMR2                         ((mxc_tmr_regs_t *) MXC_BASE_TMR2)
224
225 #define MXC_BASE_TMR3                    ((uint32_t)0x40015000UL)
226 #define MXC_BASE_TMR3_BITBAND            ((uint32_t)0x422A0000UL)
227 #define MXC_TMR3                         ((mxc_tmr_regs_t *) MXC_BASE_TMR3)
228
229
230 #define MXC_TMR_GET_IRQ_32(i)            ((i) == 0 ? TMR0_IRQn :    \
231                                           (i) == 1 ? TMR1_IRQn :    \
232                                           (i) == 2 ? TMR2_IRQn :    \
233                                           (i) == 3 ? TMR3_IRQn : 0)
234
235 #define MXC_TMR_GET_IRQ_16(i)            ((i) == 0 ? TMR0_IRQn :    \
236                                           (i) == 1 ? TMR1_IRQn :    \
237                                           (i) == 2 ? TMR2_IRQn :    \
238                                           (i) == 3 ? TMR3_IRQn :    \
239                                           (i) == 4 ? TMR16_0_IRQn :    \
240                                           (i) == 5 ? TMR16_1_IRQn :    \
241                                           (i) == 6 ? TMR16_2_IRQn :    \
242                                           (i) == 7 ? TMR16_3_IRQn : 0)
243
244 #define MXC_TMR_GET_BASE(i)              ((i) == 0 ? MXC_BASE_TMR0 : \
245                                           (i) == 1 ? MXC_BASE_TMR1 : \
246                                           (i) == 2 ? MXC_BASE_TMR2 : \
247                                           (i) == 3 ? MXC_BASE_TMR3 : 0)
248
249 #define MXC_TMR_GET_TMR(i)               ((i) == 0 ? MXC_TMR0 : \
250                                           (i) == 1 ? MXC_TMR1 : \
251                                           (i) == 2 ? MXC_TMR2 : \
252                                           (i) == 3 ? MXC_TMR3 : 0)
253 /*******************************************************************************/
254 /*                                                              Watchdog Timer */
255
256 #define MXC_CFG_WDT_INSTANCES            (2)
257
258 #define MXC_BASE_WDT0                    ((uint32_t)0x40021000UL)
259 #define MXC_BASE_WDT0_BITBAND            ((uint32_t)0x42420000UL)
260 #define MXC_WDT0                         ((mxc_wdt_regs_t *)MXC_BASE_WDT0)
261
262 #define MXC_BASE_WDT1                    ((uint32_t)0x40022000UL)
263 #define MXC_BASE_WDT1_BITBAND            ((uint32_t)0x42440000UL)
264 #define MXC_WDT1                         ((mxc_wdt_regs_t *)MXC_BASE_WDT1)
265
266 #define MXC_WDT_GET_IRQ(i)               ((i) == 0 ? WDT0_IRQn : \
267                                           (i) == 1 ? WDT1_IRQn : 0)
268
269 #define MXC_WDT_GET_IRQ_P(i)             ((i) == 0 ? WDT0_P_IRQn : \
270                                           (i) == 1 ? WDT1_P_IRQn : 0)
271
272 #define MXC_WDT_GET_BASE(i)              ((i) == 0 ? MXC_BASE_WDT0 : \
273                                           (i) == 1 ? MXC_BASE_WDT1 : 0)
274
275 #define MXC_WDT_GET_WDT(i)               ((i) == 0 ? MXC_WDT0 : \
276                                           (i) == 1 ? MXC_WDT1 : 0)
277
278 /*******************************************************************************/
279 /*                                                               SPI Interface */
280
281 #define MXC_CFG_SPI_INSTANCES            (3)
282 #define MXC_CFG_SPI_FIFO_DEPTH           (16)
283
284 #define MXC_BASE_SPI0                    ((uint32_t)0x40030000UL)
285 #define MXC_SPI0                         ((mxc_spi_regs_t *)MXC_BASE_SPI0)
286
287 #define MXC_BASE_SPI0_TXFIFO             ((uint32_t)0x40100000UL)
288 #define MXC_SPI0_TXFIFO                  ((mxc_spi_txfifo_regs_t *)MXC_BASE_SPI0_TXFIFO)
289 #define MXC_BASE_SPI0_RXFIFO             ((uint32_t)0x40100800UL)
290 #define MXC_SPI0_RXFIFO                  ((mxc_spi_rxfifo_regs_t *)MXC_BASE_SPI0_RXFIFO)
291
292 #define MXC_BASE_SPI1                    ((uint32_t)0x40031000UL)
293 #define MXC_SPI1                         ((mxc_spi_regs_t *)MXC_BASE_SPI1)
294
295 #define MXC_BASE_SPI1_TXFIFO             ((uint32_t)0x40101000UL)
296 #define MXC_SPI1_TXFIFO                  ((mxc_spi_txfifo_regs_t *)MXC_BASE_SPI1_TXFIFO)
297 #define MXC_BASE_SPI1_RXFIFO             ((uint32_t)0x40101800UL)
298 #define MXC_SPI1_RXFIFO                  ((mxc_spi_rxfifo_regs_t *)MXC_BASE_SPI1_RXFIFO)
299
300 #define MXC_BASE_SPI2                    ((uint32_t)0x40032000UL)
301 #define MXC_SPI2                         ((mxc_spi_regs_t *)MXC_BASE_SPI2)
302
303 #define MXC_BASE_SPI2_TXFIFO             ((uint32_t)0x40102000UL)
304 #define MXC_SPI2_TXFIFO                  ((mxc_spi_txfifo_regs_t *)MXC_BASE_SPI2_TXFIFO)
305 #define MXC_BASE_SPI2_RXFIFO             ((uint32_t)0x40102800UL)
306 #define MXC_SPI2_RXFIFO                  ((mxc_spi_rxfifo_regs_t *)MXC_BASE_SPI2_RXFIFO)
307
308
309 #define MXC_SPI_GET_IRQ(i)               ((i) == 0 ? SPI0_IRQn :       \
310                                           (i) == 1 ? SPI1_IRQn :       \
311                                           (i) == 2 ? SPI2_IRQn : 0)
312
313 #define MXC_SPI_GET_BASE(i)              ((i) == 0 ? MXC_BASE_SPI0 :      \
314                                           (i) == 1 ? MXC_BASE_SPI1 :      \
315                                           (i) == 2 ? MXC_BASE_SPI2 : 0)
316
317 #define MXC_SPI_GET_SPI(i)               ((i) == 0 ? MXC_SPI0 :      \
318                                           (i) == 1 ? MXC_SPI1 :      \
319                                           (i) == 2 ? MXC_SPI2 : 0)
320
321 #define MXC_SPI_GET_RXFIFO(i)            ((i) == 0 ? MXC_SPI0_RXFIFO :      \
322                                           (i) == 1 ? MXC_SPI1_RXFIFO :      \
323                                           (i) == 2 ? MXC_SPI2_RXFIFO : 0)
324
325 #define MXC_SPI_GET_TXFIFO(i)            ((i) == 0 ? MXC_SPI0_TXFIFO :      \
326                                           (i) == 1 ? MXC_SPI1_TXFIFO :      \
327                                           (i) == 2 ? MXC_SPI2_TXFIFO : 0)
328
329 #define MXC_SPI_INSTANCE_TO_BASE(instance) (((uint32_t)(instance) << 12) + MXC_BASE_SPI0)
330 #define MXC_SPI_BASE_TO_INSTANCE(base)     (((uint32_t)(base) & 0x00003000) >> 12)
331
332
333 /*******************************************************************************/
334 /*                                                              UART Interface */
335
336 #define MXC_CFG_UART_INSTANCES           (2)
337
338 #define MXC_BASE_UART0                   ((uint32_t)0x40038000UL)
339 #define MXC_BASE_UART0_BITBAND           ((uint32_t)0x42700000UL)
340 #define MXC_UART0                        ((mxc_uart_regs_t *)MXC_BASE_UART0)
341
342 #define MXC_BASE_UART1                   ((uint32_t)0x40039000UL)
343 #define MXC_BASE_UART1_BITBAND           ((uint32_t)0x42720000UL)
344 #define MXC_UART1                        ((mxc_uart_regs_t *)MXC_BASE_UART1)
345
346
347 #define MXC_UART_GET_IRQ(i)              ((i) == 0 ? UART0_IRQn :      \
348                                           (i) == 1 ? UART1_IRQn : 0)
349
350 #define MXC_UART_GET_BASE(i)             ((i) == 0 ? MXC_BASE_UART0 :     \
351                                           (i) == 1 ? MXC_BASE_UART1 : 0)
352
353 #define MXC_UART_GET_UART(i)             ((i) == 0 ? MXC_UART0 :     \
354                                           (i) == 1 ? MXC_UART1 : 0)
355
356 #define MXC_UART_INSTANCE_TO_BASE(instance) (((uint32_t)(instance) << 12) + MXC_BASE_UART0)
357 #define MXC_UART_BASE_TO_INSTANCE(base)     (((uint32_t)(base) & 0x00001000) >> 12)
358
359
360 /*******************************************************************************/
361 /*                                                        I2C Master Interface */
362
363 #define MXC_CFG_I2CM_INSTANCES           (2)
364
365 #define MXC_BASE_I2CM0                   ((uint32_t)0x40040000UL)
366 #define MXC_BASE_I2CM0_BITBAND           ((uint32_t)0x42800000UL)
367 #define MXC_I2CM0                        ((mxc_i2cm_regs_t *)MXC_BASE_I2CM0)
368 #define MXC_BASE_I2CM0_TX_FIFO           ((uint32_t)0x40103000UL)
369 #define MXC_BASE_I2CM0_RX_FIFO           ((uint32_t)0x40103800UL)
370
371 #define MXC_BASE_I2CM1                   ((uint32_t)0x40042000UL)
372 #define MXC_BASE_I2CM1_BITBAND           ((uint32_t)0x42840000UL)
373 #define MXC_I2CM1                        ((mxc_i2cm_regs_t *)MXC_BASE_I2CM1)
374 #define MXC_BASE_I2CM1_TX_FIFO           ((uint32_t)0x4010D000UL)
375 #define MXC_BASE_I2CM1_RX_FIFO           ((uint32_t)0x4010D800UL)
376
377 #define MXC_I2CM_GET_IRQ(i)              ((i) == 0 ? I2CM0_IRQn :      \
378                                           (i) == 1 ? I2CM1_IRQn : 0)
379
380 #define MXC_I2CM_GET_BASE(i)             ((i) == 0 ? MXC_BASE_I2CM0 :     \
381                                           (i) == 1 ? MXC_BASE_I2CM1 : 0)
382
383 #define MXC_I2CM_GET_I2CM(i)             ((i) == 0 ? MXC_I2CM0 :     \
384                                           (i) == 1 ? MXC_I2CM1 : 0)
385
386 #define MXC_I2CM_GET_BASE_TX_FIFO(i)     ((i) == 0 ? MXC_BASE_I2CM0_TX_FIFO :  \
387                                           (i) == 1 ? MXC_BASE_I2CM1_TX_FIFO : 0)
388
389 #define MXC_I2CM_GET_BASE_RX_FIFO(i)     ((i) == 0 ? MXC_BASE_I2CM0_RX_FIFO :  \
390                                           (i) == 1 ? MXC_BASE_I2CM1_RX_FIFO : 0)
391
392 #define MXC_I2CM_INSTANCE_TO_BASE(instance)   (((uint32_t)(instance) << 13) + MXC_BASE_I2CM0)
393 #define MXC_I2CM_BASE_TO_INSTANCE(base)       (((uint32_t)(base) & 0x00002000) >> 13)
394
395
396 /*******************************************************************************/
397 /*                                                         I2C Slave Interface */
398
399 #define MXC_CFG_I2CS_INSTANCES           (1)
400
401 #define MXC_BASE_I2CS0                   ((uint32_t)0x40041000UL)
402 #define MXC_BASE_I2CS0_BITBAND           ((uint32_t)0x42820000UL)
403 #define MXC_I2CS0                        ((mxc_i2cs_regs_t *)MXC_BASE_I2CS0)
404
405 #define MXC_BASE_I2CS0_FIFO              ((uint32_t)0x40104000UL)
406 #define MXC_I2CS0_FIFO                   ((mxc_i2cs_fifo_regs_t *)MXC_BASE_I2CS0)
407
408
409
410 /*******************************************************************************/
411 /*                                                                        DACs */
412
413 #define MXC_CFG_DAC_INSTANCES            (4)
414 #define MXC_CFG_DAC_FIFO_DEPTH           (32)
415
416 #define MXC_BASE_DAC0                    ((uint32_t)0x40050000UL)
417 #define MXC_DAC0                         ((mxc_dac_regs_t *)MXC_BASE_DAC0)
418 #define MXC_BASE_DAC0_FIFO               ((uint32_t)0x40105000UL)
419 #define MXC_DAC0_FIFO                    ((mxc_dac_fifo_regs_t *)MXC_BASE_DAC0_FIFO)
420 #define MXC_DAC0_WIDTH                   ((uint8_t)(2))
421
422 #define MXC_BASE_DAC1                    ((uint32_t)0x40051000UL)
423 #define MXC_DAC1                         ((mxc_dac_regs_t *)MXC_BASE_DAC1)
424 #define MXC_BASE_DAC1_FIFO               ((uint32_t)0x40106000UL)
425 #define MXC_DAC1_FIFO                    ((mxc_dac_fifo_regs_t *)MXC_BASE_DAC1_FIFO)
426 #define MXC_DAC1_WIDTH                   ((uint8_t)(2))
427
428 #define MXC_BASE_DAC2                    ((uint32_t)0x40052000UL)
429 #define MXC_DAC2                         ((mxc_dac_regs_t *)MXC_BASE_DAC2)
430 #define MXC_BASE_DAC2_FIFO               ((uint32_t)0x40107000UL)
431 #define MXC_DAC2_FIFO                    ((mxc_dac_fifo_regs_t *)MXC_BASE_DAC2_FIFO)
432 #define MXC_DAC2_WIDTH                   ((uint8_t)(1))
433
434 #define MXC_BASE_DAC3                    ((uint32_t)0x40053000UL)
435 #define MXC_DAC3                         ((mxc_dac_regs_t *)MXC_BASE_DAC3)
436 #define MXC_BASE_DAC3_FIFO               ((uint32_t)0x40108000UL)
437 #define MXC_DAC3_FIFO                    ((mxc_dac_fifo_regs_t *)MXC_BASE_DAC3_FIFO)
438 #define MXC_DAC3_WIDTH                   ((uint8_t)(1))
439
440
441 #define MXC_DAC_GET_IRQ(i)               ((i) == 0 ? DAC0_IRQn :     \
442                                           (i) == 1 ? DAC1_IRQn :     \
443                                           (i) == 2 ? DAC2_IRQn :     \
444                                           (i) == 3 ? DAC3_IRQn : 0)
445
446
447 #define MXC_DAC_GET_BASE(i) (i == 0 ? MXC_BASE_DAC0 : \
448                              i == 1 ? MXC_BASE_DAC1 : \
449                              i == 2 ? MXC_BASE_DAC2 : \
450                              i == 3 ? MXC_BASE_DAC3 : 0)
451
452 #define MXC_DAC_GET_FIFO(i) (i == 0 ? MXC_BASE_DAC0_FIFO : \
453                              i == 1 ? MXC_BASE_DAC1_FIFO : \
454                              i == 2 ? MXC_BASE_DAC2_FIFO  : \
455                              i == 3 ? MXC_BASE_DAC3_FIFO  : 0)
456
457 #define MXC_DAC_GET_PMU_FIFO_IRQ(i) (i == 0 ? PMU_IRQ_DAC0_FIFO_AE : \
458                                      i == 1 ? PMU_IRQ_DAC1_FIFO_AE : \
459                                      i == 2 ? PMU_IRQ_DAC2_FIFO_AE  : \
460                                      i == 3 ? PMU_IRQ_DAC3_FIFO_AE  : 0)
461
462 #define MXC_DAC_GET_DAC(i)  (i == 0 ? MXC_DAC0 : \
463                              i == 1 ? MXC_DAC1 : \
464                              i == 2 ? MXC_DAC2 : \
465                              i == 3 ? MXC_DAC3 : 0)
466
467 #define MXC_DAC_GET_WIDTH(i)  (i == 0 ? MXC_DAC0_WIDTH : \
468                                i == 1 ? MXC_DAC1_WIDTH : \
469                                i == 2 ? MXC_DAC2_WIDTH : \
470                                i == 3 ? MXC_DAC3_WIDTH : 0)
471
472
473 /*******************************************************************************/
474 /*                                                            Analog Front End */
475
476 #define MXC_BASE_AFE                     ((uint32_t)0x4005401CUL)
477 #define MXC_AFE                          ((mxc_afe_regs_t *)MXC_BASE_AFE)
478
479
480
481 /*******************************************************************************/
482 /*                                                                         ADC */
483
484 #define MXC_CFG_ADC_FIFO_DEPTH           ((uint32_t)(32))
485
486 #define MXC_BASE_ADC                     ((uint32_t)0x40054000UL)
487 #define MXC_ADC                          ((mxc_adc_regs_t *)MXC_BASE_ADC)
488
489 #define MXC_BASE_ADCCFG                  ((uint32_t)0x40054038UL)
490 #define MXC_ADCCFG                       ((mxc_adccfg_regs_t *)MXC_BASE_ADCCFG)
491
492 #define MXC_BASE_ADC_FIFO                ((uint32_t)0x40109000UL)
493 #define MXC_ADC_FIFO                     ((mxc_adc_fifo_regs_t *)MXC_BASE_ADC_FIFO)
494
495
496
497 /*******************************************************************************/
498 /*                                                                         LCD */
499 #define MXC_BASE_LCD                     ((uint32_t)0x40060000)
500 #define MXC_LCD                          ((mxc_lcd_regs_t *)MXC_BASE_LCD)
501
502 /*******************************************************************************/
503 /*                  Peripheral Management Unit (PMU) - formerly DMA Controller */
504
505 #define MXC_CFG_PMU_CHANNELS             (6)
506
507 #define MXC_BASE_PMU0                    ((uint32_t)0x40070000UL)
508 #define MXC_PMU0                         ((mxc_pmu_regs_t *)MXC_BASE_PMU0)
509 #define MXC_BASE_PMU1                    ((uint32_t)0x40070020UL)
510 #define MXC_PMU1                         ((mxc_pmu_regs_t *)MXC_BASE_PMU1)
511 #define MXC_BASE_PMU2                    ((uint32_t)0x40070040UL)
512 #define MXC_PMU2                         ((mxc_pmu_regs_t *)MXC_BASE_PMU2)
513 #define MXC_BASE_PMU3                    ((uint32_t)0x40070060UL)
514 #define MXC_PMU3                         ((mxc_pmu_regs_t *)MXC_BASE_PMU3)
515 #define MXC_BASE_PMU4                    ((uint32_t)0x40070080UL)
516 #define MXC_PMU4                         ((mxc_pmu_regs_t *)MXC_BASE_PMU4)
517 #define MXC_BASE_PMU5                    ((uint32_t)0x400700A0UL)
518 #define MXC_PMU5                         ((mxc_pmu_regs_t *)MXC_BASE_PMU5)
519
520 #define MXC_BASE_PMU_BITBAND            ((uint32_t)0x42E00000UL)
521 #define MXC_BASE_PMU_BITBAND_CHOFFSET   ((uint32_t)0x00000400UL)
522 /*******************************************************************************/
523
524 typedef enum {
525     PMU_IRQ_DAC0_FIFO_AE,
526     PMU_IRQ_DAC1_FIFO_AE,
527     PMU_IRQ_DAC2_FIFO_AE,
528     PMU_IRQ_DAC3_FIFO_AE,
529     PMU_IRQ_DAC0_DONE,
530     PMU_IRQ_DAC1_DONE,
531     PMU_IRQ_DAC2_DONE,
532     PMU_IRQ_DAC3_DONE,
533     PMU_IRQ_ADC_FIFO_AF,
534     PMU_IRQ_ADC_DONE,
535     PMU_IRQ_I2C_MST0_DONE,
536     PMU_IRQ_I2C_MST1_DONE,
537     PMU_IRQ_SPI0_RSLTS_DONE,
538     PMU_IRQ_SPI1_RSLTS_DONE,
539     PMU_IRQ_SPI2_RSLTS_DONE,
540     PMU_IRQ_MAA_DONE,
541     PMU_IRQ_SPI0_TX_FIFO_AE,
542     PMU_IRQ_SPI0_RSLTS_FIFO_AF,
543     PMU_IRQ_SPI1_TX_FIFO_AE,
544     PMU_IRQ_SPI1_RSLTS_FIFO_AF,
545     PMU_IRQ_SPI2_TX_FIFO_AE,
546     PMU_IRQ_SPI3_RSLTS_FIFO_AF,
547     PMU_IRQ_I2C_MST0_TRANS_FIFO,
548     PMU_IRQ_I2C_MST0_RSLT_FIFO,
549     PMU_IRQ_I2C_MST1_TRANS_FIFO,
550     PMU_IRQ_I2C_MST2_RSLT_FIFO,
551     PMU_IRQ_I2C_SLV_TRANS_FIFO,
552     PMU_IRQ_I2C_SLV_RSLT_FIFO,
553     PMU_IRQ_UART0_TX_FIFO,
554     PMU_IRQ_UART0_RX_FIFO,
555     PMU_IRQ_UART1_TX_FIFO,
556     PMU_IRQ_UART1_RX_FIFO,
557     PMU_IRQ_SPI0_EXCP,
558     PMU_IRQ_SPI1_EXCP,
559     PMU_IRQ_SPI2_EXCP,
560     PMU_IRQ_RSVD0,
561     PMU_IRQ_I2C_MST0_EXCP,
562     PMU_IRQ_I2C_MST1_EXCP,
563     PMU_IRQ_I2C_SLV_EXCP,
564     PMU_IRQ_RSVD1,
565     PMU_IRQ_GPIO0,
566     PMU_IRQ_GPIO1,
567     PMU_IRQ_GPIO2,
568     PMU_IRQ_GPIO3,
569     PMU_IRQ_GPIO4,
570     PMU_IRQ_GPIO5,
571     PMU_IRQ_GPIO6,
572     PMU_IRQ_GPIO7,
573     PMU_IRQ_GPIO8,
574     PMU_IRQ_AFE_COMP_NMI,
575     PMU_IRQ_AES_ENGINE,
576 } pmu_int_mask_t;
577
578 /*******************************************************************************/
579 /*                                                                         USB */
580
581 #define MXC_BASE_USB                     ((uint32_t)0x4010C000UL)
582 #define MXC_USB                          ((mxc_usb_regs_t *)MXC_BASE_USB)
583
584 #define MXC_USB_MAX_PACKET               (64)
585 #define MXC_USB_NUM_EP                   (8)
586
587
588 /*******************************************************************************/
589 /*                                                Instruction Cache Controller */
590
591 #define MXC_BASE_ICC                     ((uint32_t)0x40080000UL)
592 #define MXC_ICC                          ((mxc_icc_regs_t *)MXC_BASE_ICC)
593
594 /*                                                              System Manager */
595
596 #define MXC_BASE_SYSMAN                 ((uint32_t)0x40090000UL)
597
598 /*******************************************************************************/
599 /*                                                               Clock Manager */
600
601 #define MXC_BASE_CLKMAN                  ((uint32_t)0x40090400UL)
602 #define MXC_CLKMAN                       ((mxc_clkman_regs_t *)MXC_BASE_CLKMAN)
603
604
605 /*******************************************************************************/
606 /*                                                               Power Manager */
607
608 #define MXC_BASE_PWRMAN                  ((uint32_t)0x40090800UL)
609 #define MXC_PWRMAN                       ((mxc_pwrman_regs_t *)MXC_BASE_PWRMAN)
610
611 /*******************************************************************************/
612 /*                                                                 I/O Manager */
613
614 #define MXC_BASE_IOMAN                   ((uint32_t)0x40090C00UL)
615 #define MXC_IOMAN                        ((mxc_ioman_regs_t *)MXC_BASE_IOMAN)
616
617
618 /*******************************************************************************/
619 /*                                                           RTC: Timer/Alarms */
620
621 #define MXC_BASE_RTCTMR                 ((uint32_t)0x40090A00UL)
622 #define MXC_RTCTMR                       ((mxc_rtctmr_regs_t *)MXC_BASE_RTCTMR)
623
624 #define MXC_RTCTMR_GET_IRQ(i) (i == 0 ? RTC0_IRQn :    \
625                                i == 1 ? RTC1_IRQn :    \
626                                i == 2 ? RTC2_IRQn :    \
627                                i == 3 ? RTC3_IRQn : 0)
628
629 #define MXC_BASE_RTCCFG                  ((uint32_t)0x40090A70UL)
630 #define MXC_RTCCFG                       ((mxc_rtccfg_regs_t *)MXC_BASE_RTCCFG)
631 /*******************************************************************************/
632 /*                                                        RTC: Power Sequencer */
633
634 #define MXC_BASE_PWRSEQ                  ((uint32_t)0x40090A30UL)
635 #define MXC_PWRSEQ                       ((mxc_pwrseq_regs_t *)MXC_BASE_PWRSEQ)
636
637 /*******************************************************************************/
638 /*                                                       Trim Shadow Registers */
639
640 #define MXC_BASE_TRIM                    ((uint32_t)0x400E0000UL)
641 #define MXC_TRIM                         ((mxc_ftr_regs_t *)MXC_BASE_TRIM)
642
643 /*******************************************************************************/
644 /*                                          Flash Memory Controller / Security */
645
646 #define MXC_BASE_FLC                     ((uint32_t)0x400F0000UL)
647 #define MXC_FLC                          ((mxc_flc_regs_t *)MXC_BASE_FLC)
648 #define MXC_BASE_FLC_BITBAND             ((uint32_t)0x43E00000UL)
649 #define MXC_FLC_PAGE_SIZE_SHIFT          11
650 #define MXC_FLC_PAGE_SIZE                (1 << MXC_FLC_PAGE_SIZE_SHIFT)
651 #define MXC_FLC_PAGE_ERASE_MSK           ((~(1 << (MXC_FLC_PAGE_SIZE_SHIFT - 1))) >> MXC_FLC_PAGE_SIZE_SHIFT) << MXC_FLC_PAGE_SIZE_SHIFT
652
653 /*******************************************************************************/
654
655 #define MXC_SET_FIELD(reg, clr, set) (*(volatile uint32_t *)reg = ((*(volatile uint32_t *)reg & ~clr) | set))
656
657 /*******************************************************************************/
658
659 #define BITBAND(reg, bit)        ((0xf0000000 & (uint32_t)(reg)) + 0x2000000 + (((uint32_t)(reg) & 0x0fffffff) << 5) + ((bit) << 2))
660 #define BITBAND_ClrBit(reg, bit) *(volatile uint32_t *)BITBAND(reg, bit) = 0
661 #define BITBAND_SetBit(reg, bit) *(volatile uint32_t *)BITBAND(reg, bit) = 1
662 #define BITBAND_GetBit(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit))
663
664 /*******************************************************************************/
665
666 #endif  /* _MAX32600_H_ */