--- /dev/null
+#include "MRI_Hooks.h"
+
+#include <sLPC17xx.h>
+#include <mri.h>
+
+extern "C" {
+ static uint32_t _set_high_on_debug[5] = {
+// (1 << 4) | (1 << 10) | (1 << 19) | (1 << 21), // smoothieboard stepper EN pins
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ };
+ static uint32_t _set_low_on_debug[5] = {
+ 0,
+ 0,
+// (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7), // smoothieboard heater outputs
+ 0,
+ 0,
+ 0
+ };
+
+ static uint32_t _previous_state[5];
+
+ static LPC_GPIO_TypeDef* io;
+ static int i;
+
+ void __mriPlatform_EnteringDebuggerHook()
+ {
+ for (i = 0; i < 5; i++)
+ {
+ io = (LPC_GPIO_TypeDef*) (LPC_GPIO_BASE + (0x20 * i));
+ io->FIOMASK &= ~(_set_high_on_debug[i] | _set_low_on_debug[i]);
+
+ _previous_state[i] = io->FIOPIN;
+
+ io->FIOSET = _set_high_on_debug[i];
+ io->FIOCLR = _set_low_on_debug[i];
+ }
+ }
+
+ void __mriPlatform_LeavingDebuggerHook()
+ {
+ for (i = 0; i < 5; i++)
+ {
+ io = (LPC_GPIO_TypeDef*) (LPC_GPIO_BASE + (0x20 * i));
+ io->FIOMASK &= ~(_set_high_on_debug[i] | _set_low_on_debug[i]);
+ io->FIOSET = _previous_state[i] & (_set_high_on_debug[i] | _set_low_on_debug[i]);
+ io->FIOCLR = (~_previous_state[i]) & (_set_high_on_debug[i] | _set_low_on_debug[i]);
+ }
+ }
+
+ void set_high_on_debug(int port, int pin)
+ {
+ if ((port >= 5) || (port < 0))
+ return;
+ if ((pin >= 32) || (pin < 0))
+ return;
+ _set_high_on_debug[port] |= (1<<pin);
+ }
+
+ void set_low_on_debug(int port, int pin)
+ {
+ if ((port >= 5) || (port < 0))
+ return;
+ if ((pin >= 32) || (pin < 0))
+ return;
+ _set_low_on_debug[port] |= (1<<pin);
+ }
+}
--- /dev/null
+#ifndef _MRI_HOOKS_H
+#define _MRI_HOOKS_H
+
+extern "C" {
+ void __mriPlatform_EnteringDebuggerHook();
+ void __mriPlatform_LeavingDebuggerHook();
+
+ void set_high_on_debug(int port, int pin);
+ void set_low_on_debug(int port, int pin);
+}
+
+#endif /* _MRI_HOOKS_H */
#include "mri.h"
#include "libs/Kernel.h"
#include "StepperMotor.h"
+#include "MRI_Hooks.h"
StepperMotor::StepperMotor(){
this->moving = false;
this->is_move_finished = false;
this->signal_step = false;
this->step_signal_hook = new Hook();
+
+ set_high_on_debug(en->port_number, en->pin);
}
// Called a great many times per second, to step if we have to now
#include <mri.h>
-extern "C" {
- static uint32_t _set_high_on_debug[5] = {
- (1 << 4) | (1 << 10) | (1 << 19) | (1 << 21),
- 0,
- 0,
- 0,
- 0
- };
- static uint32_t _set_low_on_debug[5] = {
- 0,
- 0,
- (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7),
- 0,
- 0
- };
-
- static LPC_GPIO_TypeDef* io;
- static int i;
-
- void __mriPlatform_EnteringDebuggerHook()
- {
- for (i = 0; i < 5; i++)
- {
- io = (LPC_GPIO_TypeDef*) (LPC_GPIO_BASE + (0x20 * i));
- io->FIOMASK &= ~(_set_high_on_debug[i] | _set_low_on_debug[i]);
- io->FIOSET = _set_high_on_debug[i];
- io->FIOCLR = _set_low_on_debug[i];
- }
- }
-
- void __mriPlatform_LeavingDebuggerHook()
- {
- }
-}
-
Watchdog::Watchdog(uint32_t timeout, WDT_ACTION action)
{
WDT_Init(WDT_CLKSRC_IRC, (action == WDT_MRI)?WDT_MODE_INT_ONLY:WDT_MODE_RESET);
WDT_RESET,
} WDT_ACTION;
-extern "C" {
- void __mriPlatform_EnteringDebuggerHook();
- void __mriPlatform_LeavingDebuggerHook();
-}
-
class Watchdog : public Module
{
public:
#include "Switch.h"
#include "libs/Pin.h"
+#include "MRI_Hooks.h"
+
Switch::Switch(){}
Switch::Switch(uint16_t name){
this->off_m_code = this->kernel->config->value(switch_checksum, this->name_checksum, off_m_code_checksum )->required()->as_number();
this->output_pin = this->kernel->config->value(switch_checksum, this->name_checksum, output_pin_checksum )->required()->as_pwm()->as_output();
this->output_pin->set(this->kernel->config->value(switch_checksum, this->name_checksum, startup_state_checksum )->by_default(0)->as_number() );
+
+ set_low_on_debug(output_pin->pin->port_number, output_pin->pin->pin);
}
// Turn pin on and off
#include "libs/Pin.h"
#include "libs/Median.h"
+#include "MRI_Hooks.h"
+
TemperatureControl::TemperatureControl(){}
TemperatureControl::TemperatureControl(uint16_t name){
this->heater_pin = this->kernel->config->value(temperature_control_checksum, this->name_checksum, heater_pin_checksum)->required()->as_pwm()->as_output();
this->heater_pin->set(0);
+ set_low_on_debug(heater_pin->pin->port_number, heater_pin->pin->pin);
+
// activate SD-DAC timer
this->kernel->slow_ticker->attach(1000, this->heater_pin, &Pwm::on_tick);
void TemperatureControl::on_second_tick(void* argument)
{
if (waiting)
- kernel->streams->printf("%s:%3.1f /%3.1f @%d\n", designator.c_str(), get_temperature(), ((target_temperature == UNDEFINED)?0.0:target_temperature), o, waiting);
+ kernel->streams->printf("%s:%3.1f /%3.1f @%d\n", designator.c_str(), get_temperature(), ((target_temperature == UNDEFINED)?0.0:target_temperature), o);
}