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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #pragma once
  23. #include "../../../inc/MarlinConfig.h"
  24. #include <SPI.h>
  25. #include <lpc17xx_ssp.h>
  26. // #include <lpc17xx_gpdma.h>
  27. #ifndef LCD_READ_ID
  28. #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
  29. #endif
  30. #ifndef LCD_READ_ID4
  31. #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
  32. #endif
  33. #define DATASIZE_8BIT SSP_DATABIT_8
  34. #define DATASIZE_16BIT SSP_DATABIT_16
  35. #define TFT_IO_DRIVER TFT_SPI
  36. #define DMA_MINC_ENABLE 1
  37. #define DMA_MINC_DISABLE 0
  38. class TFT_SPI {
  39. private:
  40. static uint32_t ReadID(uint16_t Reg);
  41. static void Transmit(uint16_t Data);
  42. static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
  43. public:
  44. static SPIClass SPIx;
  45. static void Init();
  46. static uint32_t GetID();
  47. static bool isBusy();
  48. static void Abort();
  49. static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT);
  50. static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); };
  51. static void DataTransferAbort();
  52. static void WriteData(uint16_t Data) { Transmit(Data); }
  53. static void WriteReg(uint16_t Reg) { OUT_WRITE(TFT_A0_PIN, LOW); Transmit(Reg); OUT_WRITE(TFT_A0_PIN, HIGH); }
  54. static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
  55. // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
  56. static void WriteMultiple(uint16_t Color, uint32_t Count) {
  57. static uint16_t Data; Data = Color;
  58. //LPC dma can only write 0xFFF bytes at once.
  59. #define MAX_DMA_SIZE (0xFFF - 1)
  60. while (Count > 0) {
  61. TransmitDMA(DMA_MINC_DISABLE, &Data, Count > MAX_DMA_SIZE ? MAX_DMA_SIZE : Count);
  62. Count = Count > MAX_DMA_SIZE ? Count - MAX_DMA_SIZE : 0;
  63. }
  64. #undef MAX_DMA_SIZE
  65. }
  66. };