Cypress F-RAM FM25W256 library
Dependents: Hello-FM25W256 Hello-FM25W256
Diff: FM25W256.h
- Revision:
- 2:4939ff09bf12
- Parent:
- 1:bb2b1e4bfb6e
- Child:
- 3:aa1c1f07c942
diff -r bb2b1e4bfb6e -r 4939ff09bf12 FM25W256.h
--- a/FM25W256.h Sat Mar 05 14:05:39 2016 +0000
+++ b/FM25W256.h Sat Mar 05 14:12:08 2016 +0000
@@ -38,38 +38,38 @@
#define FM25W256_CLK (20000000) // SPI clock 20MHz
/** An interface for the Cypress 32k byte FM25W256 F-RAM over SPI
-
-@code
-#include "mbed.h"
-#include "FM25W256.h"
-
-Serial pc(USBTX, USBRX);
-FM25W256 f_ram(dp2, dp1, dp6, dp18);
-
-int main()
-{
- uint8_t buf[16];
- // Fill buffer
- for(int i=0; i<16; i++) {
- buf[i] = i;
- }
- // Write data to F-RAM
- f_ram.write(0, buf, 16);
-
- // Read data from F-RAM
- uint16_t adrs = 0;
- for(int i=0; i<16; i++) {
- pc.printf("0x%04X : ", i * 16);
- for(int j=0; j<16; j++) {
- pc.printf("%02X ", f_ram.read(adrs++));
- }
- pc.printf("\n");
- }
-
- while(1) {
- }
-}
-*/
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "FM25W256.h"
+ *
+ * Serial pc(USBTX, USBRX);
+ * FM25W256 f_ram(dp2, dp1, dp6, dp18);
+ *
+ * int main()
+ * {
+ * uint8_t buf[16];
+ * // Fill buffer
+ * for(int i=0; i<16; i++) {
+ * buf[i] = i;
+ * }
+ * // Write data to F-RAM
+ * f_ram.write(0, buf, 16);
+ *
+ * // Read data from F-RAM
+ * uint16_t adrs = 0;
+ * for(int i=0; i<16; i++) {
+ * pc.printf("0x%04X : ", i * 16);
+ * for(int j=0; j<16; j++) {
+ * pc.printf("%02X ", f_ram.read(adrs++));
+ * }
+ * pc.printf("\n");
+ * }
+ *
+ * while(1) {
+ * }
+ * }
+ */
class FM25W256 {
public:
@@ -81,64 +81,64 @@
};
/** Create an interface
-*
-* @param mosi SPI master-out-slave-in
-* @param miso SPI master-in-slave-out
-* @param clk SPI clock
-* @param cs chip select pin - any free Digital pin will do
-*/
+ *
+ * @param mosi SPI master-out-slave-in
+ * @param miso SPI master-in-slave-out
+ * @param clk SPI clock
+ * @param cs chip select pin - any free Digital pin will do
+ */
FM25W256(PinName mosi, PinName miso, PinName clk, PinName cs);
/** Create an interface
-*
-* @param &spi SPI instance
-* @param cs chip select pin - any free Digital pin will do
-*/
+ *
+ * @param &spi SPI instance
+ * @param cs chip select pin - any free Digital pin will do
+ */
FM25W256(SPI &spi, PinName cs);
/** write a byte to F-RAM
-* @param address The address F-RAM to write to
-* @param data The byte to write there
-*/
+ * @param address The address F-RAM to write to
+ * @param data The byte to write there
+ */
void write(uint16_t address, uint8_t data);
/** write multiple bytes to F-RAM from a buffer
-* @param address The F-RAM address write to
-* @param data The buffer to write from
-* @param size The number of bytes to write
-*/
+ * @param address The F-RAM address write to
+ * @param data The buffer to write from
+ * @param size The number of bytes to write
+ */
void write(uint16_t address, uint8_t *data, uint16_t size);
/** read a byte from F-RAM
-* @param address The address to read from
-* @return the character at that address
-*/
+ * @param address The address to read from
+ * @return the character at that address
+ */
uint8_t read(uint16_t address);
/** read multiple bytes from F-RAM into a buffer
-* @param address The F-RAM address to read from
-* @param data The buffer to read into (must be big enough!)
-* @param size The number of bytes to read
-*/
+ * @param address The F-RAM address to read from
+ * @param data The buffer to read into (must be big enough!)
+ * @param size The number of bytes to read
+ */
void read(uint16_t address, uint8_t *data, uint16_t size);
/** write a byte to the status register
-* @param data The byte to write the register
-*/
+ * @param data The byte to write the register
+ */
void wirte_status(uint8_t data);
/** read a byte from the status register
-* @return the character at the register
-*/
+ * @return the character at the register
+ */
uint8_t read_status();
/** Set write protect mode
-* @param bp E_WP enum value
-*/
+ * @param bp E_WP enum value
+ */
void set_write_protect(E_WP bp);
/** Set write protect to non-protect mode
-*/
+ */
void clear_write_protect();
protected:
Toyomasa Watarai
Cypress FM25W256 256Kb Wide Voltage SPI F-RAM