at24cm0x 1.0
at24cm0x driver library
Loading...
Searching...
No Matches
at24cm0x.h
Go to the documentation of this file.
1
18
19#ifndef AT24CM0X_H_
20#define AT24CM0X_H_
21
22 #ifndef AT24CM0X_HAL_PLATFORM
32 #define AT24CM0X_HAL_PLATFORM avr0
33 #endif
34
35 #ifndef AT24CM0X_MEMORY_SIZE
44 #define AT24CM0X_MEMORY_SIZE 262144UL
45 #endif
46
47 #ifndef AT24CM0X_PAGES
56 #define AT24CM0X_PAGES 1024UL
57 #endif
58
59 #ifndef AT24CM0X_PAGE_SIZE
68 #define AT24CM0X_PAGE_SIZE 256UL
69 #endif
70
71 #ifndef AT24CM0X_ENABLE_INTEGRITY_CHECK
80 //#define AT24CM0X_ENABLE_INTEGRITY_CHECK
81
82 #ifdef _DOXYGEN_ // Used for documentation, can be ignored
83 #define AT24CM0X_ENABLE_INTEGRITY_CHECK
84 #endif
85 #endif
86
87 #ifndef AT24CM0X_WRITE_ACKNOWLEDGE_POLLING
96 //#define AT24CM0X_WRITE_ACKNOWLEDGE_POLLING
97
98 #ifdef _DOXYGEN_ // Used for documentation, can be ignored
99 #define AT24CM0X_WRITE_ACKNOWLEDGE_POLLING
100 #endif
101 #endif
102
111 #ifndef AT24CM0X_BASE_ADDRESS
112 #define AT24CM0X_BASE_ADDRESS 0x50
113
122 #ifndef AT24CM0X_ADDRESS_MASK
123 #if AT24CM0X_MEMORY_SIZE < 262144UL
124 #define AT24CM0X_ADDRESS_MASK 0x06
125 #else
126 #define AT24CM0X_ADDRESS_MASK 0x04
127 #endif
128 #endif
129
139 #ifndef AT24CM0X_ADDRESS_HIGH_MASK
140 #if AT24CM0X_MEMORY_SIZE < 262144UL
141 #define AT24CM0X_ADDRESS_HIGH_MASK 0x01
142 #else
143 #define AT24CM0X_ADDRESS_HIGH_MASK 0x03
144 #endif
145 #endif
146 #endif
147
148 #ifndef AT24CM0X_MULTI_DEVICES
156 //#define AT24CM0X_MULTI_DEVICES
157
158 #ifdef _DOXYGEN_ // Used for documentation, can be ignored
159 #define AT24CM0X_MULTI_DEVICES
160 #endif
161 #endif
162
163 #ifndef AT24CM0X_MULTI_DEVICES
172 #ifndef AT24CM0X_ADDRESS_A2
173 #define AT24CM0X_ADDRESS_A2 1
174 #endif
175
176 #ifndef AT24CM0X_ADDRESS
177
186 #if AT24CM0X_MEMORY_SIZE < 262144UL
187 #ifndef AT24CM0X_ADDRESS_A1
188 #define AT24CM0X_ADDRESS_A1 1
189 #endif
190
199 #define AT24CM0X_ADDRESS (AT24CM0X_BASE_ADDRESS | (AT24CM0X_ADDRESS_A2<<2) | (AT24CM0X_ADDRESS_A1<<1))
200 #else
209 #define AT24CM0X_ADDRESS (AT24CM0X_BASE_ADDRESS | (AT24CM0X_ADDRESS_A2<<2))
210 #endif
211
212 #endif
213 #endif
214
215 #ifndef AT24CM0X_WP_CONTROL_EN
224 //#define AT24CM0X_WP_CONTROL_EN
225
226 #ifdef _DOXYGEN_ // Used for documentation, can be ignored
227 #define AT24CM0X_WP_CONTROL_EN
228 #endif
229 #endif
230
231 #ifndef AT24CM0X_WRITE_CYCLE_MS
240 #define AT24CM0X_WRITE_CYCLE_MS 10UL
241 #endif
242
244
245 #include _STR(../../../hal/AT24CM0X_HAL_PLATFORM/twi/twi.h)
246
248
249 #ifdef AT24CM0X_WP_CONTROL_EN
262
267 #endif
268
286
291
292 void at24cm0x_init(void);
293
294 #ifdef AT24CM0X_MULTI_DEVICES
295 void at24cm0x_device(unsigned char identifier);
296 #endif
297
298 #ifdef AT24CM0X_WP_CONTROL_EN
300 #endif
301
302 AT24CM0X_Status at24cm0x_write_byte(unsigned long address, unsigned char data);
303 AT24CM0X_Status at24cm0x_write_page(unsigned int page, unsigned char *data, unsigned int size);
304 AT24CM0X_Status at24cm0x_read_current_byte(unsigned char *data);
305 AT24CM0X_Status at24cm0x_read_byte(unsigned long address, unsigned char *data);
306 AT24CM0X_Status at24cm0x_read_sequential(unsigned long address, unsigned char *data, unsigned int size);
307
308#endif /* AT24CM0X_H_ */
enum AT24CM0X_WP_Mode_t AT24CM0X_WP_Mode
Alias for enum AT24CM0X_WP_Mode_t representing WP control modes.
Definition at24cm0x.h:266
AT24CM0X_Status at24cm0x_read_sequential(unsigned long address, unsigned char *data, unsigned int size)
Reads a sequence of bytes from the AT24CM0X EEPROM.
Definition at24cm0x.c:322
AT24CM0X_Status_t
Status codes returned by AT24CM0X driver operations.
Definition at24cm0x.h:277
@ AT24CM0X_Status_Data_Error
Definition at24cm0x.h:282
@ AT24CM0X_Status_Page_Error
Definition at24cm0x.h:280
@ AT24CM0X_Status_General_Error
Definition at24cm0x.h:284
@ AT24CM0X_Status_TWI_Error
Definition at24cm0x.h:283
@ AT24CM0X_Status_Address_Error
Definition at24cm0x.h:279
@ AT24CM0X_Status_Done
Definition at24cm0x.h:278
@ AT24CM0X_Status_Size_Error
Definition at24cm0x.h:281
AT24CM0X_Status at24cm0x_write_page(unsigned int page, unsigned char *data, unsigned int size)
Writes a sequence of bytes to a single EEPROM page.
Definition at24cm0x.c:172
void at24cm0x_init(void)
Initializes the AT24CM0X EEPROM driver.
Definition at24cm0x.c:32
AT24CM0X_Status at24cm0x_write_byte(unsigned long address, unsigned char data)
Writes a single byte to the AT24CM0X EEPROM.
Definition at24cm0x.c:104
enum AT24CM0X_Status_t AT24CM0X_Status
Alias for enum AT24CM0X_Status_t representing driver status codes.
Definition at24cm0x.h:290
void at24cm0x_wp(AT24CM0X_WP_Mode mode)
AT24CM0X_Status at24cm0x_read_current_byte(unsigned char *data)
Reads the current byte from the AT24CM0X EEPROM.
Definition at24cm0x.c:248
AT24CM0X_Status at24cm0x_read_byte(unsigned long address, unsigned char *data)
Reads a single byte from the AT24CM0X EEPROM.
Definition at24cm0x.c:280
AT24CM0X_WP_Mode_t
Specifies the write-protect mode for the AT24CM0X device.
Definition at24cm0x.h:258
@ AT24CM0X_WP_Mode_Enabled
Definition at24cm0x.h:259
@ AT24CM0X_WP_Mode_Disabled
Definition at24cm0x.h:260
void at24cm0x_device(unsigned char identifier)
Selects the active AT24CM0X device.
Definition at24cm0x.c:54
Helper macros for stringification in C preprocessor.
Header file with declarations and macros for systick utility.