This repository was archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI2CInstruction.h
59 lines (43 loc) · 1.83 KB
/
I2CInstruction.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
56
57
58
59
#ifndef I2CINSTRUCTION_H_
#define I2CINSTRUCTION_H_
#include <string.h>
#include <stdio.h>
#define I2C_MAX_BUFFER_SIZE 32
#define I2C_WRITE 0
#define I2C_READ 1
/* I2CInstruction_ID is the memory safe way to identify I2CInstructions */
typedef uint32_t I2CInstruction_ID;
/* Moves the I2CBuffer to the next instruction, deleting the current one
* Returns the new current instruction's id
* Sets global interrupt enable */
I2CInstruction_ID I2CBufferMoveToNextInstruction();
/* Returns the current instruction's device address */
int I2CBufferGetCurrentInstructionAddress();
/* Returns the current instruction's length */
int I2CBufferGetCurrentInstructionLength();
/* Returns the current instruction's data offset by offset */
uint8_t I2CBufferGetCurrentInstructionData(int offset);
/* Sets the current instructions data at offset with ddata */
void I2CBufferSetCurrentInstructionData(int offset, int ddata);
/* Returns whether the current instruction is read or write */
int I2CBufferGetCurrentInstructionReadWrite();
/* Returns the current instruction's id */
I2CInstruction_ID I2CBufferGetCurrentInstructionID();
/* Adds a new instruction to the end of buf, where the new instruction has the following data
* dev_addr = d_add
* readWrite = rw
* data = dat
* length = leng
* nextInstr = NULL
* Sets global interrupt enable */
I2CInstruction_ID I2CBufferAddInstruction(int8_t d_add, int8_t rw, uint8_t* dat, int8_t leng);
/* Returns the I2CBuffer's current size */
size_t I2CBufferGetCurrentSize();
/* Returns 1 (true) if buf contains instr, or 0 (false) if buf does not
* contain instr
* Sets global interrupt enable */
int I2CBufferContains(I2CInstruction_ID instr);
/* Prints out a human readable form of the I2C Buffer to ostream
* Returns -1 if fails, 0 if succeeds */
int I2CBufferPrint(FILE * ostream);
#endif /* I2CINSTRUCTION_H_ */