NetBurner 3.5.6
PDF Version
cortex-m7/include/debugtraps.h
1#ifndef DBUGTRAP_H
2#define DBUGTRAP_H
3/*NB_REVISION*/
4
5/*NB_COPYRIGHT*/
6#include <stdint.h>
7
8enum db_trap_acc_t
9{
10 DB_TRP_ACC_RD = 0x5,
11 DB_TRP_ACC_WR = 0x6,
12 DB_TRP_ACC_RW = 0x7,
13};
14
15enum db_trap_mem_width_t
16{
17 DB_TRP_WIDTH_8 = 0,
18 DB_TRP_WIDTH_16 = 1,
19 DB_TRP_WIDTH_32 = 2,
20};
21
22void SetValueWrittenTrap(volatile uint32_t value);
23void SetAddressWrittenTrap(uint32_t addr);
24void SetAddressWrittenTrap(uint32_t addr, uint32_t value, db_trap_mem_width_t width);
25void SetAddressWriteRangeTrap(uint32_t startaddr, uint32_t endaddr, int debugModule = 1);
26void SetAddressReadTrap(uint32_t addr);
27void SetAddressReadRangeTrap(uint32_t startaddr, uint32_t endaddr);
28
29/* Call this macro to monitor writes to a single variable */
30/* You may only monitor ONE VARIABLE */
31/* You may not write to this variable after making this call unless */
32/* You first use the BEFORE_WRITING_MONITORED_VAR macro */
33#define MONITOR_VAR_WRITES(x) SetAddressWrittenTrap((uint32_t)&x);
34
35/* use this before writing to a monitored var */
36#define BEFORE_WRITING_MONITORED_VAR(x) \
37 asm("cpsid i"); \
38 SetAddressWrittenTrap(0);
39
40/* Use this after writing to a monitored var */
41#define AFTER_WRITING_MONITORED_VAR(x) \
42 asm(" dsb"); \
43 SetAddressWrittenTrap((uint32_t)&x); \
44 asm(" cpsie i");
45
46#endif