My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

LPC1768_PWM.h 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2017 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. * The class Servo uses the PWM class to implement its functions
  24. *
  25. * All PWMs use the same repetition rate - 20mS because that's the normal servo rate
  26. */
  27. /**
  28. * This is a hybrid system.
  29. *
  30. * The PWM1 module is used to directly control the Servo 0, 1 & 3 pins. This keeps
  31. * the pulse width jitter to under a microsecond.
  32. *
  33. * For all other pins the PWM1 module is used to generate interrupts. The ISR
  34. * routine does the actual setting/clearing of pins. The upside is that any pin can
  35. * have a PWM channel assigned to it. The downside is that there is more pulse width
  36. * jitter. The jitter depends on what else is happening in the system and what ISRs
  37. * prempt the PWM ISR. Writing to the SD card can add 20 microseconds to the pulse
  38. * width.
  39. */
  40. /**
  41. * The data structures are setup to minimize the computation done by the ISR which
  42. * minimizes ISR execution time. Execution times are 2.2 - 3.7 microseconds.
  43. *
  44. * Two tables are used. active_table is used by the ISR. Changes to the table are
  45. * are done by copying the active_table into the work_table, updating the work_table
  46. * and then swapping the two tables. Swapping is done by manipulating pointers.
  47. *
  48. * Immediately after the swap the ISR uses the work_table until the start of the
  49. * next 20mS cycle. During this transition the "work_table" is actually the table
  50. * that was being used before the swap. The "active_table" contains the data that
  51. * will start being used at the start of the next 20mS period. This keeps the pins
  52. * well behaved during the transition.
  53. *
  54. * The ISR's priority is set to the maximum otherwise other ISRs can cause considerable
  55. * jitter in the PWM high time.
  56. *
  57. * See the end of this file for details on the hardware/firmware interaction
  58. */
  59. #ifndef _LPC1768_PWM_H_
  60. #define _LPC1768_PWM_H_
  61. #include <pinmapping.h>
  62. #include <lpc17xx_clkpwr.h>
  63. #define LPC_PWM1_MR0 19999 // base repetition rate minus one count - 20mS
  64. #define LPC_PWM1_PCLKSEL0 CLKPWR_PCLKSEL_CCLK_DIV_4 // select clock divider for prescaler - defaults to 4 on power up
  65. #define MR0_MARGIN 200 // if channel value too close to MR0 the system locks up
  66. void LPC1768_PWM_init(void);
  67. bool LPC1768_PWM_attach_pin(pin_t pin, uint32_t min=1, uint32_t max=(LPC_PWM1_MR0 - (MR0_MARGIN)), uint8_t servo_index=0xFF);
  68. bool LPC1768_PWM_write(pin_t pin, uint32_t value);
  69. bool LPC1768_PWM_detach_pin(pin_t pin);
  70. bool useable_hardware_PWM(pin_t pin);
  71. #endif // _LPC1768_PWM_H_