mpu.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef __MPU_H__
33 #define __MPU_H__
34 
35 //*****************************************************************************
36 //
39 //
40 //*****************************************************************************
41 
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 #include <ti/devices/msp432p4xx/inc/msp.h>
55 #include <stdint.h>
56 
57 //*****************************************************************************
58 //
59 // Flags that can be passed to MPU_enableModule.
60 //
61 //*****************************************************************************
62 #define MPU_CONFIG_PRIV_DEFAULT MPU_CTRL_PRIVDEFENA_Msk
63 #define MPU_CONFIG_HARDFLT_NMI MPU_CTRL_HFNMIENA_Msk
64 #define MPU_CONFIG_NONE 0
65 
66 //*****************************************************************************
67 //
68 // Flags for the region size to be passed to MPU_setRegion.
69 //
70 //*****************************************************************************
71 #define MPU_RGN_SIZE_32B (4 << 1)
72 #define MPU_RGN_SIZE_64B (5 << 1)
73 #define MPU_RGN_SIZE_128B (6 << 1)
74 #define MPU_RGN_SIZE_256B (7 << 1)
75 #define MPU_RGN_SIZE_512B (8 << 1)
76 
77 #define MPU_RGN_SIZE_1K (9 << 1)
78 #define MPU_RGN_SIZE_2K (10 << 1)
79 #define MPU_RGN_SIZE_4K (11 << 1)
80 #define MPU_RGN_SIZE_8K (12 << 1)
81 #define MPU_RGN_SIZE_16K (13 << 1)
82 #define MPU_RGN_SIZE_32K (14 << 1)
83 #define MPU_RGN_SIZE_64K (15 << 1)
84 #define MPU_RGN_SIZE_128K (16 << 1)
85 #define MPU_RGN_SIZE_256K (17 << 1)
86 #define MPU_RGN_SIZE_512K (18 << 1)
87 
88 #define MPU_RGN_SIZE_1M (19 << 1)
89 #define MPU_RGN_SIZE_2M (20 << 1)
90 #define MPU_RGN_SIZE_4M (21 << 1)
91 #define MPU_RGN_SIZE_8M (22 << 1)
92 #define MPU_RGN_SIZE_16M (23 << 1)
93 #define MPU_RGN_SIZE_32M (24 << 1)
94 #define MPU_RGN_SIZE_64M (25 << 1)
95 #define MPU_RGN_SIZE_128M (26 << 1)
96 #define MPU_RGN_SIZE_256M (27 << 1)
97 #define MPU_RGN_SIZE_512M (28 << 1)
98 
99 #define MPU_RGN_SIZE_1G (29 << 1)
100 #define MPU_RGN_SIZE_2G (30 << 1)
101 #define MPU_RGN_SIZE_4G (31 << 1)
102 
103 //*****************************************************************************
104 //
105 // Flags for the permissions to be passed to MPU_setRegion.
106 //
107 //*****************************************************************************
108 #define MPU_RGN_PERM_EXEC 0x00000000
109 #define MPU_RGN_PERM_NOEXEC 0x10000000
110 #define MPU_RGN_PERM_PRV_NO_USR_NO 0x00000000
111 #define MPU_RGN_PERM_PRV_RW_USR_NO 0x01000000
112 #define MPU_RGN_PERM_PRV_RW_USR_RO 0x02000000
113 #define MPU_RGN_PERM_PRV_RW_USR_RW 0x03000000
114 #define MPU_RGN_PERM_PRV_RO_USR_NO 0x05000000
115 #define MPU_RGN_PERM_PRV_RO_USR_RO 0x06000000
116 
117 //*****************************************************************************
118 //
119 // Flags for the sub-region to be passed to MPU_setRegion.
120 //
121 //*****************************************************************************
122 #define MPU_SUB_RGN_DISABLE_0 0x00000100
123 #define MPU_SUB_RGN_DISABLE_1 0x00000200
124 #define MPU_SUB_RGN_DISABLE_2 0x00000400
125 #define MPU_SUB_RGN_DISABLE_3 0x00000800
126 #define MPU_SUB_RGN_DISABLE_4 0x00001000
127 #define MPU_SUB_RGN_DISABLE_5 0x00002000
128 #define MPU_SUB_RGN_DISABLE_6 0x00004000
129 #define MPU_SUB_RGN_DISABLE_7 0x00008000
130 
131 //*****************************************************************************
132 //
133 // Flags to enable or disable a region, to be passed to MPU_setRegion.
134 //
135 //*****************************************************************************
136 #define MPU_RGN_ENABLE 1
137 #define MPU_RGN_DISABLE 0
138 
139 #define NVIC_MPU_TYPE_DREGION_S 8
140 
141 //*****************************************************************************
142 //
143 // API Function prototypes
144 //
145 //*****************************************************************************
146 
147 //*****************************************************************************
148 //
177 //
178 //*****************************************************************************
179 extern void MPU_enableModule(uint32_t mpuConfig);
180 
181 //*****************************************************************************
182 //
190 //
191 //*****************************************************************************
192 extern void MPU_disableModule(void);
193 
194 //*****************************************************************************
195 //
203 //
204 //*****************************************************************************
205 extern uint32_t MPU_getRegionCount(void);
206 
207 //*****************************************************************************
208 //
220 //
221 //*****************************************************************************
222 extern void MPU_enableRegion(uint32_t region);
223 
224 //*****************************************************************************
225 //
237 //
238 //*****************************************************************************
239 extern void MPU_disableRegion(uint32_t region);
240 
241 //*****************************************************************************
242 //
350 //
351 //*****************************************************************************
352 extern void MPU_setRegion(uint32_t region, uint32_t addr, uint32_t flags);
353 
354 //*****************************************************************************
355 //
372 //
373 //*****************************************************************************
374 extern void MPU_getRegion(uint32_t region, uint32_t *addr, uint32_t *pflags);
375 
376 //*****************************************************************************
377 //
391 //
392 //*****************************************************************************
393 extern void MPU_registerInterrupt(void (*intHandler)(void));
394 
395 //*****************************************************************************
396 //
406 //
407 //*****************************************************************************
408 extern void MPU_unregisterInterrupt(void);
409 
410 //*****************************************************************************
411 //
415 //
416 //*****************************************************************************
417 extern void MPU_enableInterrupt(void);
418 
419 //*****************************************************************************
420 //
424 //
425 //*****************************************************************************
426 extern void MPU_disableInterrupt(void);
427 
428 //*****************************************************************************
429 //
430 // Mark the end of the C bindings section for C++ compilers.
431 //
432 //*****************************************************************************
433 #ifdef __cplusplus
434 }
435 #endif
436 
437 //*****************************************************************************
438 //
439 // Close the Doxygen group.
441 //
442 //*****************************************************************************
443 
444 #endif // __MPU_H__
uint32_t MPU_getRegionCount(void)
Definition: mpu.c:59
void MPU_enableRegion(uint32_t region)
Definition: mpu.c:68
void MPU_enableInterrupt(void)
Definition: mpu.c:173
void MPU_registerInterrupt(void(*intHandler)(void))
Definition: mpu.c:151
void MPU_getRegion(uint32_t region, uint32_t *addr, uint32_t *pflags)
Definition: mpu.c:126
void MPU_unregisterInterrupt(void)
Definition: mpu.c:165
void MPU_disableModule(void)
Definition: mpu.c:50
void MPU_enableModule(uint32_t mpuConfig)
Definition: mpu.c:36
void MPU_disableInterrupt(void)
Definition: mpu.c:183
void MPU_setRegion(uint32_t region, uint32_t addr, uint32_t flags)
Definition: mpu.c:104
void MPU_disableRegion(uint32_t region)
Definition: mpu.c:86

Copyright 2018, Texas Instruments Incorporated