-
Notifications
You must be signed in to change notification settings - Fork 5
/
SRAMsimple.h
55 lines (49 loc) · 2.48 KB
/
SRAMsimple.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SRAMsimple.h - Library for reading and writing data from an Arduino Uno to a 23LC1024 chip.
* Original sketch created by J. B. Gallaher on 07/09/2016.
* Library created by David Dubins, November 12th, 2018.
* Released into the public domain.
*/
#ifndef SRAMsimple_h
#define SRAMsimple_h
#include <Arduino.h>
#include <SPI.h>
/************SRAM opcodes: commands to the 23LC1024 memory chip ******************/
#define RDMR 5 // Read the Mode Register
#define WRMR 1 // Write to the Mode Register
#define READ 3 // Read command
#define WRITE 2 // Write command
#define RSTIO 0xFF // Reset memory to SPI mode
#define ByteMode 0x00 // Byte mode (read/write one byte at a time)
#define Sequential 0x40 // Sequential mode (read/write blocks of memory)
extern byte CS; // Global variable for CS pin (default 10)
class SRAMsimple {
public:
SRAMsimple();
~SRAMsimple();
void SetMode(byte CSpin, char Mode);
void WriteByte(uint32_t address, byte data_byte);
byte ReadByte(uint32_t address);
void WriteByteArray(uint32_t address, byte *data, uint16_t big);
void ReadByteArray(uint32_t address, byte *data, uint16_t big);
void WriteInt(uint32_t address, int data);
int ReadInt(uint32_t address);
void WriteIntArray(uint32_t address, int *data, uint16_t big);
void ReadIntArray(uint32_t address, int *data, uint16_t big);
void WriteUnsignedInt(uint32_t address, unsigned int data);
unsigned int ReadUnsignedInt(uint32_t address);
void WriteUnsignedIntArray(uint32_t address, unsigned int *data, uint16_t big);
void ReadUnsignedIntArray(uint32_t address, unsigned int *data, uint16_t big);
void WriteLong(uint32_t address, long data);
long ReadLong(uint32_t address);
void WriteLongArray(uint32_t address, long *data, uint16_t big);
void ReadLongArray(uint32_t address, long *data, uint16_t big);
void WriteUnsignedLong(uint32_t address, unsigned long data);
unsigned long ReadUnsignedLong(uint32_t address);
void WriteUnsignedLongArray(uint32_t address, unsigned long *data, uint16_t big);
void ReadUnsignedLongArray(uint32_t address, unsigned long *data, uint16_t big);
void WriteFloat(uint32_t address, float data);
float ReadFloat(uint32_t address);
void WriteFloatArray(uint32_t address, float *data, uint16_t big);
void ReadFloatArray(uint32_t address, float *data, uint16_t big);
};
#endif