Phoenard
PHNSRAM.h
Go to the documentation of this file.
1 /*
2 The MIT License (MIT)
3 
4 This file is part of the Phoenard Arduino library
5 Copyright (c) 2014 Phoenard
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 */
25 
30 #ifndef _PHN_SRAM_H_
31 #define _PHN_SRAM_H_
32 
33 #include <Arduino.h>
34 #include "PHNCore.h"
35 
44 class PHN_SRAM {
45  public:
47  uint8_t begin();
48 
50  void readBlock(uint16_t address, char* data, uint16_t length);
52  void readSegment(uint16_t index, void* ptr, uint16_t segmentSize);
54  void writeBlock(uint16_t address, const char* data, uint16_t length);
56  void writeSegment(uint16_t index, const void* ptr, uint16_t segmentSize);
58  char read(uint16_t address);
60  void write(uint16_t address, char dataByte);
61 
63  uint8_t writeBlockVerify(uint16_t address, const char* data, uint16_t length);
64 
66  uint8_t verifyBlock(uint16_t address, const char* data, uint16_t length);
67 
68  private:
70  void setAddress(uint8_t mode, uint16_t address);
71 };
72 
74 extern PHN_SRAM sram;
75 
76 #endif
char read(uint16_t address)
Reads the byte of data stored at an address specified.
Definition: PHNSRAM.cpp:136
void readBlock(uint16_t address, char *data, uint16_t length)
Reads a block of data.
Definition: PHNSRAM.cpp:81
PHN_SRAM sram
Global variable from which the SRAM functions can be accessed.
Definition: PHNSRAM.cpp:29
void readSegment(uint16_t index, void *ptr, uint16_t segmentSize)
Reads a segment block of data; useful for reading structures.
Definition: PHNSRAM.cpp:107
Simplistic library for accessing the 32 Kilobyte 23K256 SRAM chip.
Definition: PHNSRAM.h:44
void write(uint16_t address, char dataByte)
Writes a byte of data at an address specified.
Definition: PHNSRAM.cpp:142
uint8_t begin()
Initializes SPI and sets the chip up for first use.
Definition: PHNSRAM.cpp:47
Pinout information for the Phoenard hardware components.
uint8_t verifyBlock(uint16_t address, const char *data, uint16_t length)
Reads in a block of data and verifies the contents.
Definition: PHNSRAM.cpp:120
void writeBlock(uint16_t address, const char *data, uint16_t length)
Writes a block of data.
Definition: PHNSRAM.cpp:95
void writeSegment(uint16_t index, const void *ptr, uint16_t segmentSize)
Writes a segment block of data; useful for storing structures.
Definition: PHNSRAM.cpp:111
uint8_t writeBlockVerify(uint16_t address, const char *data, uint16_t length)
Writes a block of data and then verifies the contents by reading.
Definition: PHNSRAM.cpp:115