FRAM SPI Access Library
Dependents: FRAM_Dump SDFile_Logger
Revision 2:9a0f9faada7f, committed 2017-08-18
- Comitter:
- APS_Lab
- Date:
- Fri Aug 18 05:27:05 2017 +0000
- Parent:
- 0:c31c06ec36da
- Commit message:
- No change
Changed in this revision
MB85RSxx_SPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
MB85RSxx_SPI.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MB85RSxx_SPI.cpp Thu Jun 22 08:30:47 2017 +0000 +++ b/MB85RSxx_SPI.cpp Fri Aug 18 05:27:05 2017 +0000 @@ -3,7 +3,7 @@ * @file MB85RSxx_SPI.cpp * @author APS Lab * @version V1.0.0 - * @date 16 June 2017 + * @date 26 June 2017 * @brief MB85RSxx_SPI class implementation ****************************************************************************** * @attention @@ -59,7 +59,7 @@ wait(0.2); _di=0; _spi.write(WRSR); - _spi.write(0x02); + _spi.write(SR_WEL); _di=1; wait(0.2); _di=0; @@ -76,8 +76,8 @@ _di=1; _di=0; _spi.write(WRITE); - _spi.write((address & 0x3F00) >> 8);//Addr H - _spi.write((address & 0x00FF)); //Addr L + _spi.write((address & 0x3F00) >> 8);//Addr H for 64Kbits + _spi.write((address & 0x00FF)); //Addr L for 64Kbits _spi.write(data); //Write Data _di=1; } @@ -87,8 +87,8 @@ char ch; _di=0; _spi.write(READ); - _spi.write((address & 0x3F00) >> 8);//Addr H - _spi.write((address & 0x00FF)); //Addr L + _spi.write((address & 0x3F00) >> 8);//Addr H for 64Kbits + _spi.write((address & 0x00FF)); //Addr L for 64Kbits ch = _spi.write(0x00);//Write dummy 0x00, Reade Data _di=1; return ch; @@ -104,14 +104,12 @@ } } -uint32_t MB85RSxx_SPI::read(uint32_t address, char *data, uint32_t length) +void MB85RSxx_SPI::read(uint32_t address, char *data, uint32_t length) { - uint32_t error=0; uint32_t idx; for(idx=0; idx < length; idx++) { *(data+idx) = MB85RSxx_SPI::read(address+idx); } - return error; }
--- a/MB85RSxx_SPI.h Thu Jun 22 08:30:47 2017 +0000 +++ b/MB85RSxx_SPI.h Fri Aug 18 05:27:05 2017 +0000 @@ -3,7 +3,7 @@ * @file MB85RSxx_SPI.h * @author APS Lab * @version V1.0.0 - * @date 16 June 2017 + * @date 26 June 2017 * @brief This file contains the class of an MB85RSxx FRAM library with SPI interface ****************************************************************************** * @attention @@ -32,15 +32,6 @@ #include "mbed.h" -#define MB85_DENSITY_64K 0x3 -#define MB85_DENSITY_256K 0x5 -#define MB85_DENSITY_512K 0x6 -#define MB85_DENSITY_1M 0x7 -#define MB85_DENSITY_2M 0x8 -#define MB85RC_SPI_ADDRESS 0xA0 -#define SPI_WRITE 0 -#define SPI_READ 1 - #define WREN 0x06 #define WRDI 0x04 #define RDSR 0x05 @@ -48,6 +39,11 @@ #define READ 0x03 #define WRITE 0x02 +#define SR_WPEN 0x80 +#define SR_BP0 0x08 +#define SR_BP1 0x04 +#define SR_WEL 0x02 + /** Interface for accessing Fujitsu MB85RSxx FRAM * * @code @@ -143,9 +139,8 @@ * @param FRAM address * @param FRAM data Pointer to the byte-array to read data in to * @prama length Number of bytes to read - * return 0:success, 1:pointer error */ - uint32_t read(uint32_t address, char *data, uint32_t length); + void read(uint32_t address, char *data, uint32_t length); private: