in table 10.2.2 states M7-M0 are part of the JEDEC register, same with ID15-ID0.
so when you send your command to read that register it will return those portions of the Register, (MSB first).
Ehf is the JEDEC manufacture ID, I believe that is the same for all winbond chips in that family.
The datasheet for the part you listed states that a 24-bit address should be written after the 0x90 code. Then the 2-byte Manufacturer and Device codes can be read. So insert 3 write instructions and it should work.
pc.printf("response from sending 90h: %d\r\n", spi.write(0x90));
pc.printf("response from sending 00h: %d\r\n", spi.write(0x00)); //Address 23..16
pc.printf("response from sending 00h: %d\r\n", spi.write(0x00)); //Address 15..8
pc.printf("response from sending 00h: %d\r\n", spi.write(0x00)); //Address 7..0
pc.printf("response from sending 00h: %d\r\n", spi.write(0x00)); //Manufacturer ID
pc.printf("response from sending 00h: %d\r\n", spi.write(0x00)); //Device ID
If you get inconsistent results, you may want to do your writes in a loop, then print when finished. I'm not sure how the printf IO affects the mbed SPI implementation timing, but if you get gaps between byte writes, that may affect how the flash part responds.
unsigned char command[6] = {0x90, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char response[6];
for(int i=0; i<6; i++)
{
response[i] = spi.write(command[i]);
}
pc.printf("Manufacturer ID: %d\r\n", command[4]);
pc.printf("Device ID: %d:\r\n", command[5]);
You also have instruction 90h in your source, but your diagram is for instruction 9Fh. Just changing the instruction may allow your original code to work.
Best Answer
send 06h to enable write then send page program (02h) which is the write function. (send 02h -> address 24 bits -> then min 2 bytes and up to 256bytes max) check 9.2.8 in the datasheet.