My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

arduino.cpp 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifdef __PLAT_LINUX__
  23. #include <iostream>
  24. #include "../../inc/MarlinConfig.h"
  25. #include "hardware/Clock.h"
  26. #include "../shared/Delay.h"
  27. // Interrupts
  28. void cli() { } // Disable
  29. void sei() { } // Enable
  30. // Time functions
  31. void _delay_ms(const int ms) { delay(ms); }
  32. uint32_t millis() {
  33. return (uint32_t)Clock::millis();
  34. }
  35. // This is required for some Arduino libraries we are using
  36. void delayMicroseconds(uint32_t us) {
  37. Clock::delayMicros(us);
  38. }
  39. extern "C" void delay(const int msec) {
  40. Clock::delayMillis(msec);
  41. }
  42. // IO functions
  43. // As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
  44. void pinMode(const pin_t pin, const uint8_t mode) {
  45. if (!VALID_PIN(pin)) return;
  46. Gpio::setMode(pin, mode);
  47. }
  48. void digitalWrite(pin_t pin, uint8_t pin_status) {
  49. if (!VALID_PIN(pin)) return;
  50. Gpio::set(pin, pin_status);
  51. }
  52. bool digitalRead(pin_t pin) {
  53. if (!VALID_PIN(pin)) return false;
  54. return Gpio::get(pin);
  55. }
  56. void analogWrite(pin_t pin, int pwm_value) { // 1 - 254: pwm_value, 0: LOW, 255: HIGH
  57. if (!VALID_PIN(pin)) return;
  58. Gpio::set(pin, pwm_value);
  59. }
  60. uint16_t analogRead(pin_t adc_pin) {
  61. if (!VALID_PIN(DIGITAL_PIN_TO_ANALOG_PIN(adc_pin))) return 0;
  62. return Gpio::get(DIGITAL_PIN_TO_ANALOG_PIN(adc_pin));
  63. }
  64. char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s) {
  65. char format_string[20];
  66. snprintf(format_string, 20, "%%%d.%df", __width, __prec);
  67. sprintf(__s, format_string, __val);
  68. return __s;
  69. }
  70. int32_t random(int32_t max) {
  71. return rand() % max;
  72. }
  73. int32_t random(int32_t min, int32_t max) {
  74. return min + rand() % (max - min);
  75. }
  76. void randomSeed(uint32_t value) {
  77. srand(value);
  78. }
  79. int map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max) {
  80. return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  81. }
  82. #endif // __PLAT_LINUX__