/* PSRAM driver for IPS6404 */ #include "psram_t.h" #include #include #include "psram_spi.h" #ifdef PSCACHE Page PSRAM_T::pages[MAX_PAGES]; uint8_t PSRAM_T::nbPages=0; int8_t PSRAM_T::top=0; int8_t PSRAM_T::last=0; #endif #define RAM_READ 0xB //#define RAM_READ 0x3 #define RAM_WRITE 0x2 static psram_spi_inst_t psram_spi; PSRAM_T::PSRAM_T(uint8_t cs, uint8_t mosi, uint8_t sclk, uint8_t miso) { } void PSRAM_T::begin(void) { psram_spi = psram_spi_init(pio2, 0); } uint8_t PSRAM_T::psram_read(uint32_t addr) { return psram_read8(&psram_spi, addr); } uint16_t PSRAM_T::psram_read_w(uint32_t addr) { return psram_read16(&psram_spi, addr); } void PSRAM_T::psram_read_n(uint32_t addr, uint8_t * val, int n) { //printf("r %d %d\n", addr, n); psram_readn(&psram_spi, addr, val, n); } void PSRAM_T::psram_write(uint32_t addr, uint8_t val) { psram_write8(&psram_spi, addr, val); } void PSRAM_T::psram_write_w(uint32_t addr, uint16_t val) { psram_write16(&psram_spi, addr, val); } static uint8_t resp[PAGE_SIZE]; void PSRAM_T::psram_write_n(uint32_t addr, uint8_t * val, int n) { printf("w %d %d\n", addr, n); psram_writen(&psram_spi, addr, val, n); } void PSRAM_T::pswrite(uint32_t addr, uint8_t val) { psram_write(addr, val); #ifdef PSCACHE uint32_t curPage=addr&(~(PAGE_SIZE-1)); for (int i=0; i>8 ; break; } } #endif }