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.

arduino.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef __ARDUINO_H__
  23. #define __ARDUINO_H__
  24. #include <stddef.h>
  25. #include <stdint.h>
  26. #include <math.h>
  27. #include "../pinmapping.h"
  28. #define LOW 0x00
  29. #define HIGH 0x01
  30. #define CHANGE 0x02
  31. #define FALLING 0x03
  32. #define RISING 0x04
  33. #define INPUT 0x00
  34. #define OUTPUT 0x01
  35. #define INPUT_PULLUP 0x02
  36. #define _BV(bit) (1 << (bit))
  37. #define E2END 0xFFF // EEPROM end address
  38. typedef uint8_t byte;
  39. #define PROGMEM
  40. #define PSTR(v) (v)
  41. #define PGM_P const char *
  42. #define min(a,b) ((a)<(b)?(a):(b))
  43. #define max(a,b) ((a)>(b)?(a):(b))
  44. #define abs(x) ((x)>0?(x):-(x))
  45. #ifndef isnan
  46. #define isnan std::isnan
  47. #endif
  48. #ifndef isinf
  49. #define isinf std::isinf
  50. #endif
  51. //not constexpr until c++14
  52. //#define max(v1, v2) std::max((int)v1,(int)v2)
  53. //#define min(v1, v2) std::min((int)v1,(int)v2)
  54. //#define abs(v) std::abs(v)
  55. #define sq(v) ((v) * (v))
  56. #define square(v) sq(v)
  57. #define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value)))
  58. //Interrupts
  59. void cli(void); // Disable
  60. void sei(void); // Enable
  61. void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode);
  62. void detachInterrupt(uint32_t pin);
  63. extern "C" void GpioEnableInt(uint32_t port, uint32_t pin, uint32_t mode);
  64. extern "C" void GpioDisableInt(uint32_t port, uint32_t pin);
  65. // Program Memory
  66. #define pgm_read_ptr(addr) (*((void**)(addr)))
  67. #define pgm_read_byte_near(addr) (*((uint8_t*)(addr)))
  68. #define pgm_read_float_near(addr) (*((float*)(addr)))
  69. #define pgm_read_word_near(addr) (*((uint16_t*)(addr)))
  70. #define pgm_read_dword_near(addr) (*((uint32_t*)(addr)))
  71. #define pgm_read_byte(addr) pgm_read_byte_near(addr)
  72. #define pgm_read_float(addr) pgm_read_float_near(addr)
  73. #define pgm_read_word(addr) pgm_read_word_near(addr)
  74. #define pgm_read_dword(addr) pgm_read_dword_near(addr)
  75. #define memcpy_P memcpy
  76. #define sprintf_P sprintf
  77. #define strstr_P strstr
  78. #define strncpy_P strncpy
  79. #define vsnprintf_P vsnprintf
  80. #define strcpy_P strcpy
  81. #define snprintf_P snprintf
  82. // Time functions
  83. extern "C" {
  84. void delay(const int milis);
  85. }
  86. void _delay_ms(const int delay);
  87. void delayMicroseconds(unsigned long);
  88. uint32_t millis();
  89. //IO functions
  90. void pinMode(pin_t, uint8_t);
  91. void digitalWrite(pin_t, uint8_t);
  92. bool digitalRead(pin_t);
  93. void analogWrite(pin_t, int);
  94. uint16_t analogRead(pin_t);
  95. // EEPROM
  96. void eeprom_write_byte(unsigned char *pos, unsigned char value);
  97. unsigned char eeprom_read_byte(unsigned char *pos);
  98. void eeprom_read_block (void *__dst, const void *__src, size_t __n);
  99. void eeprom_update_block (const void *__src, void *__dst, size_t __n);
  100. int32_t random(int32_t);
  101. int32_t random(int32_t, int32_t);
  102. void randomSeed(uint32_t);
  103. char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s);
  104. int map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
  105. #endif // __ARDUINO_DEF_H__