LibDriver GT24CXX
Loading...
Searching...
No Matches
driver_gt24cxx.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_GT24CXX_H
38#define DRIVER_GT24CXX_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
64 GT24C02 = 256,
65 GT24C04 = 512,
66 GT24C08 = 1024,
67 GT24C16 = 2048,
68 GT24C32 = 4096,
69 GT24C64 = 8192,
70 GT24C128 = 16384,
71 GT24C256 = 32768,
72 GT24C512 = 65536,
73 GT24C1024 = 131072,
74 GT24C2048 = 262144,
75} gt24cxx_t;
76
91
95typedef struct gt24cxx_handle_s
96{
97 uint8_t iic_addr;
98 uint8_t (*iic_init)(void);
99 uint8_t (*iic_deinit)(void);
100 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
101 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
102 uint8_t (*iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
103 uint8_t (*iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
104 void (*delay_ms)(uint32_t ms);
105 void (*debug_print)(const char *const fmt, ...);
106 uint32_t id;
107 uint8_t inited;
109
125
129
136
143#define DRIVER_GT24CXX_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
144
151#define DRIVER_GT24CXX_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
152
159#define DRIVER_GT24CXX_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
160
167#define DRIVER_GT24CXX_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
168
175#define DRIVER_GT24CXX_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
176
183#define DRIVER_GT24CXX_LINK_IIC_READ_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_read_address16 = FUC
184
191#define DRIVER_GT24CXX_LINK_IIC_WRITE_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_write_address16 = FUC
192
199#define DRIVER_GT24CXX_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
200
207#define DRIVER_GT24CXX_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
208
212
219
228uint8_t gt24cxx_info(gt24cxx_info_t *info);
229
240uint8_t gt24cxx_init(gt24cxx_handle_t *handle);
241
252uint8_t gt24cxx_deinit(gt24cxx_handle_t *handle);
253
263uint8_t gt24cxx_set_type(gt24cxx_handle_t *handle, gt24cxx_t type);
264
274uint8_t gt24cxx_get_type(gt24cxx_handle_t *handle, gt24cxx_t *type);
275
286
297
312uint8_t gt24cxx_read(gt24cxx_handle_t *handle, uint32_t address, uint8_t *buf, uint16_t len);
313
328uint8_t gt24cxx_write(gt24cxx_handle_t *handle, uint32_t address, uint8_t *buf, uint16_t len);
329
333
337
338#ifdef __cplusplus
339}
340#endif
341
342#endif
uint8_t gt24cxx_init(gt24cxx_handle_t *handle)
initialize the chip
uint8_t gt24cxx_deinit(gt24cxx_handle_t *handle)
close the chip
uint8_t gt24cxx_info(gt24cxx_info_t *info)
get chip's information
uint8_t gt24cxx_set_addr_pin(gt24cxx_handle_t *handle, gt24cxx_address_t addr_pin)
set the chip address pin
uint8_t gt24cxx_set_type(gt24cxx_handle_t *handle, gt24cxx_t type)
set the chip type
uint8_t gt24cxx_write(gt24cxx_handle_t *handle, uint32_t address, uint8_t *buf, uint16_t len)
write bytes to the chip
uint8_t gt24cxx_read(gt24cxx_handle_t *handle, uint32_t address, uint8_t *buf, uint16_t len)
read bytes from the chip
uint8_t gt24cxx_get_type(gt24cxx_handle_t *handle, gt24cxx_t *type)
get the chip type
struct gt24cxx_handle_s gt24cxx_handle_t
gt24cxx handle structure definition
gt24cxx_t
gt24cxx type enumeration definition
uint8_t gt24cxx_get_addr_pin(gt24cxx_handle_t *handle, gt24cxx_address_t *addr_pin)
get the chip address pin
struct gt24cxx_info_s gt24cxx_info_t
gt24cxx information structure definition
gt24cxx_address_t
gt24cxx address enumeration definition
@ GT24C08
@ GT24C1024
@ GT24C04
@ GT24C16
@ GT24C02
@ GT24C256
@ GT24C32
@ GT24C512
@ GT24C2048
@ GT24C64
@ GT24C128
@ GT24CXX_ADDRESS_A110
@ GT24CXX_ADDRESS_A111
@ GT24CXX_ADDRESS_A100
@ GT24CXX_ADDRESS_A101
@ GT24CXX_ADDRESS_A001
@ GT24CXX_ADDRESS_A011
@ GT24CXX_ADDRESS_A000
@ GT24CXX_ADDRESS_A010
gt24cxx handle structure definition
void(* delay_ms)(uint32_t ms)
uint8_t(* iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
gt24cxx information structure definition
uint32_t driver_version
char manufacturer_name[32]