LibDriver SYN6658
Loading...
Searching...
No Matches
driver_syn6658_basic.c
Go to the documentation of this file.
1
36
38
39static syn6658_handle_t gs_handle;
40
50{
51 uint8_t res;
52
53 /* link interface function */
68
69 /* set interface */
70 res = syn6658_set_interface(&gs_handle, interface);
71 if (res != 0)
72 {
73 syn6658_interface_debug_print("syn6658: set interface failed.\n");
74
75 return 1;
76 }
77
78 /* syn6658 init */
79 res = syn6658_init(&gs_handle);
80 if (res != 0)
81 {
82 syn6658_interface_debug_print("syn6658: init failed.\n");
83
84 return 1;
85 }
86
87 /* set default text type */
89 if (res != 0)
90 {
91 syn6658_interface_debug_print("syn6658: set text type failed.\n");
92 (void)syn6658_deinit(&gs_handle);
93
94 return 1;
95 }
96
97#if SYN6658_BASIC_SEND_CONFIG != 0
98 /* set defalut synthesis volume */
100 if (res != 0)
101 {
102 syn6658_interface_debug_print("syn6658: set synthesis volume failed.\n");
103 (void)syn6658_deinit(&gs_handle);
104
105 return 1;
106 }
107
108 /* set defalut synthesis speed */
110 if (res != 0)
111 {
112 syn6658_interface_debug_print("syn6658: set synthesis speed failed.\n");
113 (void)syn6658_deinit(&gs_handle);
114
115 return 1;
116 }
117
118 /* set defalut synthesis speaker */
120 if (res != 0)
121 {
122 syn6658_interface_debug_print("syn6658: set synthesis speaker failed.\n");
123 (void)syn6658_deinit(&gs_handle);
124
125 return 1;
126 }
127#endif
128
129 return 0;
130}
131
140uint8_t syn6658_basic_synthesis(const char *const fmt, ...)
141{
142 uint8_t res;
143 syn6658_status_t status;
144
145 /* get status */
146 res = syn6658_get_status(&gs_handle, &status);
147 if (res != 0)
148 {
149 return 1;
150 }
151
152 /* check status */
153 if (status == SYN6658_STATUS_BUSY)
154 {
155 return 1;
156 }
157
158 /* synthesis text */
159 if (syn6658_synthesis_text(&gs_handle, fmt) != 0)
160 {
161 return 1;
162 }
163
164 return 0;
165}
166
175{
176 uint8_t res;
177 syn6658_status_t status;
178
179 status = SYN6658_STATUS_BUSY;
180 while (status == SYN6658_STATUS_BUSY)
181 {
183 res = syn6658_get_status(&gs_handle, &status);
184 if (res != 0)
185 {
186 return 1;
187 }
188 }
189
190 return 0;
191}
192
201{
202 /* deinit syn6658 */
203 if (syn6658_deinit(&gs_handle) != 0)
204 {
205 return 1;
206 }
207
208 return 0;
209}
210
219{
220 /* stop */
221 if (syn6658_stop(&gs_handle) != 0)
222 {
223 return 1;
224 }
225
226 return 0;
227}
228
237{
238 /* pause */
239 if (syn6658_pause(&gs_handle) != 0)
240 {
241 return 1;
242 }
243
244 return 0;
245}
246
255{
256 /* resume */
257 if (syn6658_resume(&gs_handle) != 0)
258 {
259 return 1;
260 }
261
262 return 0;
263}
264
273{
274 /* standby */
275 if (syn6658_standby(&gs_handle) != 0)
276 {
277 return 1;
278 }
279
280 return 0;
281}
282
291{
292 /* wake up */
293 if (syn6658_wake_up(&gs_handle) != 0)
294 {
295 return 1;
296 }
297
298 return 0;
299}
300
311uint8_t syn6658_basic_save_text(uint8_t offset, char *text)
312{
313 /* save text */
314 if (syn6658_save_text(&gs_handle, offset, text) != 0)
315 {
316 return 1;
317 }
318
319 return 0;
320}
321
331uint8_t syn6658_basic_play_text(uint8_t times, syn6658_type_t type)
332{
333 /* play text */
334 if (syn6658_play_text(&gs_handle, times, type) != 0)
335 {
336 return 1;
337 }
338
339 return 0;
340}
driver syn6658 basic header file
uint8_t syn6658_init(syn6658_handle_t *handle)
initialize the chip
uint8_t syn6658_play_text(syn6658_handle_t *handle, uint8_t times, syn6658_type_t type)
play text
uint8_t syn6658_set_synthesis_speaker(syn6658_handle_t *handle, syn6658_speaker_t speaker)
set the synthesis speaker
syn6658_type_t
syn6658 type enumeration definition
uint8_t syn6658_resume(syn6658_handle_t *handle)
resume the chip
uint8_t syn6658_get_status(syn6658_handle_t *handle, syn6658_status_t *status)
get the current status
uint8_t syn6658_set_synthesis_speed(syn6658_handle_t *handle, uint8_t speed)
set the synthesis speed
uint8_t syn6658_save_text(syn6658_handle_t *handle, uint8_t offset, char *text)
save text to the buffer
uint8_t syn6658_standby(syn6658_handle_t *handle)
set the chip to standby mode
uint8_t syn6658_set_synthesis_volume(syn6658_handle_t *handle, uint8_t volume)
set the chip synthesis volume
uint8_t syn6658_deinit(syn6658_handle_t *handle)
close the chip
struct syn6658_handle_s syn6658_handle_t
syn6658 handle structure definition
uint8_t syn6658_pause(syn6658_handle_t *handle)
pause the chip
uint8_t syn6658_set_text_type(syn6658_handle_t *handle, syn6658_type_t type)
set the chip text type
uint8_t syn6658_synthesis_text(syn6658_handle_t *handle, const char *const fmt,...)
synthesis the test
syn6658_status_t
syn6658 status enumeration definition
uint8_t syn6658_set_interface(syn6658_handle_t *handle, syn6658_interface_t interface)
set the chip interface
syn6658_interface_t
syn6658 interface enumeration definition
uint8_t syn6658_wake_up(syn6658_handle_t *handle)
wake up the chip
uint8_t syn6658_stop(syn6658_handle_t *handle)
stop the chip
@ SYN6658_STATUS_BUSY
uint8_t syn6658_basic_deinit(void)
basic example deinit
uint8_t syn6658_basic_sync(void)
basic example sync
uint8_t syn6658_basic_init(syn6658_interface_t interface)
basic example init
#define SYN6658_BASIC_DEFAULT_SYNTHESIS_SPEED
#define SYN6658_BASIC_DEFAULT_TEXT_TYPE
syn6658 basic example default definition
uint8_t syn6658_basic_standby(void)
basic example standby
uint8_t syn6658_basic_synthesis(const char *const fmt,...)
basic example synthesis
#define SYN6658_BASIC_DEFAULT_SYNTHESIS_VOLUME
uint8_t syn6658_basic_stop(void)
basic example stop
uint8_t syn6658_basic_pause(void)
basic example pause
#define SYN6658_BASIC_DEFAULT_SYNTHESIS_SPEAKER
uint8_t syn6658_basic_resume(void)
basic example resume
uint8_t syn6658_basic_wake_up(void)
basic example wake up
uint8_t syn6658_basic_play_text(uint8_t times, syn6658_type_t type)
basic example play text
uint8_t syn6658_basic_save_text(uint8_t offset, char *text)
basic example save text
uint8_t syn6658_interface_gpio_ready_deinit(void)
interface gpio ready deinit
uint8_t syn6658_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len)
interface spi transmit
uint8_t syn6658_interface_gpio_ready_init(void)
interface gpio ready init
uint8_t syn6658_interface_uart_init(void)
interface uart init
uint8_t syn6658_interface_spi_init(void)
interface spi init
void syn6658_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t syn6658_interface_gpio_ready_read(uint8_t *value)
interface gpio ready read
uint8_t syn6658_interface_uart_write(uint8_t *buf, uint16_t len)
interface uart write
uint8_t syn6658_interface_uart_deinit(void)
interface uart deinit
void syn6658_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t syn6658_interface_uart_flush(void)
interface uart flush
uint8_t syn6658_interface_spi_deinit(void)
interface spi deinit
uint16_t syn6658_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read