![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Basic fram test for spi connectivity
Dependencies: mbed
main.cpp
- Committer:
- smigielski
- Date:
- 2015-01-31
- Revision:
- 4:a12fae0b702b
- Parent:
- 3:f71a526212cc
- Child:
- 5:25197dce2db7
File content as of revision 4:a12fae0b702b:
#include "mbed.h" SPI spi(P0_2, P0_3, P0_4); // mosi, miso, sclk DigitalOut cs(P0_30); DigitalOut hold(P0_1); // ACC Registers #define FM25CL_WREN 0x06 #define FM25CL_WRDI 0x04 #define FM25CL_RDSR 0x05 #define FM25CL_WRSR 0x01 #define FM25CL_READ 0x03 #define FM25CL_WRITE 0x02 #define TEST_LENGTH 4 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); cs = 1; } //Test that spi is working with fram FM25CL memory int main() { hold=1; cs=1; while(1) { readRegister(); enableWrite(); readRegister(); wait(0.5); } }