My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Marlin.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef __MARLINH
  2. #define __MARLINH
  3. // Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
  4. // Licence: GPL
  5. #define HardwareSerial_h // trick to disable the standard HWserial
  6. #include <math.h>
  7. #if ARDUINO >= 100
  8. #include "Arduino.h"
  9. #else
  10. #include "WProgram.h"
  11. #endif
  12. #include "fastio.h"
  13. #include <avr/pgmspace.h>
  14. #include "Configuration.h"
  15. #include "MarlinSerial.h"
  16. #define FORCE_INLINE __attribute__((always_inline)) inline
  17. //#define SERIAL_ECHO(x) Serial << "echo: " << x;
  18. //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
  19. //#define SERIAL_ERROR(x) Serial << "Error: " << x;
  20. //#define SERIAL_ERRORLN(x) Serial << "Error: " << x<<endl;
  21. //#define SERIAL_PROTOCOL(x) Serial << x;
  22. //#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
  23. //this is a unfinsihed attemp to removes a lot of warning messages, see:
  24. // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
  25. //typedef char prog_char PROGMEM;
  26. // //#define PSTR (s ) ((const PROGMEM char *)(s))
  27. // //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];}))
  28. // //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
  29. // //#define MYPGM(s) PSTR(s)
  30. #define MYPGM(s) (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];})) //This is the normal behaviour
  31. //#define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) //this does not work but hides the warnings
  32. #define SERIAL_PROTOCOL(x) MSerial.print(x);
  33. #define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
  34. #define SERIAL_PROTOCOLLN(x) {MSerial.print(x);MSerial.write('\n');}
  35. #define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MSerial.write('\n');}
  36. const prog_char errormagic[] PROGMEM ="Error:";
  37. const prog_char echomagic[] PROGMEM ="echo:";
  38. #define SERIAL_ERROR_START serialprintPGM(errormagic);
  39. #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
  40. #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
  41. #define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
  42. #define SERIAL_ERRORLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
  43. #define SERIAL_ECHO_START serialprintPGM(echomagic);
  44. #define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
  45. #define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
  46. #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
  47. #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
  48. #define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
  49. //things to write to serial from Programmemory. saves 400 to 2k of RAM.
  50. #define SerialprintPGM(x) serialprintPGM(MYPGM(x))
  51. FORCE_INLINE void serialprintPGM(const char *str)
  52. {
  53. char ch=pgm_read_byte(str);
  54. while(ch)
  55. {
  56. MSerial.write(ch);
  57. ch=pgm_read_byte(++str);
  58. }
  59. }
  60. void get_command();
  61. void process_commands();
  62. void manage_inactivity(byte debug);
  63. #if X_ENABLE_PIN > -1
  64. #define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
  65. #define disable_x() WRITE(X_ENABLE_PIN,!X_ENABLE_ON)
  66. #else
  67. #define enable_x() ;
  68. #define disable_x() ;
  69. #endif
  70. #if Y_ENABLE_PIN > -1
  71. #define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
  72. #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
  73. #else
  74. #define enable_y() ;
  75. #define disable_y() ;
  76. #endif
  77. #if Z_ENABLE_PIN > -1
  78. #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
  79. #define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON)
  80. #else
  81. #define enable_z() ;
  82. #define disable_z() ;
  83. #endif
  84. #if E_ENABLE_PIN > -1
  85. #define enable_e() WRITE(E_ENABLE_PIN, E_ENABLE_ON)
  86. #define disable_e() WRITE(E_ENABLE_PIN,!E_ENABLE_ON)
  87. #else
  88. #define enable_e() ;
  89. #define disable_e() ;
  90. #endif
  91. enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
  92. void FlushSerialRequestResend();
  93. void ClearToSend();
  94. void get_coordinates();
  95. void prepare_move();
  96. void kill();
  97. void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
  98. void prepare_arc_move(char isclockwise);
  99. #ifndef CRITICAL_SECTION_START
  100. #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
  101. #define CRITICAL_SECTION_END SREG = _sreg;
  102. #endif //CRITICAL_SECTION_START
  103. extern float homing_feedrate[];
  104. extern bool axis_relative_modes[];
  105. extern float current_position[NUM_AXIS] ;
  106. extern float add_homeing[3];
  107. #endif