![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Basic fram test for spi connectivity
Dependencies: mbed
Diff: main.cpp
- Revision:
- 2:d11473ce92d6
- Parent:
- 1:711a282f7332
- Child:
- 3:f71a526212cc
--- a/main.cpp Fri Jan 30 20:00:37 2015 +0000 +++ b/main.cpp Fri Jan 30 22:38:04 2015 +0000 @@ -15,15 +15,20 @@ #define TEST_LENGTH 4 -void writeMemory(){ +void readRegister(){ cs = 0; spi.write(FM25CL_RDSR); //should be 0x00 uint8_t val_register = spi.write(0x00); + cs = 1; +} +void enableWrite(){ + cs = 0; spi.write(FM25CL_WREN); - spi.write(FM25CL_RDSR); - //should be 0x04 - uint8_t val_register2 = spi.write(0x00); + cs = 1; +} +void writeMemory(){ + cs = 0; spi.write(FM25CL_WRITE); spi.write(0x00); spi.write(0x00); @@ -34,9 +39,6 @@ } void readMemory(){ cs = 0; - spi.write(FM25CL_RDSR); - //should be 0x00 - uint8_t val_register = spi.write(0x00); spi.write(FM25CL_READ); spi.write(0x00); spi.write(0x00); @@ -52,8 +54,11 @@ hold=1; cs=1; while(1) { - writeMemory(); - wait(0.5); + readRegister(); + enableWrite(); + readRegister(); + writeMemory(); + readRegister(); readMemory(); wait(0.5); }