Guest User

Untitled

a guest
Jul 16th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #define LCDSTAT *((uint32_t*)0x3830001C)
  2. #define LCDCMD *((uint32_t*)0x38300004)
  3. #define LCDDATA *((uint32_t*)0x38300040)
  4.  
  5. void waitlcd()
  6. {
  7. while (LCDSTAT & 0x10);
  8. }
  9.  
  10. void sendlcdc(uint32_t cmd)
  11. {
  12. waitlcd();
  13. LCDCMD = cmd;
  14. }
  15.  
  16. void sendlcdd(uint32_t data)
  17. {
  18. waitlcd();
  19. LCDDATA = data;
  20. }
  21.  
  22. void displaylcd(uint32_t startcol, uint32_t endcol, uint32_t startrow,
  23. uint32_t endrow, uint16_t* buffer, uint32_t color)
  24. {
  25. uint32_t pixels = (endcol - startcol + 1) * (endrow - startrow + 1);
  26. if (endrow & 0x100) endrow ^= 0x300; // WTF... But the LCD needs it.
  27. sendlcdc(0x2A);
  28. sendlcdd(startcol);
  29. sendlcdd(endcol);
  30. sendlcdc(0x2B);
  31. sendlcdd(startrow);
  32. sendlcdd(endrow);
  33. sendlcdc(0x2C);
  34. while (pixels--)
  35. {
  36. if ((uint32_t)buffer == 0x40000000) sendlcdd(color);
  37. else
  38. {
  39. sendlcdd(*buffer);
  40. buffer = &buffer[1];
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment