LibDriver SYN6988  1.0.0
SYN6988 full-featured driver
driver_syn6988.h
Go to the documentation of this file.
1 
37 #ifndef DRIVER_SYN6988_H
38 #define DRIVER_SYN6988_H
39 
40 #include <stdio.h>
41 #include <stdint.h>
42 #include <string.h>
43 
44 #ifdef __cplusplus
45 extern "C"{
46 #endif
47 
62 #ifndef SYN6988_BUSY_TIMEOUT
63  #define SYN6988_BUSY_TIMEOUT 1000
64 #endif
65 
69 #define SYN6988_SOUND_101 "sound101"
70 #define SYN6988_SOUND_102 "sound102"
71 #define SYN6988_SOUND_103 "sound103"
72 #define SYN6988_SOUND_104 "sound104"
73 #define SYN6988_SOUND_105 "sound105"
74 #define SYN6988_SOUND_106 "sound106"
75 #define SYN6988_SOUND_107 "sound107"
76 #define SYN6988_SOUND_108 "sound108"
77 #define SYN6988_SOUND_109 "sound109"
78 #define SYN6988_SOUND_110 "sound110"
79 #define SYN6988_SOUND_111 "sound111"
80 #define SYN6988_SOUND_112 "sound112"
81 #define SYN6988_SOUND_113 "sound113"
82 #define SYN6988_SOUND_114 "sound114"
83 #define SYN6988_SOUND_115 "sound115"
84 #define SYN6988_SOUND_116 "sound116"
85 #define SYN6988_SOUND_117 "sound117"
86 #define SYN6988_SOUND_118 "sound118"
87 #define SYN6988_SOUND_119 "sound119"
88 #define SYN6988_SOUND_120 "sound120"
89 #define SYN6988_SOUND_121 "sound121"
90 #define SYN6988_SOUND_122 "sound122"
91 #define SYN6988_SOUND_123 "sound123"
92 #define SYN6988_SOUND_124 "sound124"
93 #define SYN6988_SOUND_201 "sound201"
94 #define SYN6988_SOUND_202 "sound202"
95 #define SYN6988_SOUND_203 "sound203"
96 #define SYN6988_SOUND_204 "sound204"
97 #define SYN6988_SOUND_205 "sound205"
98 #define SYN6988_SOUND_206 "sound206"
99 #define SYN6988_SOUND_207 "sound207"
100 #define SYN6988_SOUND_208 "sound208"
101 #define SYN6988_SOUND_209 "sound209"
102 #define SYN6988_SOUND_301 "sound301"
103 #define SYN6988_SOUND_302 "sound302"
104 #define SYN6988_SOUND_303 "sound303"
105 #define SYN6988_SOUND_304 "sound304"
106 #define SYN6988_SOUND_305 "sound305"
107 #define SYN6988_SOUND_306 "sound306"
108 #define SYN6988_SOUND_307 "sound307"
109 #define SYN6988_SOUND_308 "sound308"
110 #define SYN6988_SOUND_309 "sound309"
111 #define SYN6988_SOUND_310 "sound310"
112 #define SYN6988_SOUND_311 "sound311"
113 #define SYN6988_SOUND_312 "sound312"
114 #define SYN6988_SOUND_313 "sound313"
115 #define SYN6988_SOUND_314 "sound314"
116 #define SYN6988_SOUND_315 "sound315"
117 #define SYN6988_SOUND_316 "sound316"
118 #define SYN6988_SOUND_317 "sound317"
119 #define SYN6988_SOUND_318 "sound318"
120 #define SYN6988_SOUND_401 "sound401"
121 #define SYN6988_SOUND_402 "sound402"
122 #define SYN6988_SOUND_403 "sound403"
123 #define SYN6988_SOUND_404 "sound404"
124 #define SYN6988_SOUND_405 "sound405"
125 #define SYN6988_SOUND_406 "sound406"
126 #define SYN6988_SOUND_407 "sound407"
127 #define SYN6988_SOUND_408 "sound408"
132 typedef enum
133 {
137 
141 typedef enum
142 {
149 
153 typedef enum
154 {
158 
162 typedef enum
163 {
168 
172 typedef struct syn6988_handle_s
173 {
174  uint8_t (*gpio_ready_init)(void);
175  uint8_t (*gpio_ready_deinit)(void);
176  uint8_t (*gpio_ready_read)(uint8_t *value);
177  uint8_t (*uart_init)(void);
178  uint8_t (*uart_deinit)(void);
179  uint16_t (*uart_read)(uint8_t *buf, uint16_t len);
180  uint8_t (*uart_flush)(void);
181  uint8_t (*uart_write)(uint8_t *buf, uint16_t len);
182  uint8_t (*spi_init)(void);
183  uint8_t (*spi_deinit)(void);
184  uint8_t (*spi_transmit)(uint8_t *tx, uint8_t *rx, uint16_t len);
185  void (*delay_ms)(uint32_t ms);
186  void (*debug_print)(const char *const fmt, ...);
187  uint8_t inited;
188  uint8_t uart_spi;
189  uint8_t type;
190  uint8_t buf[4096];
192 
196 typedef struct syn6988_info_s
197 {
198  char chip_name[32];
199  char manufacturer_name[32];
200  char interface[16];
206  uint32_t driver_version;
208 
226 #define DRIVER_SYN6988_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
227 
234 #define DRIVER_SYN6988_LINK_UART_INIT(HANDLE, FUC) (HANDLE)->uart_init = FUC
235 
242 #define DRIVER_SYN6988_LINK_UART_DEINIT(HANDLE, FUC) (HANDLE)->uart_deinit = FUC
243 
250 #define DRIVER_SYN6988_LINK_UART_READ(HANDLE, FUC) (HANDLE)->uart_read = FUC
251 
258 #define DRIVER_SYN6988_LINK_UART_WRITE(HANDLE, FUC) (HANDLE)->uart_write = FUC
259 
266 #define DRIVER_SYN6988_LINK_UART_FLUSH(HANDLE, FUC) (HANDLE)->uart_flush = FUC
267 
274 #define DRIVER_SYN6988_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
275 
282 #define DRIVER_SYN6988_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
283 
290 #define DRIVER_SYN6988_LINK_SPI_TRANSMIT(HANDLE, FUC) (HANDLE)->spi_transmit = FUC
291 
298 #define DRIVER_SYN6988_LINK_GPIO_READY_INIT(HANDLE, FUC) (HANDLE)->gpio_ready_init = FUC
299 
306 #define DRIVER_SYN6988_LINK_GPIO_READY_DEINIT(HANDLE, FUC) (HANDLE)->gpio_ready_deinit = FUC
307 
314 #define DRIVER_SYN6988_LINK_GPIO_READY_READ(HANDLE, FUC) (HANDLE)->gpio_ready_read = FUC
315 
322 #define DRIVER_SYN6988_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
323 
330 #define DRIVER_SYN6988_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
331 
351 uint8_t syn6988_info(syn6988_info_t *info);
352 
363 
373 uint8_t syn6988_get_interface(syn6988_handle_t *handle, syn6988_interface_t *interface);
374 
386 uint8_t syn6988_init(syn6988_handle_t *handle);
387 
399 uint8_t syn6988_deinit(syn6988_handle_t *handle);
400 
412 
424 
438 uint8_t syn6988_synthesis_text(syn6988_handle_t *handle, const char *const fmt, ...);
439 
451 uint8_t syn6988_get_status(syn6988_handle_t *handle, syn6988_status_t *status);
452 
464 uint8_t syn6988_stop(syn6988_handle_t *handle);
465 
477 uint8_t syn6988_pause(syn6988_handle_t *handle);
478 
490 uint8_t syn6988_resume(syn6988_handle_t *handle);
491 
503 uint8_t syn6988_standby(syn6988_handle_t *handle);
504 
516 uint8_t syn6988_wake_up(syn6988_handle_t *handle);
517 
530 uint8_t syn6988_set_synthesis_volume(syn6988_handle_t *handle, uint8_t volume);
531 
544 uint8_t syn6988_set_synthesis_speed(syn6988_handle_t *handle, uint8_t speed);
545 
558 
584 uint8_t syn6988_set_command(syn6988_handle_t *handle, uint8_t command, uint32_t timeout);
585 
603 uint8_t syn6988_set_command_with_arg(syn6988_handle_t *handle, uint8_t command, uint8_t param, char *txt, uint32_t timeout);
604 
613 #ifdef __cplusplus
614 }
615 #endif
616 
617 #endif
syn6988_type_t
syn6988 type enumeration definition
uint8_t syn6988_stop(syn6988_handle_t *handle)
stop the chip
uint8_t syn6988_get_text_type(syn6988_handle_t *handle, syn6988_type_t *type)
get the chip text type
uint8_t syn6988_synthesis_text(syn6988_handle_t *handle, const char *const fmt,...)
synthesis the test
uint8_t syn6988_init(syn6988_handle_t *handle)
initialize the chip
syn6988_status_t
syn6988 status enumeration definition
uint8_t syn6988_set_interface(syn6988_handle_t *handle, syn6988_interface_t interface)
set the chip interface
syn6988_interface_t
syn6988 interface enumeration definition
uint8_t syn6988_set_synthesis_language(syn6988_handle_t *handle, syn6988_language_t language)
set synthesis language
struct syn6988_handle_s syn6988_handle_t
syn6988 handle structure definition
uint8_t syn6988_wake_up(syn6988_handle_t *handle)
wake up the chip
uint8_t syn6988_get_interface(syn6988_handle_t *handle, syn6988_interface_t *interface)
get the chip interface
uint8_t syn6988_pause(syn6988_handle_t *handle)
pause the chip
uint8_t syn6988_info(syn6988_info_t *info)
get chip's information
uint8_t syn6988_deinit(syn6988_handle_t *handle)
close the chip
uint8_t syn6988_standby(syn6988_handle_t *handle)
set the chip to standby mode
uint8_t syn6988_get_status(syn6988_handle_t *handle, syn6988_status_t *status)
get the current status
uint8_t syn6988_set_synthesis_speed(syn6988_handle_t *handle, uint8_t speed)
set the synthesis speed
syn6988_language_t
syn6988 language enumeration definition
uint8_t syn6988_resume(syn6988_handle_t *handle)
resume the chip
uint8_t syn6988_set_synthesis_volume(syn6988_handle_t *handle, uint8_t volume)
set the chip synthesis volume
uint8_t syn6988_set_text_type(syn6988_handle_t *handle, syn6988_type_t type)
set the chip text type
struct syn6988_info_s syn6988_info_t
syn6988 information structure definition
@ SYN6988_TYPE_UNICODE_BIG
@ SYN6988_TYPE_BIG5
@ SYN6988_TYPE_GBK
@ SYN6988_TYPE_UNICODE_LITTLE
@ SYN6988_TYPE_GB2312
@ SYN6988_STATUS_BUSY
@ SYN6988_STATUS_OK
@ SYN6988_INTERFACE_SPI
@ SYN6988_INTERFACE_UART
@ SYN6988_LANGUAGE_AUTO
@ SYN6988_LANGUAGE_ENGLISH
@ SYN6988_LANGUAGE_CHINESE
uint8_t syn6988_set_command(syn6988_handle_t *handle, uint8_t command, uint32_t timeout)
send the command to the chip
uint8_t syn6988_set_command_with_arg(syn6988_handle_t *handle, uint8_t command, uint8_t param, char *txt, uint32_t timeout)
send the command with arg to the chip
syn6988 handle structure definition
uint8_t(* uart_flush)(void)
uint8_t(* uart_write)(uint8_t *buf, uint16_t len)
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* gpio_ready_read)(uint8_t *value)
uint8_t(* uart_deinit)(void)
uint8_t(* gpio_ready_init)(void)
uint8_t buf[4096]
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_transmit)(uint8_t *tx, uint8_t *rx, uint16_t len)
uint8_t(* spi_deinit)(void)
uint16_t(* uart_read)(uint8_t *buf, uint16_t len)
uint8_t(* gpio_ready_deinit)(void)
uint8_t(* uart_init)(void)
syn6988 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char interface[16]
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]