LibDriver GT24CXX
Loading...
Searching...
No Matches
driver_gt24cxx_basic.c
Go to the documentation of this file.
1
36
38
39static gt24cxx_handle_t gs_handle;
40
51{
52 uint8_t res;
53
54 /* link interface function */
64
65 /* set chip type */
66 res = gt24cxx_set_type(&gs_handle, type);
67 if (res != 0)
68 {
69 gt24cxx_interface_debug_print("gt24cxx: set type failed.\n");
70
71 return 1;
72 }
73
74 /* set addr pin */
75 res = gt24cxx_set_addr_pin(&gs_handle, address);
76 if (res != 0)
77 {
78 gt24cxx_interface_debug_print("gt24cxx: set address pin failed.\n");
79
80 return 1;
81 }
82
83 /* gt24cxx init */
84 res = gt24cxx_init(&gs_handle);
85 if (res != 0)
86 {
87 gt24cxx_interface_debug_print("gt24cxx: init failed.\n");
88
89 return 1;
90 }
91
92 return 0;
93}
94
105uint8_t gt24cxx_basic_read(uint32_t address, uint8_t *buf, uint16_t len)
106{
107 /* read data */
108 if (gt24cxx_read(&gs_handle, address, buf, len) != 0)
109 {
110 return 1;
111 }
112
113 return 0;
114}
115
126uint8_t gt24cxx_basic_write(uint32_t address, uint8_t *buf, uint16_t len)
127{
128 /* write data */
129 if (gt24cxx_write(&gs_handle, address, buf, len) != 0)
130 {
131 return 1;
132 }
133
134 return 0;
135}
136
145{
146 /* gt24cxx deinit */
147 if (gt24cxx_deinit(&gs_handle) != 0)
148 {
149 return 1;
150 }
151
152 return 0;
153}
driver gt24cxx basic header file
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_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
struct gt24cxx_handle_s gt24cxx_handle_t
gt24cxx handle structure definition
gt24cxx_t
gt24cxx type enumeration definition
gt24cxx_address_t
gt24cxx address enumeration definition
uint8_t gt24cxx_basic_deinit(void)
basic example deinit
uint8_t gt24cxx_basic_init(gt24cxx_t type, gt24cxx_address_t address)
basic example init
uint8_t gt24cxx_basic_read(uint32_t address, uint8_t *buf, uint16_t len)
basic example read
uint8_t gt24cxx_basic_write(uint32_t address, uint8_t *buf, uint16_t len)
basic example write
void gt24cxx_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t gt24cxx_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t gt24cxx_interface_iic_write_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
interface iic bus write with 16 bits register address
uint8_t gt24cxx_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
void gt24cxx_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t gt24cxx_interface_iic_deinit(void)
interface iic bus deinit
uint8_t gt24cxx_interface_iic_read_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
interface iic bus read with 16 bits register address
uint8_t gt24cxx_interface_iic_init(void)
interface iic bus init