// The manufacturer and device id command (0x9F) returns 4 bytes normally // (including info on id, family, density, etc.), but this functions returns // only the 5 bits pertaining to the memory density. unsigned char dfmemGetChipSize (void) { unsigned char byte; dfmemSelectChip(); dfmemWriteByte(0x9F); byte = dfmemReadByte(); // Manufacturer ID, not needed byte = dfmemReadByte() & 0b00011111; dfmemDeselectChip(); return byte; }
void dfmemRead (unsigned int page, unsigned int byte, unsigned int length, unsigned char *data) { while(!dfmemIsReady()); // Restructure page/byte addressing // 1 don't care bit + 13 page address bits + byte address bits MemAddr.address = (((unsigned long)page) << dfmem_byte_address_bits) + byte; // Read data from memory dfmemSelectChip(); dfmemWriteByte(READ_PAGE); dfmemWriteByte(MemAddr.chr_addr[2]); dfmemWriteByte(MemAddr.chr_addr[1]); dfmemWriteByte(MemAddr.chr_addr[0]); dfmemWriteByte(0x00); // 4 don't care bytes dfmemWriteByte(0x00); dfmemWriteByte(0x00); dfmemWriteByte(0x00); while (length--) { *data++ = dfmemReadByte(); } dfmemDeselectChip(); }
// The manufacturer and device id command (0x9F) returns 4 bytes normally // (including info on id, family, density, etc.), but this functions returns // just the manufacturer id and discards the rest when de-selecting the chip. unsigned char dfmemGetManufacturerID (void) { unsigned char byte; dfmemSelectChip(); dfmemWriteByte(0x9F); byte = dfmemReadByte(); dfmemDeselectChip(); return byte; }
unsigned char dfmemGetStatus (void) { unsigned char byte; dfmemSelectChip(); dfmemWriteByte(0xD7); byte = dfmemReadByte(); dfmemDeselectChip(); return byte; }