Microchip SPI SRAM (23LC1024, 23LC512) access library.
Diff: 23LCxx_SPI.h
- Revision:
- 1:56e01e806364
- Parent:
- 0:625ac56d810e
- Child:
- 2:52d3272b886c
--- a/23LCxx_SPI.h Thu Nov 26 16:24:04 2015 +0000 +++ b/23LCxx_SPI.h Fri Nov 27 03:46:10 2015 +0000 @@ -3,9 +3,9 @@ #include <mbed.h> -/** - * Microchip SPI SRAM access library for 23LC1024, 23K256 +/** Microchip SPI SRAM access library for 23LC1024, 23LC512 * + * Example: * @code * #include <mbed.h> * #include "23LCxx_SPI.h" @@ -36,7 +36,19 @@ */ class Microchip23LCxx { public: - enum Microchip23LC1024Mode { + /** SPI COMMAND for Microchip 23LC1024, 23LC512 */ + enum Microchip23LCxxCommnd { + READ = 0x03u, + WRITE = 0x02u, + EDIO = 0x3bu, + EQIO = 0x38u, + RSTIO = 0xffu, + RDMR = 0x05u, + WRMR = 0x01u, + }; + + /** Access mode for Microchip 23LC1024, 23LC512 */ + enum Microchip23LCxxMode { MODE_MASK = 0xc0u, BYTE = 0x00u, SEQUENTIAL = 0x40u, // default operation @@ -44,53 +56,58 @@ RESERVED = 0xc0u, }; - /** - * Constructor. + /** Constructor. + * + * @param[in] mosi SPI MOSI pin name + * @param[in] miso SPI MISO pin name + * @param[in] sck SPI SCK pin name + * @param[in] cs SPI CS pin name + * @param[in] hz SPI Frequency */ - Microchip23LCxx(PinName mosi, PinName miso, PinName sck, PinName cs, uint32_t hz); + Microchip23LCxx(const PinName mosi, const PinName miso, const PinName sck, const PinName cs, const uint32_t hz); - /** - * read from mode register. + /** read from mode register. + * * @return register value */ uint8_t read_mode_register(); - /** - * write to mode register. + /** write to mode register. + * * @param[in] mode */ void write_mode_register(const uint8_t value); - /** - * change mode bits. + /** change mode bits. + * * @param[in] mode mode * @return mode before change * @invariant other bits in register. */ uint8_t change_mode(const uint8_t next_mode); - /** - * 1byte read + /** 1byte read + * * @param[in] address adress in 24bit * @return read data */ uint8_t read_byte(const uint32_t address); - /** - * 1byte write + /** 1byte write + * * @param[in] address address in 24bit * @param[in] write data */ void write_byte(const uint32_t address, const uint8_t data); - /** - * multi-byte read + /** multi-byte read + * * @pre sequential mode or page mode is required. */ void read_bytes(const uint32_t address, uint8_t __restrict data[], const uint32_t size); - /** - * multi-byte write + /** multi-byte write + * * @pre sequential mode or page mode is required. */ void write_bytes(const uint32_t address, const uint8_t __restrict data[], const uint32_t size);