IP12B512 class for comunicating with the IPSiLog IP12B512 SPI RAM

Files at this revision

API Documentation at this revision

Comitter:
adamumpsimus
Date:
Sun Nov 06 16:08:04 2016 +0000
Parent:
1:bcbe2cf57840
Commit message:
updated the docs

Changed in this revision

IP12B512.cpp Show annotated file Show diff for this revision Revisions of this file
IP12B512.h Show annotated file Show diff for this revision Revisions of this file
--- a/IP12B512.cpp	Fri Nov 04 08:19:09 2016 +0000
+++ b/IP12B512.cpp	Sun Nov 06 16:08:04 2016 +0000
@@ -1,49 +1,6 @@
-/** IP12B512 class.
- *  Main class for comunicating with the IP12B512 SPI RAM.
- */
 #include "IP12B512.h"
 
-/** Constructor: setup the SPI and write to "Status Register" that we are going to use it in "Virtual Chip Mode"
- * 
- * Notes:
- * - the MOSI and MISO pins must have 5k6 pulldown resistors
- * - the SCLK pin has a 5k6 pulldown resistor
- * - the HOLD pin is connected to VCC
- * - the CS pin has a 5k6 pullup resistor
- * 
- * @param pin_mosi the hardware MOSI pin on the board
- * @param pin_miso the hardware MISO pin on the board
- * @param pin_sclk the hardware SCLK pin on the board
- * @param pin_cs the software CS pin on the board (can be any output pin)
- *
- * Example:
- * @code
- *
- * #include "mbed.h"
- * #include "IP12B512.cpp"
- *
- * IP12B512 sram(SPI_MOSI, SPI_MISO, SPI_SCK, D6); // MOSI, MISO, SCK, CS
- *
- * int main() {
- *     // GET SRAM SIZE
- *     uint32_t ram_size = sram.GetRamSize();
- *     printf("ram_size %d\n", ram_size);
- *     
- *     // CLEAR ALL SRAM
- *     sram.ClearAll();
- *     
- *     // WRITE A SINGLE BYTE TO SRAM
- *     uint16_t ram_addr = 0;
- *     uint8_t sent_data = 0x6F;
- *     sram.Write(ram_addr, sent_data);
- *     printf("written at address %d data 0x%02X\n", ram_addr, sent_data);
- *     
- *     // READ A SINGLE BYTE FROM RAM
- *     uint8_t rec_data = sram.Read(ram_addr);
- *     printf("read at address %d data 0x%02X\n", address, rec_data);
- * }
- * @endcode
- */
+// Constructor
 IP12B512::IP12B512(
     PinName pin_mosi, 
     PinName pin_miso, 
@@ -68,7 +25,7 @@
     _cs = 1;
 }
 
-/// Write SRAM in byte mode (sends the most data to SRAM prior to write)
+// Write SRAM in byte mode (sends the most data to SRAM prior to write)
 void IP12B512::Write(uint16_t addr, uint8_t data)
 {
     _cs = 0;
@@ -79,7 +36,7 @@
     _cs = 1;
 }
 
-/// Write SRAM in stream mode (sends the least data to SRAM prior to write)
+// Write SRAM in stream mode (sends the least data to SRAM prior to write)
 void IP12B512::StreamWrite(uint16_t addr, uint8_t *data, uint32_t size)
 {
     uint8_t * p = data;
@@ -96,7 +53,7 @@
     _cs = 1;
 }
 
-/// Read SRAM in byte mode (sends the most data to SRAM prior to read)
+// Read SRAM in byte mode (sends the most data to SRAM prior to read)
 uint8_t IP12B512::Read(uint16_t addr)
 {
     uint8_t data;
@@ -111,7 +68,7 @@
     return data;
 }
 
-/// Read SRAM in stream mode (sends the least data to SRAM prior to read)
+// Read SRAM in stream mode (sends the least data to SRAM prior to read)
 void IP12B512::StreamRead(uint16_t addr, uint8_t *data, uint32_t size)
 {
     uint8_t * p = data;
@@ -128,7 +85,7 @@
     _cs = 1;
 }
 
