Double_G

SPI ILI9341 + 25aa512 eeprom

May 31st, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #include "SPI.h"
  2. #include "Adafruit_GFX.h"
  3. #include "Adafruit_ILI9341.h"
  4.  
  5. #define _cs   17  // goes to TFT CS
  6. #define _dc   16  // goes to TFT DC
  7. #define _mosi 23  // goes to TFT & eeprom MOSI
  8. #define _sclk 18  // goes to TFT & eeprom SCK/CLK
  9. #define _rst  5   // goes to TFT RESET
  10. #define _miso 19  // goes to eeprom MISO
  11. //       5v       // goes to TFT & eeprom Vcc
  12. //       Gnd      // goes to TFT & eeprom Gnd  
  13. #define EE_CS 4   // goes to eeprom cs
  14.  
  15. Adafruit_ILI9341 tft = Adafruit_ILI9341(_cs, _dc, _rst);
  16.  
  17. void setup() {
  18.   Serial.begin(115200);
  19.   Serial.println("A torles elindult");
  20.  
  21.   tft.begin();
  22.   tft.setRotation(3);
  23.   tft.fillScreen(ILI9341_BLACK);
  24.   tft.setTextSize(3);
  25.   tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
  26.   tft.println("A torles elindult");
  27.  
  28.   pinMode(EE_CS,OUTPUT);            //CS lábat kimenetre állítani
  29.   digitalWrite(EE_CS, HIGH);        //CS lábat felhúzni (inicializálás)
  30.   SPI.begin();                      //SPI inicializálni
  31.   SPI.setDataMode(SPI_MODE3);       //SPI protokol kiválasztása
  32.   SPI.setBitOrder(MSBFIRST);        //SPI byte sorrend
  33.  
  34.   delay(1000);
  35.  
  36.   digitalWrite(EE_CS, LOW);
  37.   SPI.transfer(6);
  38.   digitalWrite(EE_CS, HIGH);
  39.  
  40.   digitalWrite(EE_CS, LOW);
  41.   SPI.transfer(1);
  42.   SPI.transfer(0);
  43.   digitalWrite(EE_CS, HIGH);
  44.  
  45.   for(unsigned int j=0; j< 65535; )
  46.  {
  47.     digitalWrite(EE_CS, LOW);
  48.     SPI.transfer(6); // write enabled 6
  49.     digitalWrite(EE_CS, HIGH);
  50.      
  51.     digitalWrite(EE_CS, LOW);
  52.     SPI.transfer(2); // write 2,0
  53.     SPI.transfer(j >>8);           //a cím felső 8 bit-je
  54.     SPI.transfer(j & 0x00FF);      //a cím alsó 8 bit-je
  55.     SPI.transfer(j);               //a menteni kívánt adat beírása
  56.     digitalWrite(EE_CS, HIGH);
  57.     delay(4);                      //4 ms míg beírja az értéket az eepromba
  58.     Serial.println(j);
  59.    
  60.     j++;
  61.  
  62.     digitalWrite(EE_CS, LOW);
  63.     SPI.transfer(4); // write disabled 4
  64.     digitalWrite(EE_CS, HIGH);
  65.     }
  66.  
  67. tft.fillScreen(ILI9341_BLACK);
  68. tft.println("Kesz!");
  69. }
  70.  
  71. void loop(void) {
  72.  
  73.    
  74. }
Advertisement
Add Comment
Please, Sign In to add comment