psram_t.h
1 /* 2 PSRAM driver for IPS6404 3 */ 4 5 #ifndef _PSRAM_T_H_ 6 #define _PSRAM_T_H_ 7 8 #ifdef __cplusplus 9 #include <Arduino.h> 10 #include "platform_config.h" 11 12 #ifdef HAS_PSRAM 13 #define PAGE_SIZE 16 //32 //2048 //1024 14 #define MAX_PAGES 8 15 #else 16 #define PAGE_SIZE 256 17 #define MAX_PAGES 8 18 #endif 19 20 struct Page { 21 uint8_t page[PAGE_SIZE]; 22 uint32_t pageid; 23 int8_t next; 24 int8_t prev; 25 }; 26 27 class PSRAM_T 28 { 29 public: 30 PSRAM_T(uint8_t _CS, uint8_t _MOSI=11, uint8_t _SCLK=13, uint8_t _MISO=12); 31 void begin(void); 32 void pswrite(uint32_t addr, uint8_t val); 33 uint8_t psread(uint32_t addr); 34 uint16_t psread_w(uint32_t addr); 35 36 private: 37 static uint8_t psram_read(uint32_t addr); 38 static void psram_read_n(uint32_t addr, uint8_t * val, int n); 39 static void psram_write(uint32_t addr, uint8_t val); 40 static void psram_write_n(uint32_t addr, uint8_t * val, int n); 41 42 protected: 43 static uint8_t _cs, _miso, _mosi, _sclk; 44 static Page pages[MAX_PAGES]; 45 static uint8_t nbPages; 46 static int8_t top; 47 static int8_t last; 48 }; 49 #endif 50 51 #endif 52