My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

main.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifdef TARGET_LPC1768
  2. #include <usb/usb.h>
  3. #include <usb/usbcfg.h>
  4. #include <usb/usbhw.h>
  5. #include <usb/usbcore.h>
  6. #include <usb/cdc.h>
  7. #include <usb/cdcuser.h>
  8. #include <usb/mscuser.h>
  9. #include <CDCSerial.h>
  10. #include <usb/mscuser.h>
  11. extern "C" {
  12. #include <debug_frmwrk.h>
  13. }
  14. #include "../../sd/cardreader.h"
  15. #include "../../inc/MarlinConfig.h"
  16. #include "HAL.h"
  17. #include "HAL_timers.h"
  18. extern uint32_t MSC_SD_Init(uint8_t pdrv);
  19. extern "C" int isLPC1769();
  20. extern "C" void disk_timerproc(void);
  21. void SysTick_Callback() {
  22. disk_timerproc();
  23. }
  24. void HAL_init() {
  25. // Support the 4 LEDs some LPC176x boards have
  26. #if PIN_EXISTS(LED)
  27. SET_DIR_OUTPUT(LED_PIN);
  28. WRITE_PIN_CLR(LED_PIN);
  29. #if PIN_EXISTS(LED2)
  30. SET_DIR_OUTPUT(LED2_PIN);
  31. WRITE_PIN_CLR(LED2_PIN);
  32. #if PIN_EXISTS(LED3)
  33. SET_DIR_OUTPUT(LED3_PIN);
  34. WRITE_PIN_CLR(LED3_PIN);
  35. #if PIN_EXISTS(LED4)
  36. SET_DIR_OUTPUT(LED4_PIN);
  37. WRITE_PIN_CLR(LED4_PIN);
  38. #endif
  39. #endif
  40. #endif
  41. // Flash status LED 3 times to indicate Marlin has started booting
  42. for (uint8_t i = 0; i < 6; ++i) {
  43. TOGGLE(LED_PIN);
  44. delay(100);
  45. }
  46. #endif
  47. //debug_frmwrk_init();
  48. //_DBG("\n\nDebug running\n");
  49. // Initialise the SD card chip select pins as soon as possible
  50. #if PIN_EXISTS(SS)
  51. WRITE(SS_PIN, HIGH);
  52. SET_OUTPUT(SS_PIN);
  53. #endif
  54. #if defined(ONBOARD_SD_CS) && ONBOARD_SD_CS > -1
  55. WRITE(ONBOARD_SD_CS, HIGH);
  56. SET_OUTPUT(ONBOARD_SD_CS);
  57. #endif
  58. USB_Init(); // USB Initialization
  59. USB_Connect(FALSE); // USB clear connection
  60. delay(1000); // Give OS time to notice
  61. USB_Connect(TRUE);
  62. #if DISABLED(USB_SD_DISABLED)
  63. MSC_SD_Init(0); // Enable USB SD card access
  64. #endif
  65. const millis_t usb_timeout = millis() + 2000;
  66. while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
  67. delay(50);
  68. HAL_idletask();
  69. #if PIN_EXISTS(LED)
  70. TOGGLE(LED_PIN); // Flash quickly during USB initialization
  71. #endif
  72. }
  73. #if NUM_SERIAL > 0
  74. MYSERIAL0.begin(BAUDRATE);
  75. #if NUM_SERIAL > 1
  76. MYSERIAL1.begin(BAUDRATE);
  77. #endif
  78. SERIAL_PRINTF("\n\necho:%s (%dMhz) Initialized\n", isLPC1769() ? "LPC1769" : "LPC1768", SystemCoreClock / 1000000);
  79. SERIAL_FLUSHTX();
  80. #endif
  81. HAL_timer_init();
  82. }
  83. // HAL idle task
  84. void HAL_idletask(void) {
  85. #if ENABLED(SDSUPPORT) && ENABLED(SHARED_SD_CARD)
  86. // If Marlin is using the SD card we need to lock it to prevent access from
  87. // a PC via USB.
  88. // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
  89. // this will not reliably detect delete operations. To be safe we will lock
  90. // the disk if Marlin has it mounted. Unfortuately there is currently no way
  91. // to unmount the disk from the LCD menu.
  92. // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
  93. if (card.isDetected())
  94. MSC_Aquire_Lock();
  95. else
  96. MSC_Release_Lock();
  97. #endif
  98. // Perform USB stack housekeeping
  99. MSC_RunDeferredCommands();
  100. }
  101. #endif // TARGET_LPC1768