Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Demo_MX25Rxx35F_Serial_NOR_Flash_Testbench mbed-lorawan-pulga mbed-lorawan-pulga-serial_rx mbed-lorawan-pulga-gps-added_shared
Fork of SPI_MX25R by
Revision 3:b6bb8d236251, committed 2018-03-28
- Comitter:
- Arkadi
- Date:
- Wed Mar 28 13:17:02 2018 +0000
- Parent:
- 2:f72110475fec
- Commit message:
- Modified for page read, n bytes read
Changed in this revision
| SPI_MX25R.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SPI_MX25R.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SPI_MX25R.cpp Thu Jul 23 17:11:27 2015 +0000
+++ b/SPI_MX25R.cpp Wed Mar 28 13:17:02 2018 +0000
@@ -303,3 +303,17 @@
return( data ) ;
}
+
+void SPI_MX25R::readNBytes(int addr, uint8_t *data, int nBytes) // read sequential n bytes
+{
+ int i;
+ m_cs = CS_LOW ;
+ m_spi.write(CMD_READ) ; // send 03h
+ m_spi.write((addr >> 16)&0xFF) ;
+ m_spi.write((addr >> 8)&0xFF) ;
+ m_spi.write(addr & 0xFF) ;
+ for (i = 0 ; i < nBytes ; i++ ) { // data: sequential data bytes
+ data[i] = m_spi.write(DUMMY) ;
+ }
+ m_cs = CS_HIGH ;
+}
\ No newline at end of file
--- a/SPI_MX25R.h Thu Jul 23 17:11:27 2015 +0000 +++ b/SPI_MX25R.h Wed Mar 28 13:17:02 2018 +0000 @@ -3,6 +3,10 @@ #include "mbed.h" + /** + Page Defines, write read based on page size + */ + #define MX25R_PAGES 0x7FFF // total memory size - Addresses 0x7FFFFF /** * Macronix Serial Flash Low Power Memories * SPI_MX25R Series SPI-Flash Memory @@ -178,6 +182,8 @@ uint8_t readFREAD(int addr) ; uint8_t read8(int addr) ; void write8(int addr, uint8_t data) ; + // read sequential n bytes + void readNBytes(int addr, uint8_t *data, int nBytes); private: } ;
