mpu.h
Go to the documentation of this file.
1 #ifndef __MPU_H__
2 #define __MPU_H__
3 
4 //*****************************************************************************
5 //
8 //
9 //*****************************************************************************
10 
11 
12 //*****************************************************************************
13 //
14 // If building with a C++ compiler, make all of the definitions in this header
15 // have a C binding.
16 //
17 //*****************************************************************************
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include <msp432.h>
24 #include <stdint.h>
25 #include "register_remap.h"
26 
27 //*****************************************************************************
28 //
29 // Flags that can be passed to MPU_enableModule.
30 //
31 //*****************************************************************************
32 #define MPU_CONFIG_PRIV_DEFAULT MPU_CTRL_PRIVDEFENA
33 #define MPU_CONFIG_HARDFLT_NMI MPU_CTRL_HFNMIENA
34 #define MPU_CONFIG_NONE 0
35 
36 //*****************************************************************************
37 //
38 // Flags for the region size to be passed to MPU_setRegion.
39 //
40 //*****************************************************************************
41 #define MPU_RGN_SIZE_32B (4 << 1)
42 #define MPU_RGN_SIZE_64B (5 << 1)
43 #define MPU_RGN_SIZE_128B (6 << 1)
44 #define MPU_RGN_SIZE_256B (7 << 1)
45 #define MPU_RGN_SIZE_512B (8 << 1)
46 
47 #define MPU_RGN_SIZE_1K (9 << 1)
48 #define MPU_RGN_SIZE_2K (10 << 1)
49 #define MPU_RGN_SIZE_4K (11 << 1)
50 #define MPU_RGN_SIZE_8K (12 << 1)
51 #define MPU_RGN_SIZE_16K (13 << 1)
52 #define MPU_RGN_SIZE_32K (14 << 1)
53 #define MPU_RGN_SIZE_64K (15 << 1)
54 #define MPU_RGN_SIZE_128K (16 << 1)
55 #define MPU_RGN_SIZE_256K (17 << 1)
56 #define MPU_RGN_SIZE_512K (18 << 1)
57 
58 #define MPU_RGN_SIZE_1M (19 << 1)
59 #define MPU_RGN_SIZE_2M (20 << 1)
60 #define MPU_RGN_SIZE_4M (21 << 1)
61 #define MPU_RGN_SIZE_8M (22 << 1)
62 #define MPU_RGN_SIZE_16M (23 << 1)
63 #define MPU_RGN_SIZE_32M (24 << 1)
64 #define MPU_RGN_SIZE_64M (25 << 1)
65 #define MPU_RGN_SIZE_128M (26 << 1)
66 #define MPU_RGN_SIZE_256M (27 << 1)
67 #define MPU_RGN_SIZE_512M (28 << 1)
68 
69 #define MPU_RGN_SIZE_1G (29 << 1)
70 #define MPU_RGN_SIZE_2G (30 << 1)
71 #define MPU_RGN_SIZE_4G (31 << 1)
72 
73 //*****************************************************************************
74 //
75 // Flags for the permissions to be passed to MPU_setRegion.
76 //
77 //*****************************************************************************
78 #define MPU_RGN_PERM_EXEC 0x00000000
79 #define MPU_RGN_PERM_NOEXEC 0x10000000
80 #define MPU_RGN_PERM_PRV_NO_USR_NO 0x00000000
81 #define MPU_RGN_PERM_PRV_RW_USR_NO 0x01000000
82 #define MPU_RGN_PERM_PRV_RW_USR_RO 0x02000000
83 #define MPU_RGN_PERM_PRV_RW_USR_RW 0x03000000
84 #define MPU_RGN_PERM_PRV_RO_USR_NO 0x05000000
85 #define MPU_RGN_PERM_PRV_RO_USR_RO 0x06000000
86 
87 //*****************************************************************************
88 //
89 // Flags for the sub-region to be passed to MPU_setRegion.
90 //
91 //*****************************************************************************
92 #define MPU_SUB_RGN_DISABLE_0 0x00000100
93 #define MPU_SUB_RGN_DISABLE_1 0x00000200
94 #define MPU_SUB_RGN_DISABLE_2 0x00000400
95 #define MPU_SUB_RGN_DISABLE_3 0x00000800
96 #define MPU_SUB_RGN_DISABLE_4 0x00001000
97 #define MPU_SUB_RGN_DISABLE_5 0x00002000
98 #define MPU_SUB_RGN_DISABLE_6 0x00004000
99 #define MPU_SUB_RGN_DISABLE_7 0x00008000
100 
101 //*****************************************************************************
102 //
103 // Flags to enable or disable a region, to be passed to MPU_setRegion.
104 //
105 //*****************************************************************************
106 #define MPU_RGN_ENABLE 1
107 #define MPU_RGN_DISABLE 0
108 
109 #define NVIC_MPU_TYPE_DREGION_S 8
110 
111 //*****************************************************************************
112 //
113 // API Function prototypes
114 //
115 //*****************************************************************************
116 
117 //*****************************************************************************
118 //
147 //
148 //*****************************************************************************
149 extern void MPU_enableModule(uint32_t mpuConfig);
150 
151 //*****************************************************************************
152 //
160 //
161 //*****************************************************************************
162 extern void MPU_disableModule(void);
163 
164 //*****************************************************************************
165 //
173 //
174 //*****************************************************************************
175 extern uint32_t MPU_getRegionCount(void);
176 
177 //*****************************************************************************
178 //
190 //
191 //*****************************************************************************
192 extern void MPU_enableRegion(uint32_t region);
193 
194 //*****************************************************************************
195 //
207 //
208 //*****************************************************************************
209 extern void MPU_disableRegion(uint32_t region);
210 
211 //*****************************************************************************
212 //
320 //
321 //*****************************************************************************
322 extern void MPU_setRegion(uint32_t region, uint32_t addr, uint32_t flags);
323 
324 //*****************************************************************************
325 //
342 //
343 //*****************************************************************************
344 extern void MPU_getRegion(uint32_t region, uint32_t *addr, uint32_t *pflags);
345 
346 //*****************************************************************************
347 //
361 //
362 //*****************************************************************************
363 extern void MPU_registerInterrupt(void (*intHandler)(void));
364 
365 //*****************************************************************************
366 //
376 //
377 //*****************************************************************************
378 extern void MPU_unregisterInterrupt(void);
379 
380 //*****************************************************************************
381 //
385 //
386 //*****************************************************************************
387 extern void MPU_enableInterrupt(void);
388 
389 //*****************************************************************************
390 //
394 //
395 //*****************************************************************************
396 extern void MPU_disableInterrupt(void);
397 
398 //*****************************************************************************
399 //
400 // Mark the end of the C bindings section for C++ compilers.
401 //
402 //*****************************************************************************
403 #ifdef __cplusplus
404 }
405 #endif
406 
407 //*****************************************************************************
408 //
409 // Close the Doxygen group.
411 //
412 //*****************************************************************************
413 
414 #endif // __MPU_H__
uint32_t MPU_getRegionCount(void)
Definition: mpu.c:28
void MPU_enableRegion(uint32_t region)
Definition: mpu.c:37
void MPU_enableInterrupt(void)
Definition: mpu.c:142
void MPU_registerInterrupt(void(*intHandler)(void))
Definition: mpu.c:120
void MPU_getRegion(uint32_t region, uint32_t *addr, uint32_t *pflags)
Definition: mpu.c:95
void MPU_unregisterInterrupt(void)
Definition: mpu.c:134
void MPU_disableModule(void)
Definition: mpu.c:19
void MPU_enableModule(uint32_t mpuConfig)
Definition: mpu.c:5
void MPU_disableInterrupt(void)
Definition: mpu.c:152
void MPU_setRegion(uint32_t region, uint32_t addr, uint32_t flags)
Definition: mpu.c:73
void MPU_disableRegion(uint32_t region)
Definition: mpu.c:55

Copyright 2014, Texas Instruments Incorporated