My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

tft_fsmc.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef LCD_READ_ID
  24. #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
  25. #endif
  26. #ifndef LCD_READ_ID4
  27. #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
  28. #endif
  29. #include <libmaple/dma.h>
  30. #define DATASIZE_8BIT DMA_SIZE_8BITS
  31. #define DATASIZE_16BIT DMA_SIZE_16BITS
  32. #define TFT_IO_DRIVER TFT_FSMC
  33. typedef struct {
  34. __IO uint16_t REG;
  35. __IO uint16_t RAM;
  36. } LCD_CONTROLLER_TypeDef;
  37. class TFT_FSMC {
  38. private:
  39. static LCD_CONTROLLER_TypeDef *LCD;
  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 void Init();
  45. static uint32_t GetID();
  46. static bool isBusy();
  47. static void Abort();
  48. static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) {};
  49. static void DataTransferEnd() {};
  50. static void WriteData(uint16_t Data) { Transmit(Data); }
  51. static void WriteReg(uint16_t Reg);
  52. static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_MODE, Data, Count); }
  53. static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_CIRC_MODE, &Data, Count); }
  54. static void WriteMultiple(uint16_t Color, uint32_t Count) {
  55. static uint16_t Data; Data = Color;
  56. while (Count > 0) {
  57. TransmitDMA(DMA_CIRC_MODE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
  58. Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
  59. }
  60. }
  61. };