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.

servo_private.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. /**
  23. servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
  24. Copyright (c) 2009 Michael Margolis. All right reserved.
  25. This library is free software; you can redistribute it and/or
  26. modify it under the terms of the GNU Lesser General Public
  27. License as published by the Free Software Foundation; either
  28. version 2.1 of the License, or (at your option) any later version.
  29. This library is distributed in the hope that it will be useful,
  30. but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  32. Lesser General Public License for more details.
  33. You should have received a copy of the GNU Lesser General Public
  34. License along with this library; if not, write to the Free Software
  35. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  36. */
  37. #ifndef servo_private_h
  38. #define servo_private_h
  39. #include <inttypes.h>
  40. // Architecture specific include
  41. #ifdef ARDUINO_ARCH_AVR
  42. #include "HAL_AVR/ServoTimers.h"
  43. #elif defined(ARDUINO_ARCH_SAM)
  44. #include "HAL_DUE/ServoTimers.h"
  45. #else
  46. #error "This library only supports boards with an AVR or SAM3X processor."
  47. #endif
  48. // Macros
  49. #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo
  50. #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo
  51. #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
  52. #define REFRESH_INTERVAL 20000 // minimum time to refresh servos in microseconds
  53. #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer
  54. #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER)
  55. #define INVALID_SERVO 255 // flag indicating an invalid servo index
  56. //
  57. #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / PRESCALER) // converts microseconds to tick (PRESCALER depends on architecture)
  58. #define ticksToUs(_ticks) (( (unsigned)_ticks * PRESCALER)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
  59. //#define NBR_TIMERS ((MAX_SERVOS) / (SERVOS_PER_TIMER))
  60. // convenience macros
  61. #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / (SERVOS_PER_TIMER))) // returns the timer controlling this servo
  62. #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % (SERVOS_PER_TIMER)) // returns the index of the servo on this timer
  63. #define SERVO_INDEX(_timer,_channel) ((_timer*(SERVOS_PER_TIMER)) + _channel) // macro to access servo index by timer and channel
  64. #define SERVO(_timer,_channel) (servo_info[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel
  65. // Types
  66. typedef struct {
  67. uint8_t nbr : 6 ; // a pin number from 0 to 63
  68. uint8_t isActive : 1 ; // true if this channel is enabled, pin not pulsed if false
  69. } ServoPin_t;
  70. typedef struct {
  71. ServoPin_t Pin;
  72. unsigned int ticks;
  73. } ServoInfo_t;
  74. // Global variables
  75. extern uint8_t ServoCount;
  76. extern ServoInfo_t servo_info[MAX_SERVOS];
  77. // Public functions
  78. extern void initISR(timer16_Sequence_t timer);
  79. extern void finISR(timer16_Sequence_t timer);
  80. #endif