-/// Fill SRAM with data
+// Fill SRAM with data
 void IP12B512::ClearAll()
 {
     uint32_t ram_size = GetRamSize();
@@ -145,7 +102,7 @@
     _cs = 1;
 }
 
-/// Gets the SRAM size in bytes
+// Gets the SRAM size in bytes
 uint32_t IP12B512::GetRamSize()
 {
     uint8_t data;
--- a/IP12B512.h	Fri Nov 04 08:19:09 2016 +0000
+++ b/IP12B512.h	Sun Nov 06 16:08:04 2016 +0000
@@ -10,20 +10,79 @@
 #define IP12B512_WRSR  0x01 // Write status register
 #define IP12B512_RDMI  0x0E // Read Memory Size
 
+/** IP12B512 class.
+ *  Read/write byte and read/write chunks from/to IP12B512 SPI RAM
+ * 
+ *  PDF manual @ http://www.search-pdf-manuals.com/manual/ipsilog-ip12b512-512k-spi-low-power-serial-sram-46
+ * 
+ * Notes:
+ * - the MOSI and MISO pins must have pulldown resistors (i used 5k6 resistors)
+ * - the SCLK pin has a pulldown resistor (i used 5k6 resistor)
+ * - the HOLD pin is connected directly to VCC
+ * - the CS pin has a pullup resistor (i used 5k6 resistor)
+ *
+ * Example:
+ * @code
+ *
+ * #include "mbed.h"
+ * #include "IP12B512.cpp"
+ *
+ * IP12B512 sram(SPI_MOSI, SPI_MISO, SPI_SCK, D6); // MOSI, MISO, SCK, CS
+ *
+ * int main() {
+ *     // GET SRAM SIZE
+ *     uint32_t ram_size = sram.GetRamSize();
+ *     printf("ram_size %d\n", ram_size);
+ *     
+ *     // CLEAR ALL SRAM
+ *     sram.ClearAll();
+ *     
+ *     // WRITE A SINGLE BYTE TO SRAM
+ *     uint16_t ram_addr = 0;
+ *     uint8_t sent_data = 0x6F;
+ *     sram.Write(ram_addr, sent_data);
+ *     printf("written at address %d data 0x%02X\n", ram_addr, sent_data);
+ *     
+ *     // READ A SINGLE BYTE FROM RAM
+ *     uint8_t rec_data = sram.Read(ram_addr);
+ *     printf("read at address %d data 0x%02X\n", ram_addr, rec_data);
+ * }
+ * @endcode
+ */
 class IP12B512
 {
     public:
+/** Constructor: setup the SPI and write to "Status Register" that we are going to use it in "Virtual Chip Mode"
+ * 
+ * @param pin_mosi the hardware MOSI pin on the board
+ * @param pin_miso the hardware MISO pin on the board
+ * @param pin_sclk the hardware SCLK pin on the board
+ * @param pin_cs the software CS pin on the board (can be any output pin)
+ * 
+ */
         IP12B512(
             PinName pin_mosi, 
             PinName pin_miso, 
             PinName pin_sclk, 
             PinName pin_cs
         );
+/** Write SRAM in byte mode (sends the highest amount of data to SRAM prior to write)
+ */
         void Write(uint16_t addr, uint8_t data);
+/** Write SRAM in stream mode (faster then Write method)
+ */
         void StreamWrite(uint16_t addr, uint8_t *data, uint32_t size);
+/** Read SRAM in byte mode (sends the highest amount of data to SRAM prior to read)
+ */
         uint8_t Read(uint16_t addr);
+/** Read SRAM in stream mode (faster then Read method)
+ */
         void StreamRead(uint16_t addr, uint8_t *data, uint32_t size);
+/** Fill SRAM with data
+ */
         void ClearAll();
+/** Get the SRAM size in bytes
+ */
         uint32_t GetRamSize();
 
     private: