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