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.
23LCV1024.cpp
00001 #include "mbed.h" 00002 #include "23LCV1024.h" 00003 00004 SRAM23LCV1024::SRAM23LCV1024(SPI& spi, PinName cs) : _spi(spi), _cs(cs) { 00005 _cs = 1; // Deselect the device so that it can initialize 00006 } 00007 00008 int SRAM23LCV1024::getReadMode() { 00009 /* The mode bits indicate the operating mode of the SRAM: 00010 00 = Byte mode 00011 10 = Page mode 00012 01 = Sequential mode (default) 00013 11 = Reserved 00014 */ 00015 00016 _cs = 0; 00017 _spi.write(CMD_RDMR); 00018 int ram_mode = _spi.write(0)>>6; 00019 _cs = 1; 00020 00021 return ram_mode; 00022 } 00023 00024 int SRAM23LCV1024::readBytes(int address, char* buffer, int length) { 00025 int i; 00026 00027 _cs = 0; 00028 _spi.write(CMD_READ); 00029 _spi.write((address >> 16) & 0xff); 00030 _spi.write((address >> 8) & 0xff); 00031 _spi.write(address & 0xff); 00032 00033 for (i = 0; i < length; i ++) buffer[i] = _spi.write(0); 00034 00035 _cs = 1; 00036 return 0; 00037 } 00038 00039 00040 int SRAM23LCV1024::writeBytes(int address, char* buffer, int length) { 00041 int i; 00042 00043 _cs = 0; 00044 _spi.write(CMD_WRITE); 00045 _spi.write((address >> 16) & 0xff); 00046 _spi.write((address >> 8) & 0xff); 00047 _spi.write(address & 0xff); 00048 00049 for (i = 0; i < length; i ++) _spi.write(buffer[i]); 00050 00051 _cs = 1; 00052 return 0; 00053 } 00054
Generated on Thu Jul 21 2022 03:21:59 by
1.7.2