temperaturecontrol: allow setting background tool without activating
[clinton/Smoothieware.git] / mri / mri.h
1 /* Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/)
2
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as published
5 by the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU Lesser General Public License for more details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 /* Monitor for Remote Inspection. */
17 #ifndef _MRI_H_
18 #define _MRI_H_
19
20 #include <stdint.h>
21
22 /* Used to insert hardcoded breakpoint into user's code. */
23 #ifndef __debugbreak
24 #define __debugbreak() { __asm volatile ("bkpt #0"); }
25 #endif
26
27 /* Error strings that can be returned to GDB. */
28 #define MRI_ERROR_INVALID_ARGUMENT "E01" /* Encountered error when parsing command arguments. */
29 #define MRI_ERROR_MEMORY_ACCESS_FAILURE "E03" /* Couldn't access requested memory. */
30 #define MRI_ERROR_BUFFER_OVERRUN "E04" /* Overflowed internal input/output buffer. */
31 #define MRI_ERROR_NO_FREE_BREAKPOINT "E05" /* No free FPB breakpoint comparator slots. */
32
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39
40 /* pDebuggerParameters string passed into __mriInit contains a space separated list of configuration parameters to be
41 used to initialize the debug monitor. The supported options include:
42
43 One of these options to indicate which UART to be used for the debugger connection:
44 MRI_UART_MBED_USB
45 MRI_UART_MBED_P9_P10
46 MRI_UART_MBED_P13_P14
47 MRI_UART_MBED_P28_P27
48 MRI_UART_0
49 MRI_UART_1
50 MRI_UART_2
51 MRI_UART_3
52
53 By default the debug monitor expects to take full control of the UART to configure baud rate, etc. However
54 including the following option will tell the monitor to assume that the user's firmware will configure and use the
55 serial port until the first exception occurs:
56 MRI_UART_SHARE
57
58 When not sharing the UART, MRI will typically try to use the auto-baud functionality of the device so that the user
59 can select the desired baud rate when they start GDB. However it is possible to override this in the init string.
60 For example the following option would set the baud rate to 230400 (note that spaces aren't allowed before or after
61 the '=' character):
62 MRI_UART_BAUD=230400
63 NOTE: LPC176x version of MRI supports a maximum baud rate of 3Mbaud and the core clock can't run faster than
64 128MHz or calculating baud rate divisors will fail.
65 */
66 void __mriInit(const char* pDebuggerParameters);
67
68
69 /* Simple assembly language stubs that can be called from user's newlib stubs routines which will cause the operations
70 to be redirected to the GDB host via MRI. */
71 int __mriNewLib_SemihostOpen(const char *pFilename, int flags, int mode);
72 int __mriNewLib_SemihostRename(const char *pOldFilename, const char *pNewFilename);
73 int __mriNewLib_SemihostUnlink(const char *pFilename);
74 int __mriNewLib_SemihostStat(const char *pFilename, void *pStat);
75 int __mriNewlib_SemihostWrite(int file, const char *ptr, int len);
76 int __mriNewlib_SemihostRead(int file, char *ptr, int len);
77 int __mriNewlib_SemihostLSeek(int file, int offset, int whence);
78 int __mriNewlib_SemihostClose(int file);
79 int __mriNewlib_SemihostFStat(int file, void *pStat);
80
81
82
83 /* Can be used by semihosting hooks to determine the index of the UART being used by MRI. */
84 int __mriPlatform_CommUartIndex(void);
85
86
87 #ifdef __cplusplus
88 }
89 #endif
90
91 #endif /* _MRI_H_ */
92
93
94 #ifndef MRI_VERSION_STRING
95
96 #define MRI_BRANCH "https://github.com/adamgreen/mri/tree/version_0.6"
97
98 #define MRI_VERSION_MAJOR 0
99 #define MRI_VERSION_MINOR 6
100 #define MRI_VERSION_BUILD 20140515
101 #define MRI_VERSION_SUBBUILD 2
102
103 #define MRI_STR(X) MRI_STR2(X)
104 #define MRI_STR2(X) #X
105
106 #define MRI_VERSION_STRING MRI_STR(MRI_VERSION_MAJOR) "." MRI_STR(MRI_VERSION_MINOR) "-" MRI_STR(MRI_VERSION_BUILD) "." MRI_STR(MRI_VERSION_SUBBUILD)
107
108 #endif