LibDriver TTP229
Loading...
Searching...
No Matches
driver_ttp229_basic.c
Go to the documentation of this file.
1
36
37#include "driver_ttp229_basic.h"
38
39static ttp229_handle_t gs_handle;
40
51{
52 uint8_t res;
53
54 /* link interface function */
64
65 /* set interface */
66 res = ttp229_set_interface(&gs_handle, interface);
67 if (res != 0)
68 {
69 ttp229_interface_debug_print("ttp229: set interface failed.\n");
70
71 return 1;
72 }
73
74 /* ttp229 init */
75 res = ttp229_init(&gs_handle);
76 if (res != 0)
77 {
78 ttp229_interface_debug_print("ttp229: init failed.\n");
79
80 return 1;
81 }
82
83 /* set active */
84 res = ttp229_set_active(&gs_handle, active_level);
85 if (res != 0)
86 {
87 ttp229_interface_debug_print("ttp229: set active failed.\n");
88 (void)ttp229_deinit(&gs_handle);
89
90 return 1;
91 }
92
93 return 0;
94}
95
104uint8_t ttp229_basic_read_16_keys(uint8_t keys[16])
105{
106 /* read keys */
107 if (ttp229_read_16_keys(&gs_handle, keys) != 0)
108 {
109 return 1;
110 }
111
112 return 0;
113}
114
123uint8_t ttp229_basic_read_8_keys(uint8_t keys[8])
124{
125 /* read keys */
126 if (ttp229_read_8_keys(&gs_handle, keys) != 0)
127 {
128 return 1;
129 }
130
131 return 0;
132}
133
142{
143 /* close ttp229 */
144 if (ttp229_deinit(&gs_handle) != 0)
145 {
146 return 1;
147 }
148
149 return 0;
150}
driver ttp229 basic header file
ttp229_active_t
ttp229 active enumeration definition
uint8_t ttp229_init(ttp229_handle_t *handle)
initialize the chip
ttp229_interface_t
ttp229 interface enumeration definition
uint8_t ttp229_set_active(ttp229_handle_t *handle, ttp229_active_t active_level)
set the active level
uint8_t ttp229_deinit(ttp229_handle_t *handle)
close the chip
uint8_t ttp229_read_8_keys(ttp229_handle_t *handle, uint8_t keys[8])
read 8 keys
uint8_t ttp229_read_16_keys(ttp229_handle_t *handle, uint8_t keys[16])
read 16 keys
uint8_t ttp229_set_interface(ttp229_handle_t *handle, ttp229_interface_t interface)
set the interface
struct ttp229_handle_s ttp229_handle_t
ttp229 handle structure definition
uint8_t ttp229_basic_read_8_keys(uint8_t keys[8])
basic example read 8 keys
uint8_t ttp229_basic_read_16_keys(uint8_t keys[16])
basic example read 16 keys
uint8_t ttp229_basic_deinit(void)
basic example deinit
uint8_t ttp229_basic_init(ttp229_interface_t interface, ttp229_active_t active_level)
basic example init
uint8_t ttp229_interface_spi_init(void)
interface spi bus init
uint8_t ttp229_interface_spi_read_cmd(uint8_t *buf, uint16_t len)
interface spi bus read command
uint8_t ttp229_interface_iic_init(void)
interface iic bus init
void ttp229_interface_debug_print(const char *const fmt,...)
interface print format data
void ttp229_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t ttp229_interface_iic_deinit(void)
interface iic bus deinit
uint8_t ttp229_interface_iic_read_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus read command
uint8_t ttp229_interface_spi_deinit(void)
interface spi bus deinit