6 // This is used by MRI to turn pins on and off when entering and leaving MRI. Useful for not burning everything down
7 // See http://smoothieware.org/mri-debugging
10 static uint32_t _set_high_on_debug
[5] = {
11 // (1 << 4) | (1 << 10) | (1 << 19) | (1 << 21), // smoothieboard stepper EN pins
18 static uint32_t _set_low_on_debug
[5] = {
21 // (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7), // smoothieboard heater outputs
27 static uint32_t _previous_state
[5];
29 static LPC_GPIO_TypeDef
* io
;
32 void __mriPlatform_EnteringDebuggerHook()
34 for (i
= 0; i
< 5; i
++)
36 io
= (LPC_GPIO_TypeDef
*) (LPC_GPIO_BASE
+ (0x20 * i
));
37 io
->FIOMASK
&= ~(_set_high_on_debug
[i
] | _set_low_on_debug
[i
]);
39 _previous_state
[i
] = io
->FIOPIN
;
41 io
->FIOSET
= _set_high_on_debug
[i
];
42 io
->FIOCLR
= _set_low_on_debug
[i
];
46 void __mriPlatform_LeavingDebuggerHook()
48 for (i
= 0; i
< 5; i
++)
50 io
= (LPC_GPIO_TypeDef
*) (LPC_GPIO_BASE
+ (0x20 * i
));
51 io
->FIOMASK
&= ~(_set_high_on_debug
[i
] | _set_low_on_debug
[i
]);
52 io
->FIOSET
= _previous_state
[i
] & (_set_high_on_debug
[i
] | _set_low_on_debug
[i
]);
53 io
->FIOCLR
= (~_previous_state
[i
]) & (_set_high_on_debug
[i
] | _set_low_on_debug
[i
]);
57 void set_high_on_debug(int port
, int pin
)
59 if ((port
>= 5) || (port
< 0))
61 if ((pin
>= 32) || (pin
< 0))
63 _set_high_on_debug
[port
] |= (1<<pin
);
66 void set_low_on_debug(int port
, int pin
)
68 if ((port
>= 5) || (port
< 0))
70 if ((pin
>= 32) || (pin
< 0))
72 _set_low_on_debug
[port
] |= (1<<pin
);