Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pelnar <robert.pelnar@seznam.cz>2017-08-17 16:23:34 +0300
committerRobert Pelnar <robert.pelnar@seznam.cz>2017-08-17 16:23:34 +0300
commit683784c4c7d92f352c65b53e750b48fb50d2354b (patch)
tree0545097a1aa6bd19850b09158ba716f0f98e59a3
parenta7477673de5ee67b09d04a8c81129ebd5345ebb7 (diff)
PAT9125 I2C, hardware SG homing
separate pin configuration file for each board changed board codes: RAMBO =100, MiniRambo1.0 =200, MiniRambo1.3 = 203, Einy03 =303, Einy04 =304
-rw-r--r--Firmware/Configuration.h7
-rw-r--r--Firmware/Marlin_main.cpp100
-rw-r--r--Firmware/boards.h13
-rw-r--r--Firmware/mesh_bed_calibration.cpp4
-rwxr-xr-xFirmware/pat9125.cpp170
-rwxr-xr-xFirmware/pat9125.h80
-rw-r--r--Firmware/pins.h547
-rw-r--r--Firmware/pins_Einy_0_3.h130
-rw-r--r--Firmware/pins_Einy_0_4.h120
-rw-r--r--Firmware/pins_Rambo.h162
-rw-r--r--Firmware/pins_Rambo_1_0.h94
-rw-r--r--Firmware/pins_Rambo_1_3.h102
-rw-r--r--Firmware/stepper.cpp28
-rw-r--r--Firmware/swi2c.cpp209
-rw-r--r--Firmware/swi2c.h22
-rwxr-xr-xFirmware/swspi.cpp201
-rwxr-xr-xFirmware/swspi.h47
-rw-r--r--Firmware/tmc2130.cpp4
-rw-r--r--Firmware/ultralcd.cpp45
-rw-r--r--Firmware/uni_avr_rpi.h31
-rw-r--r--Firmware/variants/1_75mm_MK3-EINY03-E3Dv6full.h14
-rw-r--r--Firmware/variants/1_75mm_MK3-EINY04-E3Dv6full.h16
22 files changed, 1258 insertions, 888 deletions
diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h
index 61f38be8d..d96395f3f 100644
--- a/Firmware/Configuration.h
+++ b/Firmware/Configuration.h
@@ -186,7 +186,6 @@
#undef PREVENT_LENGTHY_EXTRUDE
#endif //DEBUG_DISABLE_PREVENT_EXTRUDER
-
#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
/*================== Thermal Runaway Protection ==============================
@@ -295,12 +294,12 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1
-#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
-#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below.
-
#ifdef DEBUG_DISABLE_SWLIMITS
#define min_software_endstops false
#define max_software_endstops false
+#else
+#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
+#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below.
#endif //DEBUG_DISABLE_SWLIMITS
diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp
index 53988194f..6e2f5b610 100644
--- a/Firmware/Marlin_main.cpp
+++ b/Firmware/Marlin_main.cpp
@@ -57,14 +57,21 @@
#include <avr/wdt.h>
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef SWSPI
#include "swspi.h"
+#endif //SWSPI
+
+#ifdef SWI2C
+#include "swi2c.h"
+#endif //SWI2C
+
+#ifdef PAT9125
#include "pat9125.h"
-#endif //HAVE_PAT9125_SENSOR
+#endif //PAT9125
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
#include "tmc2130.h"
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
#ifdef BLINKM
@@ -909,7 +916,7 @@ void servo_init()
static void lcd_language_menu();
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef PAT9125
bool fsensor_enabled = false;
bool fsensor_ignore_error = true;
@@ -993,7 +1000,7 @@ void fsensor_update()
}
}
-#endif //HAVE_PAT9125_SENSOR
+#endif //PAT9125
#ifdef MESH_BED_LEVELING
@@ -1158,15 +1165,15 @@ void setup()
plan_init(); // Initialize planner;
watchdog_init();
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef PAT9125
MYSERIAL.print("PAT9125_init:");
MYSERIAL.println(pat9125_init(200, 200));
-#endif //HAVE_PAT9125_SENSOR
+#endif //PAT9125
st_init(); // Initialize stepper, this enables interrupts!
@@ -1489,12 +1496,12 @@ void loop()
isPrintPaused ? manage_inactivity(true) : manage_inactivity(false);
checkHitEndstops();
lcd_update();
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef PAT9125
fsensor_update();
-#endif //HAVE_PAT9125_SENSOR
-#ifdef HAVE_TMC2130_DRIVERS
+#endif //PAT9125
+#ifdef TMC2130
tmc2130_check_overtemp();
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
}
void get_command()
@@ -1993,7 +2000,7 @@ void homeaxis(int axis)
if ((axis==X_AXIS)?HOMEAXIS_DO(X):(axis==Y_AXIS)?HOMEAXIS_DO(Y):0)
{
int axis_home_dir = home_dir(axis);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
current_position[axis] = 0;
@@ -2001,7 +2008,7 @@ void homeaxis(int axis)
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
feedrate = homing_feedrate[axis];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_restart(axis);
#endif
st_synchronize();
@@ -2009,18 +2016,18 @@ void homeaxis(int axis)
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[axis] = -home_retract_mm(axis) * axis_home_dir;
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_restart(axis);
#endif
st_synchronize();
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
feedrate = homing_feedrate[axis];
#else
feedrate = homing_feedrate[axis] / 2;
#endif
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_restart(axis);
#endif
st_synchronize();
@@ -2029,7 +2036,7 @@ void homeaxis(int axis)
feedrate = 0.0;
endstops_hit_on_purpose();
axis_known_position[axis] = true;
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
}
@@ -3847,7 +3854,12 @@ void process_commands()
babystep_reset();
// Mark all axes as in a need for homing.
memset(axis_known_position, 0, sizeof(axis_known_position));
-
+
+ // Home in the XY plane.
+ //set_destination_to_current();
+ setup_for_endstop_move();
+ home_xy();
+
// Let the user move the Z axes up to the end stoppers.
if (lcd_calibrate_z_end_stop_manual( onlyZ )) {
refresh_cmd_timeout();
@@ -3864,14 +3876,10 @@ void process_commands()
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], homing_feedrate[Z_AXIS]/40, active_extruder);
st_synchronize();
- // Home in the XY plane.
- set_destination_to_current();
- setup_for_endstop_move();
- home_xy();
-#ifdef HAVE_TMC2130_DRIVERS
- tmc2130_home_enter(X_AXIS_MASK | Y_AXIS_MASK);
-#endif
+//#ifdef TMC2130
+// tmc2130_home_enter(X_AXIS_MASK | Y_AXIS_MASK);
+//#endif
int8_t verbosity_level = 0;
if (code_seen('V')) {
@@ -3931,7 +3939,7 @@ void process_commands()
lcd_show_fullscreen_message_and_wait_P(MSG_BABYSTEP_Z_NOT_SET);
}
}
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
} else {
@@ -5580,13 +5588,13 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
lcd_setstatuspgm(WELCOME_MSG);
custom_message = false;
custom_message_type = 0;
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef PAT9125
if (fsensor_M600)
{
cmdqueue_pop_front(); //hack because M600 repeated 2x when enqueued to front
fsensor_enable();
}
-#endif //HAVE_PAT9125_SENSOR
+#endif //PAT9125
}
break;
@@ -5928,18 +5936,22 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
} // end if(code_seen('T')) (end of T codes)
+#ifdef DEBUG_DCODES
else if (code_seen('D')) // D codes (debug)
{
switch((int)code_value())
{
case 0: // D0 - Reset
+ if (*(strchr_pointer + 1) == 0) break;
MYSERIAL.println("D0 - Reset");
+ asm volatile("jmp 0x00000");
+ break;
+/* MYSERIAL.println("D0 - Reset");
cli(); //disable interrupts
wdt_reset(); //reset watchdog
WDTCSR = (1<<WDCE) | (1<<WDE); //enable watchdog
WDTCSR = (1<<WDE) | (1<<WDP0); //30ms prescaler
- while(1); //wait for reset
- break;
+ while(1); //wait for reset*/
case 1: // D1 - Clear EEPROM
{
MYSERIAL.println("D1 - Clear EEPROM");
@@ -5949,7 +5961,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
sei();
}
break;
- case 2: // D2 - read/write PIN
+ case 2: // D2 - Read/Write PIN
{
if (code_seen('P')) // Pin (0-255)
{
@@ -5982,13 +5994,13 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
break;
case 3:
MYSERIAL.print("fsensor_enable()");
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef PAT9125
fsensor_enable();
#endif
break;
case 4:
MYSERIAL.print("fsensor_disable()");
-#ifdef HAVE_PAT9125_SENSOR
+#ifdef PAT9125
fsensor_disable();
#endif
break;
@@ -6008,8 +6020,21 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
homeaxis(1);
}
break;
+ case 7:
+ {
+ MYSERIAL.print("pat9125_init=");
+ MYSERIAL.println(pat9125_init(200, 200));
+ }
+ break;
+ case 8:
+ {
+ MYSERIAL.print("swi2c_check=");
+ MYSERIAL.println(swi2c_check(0x75));
+ }
+ break;
}
}
+#endif //DEBUG_DCODES
else
{
@@ -6088,6 +6113,9 @@ void get_arc_coordinates()
void clamp_to_software_endstops(float target[3])
{
+#ifdef DEBUG_DISABLE_SWLIMITS
+ return;
+#endif //DEBUG_DISABLE_SWLIMITS
world2machine_clamp(target[0], target[1]);
// Clamp the Z coordinate.
diff --git a/Firmware/boards.h b/Firmware/boards.h
index ba93802a2..c5507c20f 100644
--- a/Firmware/boards.h
+++ b/Firmware/boards.h
@@ -3,15 +3,14 @@
#define BOARD_UNKNOWN -1
-#define BOARD_EINY_0_3a 300 // EINY 0.3a
-#define BOARD_EINY_0_4a 299 // EINY 0.4a
+#define BOARD_RAMBO 100 // Rambo - 100 (orig 301)
-#define BOARD_RAMBO 301 // Rambo
-#define BOARD_RAMBO_MINI_1_3 302 // Rambo-mini 1.3
-#define BOARD_RAMBO_MINI_1_0 102 // Rambo-mini 1.0
+#define BOARD_RAMBO_MINI_1_0 200 // Rambo-mini 1.0 - 200 (orig 102)
+#define BOARD_RAMBO_MINI_1_3 203 // Rambo-mini 1.3 - 203 (orig 302)
-
-#define BOARD_99 99 // This is in pins.h but...?
+#define BOARD_EINY_0_3a 303 // EINY 0.3a - 303 (orig 300)
+#define BOARD_EINY_0_4a 304 // EINY 0.4a - 304 (orig 299)
+#define BOARD_EINY_0_5a 305 // EINY 0.5a - 305 (orig 298)
#define MB(board) (MOTHERBOARD==BOARD_##board)
#define IS_RAMPS (MB(RAMPS_OLD) || MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF))
diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 9b207513e..c3a7f366c 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -19,8 +19,8 @@ float world2machine_shift[2];
#define WEIGHT_FIRST_ROW_Y_HIGH (0.3f)
#define WEIGHT_FIRST_ROW_Y_LOW (0.0f)
-#define BED_ZERO_REF_X (- 22.f + X_PROBE_OFFSET_FROM_EXTRUDER)
-#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER)
+#define BED_ZERO_REF_X (- 22.f + X_PROBE_OFFSET_FROM_EXTRUDER) // -22 + 23 = 1
+#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER) // -0.6 + 9 = 8.4
// Scaling of the real machine axes against the programmed dimensions in the firmware.
// The correction is tiny, here around 0.5mm on 250mm length.
diff --git a/Firmware/pat9125.cpp b/Firmware/pat9125.cpp
index 92b240e36..ab63736d6 100755
--- a/Firmware/pat9125.cpp
+++ b/Firmware/pat9125.cpp
@@ -1,79 +1,91 @@
-#include "pat9125.h"
-#include "swspi.h"
-
-
-#ifdef SWSPI_RPI
-// #include <bcm2835.h>
- #define DELAY(delay) usleep(delay)
-#endif //SWSPI_RPI
-
-#ifdef SWSPI_AVR
- #include "Arduino.h"
- #define DELAY(delay) delayMicroseconds(delay)
-#endif //SWSPI_AVR
-
-unsigned char ucPID1 = 0;
-unsigned char ucPID2 = 0;
-int pat9125_x = 0;
-int pat9125_y = 0;
-int pat9125_b = 0;
-
-int pat9125_init(unsigned char xres, unsigned char yres)
-{
- swspi_init();
- ucPID1 = pat9125_rd_reg(PAT9125_PID1);
- ucPID2 = pat9125_rd_reg(PAT9125_PID2);
- if ((ucPID1 != 0x31) || (ucPID2 != 0x91))
- {
- return 0;
- }
- pat9125_wr_reg(PAT9125_RES_X, xres);
- pat9125_wr_reg(PAT9125_RES_Y, yres);
- return 1;
-}
-
-int pat9125_update()
-{
- if ((ucPID1 == 0x31) && (ucPID2 == 0x91))
- {
- unsigned char ucMotion = pat9125_rd_reg(PAT9125_MOTION);
- pat9125_b = pat9125_rd_reg(PAT9125_FRAME);
- if (ucMotion & 0x80)
- {
- unsigned char ucXL = pat9125_rd_reg(PAT9125_DELTA_XL);
- unsigned char ucYL = pat9125_rd_reg(PAT9125_DELTA_YL);
- unsigned char ucXYH = pat9125_rd_reg(PAT9125_DELTA_XYH);
- int iDX = ucXL | ((ucXYH << 4) & 0xf00);
- int iDY = ucYL | ((ucXYH << 8) & 0xf00);
- if (iDX & 0x800) iDX -= 4096;
- if (iDY & 0x800) iDY -= 4096;
- pat9125_x += iDX;
- pat9125_y += iDY;
- return 1;
- }
- }
- return 0;
-}
-
-unsigned char pat9125_rd_reg(unsigned char addr)
-{
- swspi_start();
- DELAY(100);
- swspi_tx(addr & 0x7f);
- DELAY(100);
- unsigned char data = swspi_rx();
- swspi_stop();
- DELAY(100);
- return data;
-}
-
-void pat9125_wr_reg(unsigned char addr, unsigned char data)
-{
- swspi_start();
- DELAY(100);
- swspi_tx(addr | 0x80);
- DELAY(100);
- swspi_tx(data);
- swspi_stop();
- DELAY(100);
-}
+#include "uni_avr_rpi.h"
+
+#ifdef PAT9125
+
+#include "pat9125.h"
+
+#ifdef PAT9125_SWSPI
+#include "swspi.h"
+#endif //PAT9125_SWSPI
+#ifdef PAT9125_SWI2C
+#include "swi2c.h"
+#endif //PAT9125_SWI2C
+
+
+unsigned char pat9125_PID1 = 0;
+unsigned char pat9125_PID2 = 0;
+int pat9125_x = 0;
+int pat9125_y = 0;
+int pat9125_b = 0;
+
+int pat9125_init(unsigned char xres, unsigned char yres)
+{
+#ifdef PAT9125_SWSPI
+ swspi_init();
+#endif //PAT9125_SWSPI
+#ifdef PAT9125_SWI2C
+ swi2c_init(PAT9125_SWI2C_SDA, PAT9125_SWI2C_SCL, PAT9125_SWI2C_CFG);
+#endif //PAT9125_SWI2C
+ pat9125_PID1 = pat9125_rd_reg(PAT9125_PID1);
+ pat9125_PID2 = pat9125_rd_reg(PAT9125_PID2);
+ if ((pat9125_PID1 != 0x31) || (pat9125_PID2 != 0x91))
+ {
+ return 0;
+ }
+ pat9125_wr_reg(PAT9125_RES_X, xres);
+ pat9125_wr_reg(PAT9125_RES_Y, yres);
+ return 1;
+}
+
+int pat9125_update()
+{
+ if ((pat9125_PID1 == 0x31) && (pat9125_PID2 == 0x91))
+ {
+ unsigned char ucMotion = pat9125_rd_reg(PAT9125_MOTION);
+ pat9125_b = pat9125_rd_reg(PAT9125_FRAME);
+ if (ucMotion & 0x80)
+ {
+ unsigned char ucXL = pat9125_rd_reg(PAT9125_DELTA_XL);
+ unsigned char ucYL = pat9125_rd_reg(PAT9125_DELTA_YL);
+ unsigned char ucXYH = pat9125_rd_reg(PAT9125_DELTA_XYH);
+ int iDX = ucXL | ((ucXYH << 4) & 0xf00);
+ int iDY = ucYL | ((ucXYH << 8) & 0xf00);
+ if (iDX & 0x800) iDX -= 4096;
+ if (iDY & 0x800) iDY -= 4096;
+ pat9125_x += iDX;
+ pat9125_y += iDY;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+unsigned char pat9125_rd_reg(unsigned char addr)
+{
+ unsigned char data = 0;
+#ifdef PAT9125_SWSPI
+ swspi_start();
+ swspi_tx(addr & 0x7f);
+ data = swspi_rx();
+ swspi_stop();
+#endif //PAT9125_SWSPI
+#ifdef PAT9125_SWI2C
+ int iret = swi2c_readByte_A8(PAT9125_I2C_ADDR, addr, &data);
+#endif //PAT9125_SWI2C
+ return data;
+}
+
+void pat9125_wr_reg(unsigned char addr, unsigned char data)
+{
+#ifdef PAT9125_SWSPI
+ swspi_start();
+ swspi_tx(addr | 0x80);
+ swspi_tx(data);
+ swspi_stop();
+#endif //PAT9125_SWSPI
+#ifdef PAT9125_SWI2C
+ int iret = swi2c_writeByte_A8(PAT9125_I2C_ADDR, addr, &data);
+#endif //PAT9125_SWI2C
+}
+
+#endif //PAT9125
diff --git a/Firmware/pat9125.h b/Firmware/pat9125.h
index aa3d9d6d4..0c7abccc1 100755
--- a/Firmware/pat9125.h
+++ b/Firmware/pat9125.h
@@ -1,39 +1,41 @@
-#ifndef PAT9125_H
-#define PAT9125_H
-
-//#define PAT9125_RPI
-#define PAT9125_AVR
-
-//PAT9125 registers
-#define PAT9125_PID1 0x00
-#define PAT9125_PID2 0x01
-#define PAT9125_MOTION 0x02
-#define PAT9125_DELTA_XL 0x03
-#define PAT9125_DELTA_YL 0x04
-#define PAT9125_MODE 0x05
-#define PAT9125_CONFIG 0x06
-#define PAT9125_WP 0x09
-#define PAT9125_SLEEP1 0x0a
-#define PAT9125_SLEEP2 0x0b
-#define PAT9125_RES_X 0x0d
-#define PAT9125_RES_Y 0x0e
-#define PAT9125_DELTA_XYH 0x12
-#define PAT9125_SHUTTER 0x14
-#define PAT9125_FRAME 0x17
-#define PAT9125_ORIENTATION 0x19
-
-extern unsigned char ucPID1;
-extern unsigned char ucPID2;
-
-extern int pat9125_x;
-extern int pat9125_y;
-extern int pat9125_b;
-
-int pat9125_init(unsigned char xres, unsigned char yres);
-int pat9125_update();
-
-unsigned char pat9125_rd_reg(unsigned char addr);
-void pat9125_wr_reg(unsigned char addr, unsigned char data);
-
-
-#endif //PAT9125_H
+#ifndef PAT9125_H
+#define PAT9125_H
+
+//PAT9125 I2C
+#define PAT9125_I2C_ADDR 0x75 //ID=LO
+//#define PAT9125_I2C_ADDR 0x79 //ID=HI
+//#define PAT9125_I2C_ADDR 0x73 //ID=NC
+
+//PAT9125 registers
+#define PAT9125_PID1 0x00
+#define PAT9125_PID2 0x01
+#define PAT9125_MOTION 0x02
+#define PAT9125_DELTA_XL 0x03
+#define PAT9125_DELTA_YL 0x04
+#define PAT9125_MODE 0x05
+#define PAT9125_CONFIG 0x06
+#define PAT9125_WP 0x09
+#define PAT9125_SLEEP1 0x0a
+#define PAT9125_SLEEP2 0x0b
+#define PAT9125_RES_X 0x0d
+#define PAT9125_RES_Y 0x0e
+#define PAT9125_DELTA_XYH 0x12
+#define PAT9125_SHUTTER 0x14
+#define PAT9125_FRAME 0x17
+#define PAT9125_ORIENTATION 0x19
+
+extern unsigned char pat9125_PID1;
+extern unsigned char pat9125_PID2;
+
+extern int pat9125_x;
+extern int pat9125_y;
+extern int pat9125_b;
+
+extern int pat9125_init(unsigned char xres, unsigned char yres);
+extern int pat9125_update();
+
+extern unsigned char pat9125_rd_reg(unsigned char addr);
+extern void pat9125_wr_reg(unsigned char addr, unsigned char data);
+
+
+#endif //PAT9125_H
diff --git a/Firmware/pins.h b/Firmware/pins.h
index c8868ccc1..324f85ac4 100644
--- a/Firmware/pins.h
+++ b/Firmware/pins.h
@@ -22,541 +22,30 @@
/*****************************************************************
* Rambo Pin Assignments 1.3
******************************************************************/
-#if MOTHERBOARD == 302
- #define MINI_RAMBO
-
-#endif
-#if MOTHERBOARD == 301 || MOTHERBOARD == 302
- #define KNOWN_BOARD
- #ifndef __AVR_ATmega2560__
- #error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
- #endif
-
-
- #define FR_SENS 21
-
-
- #define X_STEP_PIN 37
- #define X_DIR_PIN 48
- #define X_MIN_PIN 12
- #define X_MAX_PIN 30
- #define X_ENABLE_PIN 29
- #define X_MS1_PIN 40
- #define X_MS2_PIN 41
- #define Y_STEP_PIN 36
- #define Y_DIR_PIN 49
- #define Y_MIN_PIN 11
- #define Y_MAX_PIN 24
- #define Y_ENABLE_PIN 28
- #define Y_MS1_PIN 69
- #define Y_MS2_PIN 39
- #define Z_STEP_PIN 35
- #define Z_DIR_PIN 47
- #define Z_MIN_PIN 10
- #define Z_MAX_PIN 23
- #define Z_ENABLE_PIN 27
- #define Z_MS1_PIN 68
- #define Z_MS2_PIN 67
- #define TEMP_BED_PIN 2
- #define TEMP_0_PIN 0
- #define HEATER_1_PIN 7
- #define TEMP_1_PIN 1
- #define TEMP_2_PIN -1
-
-#ifdef SNMM
-
-#define E_MUX0_PIN 17
-#define E_MUX1_PIN 16
-#define E_MUX2_PIN 84
-
-
-#endif
-
-#ifdef DIS
-#define D_REQUIRE 30
-#define D_DATA 20
-#define D_DATACLOCK 21
-
-#endif
-
-// The SDSS pin uses a different pin mapping from file Sd2PinMap.h
-#define SDSS 53
-
-#ifndef SDSUPPORT
-// these pins are defined in the SD library if building with SD support
- #define SCK_PIN 52
- #define MISO_PIN 50
- #define MOSI_PIN 51
-#endif
-
- #define BEEPER 84
-
- #define BTN_EN1 72
- #define BTN_EN2 14
- #define BTN_ENC 9
-
- #define SDCARDDETECT 15
-
- #define LCD_PINS_RS 82
- #define LCD_PINS_ENABLE 18
- #define LCD_PINS_D4 19
- #define LCD_PINS_D5 70
- #define LCD_PINS_D6 85
- #define LCD_PINS_D7 71
-
-
-
- #define E0_STEP_PIN 34
- #define E0_DIR_PIN 43
- #define E0_ENABLE_PIN 26
- #define E0_MS1_PIN 65
- #define E0_MS2_PIN 66
- #define LED_PIN 13
- #ifdef THREEMM_PRINTER
- #define FAN_PIN 8
- #else
- #define FAN_PIN 6
- #endif
- #define KILL_PIN -1 //80 with Smart Controller LCD
- #define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
- #define SDPOWER -1
- #define HEATER_2_PIN -1
- #ifdef MINI_RAMBO
-
- #define ELECTRONICS "RAMBo13a"
-
- #define HEATER_0_PIN 3
- #define HEATER_BED_PIN 4
- #define FAN_1_PIN -1 //6
- #define PS_ON_PIN 71
- #define MOTOR_CURRENT_PWM_XY_PIN 46
- #define MOTOR_CURRENT_PWM_Z_PIN 45
- #define MOTOR_CURRENT_PWM_E_PIN 44
-
- #else //RAMBo
- #define ELECTRONICS "RAMBoBig"
-
- #define E1_STEP_PIN 33
- #define E1_DIR_PIN 42
- #define E1_ENABLE_PIN 25
- #define E1_MS1_PIN 63
- #define E1_MS2_PIN 64
- #define DIGIPOTSS_PIN 38
- #define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
- #define HEATER_0_PIN 9
- #define HEATER_BED_PIN 3
- #define PS_ON_PIN 4
- #define SDSS 53
- #ifdef ULTRA_LCD
- #define KILL_PIN 80
- #ifdef NEWPANEL
- //arduino pin which triggers an piezzo beeper
- #define BEEPER 84 // Beeper on AUX-4
- #define LCD_PINS_RS 82
- #define LCD_PINS_ENABLE 18
- #define LCD_PINS_D4 19
- #define LCD_PINS_D5 70
- #define LCD_PINS_D6 85
- #define LCD_PINS_D7 71
- //buttons are directly attached using AUX-2
- #define BTN_EN1 76
- #define BTN_EN2 77
- #define BTN_ENC 78 //the click
- #define BLEN_C 2
- #define BLEN_B 1
- #define BLEN_A 0
- #define SDCARDDETECT 81 // Ramps does not use this port
- //encoder rotation values
- #define encrot0 0
- #define encrot1 2
- #define encrot2 3
- #define encrot3 1
- #else //old style panel with shift register
- //arduino pin witch triggers an piezzo beeper
- #define BEEPER 84 //No Beeper added
- //buttons are attached to a shift register
- // Not wired this yet
- // #define SHIFT_CLK 38
- // #define SHIFT_LD 42
- // #define SHIFT_OUT 40
- // #define SHIFT_EN 17
- #define LCD_PINS_RS 82
- #define LCD_PINS_ENABLE 18
- #define LCD_PINS_D4 19
- #define LCD_PINS_D5 70
- #define LCD_PINS_D6 85
- #define LCD_PINS_D7 71
- //encoder rotation values
- #define encrot0 0
- #define encrot1 2
- #define encrot2 3
- #define encrot3 1
- //bits in the shift register that carry the buttons for:
- // left up center down right red
- #define BL_LE 7
- #define BL_UP 6
- #define BL_MI 5
- #define BL_DW 4
- #define BL_RI 3
- #define BL_ST 2
- #define BLEN_B 1
- #define BLEN_A 0
- #endif
- #endif //ULTRA_LCD
- #endif //RAMBo/MiniRambo option
-#endif
-
-
-
-
-
-
-
-
-/*****************************************************************
-* Rambo mini Pin Assignments 1.0
-******************************************************************/
-#if MOTHERBOARD == 102
- #define ELECTRONICS "RAMBo10a"
- #define KNOWN_BOARD
- #ifndef __AVR_ATmega2560__
- #error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
- #endif
-
- #define FR_SENS 21
-
-#ifdef SNMM
-
-#define E_MUX0_PIN 17
-#define E_MUX1_PIN 16
-#define E_MUX2_PIN 84
-
-
-#endif
- #define LARGE_FLASH true
- #define X_STEP_PIN 37
- #define X_DIR_PIN 48
- #define X_MIN_PIN 12
- #define X_MAX_PIN 30
- #define X_ENABLE_PIN 29
- #define X_MS1_PIN 40
- #define X_MS2_PIN 41
- #define Y_STEP_PIN 36
- #define Y_DIR_PIN 49
- #define Y_MIN_PIN 11
- #define Y_MAX_PIN 24
- #define Y_ENABLE_PIN 28
- #define Y_MS1_PIN 69
- #define Y_MS2_PIN 39
- #define Z_STEP_PIN 35
- #define Z_DIR_PIN 47
- #define Z_MIN_PIN 10
- #define Z_MAX_PIN 23
- #define Z_ENABLE_PIN 27
- #define Z_MS1_PIN 68
- #define Z_MS2_PIN 67
- #define TEMP_BED_PIN 2
- #define TEMP_0_PIN 0
- #define HEATER_1_PIN 7
- #define TEMP_1_PIN 1
- #define TEMP_2_PIN -1
-
- // The SDSS pin uses a different pin mapping from file Sd2PinMap.h
-#define SDSS 53
-
-#ifndef SDSUPPORT
-// these pins are defined in the SD library if building with SD support
- #define SCK_PIN 52
- #define MISO_PIN 50
- #define MOSI_PIN 51
-#endif
-
- #define BEEPER 78
-
- #define BTN_EN1 80
- #define BTN_EN2 73
- #define BTN_ENC 21
-
- #define SDCARDDETECT 72
-
- #define LCD_PINS_RS 38
- #define LCD_PINS_ENABLE 5
- #define LCD_PINS_D4 14
- #define LCD_PINS_D5 15
- #define LCD_PINS_D6 32
- #define LCD_PINS_D7 31
-
-
-
- #define E0_STEP_PIN 34
- #define E0_DIR_PIN 43
- #define E0_ENABLE_PIN 26
- #define E0_MS1_PIN 65
- #define E0_MS2_PIN 66
- #define LED_PIN 13
- #ifdef THREEMM_PRINTER
- #define FAN_PIN 8
- #else
- #define FAN_PIN 6
- #endif
- #define KILL_PIN -1 //80 with Smart Controller LCD
- #define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
- #define SDPOWER -1
- #define HEATER_2_PIN -1
-
- #define HEATER_0_PIN 3
- #define HEATER_BED_PIN 4
- #define FAN_1_PIN -1 //6
- #define PS_ON_PIN 71
- #define MOTOR_CURRENT_PWM_XY_PIN 46
- #define MOTOR_CURRENT_PWM_Z_PIN 45
- #define MOTOR_CURRENT_PWM_E_PIN 44
-
-
-#endif
-
-/*****************************************************************
-* EINY Rambo Pin Assignments 0.3a
-******************************************************************/
-#if MOTHERBOARD == 300
-#define ELECTRONICS "EINY_03a"
-#define KNOWN_BOARD
-#ifndef __AVR_ATmega2560__
-#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
-#endif
-
-#define LARGE_FLASH true
-#define HAVE_TMC2130_DRIVERS
-#define HAVE_PAT9125_SENSOR
-
-#define SWSPI_MISO 16 //RX2
-#define SWSPI_MOSI 16 //RX2
-#define SWSPI_SCK 17 //TX2
-#define SWSPI_CS 20 //SDA
-
-#define X_TMC2130_CS 41
-#define X_TMC2130_DIAG 40
-#define X_STEP_PIN 37
-#define X_DIR_PIN 49
-//#define X_MIN_PIN 12
-//#define X_MAX_PIN 30
-#define X_MIN_PIN X_TMC2130_DIAG
-#define X_MAX_PIN X_TMC2130_DIAG
-#define X_ENABLE_PIN 29
-#define X_MS1_PIN -1
-#define X_MS2_PIN -1
-
-#define Y_TMC2130_CS 39
-#define Y_TMC2130_DIAG 69
-#define Y_STEP_PIN 36
-#define Y_DIR_PIN 48
-//#define Y_MIN_PIN 11
-//#define Y_MAX_PIN 24
-#define Y_MIN_PIN Y_TMC2130_DIAG
-#define Y_MAX_PIN Y_TMC2130_DIAG
-#define Y_ENABLE_PIN 28
-#define Y_MS1_PIN -1
-#define Y_MS2_PIN -1
-
-#define Z_TMC2130_CS 67
-#define Z_TMC2130_DIAG 68
-#define Z_STEP_PIN 35
-#define Z_DIR_PIN 47
-#define Z_MIN_PIN 10
-#define Z_MAX_PIN 23
-//#define Z_MAX_PIN Z_TMC2130_DIAG
-#define Z_ENABLE_PIN 27
-#define Z_MS1_PIN -1
-#define Z_MS2_PIN -1
-
-#define HEATER_BED_PIN 4
-#define TEMP_BED_PIN 2
-
-#define HEATER_0_PIN 3
-#define TEMP_0_PIN 0
-
-#define HEATER_1_PIN 7
-#define TEMP_1_PIN 1
-
-#ifdef BARICUDA
-#define HEATER_2_PIN 6
-#else
-#define HEATER_2_PIN -1
-#endif
-
-#define TEMP_2_PIN -1
-
-#define E0_TMC2130_CS 66
-#define E0_TMC2130_DIAG 65
-#define E0_STEP_PIN 34
-#define E0_DIR_PIN 43
-#define E0_ENABLE_PIN 26
-#define E0_MS1_PIN -1
-#define E0_MS2_PIN -1
-
-#define MOTOR_CURRENT_PWM_XY_PIN 46
-#define MOTOR_CURRENT_PWM_Z_PIN 45
-#define MOTOR_CURRENT_PWM_E_PIN 44
-#define SDPOWER -1
-#define SDSS 53
-#define LED_PIN 13
-#define FAN_PIN 6
-#define FAN_1_PIN -1
-#define PS_ON_PIN -1
-#define KILL_PIN -1 // 80 with Smart Controller LCD
-#define SUICIDE_PIN -1 // PIN that has to be turned on right after start, to keep power flowing.
-
-#ifdef ULTRA_LCD
-
-#define KILL_PIN 32
-
-#ifdef NEWPANEL
-
-#define BEEPER 84 // Beeper on AUX-4
-#define LCD_PINS_RS 82
-#define LCD_PINS_ENABLE 18
-#define LCD_PINS_D4 19
-#define LCD_PINS_D5 70
-#define LCD_PINS_D6 85
-#define LCD_PINS_D7 71
-
-//buttons are directly attached using AUX-2
-#define BTN_EN1 72
-#define BTN_EN2 14
-#define BTN_ENC 9 // the click
-
-#define SDCARDDETECT 15
-
-#define TACH_0 81
-#define TACH_1 80
-
-#endif //NEWPANEL
-#endif //ULTRA_LCD
-
-#endif //MOTHERBOARD == 300
-
-
-/*****************************************************************
-* EINY Rambo Pin Assignments 0.4a
-******************************************************************/
-#if MOTHERBOARD == 299
-#define ELECTRONICS "EINY_04a"
-#define KNOWN_BOARD
-#ifndef __AVR_ATmega2560__
-#error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
-#endif
-
-#define LARGE_FLASH true
-#define HAVE_TMC2130_DRIVERS
-#define HAVE_PAT9125_SENSOR
-
-#define SWSPI_MISO 21 //SCL
-#define SWSPI_MOSI 21 //SCL
-#define SWSPI_SCK 62 //PK0
-#define SWSPI_CS 20 //SDA
-
-#define X_TMC2130_CS 41
-#define X_TMC2130_DIAG 64 // !!! changed from 40 (EINY03)
-#define X_STEP_PIN 37
-#define X_DIR_PIN 49
-//#define X_MIN_PIN 12
-//#define X_MAX_PIN 30
-#define X_MIN_PIN X_TMC2130_DIAG
-#define X_MAX_PIN X_TMC2130_DIAG
-#define X_ENABLE_PIN 29
-#define X_MS1_PIN -1
-#define X_MS2_PIN -1
-
-#define Y_TMC2130_CS 39
-#define Y_TMC2130_DIAG 69
-#define Y_STEP_PIN 36
-#define Y_DIR_PIN 48
-//#define Y_MIN_PIN 11
-//#define Y_MAX_PIN 24
-#define Y_MIN_PIN Y_TMC2130_DIAG
-#define Y_MAX_PIN Y_TMC2130_DIAG
-#define Y_ENABLE_PIN 28
-#define Y_MS1_PIN -1
-#define Y_MS2_PIN -1
-
-#define Z_TMC2130_CS 67
-#define Z_STEP_PIN 35
-#define Z_DIR_PIN 47
-#define Z_MIN_PIN 10
-#define Z_MAX_PIN 23
-//#define Z_MAX_PIN Z_TMC2130_DIAG
-#define Z_ENABLE_PIN 27
-#define Z_MS1_PIN -1
-#define Z_MS2_PIN -1
-
-#define HEATER_BED_PIN 4
-#define TEMP_BED_PIN 2
-
-#define HEATER_0_PIN 3
-#define TEMP_0_PIN 0
-
-#define HEATER_1_PIN 7
-#define TEMP_1_PIN 1
-
-#ifdef BARICUDA
-#define HEATER_2_PIN 6
-#else
-#define HEATER_2_PIN -1
-#endif
-
-#define TEMP_2_PIN -1
-
-#define E0_TMC2130_CS 66
-#define E0_STEP_PIN 34
-#define E0_DIR_PIN 43
-#define E0_ENABLE_PIN 26
-#define E0_MS1_PIN -1
-#define E0_MS2_PIN -1
-
-#define MOTOR_CURRENT_PWM_XY_PIN 46
-#define MOTOR_CURRENT_PWM_Z_PIN 45
-#define MOTOR_CURRENT_PWM_E_PIN 44
-#define SDPOWER -1
-#define SDSS 77
-#define LED_PIN 13
-#define FAN_PIN 6
-#define FAN_1_PIN -1
-#define PS_ON_PIN -1
-#define KILL_PIN -1 // 80 with Smart Controller LCD
-#define SUICIDE_PIN -1 // PIN that has to be turned on right after start, to keep power flowing.
-
-#ifdef ULTRA_LCD
-
-//#define KILL_PIN 32
-
-#ifdef NEWPANEL
-
-
-#define BEEPER 84 // Beeper on AUX-4
-#define LCD_PINS_RS 82
-//#define LCD_PINS_ENABLE 18
-//#define LCD_PINS_D4 19
-#define LCD_PINS_ENABLE 61
-#define LCD_PINS_D4 59
-#define LCD_PINS_D5 70
-#define LCD_PINS_D6 85
-#define LCD_PINS_D7 71
-//buttons are directly attached using AUX-2
-#define BTN_EN1 72
-#define BTN_EN2 14
-#define BTN_ENC 9 // the click
+#if MOTHERBOARD == 100 //100 - orig 301
+#include "pins_Rambo.h"
+#endif //MOTHERBOARD == 100
-#define SDCARDDETECT 15
+#if MOTHERBOARD == 200 //200 - orig 102
+#include "pins_Rambo_1_0.h"
+#endif //MOTHERBOARD == 200
-#define TACH_0 79
-#define TACH_1 80
+#if MOTHERBOARD == 203 //203 - orig 302
+#include "pins_Rambo_1_3.h"
+#endif //MOTHERBOARD == 203
-#endif //NEWPANEL
-#endif //ULTRA_LCD
+#if MOTHERBOARD == 303 //303 - orig 300
+#include "pins_Einy_0_3.h"
+#endif //MOTHERBOARD == 303
-#endif //MOTHERBOARD == 300
+#if MOTHERBOARD == 304 //304 - orig 299
+#include "pins_Einy_0_4.h"
+#endif //MOTHERBOARD == 304
+#if MOTHERBOARD == 305 //305 - orig 298
+#include "pins_Einy_0_4.h"
+#endif //MOTHERBOARD == 305
#ifndef KNOWN_BOARD
#error Unknown MOTHERBOARD value in configuration.h
diff --git a/Firmware/pins_Einy_0_3.h b/Firmware/pins_Einy_0_3.h
new file mode 100644
index 000000000..d59761a12
--- /dev/null
+++ b/Firmware/pins_Einy_0_3.h
@@ -0,0 +1,130 @@
+/*****************************************************************
+* EINY Rambo 0.3a Pin Assignments
+******************************************************************/
+
+#define ELECTRONICS "EINY_03a"
+
+#define KNOWN_BOARD
+#ifndef __AVR_ATmega2560__
+ #error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define TMC2130
+#define PAT9125
+
+#define SWI2C // enable software i2c
+#define SWI2C_A8 // 8bit address functions
+
+#define PAT9125_SWI2C
+#define PAT9125_SWI2C_SDA 20 //SDA on P3
+#define PAT9125_SWI2C_SCL 21 //SCL on P3
+#define PAT9125_SWI2C_CFG 0xb1 //2us clock delay, 2048 cycles timeout
+
+//#define SWSPI_MISO 16 //RX2
+//#define SWSPI_MOSI 16 //RX2
+//#define SWSPI_SCK 17 //TX2
+//#define SWSPI_CS 20 //SDA
+
+////#define SWI2C_SDA 20 //SDA
+////#define SWI2C_SCL 21 //SCL
+//#define SWI2C_SDA 16 //RX2
+//#define SWI2C_SCL 17 //TX2
+
+#define X_TMC2130_CS 41
+#define X_TMC2130_DIAG 40
+#define X_STEP_PIN 37
+#define X_DIR_PIN 49
+//#define X_MIN_PIN 12
+//#define X_MAX_PIN 30
+#define X_MIN_PIN X_TMC2130_DIAG
+#define X_MAX_PIN X_TMC2130_DIAG
+#define X_ENABLE_PIN 29
+#define X_MS1_PIN -1
+#define X_MS2_PIN -1
+
+#define Y_TMC2130_CS 39
+#define Y_TMC2130_DIAG 69
+#define Y_STEP_PIN 36
+#define Y_DIR_PIN 48
+//#define Y_MIN_PIN 11
+//#define Y_MAX_PIN 24
+#define Y_MIN_PIN Y_TMC2130_DIAG
+#define Y_MAX_PIN Y_TMC2130_DIAG
+#define Y_ENABLE_PIN 28
+#define Y_MS1_PIN -1
+#define Y_MS2_PIN -1
+
+#define Z_TMC2130_CS 67
+#define Z_TMC2130_DIAG 68
+#define Z_STEP_PIN 35
+#define Z_DIR_PIN 47
+#define Z_MIN_PIN 10
+#define Z_MAX_PIN 23
+//#define Z_MAX_PIN Z_TMC2130_DIAG
+#define Z_ENABLE_PIN 27
+#define Z_MS1_PIN -1
+#define Z_MS2_PIN -1
+
+#define HEATER_BED_PIN 4
+#define TEMP_BED_PIN 2
+
+#define HEATER_0_PIN 3
+#define TEMP_0_PIN 0
+
+#define HEATER_1_PIN 7
+#define TEMP_1_PIN 1
+
+#ifdef BARICUDA
+#define HEATER_2_PIN 6
+#else
+#define HEATER_2_PIN -1
+#endif
+
+#define TEMP_2_PIN -1
+
+#define E0_TMC2130_CS 66
+#define E0_TMC2130_DIAG 65
+#define E0_STEP_PIN 34
+#define E0_DIR_PIN 43
+#define E0_ENABLE_PIN 26
+#define E0_MS1_PIN -1
+#define E0_MS2_PIN -1
+
+#define MOTOR_CURRENT_PWM_XY_PIN 46
+#define MOTOR_CURRENT_PWM_Z_PIN 45
+#define MOTOR_CURRENT_PWM_E_PIN 44
+#define SDPOWER -1
+#define SDSS 53
+#define LED_PIN 13
+#define FAN_PIN 6
+#define FAN_1_PIN -1
+#define PS_ON_PIN -1
+#define KILL_PIN -1 // 80 with Smart Controller LCD
+#define SUICIDE_PIN -1 // PIN that has to be turned on right after start, to keep power flowing.
+
+#ifdef ULTRA_LCD
+
+//#define KILL_PIN 32
+
+#ifdef NEWPANEL
+
+#define BEEPER 84 // Beeper on AUX-4
+#define LCD_PINS_RS 82
+#define LCD_PINS_ENABLE 18
+#define LCD_PINS_D4 19
+#define LCD_PINS_D5 70
+#define LCD_PINS_D6 85
+#define LCD_PINS_D7 71
+
+//buttons are directly attached using AUX-2
+#define BTN_EN1 72
+#define BTN_EN2 14
+#define BTN_ENC 9 // the click
+
+#define SDCARDDETECT 15
+
+#define TACH_0 81
+#define TACH_1 80
+
+#endif //NEWPANEL
+#endif //ULTRA_LCD
diff --git a/Firmware/pins_Einy_0_4.h b/Firmware/pins_Einy_0_4.h
new file mode 100644
index 000000000..7984a0170
--- /dev/null
+++ b/Firmware/pins_Einy_0_4.h
@@ -0,0 +1,120 @@
+/*****************************************************************
+* EINY Rambo 0.4a Pin Assignments
+******************************************************************/
+
+#define ELECTRONICS "EINY_04a"
+
+#define KNOWN_BOARD
+#ifndef __AVR_ATmega2560__
+ #error Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define TMC2130
+#define PAT9125
+
+#define SWI2C // enable software i2c
+#define SWI2C_A8 // 8bit address functions
+
+#define PAT9125_SWI2C
+#define PAT9125_SWI2C_SDA 20 //SDA on P3
+#define PAT9125_SWI2C_SCL 21 //SCL on P3
+#define PAT9125_SWI2C_CFG 0xb1 //2us clock delay, 2048 cycles timeout
+
+#define X_TMC2130_CS 41
+#define X_TMC2130_DIAG 64 // !!! changed from 40 (EINY03)
+#define X_STEP_PIN 37
+#define X_DIR_PIN 49
+//#define X_MIN_PIN 12
+//#define X_MAX_PIN 30
+#define X_MIN_PIN X_TMC2130_DIAG
+#define X_MAX_PIN X_TMC2130_DIAG
+#define X_ENABLE_PIN 29
+#define X_MS1_PIN -1
+#define X_MS2_PIN -1
+
+#define Y_TMC2130_CS 39
+#define Y_TMC2130_DIAG 69
+#define Y_STEP_PIN 36
+#define Y_DIR_PIN 48
+//#define Y_MIN_PIN 11
+//#define Y_MAX_PIN 24
+#define Y_MIN_PIN Y_TMC2130_DIAG
+#define Y_MAX_PIN Y_TMC2130_DIAG
+#define Y_ENABLE_PIN 28
+#define Y_MS1_PIN -1
+#define Y_MS2_PIN -1
+
+#define Z_TMC2130_CS 67
+#define Z_TMC2130_DIAG 68
+#define Z_STEP_PIN 35
+#define Z_DIR_PIN 47
+#define Z_MIN_PIN 10
+#define Z_MAX_PIN 23
+//#define Z_MAX_PIN Z_TMC2130_DIAG
+#define Z_ENABLE_PIN 27
+#define Z_MS1_PIN -1
+#define Z_MS2_PIN -1
+
+#define HEATER_BED_PIN 4
+#define TEMP_BED_PIN 2
+
+#define HEATER_0_PIN 3
+#define TEMP_0_PIN 0
+
+#define HEATER_1_PIN 7
+#define TEMP_1_PIN 1
+
+#ifdef BARICUDA
+#define HEATER_2_PIN 6
+#else
+#define HEATER_2_PIN -1
+#endif
+
+#define TEMP_2_PIN -1
+
+#define E0_TMC2130_CS 66
+#define E0_TMC2130_DIAG 65
+#define E0_STEP_PIN 34
+#define E0_DIR_PIN 43
+#define E0_ENABLE_PIN 26
+#define E0_MS1_PIN -1
+#define E0_MS2_PIN -1
+
+#define MOTOR_CURRENT_PWM_XY_PIN 46
+#define MOTOR_CURRENT_PWM_Z_PIN 45
+#define MOTOR_CURRENT_PWM_E_PIN 44
+#define SDPOWER -1
+#define SDSS 77
+#define LED_PIN 13
+#define FAN_PIN 6
+#define FAN_1_PIN -1
+#define PS_ON_PIN -1
+#define KILL_PIN -1 // 80 with Smart Controller LCD
+#define SUICIDE_PIN -1 // PIN that has to be turned on right after start, to keep power flowing.
+
+#ifdef ULTRA_LCD
+
+//#define KILL_PIN 32
+
+#ifdef NEWPANEL
+
+#define BEEPER 84 // Beeper on AUX-4
+#define LCD_PINS_RS 82
+#define LCD_PINS_ENABLE 61 // !!! changed from 18 (EINY03)
+#define LCD_PINS_D4 59 // !!! changed from 19 (EINY03)
+#define LCD_PINS_D5 70
+#define LCD_PINS_D6 85
+#define LCD_PINS_D7 71
+
+//buttons are directly attached using AUX-2
+#define BTN_EN1 72
+#define BTN_EN2 14
+#define BTN_ENC 9 // the click
+
+#define SDCARDDETECT 15
+
+#define TACH_0 79 // !!! changed from 81 (EINY03)
+#define TACH_1 80
+
+#endif //NEWPANEL
+#endif //ULTRA_LCD
diff --git a/Firmware/pins_Rambo.h b/Firmware/pins_Rambo.h
new file mode 100644
index 000000000..4ba00d1a5
--- /dev/null
+++ b/Firmware/pins_Rambo.h
@@ -0,0 +1,162 @@
+/*****************************************************************
+* Rambo Pin Assignments
+******************************************************************/
+
+#define ELECTRONICS "RAMBoBig"
+
+#define KNOWN_BOARD
+#ifndef __AVR_ATmega2560__
+ #error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define FR_SENS 21
+
+#define X_STEP_PIN 37
+#define X_DIR_PIN 48
+#define X_MIN_PIN 12
+#define X_MAX_PIN 30
+#define X_ENABLE_PIN 29
+#define X_MS1_PIN 40
+#define X_MS2_PIN 41
+#define Y_STEP_PIN 36
+#define Y_DIR_PIN 49
+#define Y_MIN_PIN 11
+#define Y_MAX_PIN 24
+#define Y_ENABLE_PIN 28
+#define Y_MS1_PIN 69
+#define Y_MS2_PIN 39
+#define Z_STEP_PIN 35
+#define Z_DIR_PIN 47
+#define Z_MIN_PIN 10
+#define Z_MAX_PIN 23
+#define Z_ENABLE_PIN 27
+#define Z_MS1_PIN 68
+#define Z_MS2_PIN 67
+#define TEMP_BED_PIN 2
+#define TEMP_0_PIN 0
+#define HEATER_1_PIN 7
+#define TEMP_1_PIN 1
+#define TEMP_2_PIN -1
+
+#ifdef SNMM
+ #define E_MUX0_PIN 17
+ #define E_MUX1_PIN 16
+ #define E_MUX2_PIN 84
+#endif
+
+#ifdef DIS
+ #define D_REQUIRE 30
+ #define D_DATA 20
+ #define D_DATACLOCK 21
+#endif
+
+// The SDSS pin uses a different pin mapping from file Sd2PinMap.h
+#define SDSS 53
+
+#ifndef SDSUPPORT
+// these pins are defined in the SD library if building with SD support
+ #define SCK_PIN 52
+ #define MISO_PIN 50
+ #define MOSI_PIN 51
+#endif
+
+#define BEEPER 84
+
+#define BTN_EN1 72
+#define BTN_EN2 14
+#define BTN_ENC 9
+
+#define SDCARDDETECT 15
+
+#define LCD_PINS_RS 82
+#define LCD_PINS_ENABLE 18
+#define LCD_PINS_D4 19
+#define LCD_PINS_D5 70
+#define LCD_PINS_D6 85
+#define LCD_PINS_D7 71
+
+#define E0_STEP_PIN 34
+#define E0_DIR_PIN 43
+#define E0_ENABLE_PIN 26
+#define E0_MS1_PIN 65
+#define E0_MS2_PIN 66
+#define LED_PIN 13
+
+#ifdef THREEMM_PRINTER
+ #define FAN_PIN 8
+#else
+ #define FAN_PIN 6
+#endif
+
+#define KILL_PIN -1 //80 with Smart Controller LCD
+#define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
+#define SDPOWER -1
+#define HEATER_2_PIN -1
+
+#define E1_STEP_PIN 33
+#define E1_DIR_PIN 42
+#define E1_ENABLE_PIN 25
+#define E1_MS1_PIN 63
+#define E1_MS2_PIN 64
+#define DIGIPOTSS_PIN 38
+#define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
+#define HEATER_0_PIN 9
+#define HEATER_BED_PIN 3
+#define PS_ON_PIN 4
+#define SDSS 53
+#ifdef ULTRA_LCD
+ #define KILL_PIN 80
+ #ifdef NEWPANEL
+ //arduino pin which triggers an piezzo beeper
+ #define BEEPER 84 // Beeper on AUX-4
+ #define LCD_PINS_RS 82
+ #define LCD_PINS_ENABLE 18
+ #define LCD_PINS_D4 19
+ #define LCD_PINS_D5 70
+ #define LCD_PINS_D6 85
+ #define LCD_PINS_D7 71
+ //buttons are directly attached using AUX-2
+ #define BTN_EN1 76
+ #define BTN_EN2 77
+ #define BTN_ENC 78 //the click
+ #define BLEN_C 2
+ #define BLEN_B 1
+ #define BLEN_A 0
+ #define SDCARDDETECT 81 // Ramps does not use this port
+ //encoder rotation values
+ #define encrot0 0
+ #define encrot1 2
+ #define encrot2 3
+ #define encrot3 1
+ #else //old style panel with shift register
+ //arduino pin witch triggers an piezzo beeper
+ #define BEEPER 84 //No Beeper added
+ //buttons are attached to a shift register
+ // Not wired this yet
+ // #define SHIFT_CLK 38
+ // #define SHIFT_LD 42
+ // #define SHIFT_OUT 40
+ // #define SHIFT_EN 17
+ #define LCD_PINS_RS 82
+ #define LCD_PINS_ENABLE 18
+ #define LCD_PINS_D4 19
+ #define LCD_PINS_D5 70
+ #define LCD_PINS_D6 85
+ #define LCD_PINS_D7 71
+ //encoder rotation values
+ #define encrot0 0
+ #define encrot1 2
+ #define encrot2 3
+ #define encrot3 1
+ //bits in the shift register that carry the buttons for:
+ // left up center down right red
+ #define BL_LE 7
+ #define BL_UP 6
+ #define BL_MI 5
+ #define BL_DW 4
+ #define BL_RI 3
+ #define BL_ST 2
+ #define BLEN_B 1
+ #define BLEN_A 0
+ #endif
+#endif //ULTRA_LCD
diff --git a/Firmware/pins_Rambo_1_0.h b/Firmware/pins_Rambo_1_0.h
new file mode 100644
index 000000000..fae9ddcc8
--- /dev/null
+++ b/Firmware/pins_Rambo_1_0.h
@@ -0,0 +1,94 @@
+/*****************************************************************
+* Rambo mini 1.0 Pin Assignments
+******************************************************************/
+
+#define ELECTRONICS "RAMBo10a"
+
+#define KNOWN_BOARD
+#ifndef __AVR_ATmega2560__
+ #error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define FR_SENS 21
+
+#define X_STEP_PIN 37
+#define X_DIR_PIN 48
+#define X_MIN_PIN 12
+#define X_MAX_PIN 30
+#define X_ENABLE_PIN 29
+#define X_MS1_PIN 40
+#define X_MS2_PIN 41
+#define Y_STEP_PIN 36
+#define Y_DIR_PIN 49
+#define Y_MIN_PIN 11
+#define Y_MAX_PIN 24
+#define Y_ENABLE_PIN 28
+#define Y_MS1_PIN 69
+#define Y_MS2_PIN 39
+#define Z_STEP_PIN 35
+#define Z_DIR_PIN 47
+#define Z_MIN_PIN 10
+#define Z_MAX_PIN 23
+#define Z_ENABLE_PIN 27
+#define Z_MS1_PIN 68
+#define Z_MS2_PIN 67
+#define TEMP_BED_PIN 2
+#define TEMP_0_PIN 0
+#define HEATER_1_PIN 7
+#define TEMP_1_PIN 1
+#define TEMP_2_PIN -1
+
+#ifdef SNMM
+ #define E_MUX0_PIN 17
+ #define E_MUX1_PIN 16
+ #define E_MUX2_PIN 84
+#endif
+
+// The SDSS pin uses a different pin mapping from file Sd2PinMap.h
+#define SDSS 53
+
+#ifndef SDSUPPORT
+// these pins are defined in the SD library if building with SD support
+ #define SCK_PIN 52
+ #define MISO_PIN 50
+ #define MOSI_PIN 51
+#endif
+
+#define BEEPER 78
+
+#define BTN_EN1 80
+#define BTN_EN2 73
+#define BTN_ENC 21
+
+#define SDCARDDETECT 72
+
+#define LCD_PINS_RS 38
+#define LCD_PINS_ENABLE 5
+#define LCD_PINS_D4 14
+#define LCD_PINS_D5 15
+#define LCD_PINS_D6 32
+#define LCD_PINS_D7 31
+
+#define E0_STEP_PIN 34
+#define E0_DIR_PIN 43
+#define E0_ENABLE_PIN 26
+#define E0_MS1_PIN 65
+#define E0_MS2_PIN 66
+#define LED_PIN 13
+#ifdef THREEMM_PRINTER
+ #define FAN_PIN 8
+#else
+ #define FAN_PIN 6
+#endif
+#define KILL_PIN -1 //80 with Smart Controller LCD
+#define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
+#define SDPOWER -1
+#define HEATER_2_PIN -1
+
+#define HEATER_0_PIN 3
+#define HEATER_BED_PIN 4
+#define FAN_1_PIN -1 //6
+#define PS_ON_PIN 71
+#define MOTOR_CURRENT_PWM_XY_PIN 46
+#define MOTOR_CURRENT_PWM_Z_PIN 45
+#define MOTOR_CURRENT_PWM_E_PIN 44
diff --git a/Firmware/pins_Rambo_1_3.h b/Firmware/pins_Rambo_1_3.h
new file mode 100644
index 000000000..3e9c45dae
--- /dev/null
+++ b/Firmware/pins_Rambo_1_3.h
@@ -0,0 +1,102 @@
+/*****************************************************************
+* Rambo mini 1.3 Pin Assignments
+******************************************************************/
+
+#define ELECTRONICS "RAMBo13a"
+
+#define KNOWN_BOARD
+#ifndef __AVR_ATmega2560__
+ #error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
+#endif
+
+#define FR_SENS 21
+
+#define X_STEP_PIN 37
+#define X_DIR_PIN 48
+#define X_MIN_PIN 12
+#define X_MAX_PIN 30
+#define X_ENABLE_PIN 29
+#define X_MS1_PIN 40
+#define X_MS2_PIN 41
+#define Y_STEP_PIN 36
+#define Y_DIR_PIN 49
+#define Y_MIN_PIN 11
+#define Y_MAX_PIN 24
+#define Y_ENABLE_PIN 28
+#define Y_MS1_PIN 69
+#define Y_MS2_PIN 39
+#define Z_STEP_PIN 35
+#define Z_DIR_PIN 47
+#define Z_MIN_PIN 10
+#define Z_MAX_PIN 23
+#define Z_ENABLE_PIN 27
+#define Z_MS1_PIN 68
+#define Z_MS2_PIN 67
+#define TEMP_BED_PIN 2
+#define TEMP_0_PIN 0
+#define HEATER_1_PIN 7
+#define TEMP_1_PIN 1
+#define TEMP_2_PIN -1
+
+#ifdef SNMM
+ #define E_MUX0_PIN 17
+ #define E_MUX1_PIN 16
+ #define E_MUX2_PIN 84
+#endif
+
+#ifdef DIS
+ #define D_REQUIRE 30
+ #define D_DATA 20
+ #define D_DATACLOCK 21
+#endif
+
+// The SDSS pin uses a different pin mapping from file Sd2PinMap.h
+#define SDSS 53
+
+#ifndef SDSUPPORT
+// these pins are defined in the SD library if building with SD support
+ #define SCK_PIN 52
+ #define MISO_PIN 50
+ #define MOSI_PIN 51
+#endif
+
+#define BEEPER 84
+
+#define BTN_EN1 72
+#define BTN_EN2 14
+#define BTN_ENC 9
+
+#define SDCARDDETECT 15
+
+#define LCD_PINS_RS 82
+#define LCD_PINS_ENABLE 18
+#define LCD_PINS_D4 19
+#define LCD_PINS_D5 70
+#define LCD_PINS_D6 85
+#define LCD_PINS_D7 71
+
+#define E0_STEP_PIN 34
+#define E0_DIR_PIN 43
+#define E0_ENABLE_PIN 26
+#define E0_MS1_PIN 65
+#define E0_MS2_PIN 66
+#define LED_PIN 13
+
+#ifdef THREEMM_PRINTER
+ #define FAN_PIN 8
+#else
+ #define FAN_PIN 6
+#endif
+
+#define KILL_PIN -1 //80 with Smart Controller LCD
+#define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
+#define SDPOWER -1
+#define HEATER_2_PIN -1
+
+#define HEATER_0_PIN 3
+#define HEATER_BED_PIN 4
+#define FAN_1_PIN -1 //6
+#define PS_ON_PIN 71
+#define MOTOR_CURRENT_PWM_XY_PIN 46
+#define MOTOR_CURRENT_PWM_Z_PIN 45
+#define MOTOR_CURRENT_PWM_E_PIN 44
diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp
index 5f131c505..b5fc90dee 100644
--- a/Firmware/stepper.cpp
+++ b/Firmware/stepper.cpp
@@ -32,9 +32,9 @@
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
#include <SPI.h>
#endif
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
#include "tmc2130.h"
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
//===========================================================================
@@ -431,7 +431,7 @@ void isr() {
CHECK_ENDSTOPS
{
{
- #if defined(X_MIN_PIN) && X_MIN_PIN > -1
+ #if defined(X_MIN_PIN) && (X_MIN_PIN > -1) && !defined(DEBUG_DISABLE_XMINLIMIT)
#ifndef TMC2130_SG_HOMING_SW
x_min_endstop = (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
#else //TMC2130_SG_HOMING_SW
@@ -451,7 +451,7 @@ void isr() {
CHECK_ENDSTOPS
{
{
- #if defined(X_MAX_PIN) && X_MAX_PIN > -1
+ #if defined(X_MAX_PIN) && (X_MAX_PIN > -1) && !defined(DEBUG_DISABLE_XMAXLIMIT)
#ifndef TMC2130_SG_HOMING_SW
x_max_endstop = (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
#else //TMC2130_SG_HOMING_SW
@@ -475,7 +475,7 @@ void isr() {
#endif
CHECK_ENDSTOPS
{
- #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
+ #if defined(Y_MIN_PIN) && (Y_MIN_PIN > -1) && !defined(DEBUG_DISABLE_YMINLIMIT)
#ifndef TMC2130_SG_HOMING_SW
y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
#else //TMC2130_SG_HOMING_SW
@@ -493,7 +493,7 @@ void isr() {
else { // +direction
CHECK_ENDSTOPS
{
- #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
+ #if defined(Y_MAX_PIN) && (Y_MAX_PIN > -1) && !defined(DEBUG_DISABLE_YMAXLIMIT)
#ifndef TMC2130_SG_HOMING_SW
y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
#else //TMC2130_SG_HOMING_SW
@@ -519,7 +519,7 @@ void isr() {
count_direction[Z_AXIS]=-1;
if(check_endstops && ! check_z_endstop)
{
- #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
+ #if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
bool z_min_endstop=(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
@@ -540,7 +540,7 @@ void isr() {
count_direction[Z_AXIS]=1;
CHECK_ENDSTOPS
{
- #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
+ #if defined(Z_MAX_PIN) && (Z_MAX_PIN > -1) && !defined(DEBUG_DISABLE_ZMAXLIMIT)
bool z_max_endstop=(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
@@ -553,7 +553,7 @@ void isr() {
}
// Supporting stopping on a trigger of the Z-stop induction sensor, not only for the Z-minus movements.
- #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
+ #if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
if(check_z_endstop) {
// Check the Z min end-stop no matter what.
// Good for searching for the center of an induction target.
@@ -829,9 +829,9 @@ void clear_current_adv_vars() {
void st_init()
{
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_init();
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
digipot_init(); //Initialize Digipot Motor Current
microstep_init(); //Initialize Microstepping Pins
@@ -1042,7 +1042,7 @@ void st_synchronize()
{
while(blocks_queued())
{
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
manage_heater();
// Vojtech: Don't disable motors inside the planner!
if (!tmc2130_update_sg())
@@ -1050,12 +1050,12 @@ void st_synchronize()
manage_inactivity(true);
lcd_update();
}
-#else //HAVE_TMC2130_DRIVERS
+#else //TMC2130
manage_heater();
// Vojtech: Don't disable motors inside the planner!
manage_inactivity(true);
lcd_update();
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
}
}
diff --git a/Firmware/swi2c.cpp b/Firmware/swi2c.cpp
new file mode 100644
index 000000000..272ac4192
--- /dev/null
+++ b/Firmware/swi2c.cpp
@@ -0,0 +1,209 @@
+#include "uni_avr_rpi.h"
+
+#ifdef SWI2C
+#include "swi2c.h"
+
+#ifdef __AVR
+unsigned char swi2c_sda = 20; // SDA pin
+unsigned char swi2c_scl = 21; // SCL pin
+#endif //__AVR
+
+#ifdef __RPI
+unsigned char swi2c_sda = 2; // SDA pin
+unsigned char swi2c_scl = 3; // SCL pin
+#endif //__RPI
+
+unsigned char swi2c_cfg = 0xb1; // config
+// bit0..3 = clock delay factor = 1 << 1 = 2 [us]
+// bit4..7 = ack timeout factor = 1 << 11 = 2048 [cycles]
+
+#define SWI2C_SDA swi2c_sda
+#define SWI2C_SCL swi2c_scl
+#define SWI2C_RMSK 0x01 //read mask (bit0 = 1)
+#define SWI2C_WMSK 0x00 //write mask (bit0 = 0)
+#define SWI2C_ASHF 0x01 //address shift (<< 1)
+#define SWI2C_DMSK 0x7f //device address mask
+
+
+void swi2c_init(unsigned char sda, unsigned char scl, unsigned char cfg)
+{
+ swi2c_sda = sda;
+ swi2c_scl = scl;
+ swi2c_cfg = cfg;
+ GPIO_OUT(SWI2C_SDA);
+ GPIO_OUT(SWI2C_SCL);
+ GPIO_SET(SWI2C_SDA);
+ GPIO_SET(SWI2C_SCL);
+ DELAY(1000);
+}
+
+void swi2c_start(int delay)
+{
+ GPIO_CLR(SWI2C_SDA);
+ DELAY(delay);
+ GPIO_CLR(SWI2C_SCL);
+ DELAY(delay);
+}
+
+void swi2c_stop(int delay)
+{
+ GPIO_SET(SWI2C_SCL);
+ DELAY(delay);
+ GPIO_SET(SWI2C_SDA);
+ DELAY(delay);
+}
+
+void swi2c_ack(int delay)
+{
+ GPIO_CLR(SWI2C_SDA);
+ DELAY(delay);
+ GPIO_SET(SWI2C_SCL);
+ DELAY(delay);
+ GPIO_CLR(SWI2C_SCL);
+ DELAY(delay);
+}
+
+int swi2c_wait_ack(int delay, int ackto)
+{
+ GPIO_INP(SWI2C_SDA);
+ DELAY(delay);
+// GPIO_SET(SWI2C_SDA);
+ DELAY(delay);
+ GPIO_SET(SWI2C_SCL);
+// DELAY(delay);
+ int ack = 0;
+ while (!(ack = !GPIO_GET(SWI2C_SDA)) && ackto--) DELAY(delay);
+ GPIO_CLR(SWI2C_SCL);
+ DELAY(delay);
+ GPIO_OUT(SWI2C_SDA);
+ DELAY(delay);
+ GPIO_CLR(SWI2C_SDA);
+ DELAY(delay);
+ return ack;
+}
+
+unsigned char swi2c_read(int delay)
+{
+ GPIO_SET(SWI2C_SDA);
+ DELAY(delay);
+ GPIO_INP(SWI2C_SDA);
+ unsigned char data = 0;
+ int bit; for (bit = 7; bit >= 0; bit--)
+ {
+ GPIO_SET(SWI2C_SCL);
+ DELAY(delay);
+ data |= GPIO_GET(SWI2C_SDA) << bit;
+ GPIO_CLR(SWI2C_SCL);
+ DELAY(delay);
+ }
+ GPIO_OUT(SWI2C_SDA);
+ return data;
+}
+
+void swi2c_write(int delay, unsigned char data)
+{
+ int bit; for (bit = 7; bit >= 0; bit--)
+ {
+ if (data & (1 << bit)) GPIO_SET(SWI2C_SDA);
+ else GPIO_CLR(SWI2C_SDA);
+ DELAY(delay);
+ GPIO_SET(SWI2C_SCL);
+ DELAY(delay);
+ GPIO_CLR(SWI2C_SCL);
+ DELAY(delay);
+ }
+}
+
+int swi2c_check(unsigned char dev_addr)
+{
+ int delay = 1 << (swi2c_cfg & 0xf);
+ int tmout = 1 << (swi2c_cfg >> 4);
+ swi2c_start(delay);
+ swi2c_write(delay, (dev_addr & SWI2C_DMSK) << SWI2C_ASHF);
+ if (!swi2c_wait_ack(delay, tmout)) { swi2c_stop(delay); return 0; }
+ swi2c_stop(delay);
+ return 1;
+}
+
+#ifdef SWI2C_A8 //8bit address
+
+int swi2c_readByte_A8(unsigned char dev_addr, unsigned char addr, unsigned char* pbyte)
+{
+ int delay = 1 << (swi2c_cfg & 0xf);
+ int tmout = 1 << (swi2c_cfg >> 4);
+ swi2c_start(delay);
+ swi2c_write(delay, SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
+ if (!swi2c_wait_ack(delay, tmout)) { swi2c_stop(delay); return 0; }
+ swi2c_write(delay, addr & 0xff);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_stop(delay);
+ swi2c_start(delay);
+ swi2c_write(delay, SWI2C_RMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ unsigned char byte = swi2c_read(delay);
+ swi2c_stop(delay);
+ if (pbyte) *pbyte = byte;
+ return 1;
+}
+
+int swi2c_writeByte_A8(unsigned char dev_addr, unsigned char addr, unsigned char* pbyte)
+{
+ int delay = 1 << (swi2c_cfg & 0xf);
+ int tmout = 1 << (swi2c_cfg >> 4);
+ swi2c_start(delay);
+ swi2c_write(delay, SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
+ if (!swi2c_wait_ack(delay, tmout)) { swi2c_stop(delay); return 0; }
+ swi2c_write(delay, addr & 0xff);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_write(delay, *pbyte);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_stop(delay);
+ return 1;
+}
+
+#endif //SWI2C_A8
+
+#ifdef SWI2C_A16 //16bit address
+
+int swi2c_readByte_A16(unsigned char dev_addr, unsigned short addr, unsigned char* pbyte)
+{
+ int delay = 1 << (swi2c_cfg & 0xf);
+ int tmout = 1 << (swi2c_cfg >> 4);
+ swi2c_start(delay);
+ swi2c_write(delay, SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
+ if (!swi2c_wait_ack(delay, tmout)) { swi2c_stop(delay); return 0; }
+ swi2c_write(delay, addr >> 8);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_write(delay, addr & 0xff);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_stop(delay);
+ swi2c_start(delay);
+ swi2c_write(delay, SWI2C_RMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ unsigned char byte = swi2c_read(delay);
+ swi2c_stop(delay);
+ if (pbyte) *pbyte = byte;
+ return 1;
+}
+
+int swi2c_writeByte_A16(unsigned char dev_addr, unsigned short addr, unsigned char* pbyte)
+{
+ int delay = 1 << (swi2c_cfg & 0xf);
+ int tmout = 1 << (swi2c_cfg >> 4);
+ swi2c_start(delay);
+ swi2c_write(delay, SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
+ if (!swi2c_wait_ack(delay, tmout)) { swi2c_stop(delay); return 0; }
+ swi2c_write(delay, addr >> 8);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_write(delay, addr & 0xff);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_write(delay, *pbyte);
+ if (!swi2c_wait_ack(delay, tmout)) return 0;
+ swi2c_stop(delay);
+ return 1;
+}
+
+#endif //SWI2C_A16
+
+
+#endif //SWI2C \ No newline at end of file
diff --git a/Firmware/swi2c.h b/Firmware/swi2c.h
new file mode 100644
index 000000000..ee2153257
--- /dev/null
+++ b/Firmware/swi2c.h
@@ -0,0 +1,22 @@
+#ifndef SWI2C_H
+#define SWI2C_H
+
+//initialize
+extern void swi2c_init(unsigned char sda, unsigned char scl, unsigned char cfg);
+
+//check device address acknowledge
+extern int swi2c_check(unsigned char dev_addr);
+
+//read write functions - 8bit address (most i2c chips)
+#ifdef SWI2C_A8
+extern int swi2c_readByte_A8(unsigned char dev_addr, unsigned char addr, unsigned char* pbyte);
+extern int swi2c_writeByte_A8(unsigned char dev_addr, unsigned char addr, unsigned char* pbyte);
+#endif //SWI2C_A8
+
+//read write functions - 16bit address (e.g. serial eeprom AT24C256)
+#ifdef SWI2C_A16
+extern int swi2c_readByte_A16(unsigned char dev_addr, unsigned short addr, unsigned char* pbyte);
+extern int swi2c_writeByte_A16(unsigned char dev_addr, unsigned short addr, unsigned char* pbyte);
+#endif //SWI2C_A16
+
+#endif //SWI2C_H
diff --git a/Firmware/swspi.cpp b/Firmware/swspi.cpp
index 87678be15..efab8f73b 100755
--- a/Firmware/swspi.cpp
+++ b/Firmware/swspi.cpp
@@ -1,108 +1,93 @@
-#include "swspi.h"
-
-
-#ifdef SWSPI_RPI
- #include <bcm2835.h>
- #define GPIO_INP(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_INPT)
- #define GPIO_OUT(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_OUTP)
- #define GPIO_SET(gpio) bcm2835_gpio_write(gpio, HIGH)
- #define GPIO_CLR(gpio) bcm2835_gpio_write(gpio, LOW)
- #define GPIO_GET(gpio) (bcm2835_gpio_lev(gpio) != LOW)
- #define DELAY(delay) usleep(delay)
-#endif //SWSPI_RPI
-
-#ifdef SWSPI_AVR
- //#include "Arduino.h"
- #include "Marlin.h"
- #define GPIO_INP(gpio) pinMode(gpio, INPUT)
- #define GPIO_OUT(gpio) pinMode(gpio, OUTPUT)
- #define GPIO_SET(gpio) digitalWrite(gpio, HIGH)
- #define GPIO_CLR(gpio) digitalWrite(gpio, LOW)
- #define GPIO_GET(gpio) (digitalRead(gpio) != LOW)
- #define DELAY(delay) delayMicroseconds(delay)
-#endif //SWSPI_AVR
-
-#if (SWSPI_POL != 0)
- #define SWSPI_SCK_UP GPIO_CLR(SWSPI_SCK)
- #define SWSPI_SCK_DN GPIO_SET(SWSPI_SCK)
-#else
- #define SWSPI_SCK_UP GPIO_SET(SWSPI_SCK)
- #define SWSPI_SCK_DN GPIO_CLR(SWSPI_SCK)
-#endif
-
-
-void swspi_init()
-{
- GPIO_INP(SWSPI_MISO);
- GPIO_OUT(SWSPI_MOSI);
- GPIO_OUT(SWSPI_SCK);
- GPIO_OUT(SWSPI_CS);
- GPIO_CLR(SWSPI_MOSI);
- SWSPI_SCK_DN;
- GPIO_SET(SWSPI_CS);
-}
-
-#if (SWSPI_MOSI == SWSPI_MISO)
-
-void swspi_tx(unsigned char tx)
-{
- GPIO_OUT(SWSPI_MOSI);
- unsigned char i = 0; for (; i < 8; i++)
- {
- if (tx & 0x80) GPIO_SET(SWSPI_MOSI);
- else GPIO_CLR(SWSPI_MOSI);
- DELAY(SWSPI_DEL);
- SWSPI_SCK_UP;
- DELAY(SWSPI_DEL);
- SWSPI_SCK_DN;
- tx <<= 1;
- }
-}
-
-unsigned char swspi_rx()
-{
- GPIO_INP(SWSPI_MISO);
- unsigned char rx = 0;
- unsigned char i = 0; for (; i < 8; i++)
- {
- rx <<= 1;
- DELAY(SWSPI_DEL);
- SWSPI_SCK_UP;
- DELAY(SWSPI_DEL);
- rx |= GPIO_GET(SWSPI_MISO)?1:0;
- SWSPI_SCK_DN;
- }
- return rx;
-}
-
-#else //(SWSPI_MOSI == SWSPI_MISO)
-
-unsigned char swspi_txrx(unsigned char tx)
-{
- unsigned char rx = 0;
- unsigned char i = 0; for (; i < 8; i++)
- {
- rx <<= 1;
- if (tx & 0x80) GPIO_SET(SWSPI_MOSI);
- else GPIO_CLR(SWSPI_MOSI);
- DELAY(SWSPI_DEL);
- SWSPI_SCK_UP;
- DELAY(SWSPI_DEL);
- rx |= GPIO_GET(SWSPI_MISO)?1:0;
- SWSPI_SCK_DN;
- tx <<= 1;
- }
- return rx;
-}
-
-#endif //(SWSPI_MOSI == SWSPI_MISO)
-
-void swspi_start()
-{
- GPIO_CLR(SWSPI_CS);
-}
-
-void swspi_stop()
-{
- GPIO_SET(SWSPI_CS);
-}
+#include "uni_avr_rpi.h"
+
+#ifdef __SWSPI
+#include "swspi.h"
+
+#ifdef __RPI
+//#define swspi_miso 9
+#define swspi_miso 10
+#define swspi_mosi 10
+#define swspi_sck 11
+#define SWSPI_CS 7
+#endif //__RPI
+
+
+#define SWSPI_DEL 0x0f //delay mask (0-3. bit, delay = 1 << DEL [us])
+#define SWSPI_POL 0x10 //polarity mask (4. bit, 1=inverted)
+#define SWSPI_PHA 0x20 //phase mask (5. bit)
+#define SWSPI_DOR 0x40 //data order mask (6. bit, 0=MSB first, 1=LSB first)
+
+#define SWSPI_SCK_UP if (swspi_cfg & SWSPI_POL) GPIO_CLR(swspi_sck); else GPIO_SET(swspi_sck);
+#define SWSPI_SCK_DN if (swspi_cfg & SWSPI_POL) GPIO_SET(swspi_sck); else GPIO_CLR(swspi_sck);
+
+unsigned char swspi_miso = 0;
+unsigned char swspi_mosi = 0;
+unsigned char swspi_sck = 0;
+unsigned char swspi_cfg = 0;
+
+void swspi_init(unsigned char miso, unsigned char mosi, unsigned char sck, unsigned char cfg)
+{
+ swspi_miso = miso;
+ swspi_mosi = mosi;
+ swspi_sck = sck;
+ swspi_cfg = cfg;
+ GPIO_INP(swspi_miso);
+ GPIO_OUT(swspi_mosi);
+ GPIO_OUT(swspi_sck);
+ GPIO_CLR(swspi_mosi);
+ SWSPI_SCK_DN;
+}
+
+void swspi_tx(unsigned char tx)
+{
+ int delay = 1 << (swspi_cfg & SWSPI_DEL));
+ if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
+ unsigned char i = 0; for (; i < 8; i++)
+ {
+ if (tx & 0x80) GPIO_SET(swspi_mosi);
+ else GPIO_CLR(swspi_mosi);
+ DELAY(delay);
+ SWSPI_SCK_UP;
+ DELAY(delay);
+ SWSPI_SCK_DN;
+ tx <<= 1;
+ }
+}
+
+unsigned char swspi_rx()
+{
+ int delay = 1 << (swspi_cfg & SWSPI_DEL));
+ if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
+ unsigned char rx = 0;
+ unsigned char i = 0; for (; i < 8; i++)
+ {
+ rx <<= 1;
+ DELAY(delay);
+ SWSPI_SCK_UP;
+ DELAY(delay);
+ rx |= GPIO_GET(swspi_miso)?1:0;
+ SWSPI_SCK_DN;
+ }
+ return rx;
+}
+
+unsigned char swspi_txrx(unsigned char tx)
+{
+ int delay = 1 << (swspi_cfg & SWSPI_DEL));
+ unsigned char rx = 0;
+ unsigned char i = 0; for (; i < 8; i++)
+ {
+ rx <<= 1;
+ if (tx & 0x80) GPIO_SET(swspi_mosi);
+ else GPIO_CLR(swspi_mosi);
+ DELAY(delay);
+ SWSPI_SCK_UP;
+ DELAY(delay);
+ rx |= GPIO_GET(swspi_miso)?1:0;
+ SWSPI_SCK_DN;
+ tx <<= 1;
+ }
+ return rx;
+}
+
+#endif //__SWSPI
diff --git a/Firmware/swspi.h b/Firmware/swspi.h
index ba75d2bb0..f95665c46 100755
--- a/Firmware/swspi.h
+++ b/Firmware/swspi.h
@@ -1,43 +1,14 @@
+// Software SPI
#ifndef SWSPI_H
#define SWSPI_H
-//#define SWSPI_RPI
-#define SWSPI_AVR
-
-#ifdef SWSPI_RPI
-//#define SWSPI_MISO 9
-#define SWSPI_MISO 10
-#define SWSPI_MOSI 10
-#define SWSPI_SCK 11
-#define SWSPI_CS 7
-#endif //SWSPI_RPI
-
-#ifdef SWSPI_AVR
-#endif //SWSPI_AVR
-
-#define SWSPI_POL 1 //polarity
-#define SWSPI_PHA 0 //phase
-#define SWSPI_DOR 0 //data order
-#define SWSPI_DEL 2 //delay
-
-
-void swspi_init();
-
-#if (SWSPI_MOSI == SWSPI_MISO)
-
-void swspi_tx(unsigned char tx);
-unsigned char swspi_rx();
-
-#else //(SWSPI_MOSI == SWSPI_MISO)
-
-#define swspi_tx swspi_txrx
-#define swspi_rx swspi_txrx
-unsigned char swspi_txrx(unsigned char tx);
-
-#endif //(SWSPI_MOSI == SWSPI_MISO)
-
-void swspi_start();
-void swspi_stop();
-
+//initialize gpio
+extern void swspi_init(unsigned char miso, unsigned char mosi, unsigned char sck, unsigned char cfg);
+//transmit and receive (full duplex mode)
+extern unsigned char swspi_txrx(unsigned char tx);
+//transmit (half dublex mode, miso == mosi)
+extern void swspi_tx(unsigned char tx);
+//receive (half dublex mode, miso == mosi)
+extern unsigned char swspi_rx();
#endif //SWSPI_H
diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp
index a2c93adbc..3abce4212 100644
--- a/Firmware/tmc2130.cpp
+++ b/Firmware/tmc2130.cpp
@@ -1,6 +1,6 @@
#include "Marlin.h"
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
#include "tmc2130.h"
#include <SPI.h>
@@ -508,4 +508,4 @@ uint8_t tmc2130_txrx(uint8_t cs, uint8_t addr, uint32_t wval, uint32_t* rval)
return stat;
}
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp
index b716912ff..f26a0328e 100644
--- a/Firmware/ultralcd.cpp
+++ b/Firmware/ultralcd.cpp
@@ -14,11 +14,14 @@
//#include "Configuration.h"
#include "SdFatUtil.h"
+
+#ifdef PAT9125
#include "pat9125.h"
+#endif //PAT9125
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
#include "tmc2130.h"
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
#define _STRINGIFY(s) #s
@@ -2487,10 +2490,10 @@ static void lcd_fsensor_state_set()
static void lcd_silent_mode_set() {
SilentModeMenu = !SilentModeMenu;
eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_mode = SilentModeMenu?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
tmc2130_init();
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
digipot_init();
lcd_goto_menu(lcd_settings_menu, 7);
}
@@ -3944,10 +3947,10 @@ static void lcd_autostart_sd()
static void lcd_silent_mode_set_tune() {
SilentModeMenu = !SilentModeMenu;
eeprom_update_byte((unsigned char*)EEPROM_SILENT, SilentModeMenu);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_mode = SilentModeMenu?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
tmc2130_init();
-#endif //HAVE_TMC2130_DRIVERS
+#endif //TMC2130
digipot_init();
lcd_goto_menu(lcd_tune_menu, 9);
}
@@ -4373,7 +4376,7 @@ static void lcd_selftest()
if (_result)
{
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
enable_endstops(false);
#endif
@@ -4436,7 +4439,7 @@ static bool lcd_selfcheck_axis_sg(char axis) {
current_position[axis] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
enable_endstops(true);
#endif
@@ -4447,7 +4450,7 @@ static bool lcd_selfcheck_axis_sg(char axis) {
SERIAL_ECHOPGM("Current position 2:");
MYSERIAL.println(current_position[axis]);*/
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
@@ -4457,7 +4460,7 @@ static bool lcd_selfcheck_axis_sg(char axis) {
st_synchronize();
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
//current_position[axis] = st_get_position_mm(axis);
@@ -4471,11 +4474,11 @@ static bool lcd_selfcheck_axis_sg(char axis) {
st_synchronize();
current_position[axis] += axis_length;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
st_synchronize();
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
//current_position[axis] = st_get_position_mm(axis);
@@ -4490,7 +4493,7 @@ static bool lcd_selfcheck_axis_sg(char axis) {
if (abs(measured_axis_length[i] - axis_length) > max_error_mm) {
//axis length
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
enable_endstops(false);
#endif
@@ -4570,7 +4573,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
}
_stepdone = true;
}
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
@@ -4652,8 +4655,8 @@ static bool lcd_selfcheck_pulleys(int axis)
//if (SilentModeMenu == 1) digipot_current(0, tmp_motor[0]); //set back to normal operation currents
//else digipot_current(0, tmp_motor_loud[0]); //set motor current back
current_position[axis] = current_position[axis] - move;
-#ifdef HAVE_TMC2130_DRIVERS
- tmc2130_home_enter(axis);
+#ifdef TMC2130
+ tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 50, active_extruder);
@@ -4662,7 +4665,7 @@ static bool lcd_selfcheck_pulleys(int axis)
lcd_selftest_error(8, (axis == 0) ? "X" : "Y", "");
return(false);
}
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
}
@@ -4671,7 +4674,7 @@ static bool lcd_selfcheck_pulleys(int axis)
manage_inactivity(true);
while (!endstop_triggered) {
if ((x_min_endstop) || (y_min_endstop)) {
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
endstop_triggered = true;
@@ -4695,15 +4698,15 @@ static bool lcd_selfcheck_pulleys(int axis)
}
}
else {
-#ifdef HAVE_TMC2130_DRIVERS
+#ifdef TMC2130
tmc2130_home_exit();
#endif
//current_position[axis] -= 1;
current_position[axis] += 50;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
current_position[axis] -= 100;
-#ifdef HAVE_TMC2130_DRIVERS
- tmc2130_home_enter(axis);
+#ifdef TMC2130
+ tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize();
diff --git a/Firmware/uni_avr_rpi.h b/Firmware/uni_avr_rpi.h
new file mode 100644
index 000000000..6a7200c31
--- /dev/null
+++ b/Firmware/uni_avr_rpi.h
@@ -0,0 +1,31 @@
+// unification for AVR and RPI
+#define __AVR
+
+#ifdef __AVR
+ //#include "Arduino.h"
+ #include "Marlin.h"
+ #define GPIO_INP(gpio) pinMode(gpio, INPUT)
+ #define GPIO_OUT(gpio) pinMode(gpio, OUTPUT)
+ #define GPIO_SET(gpio) digitalWrite(gpio, HIGH)
+ #define GPIO_CLR(gpio) digitalWrite(gpio, LOW)
+ #define GPIO_GET(gpio) (digitalRead(gpio) != LOW)
+ #define DELAY(delay) delayMicroseconds(delay)
+ #define PRINT MYSERIAL.print
+#endif //RC522_AVR
+
+#ifdef __RPI
+ #include <bcm2835.h>
+ #define GPIO_INP(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_INPT)
+ #define GPIO_OUT(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_OUTP)
+ #define GPIO_SET(gpio) bcm2835_gpio_write(gpio, HIGH)
+ #define GPIO_CLR(gpio) bcm2835_gpio_write(gpio, LOW)
+ #define GPIO_GET(gpio) (bcm2835_gpio_lev(gpio) != LOW)
+ #include <unistd.h>
+ #define DELAY(delay) usleep(delay)
+ #define PRINT(p) print(p)
+ #define DEC 10
+ #define HEX 16
+ void print(const char* pc) { printf("%s", pc); }
+ void print(int v) { printf("%d", v); }
+ void print(float v) { printf("%f", v); }
+#endif //RC522_RPI
diff --git a/Firmware/variants/1_75mm_MK3-EINY03-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINY03-E3Dv6full.h
index 129ec848c..d7f6b66a5 100644
--- a/Firmware/variants/1_75mm_MK3-EINY03-E3Dv6full.h
+++ b/Firmware/variants/1_75mm_MK3-EINY03-E3Dv6full.h
@@ -16,7 +16,6 @@
#define CUSTOM_MENDEL_NAME "Prusa i3 MK3"
// Electronics
-//#define MOTHERBOARD BOARD_EINY_0_4a
#define MOTHERBOARD BOARD_EINY_0_3a
@@ -49,7 +48,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define X_MAX_POS 255
#define X_MIN_POS 0
#define Y_MAX_POS 210
-#define Y_MIN_POS -4
+#define Y_MIN_POS -12 //orig -4
#define Z_MAX_POS 210
#define Z_MIN_POS 0.15
@@ -79,10 +78,17 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//DEBUG
#if 0
+#define DEBUG_DCODES //D codes
+#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored
+#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored
+#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored
+#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored
+#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored
+#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored
#define DEBUG_DISABLE_STARTMSGS //no startup messages
#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
-#define DEBUG_DISABLE_LCD_STATUS_LINE //sw limits ignored
+#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line
#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages
//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3)
@@ -255,7 +261,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
-#if MOTHERBOARD == 102 || MOTHERBOARD == 302 || MOTHERBOARD == 300 || MOTHERBOARD == 299
+#if MOTHERBOARD == 200 || MOTHERBOARD == 203 || MOTHERBOARD == 303 || MOTHERBOARD == 304 || MOTHERBOARD == 305
#define MOTOR_CURRENT_PWM_RANGE 2000
#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E}
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}
diff --git a/Firmware/variants/1_75mm_MK3-EINY04-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINY04-E3Dv6full.h
index 5ba54bdd1..6b6c861ec 100644
--- a/Firmware/variants/1_75mm_MK3-EINY04-E3Dv6full.h
+++ b/Firmware/variants/1_75mm_MK3-EINY04-E3Dv6full.h
@@ -17,7 +17,6 @@
// Electronics
#define MOTHERBOARD BOARD_EINY_0_4a
-//#define MOTHERBOARD BOARD_EINY_0_3a
// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier)
@@ -49,7 +48,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define X_MAX_POS 255
#define X_MIN_POS 0
#define Y_MAX_POS 210
-#define Y_MIN_POS -4
+#define Y_MIN_POS -12 //orig -4
#define Z_MAX_POS 210
#define Z_MIN_POS 0.15
@@ -79,10 +78,17 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//DEBUG
#if 0
+#define DEBUG_DCODES //D codes
+#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored
+#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored
+#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored
+#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored
+#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored
+#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored
#define DEBUG_DISABLE_STARTMSGS //no startup messages
#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
-#define DEBUG_DISABLE_LCD_STATUS_LINE //sw limits ignored
+#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line
#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages
//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3)
@@ -129,7 +135,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_TCOOLTHRS 239 // TCOOLTHRS - coolstep treshold
#define TMC2130_SG_HOMING 1 // stallguard homing
-#define TMC2130_SG_HOMING_SW 1 // stallguard "software" homing
+//#define TMC2130_SG_HOMING_SW 1 // stallguard "software" homing
#define TMC2130_SG_THRS_X 30 // stallguard sensitivity for X axis
#define TMC2130_SG_THRS_Y 30 // stallguard sensitivity for Y axis
#define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing)
@@ -255,7 +261,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
-#if MOTHERBOARD == 102 || MOTHERBOARD == 302 || MOTHERBOARD == 300 || MOTHERBOARD == 299
+#if MOTHERBOARD == 200 || MOTHERBOARD == 203 || MOTHERBOARD == 303 || MOTHERBOARD == 304 || MOTHERBOARD == 305
#define MOTOR_CURRENT_PWM_RANGE 2000
#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E}
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}