-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlc01b.h
105 lines (89 loc) · 4.26 KB
/
lc01b.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* File: lc01b.h
*/
#ifndef LC01B_H
#define LC01B_H
#ifdef __cplusplus
extern "C" {
#endif
//I2C baud rate selection values
#define I2C_BRG_100 157 //100kHz bus: FCY = 16MHz
#define I2C_BRG_400 37 //400kHz bus: FCY = 16MHz
//LC01B characteristics
#define LC01B_WRITE 0xA0 //Control byte, write mode
#define LC01B_READ 0xA1 //Control byte, read mode
#define LC01B_PAGE 8 //Eight byte page size
#define LC01B_CAP 128 //Memory capacity of 128 bytes
#define LC01B_MAX_ADR 0x7F //Max memory address
//-------------------------------------------------------
// Receives: Nothing
// Returns: Nothing
// Summary: Sets the baud rate generator and activates
// the I2C1 module
//-------------------------------------------------------
void init_I2C(uint8_t);
//-------------------------------------------------------
// Receives: Nothing
// Returns: Nothing
// Summary: Performs acknowledge polling for page writes
//-------------------------------------------------------
void ack_Poll(void);
//-------------------------------------------------------
// Receives: EEPROM memory address
// Returns: Nothing
// Summary: Sends the start bit, control byte and memory
// address byte to the EEPROM. These are common
// tasks for all writes and reads
//--------------------------------------------------------
void lc01b_SCM(uint8_t);
//--------------------------------------------------------
// Receives: Memory address and data byte to be written
// Returns: Status of bounds check
// Summary: Writes a single byte to the EEPROM at the
// desired location
//--------------------------------------------------------
ee_Errors_t lc01b_WriteByte(uint8_t,uint8_t);
//--------------------------------------------------------
// Receives: Memory address, page length and a pointer to
// the data to be written
// Returns: Status of bounds check
// Summary: Writes a page to the EEPROM. A page on the
// LC01B can be to to eight bytes in length
//---------------------------------------------------------
ee_Errors_t lc01b_WritePage(uint8_t,uint8_t,uint8_t *);
//--------------------------------------------------------
// Receives: Memory address, object length and data object
// Returns: Status of bounds check
// Summary: Used to write larger data types such as int,
// float, double etc.. to the EEPROM byte by byte
//--------------------------------------------------------
ee_Errors_t lc01b_WriteObject(uint8_t,uint8_t,void *);
//--------------------------------------------------------
// Receives: Memory address and address for data byte
// Returns: Status of bounds check
// Summary: Random access read of a single byte
//--------------------------------------------------------
ee_Errors_t lc01b_ReadByte(uint8_t,uint8_t *);
//--------------------------------------------------------
// Receives: Memory address, read length and pointer to a
// buffer to write the output into
// Returns: Status of bounds check
// Summary: Sequentially reads the requested number of
// bytes from the EEPROM, beginning at the
// specified address. Output is stored in the
// buffer provided by the client
//--------------------------------------------------------
ee_Errors_t lc01b_ReadSeq(uint8_t,uint8_t,uint8_t *);
//--------------------------------------------------------
// Receives: Memory address, data length and a pointer to
// a data object to write the output into
// Returns: Status of bounds check
// Summary: Reads the specified number of bytes from the
// EEPROM and writes the output to the data
// object provided by the client
//--------------------------------------------------------
ee_Errors_t lc01b_ReadObject(uint8_t,uint8_t,void *);
#ifdef __cplusplus
}
#endif
#endif /* LC01B_H */