LibDriver SYN6988  1.0.0
SYN6988 full-featured driver
driver_syn6988_basic.c
Go to the documentation of this file.
1 
37 #include "driver_syn6988_basic.h"
38 
39 static syn6988_handle_t gs_handle;
50 {
51  uint8_t res;
52 
53  /* link interface function */
68 
69  /* set interface */
70  res = syn6988_set_interface(&gs_handle, interface);
71  if (res != 0)
72  {
73  syn6988_interface_debug_print("syn6988: set interface failed.\n");
74 
75  return 1;
76  }
77 
78  /* syn6988 init */
79  res = syn6988_init(&gs_handle);
80  if (res != 0)
81  {
82  syn6988_interface_debug_print("syn6988: init failed.\n");
83 
84  return 1;
85  }
86 
87  /* set default text type */
89  if (res != 0)
90  {
91  syn6988_interface_debug_print("syn6988: set text type failed.\n");
92  (void)syn6988_deinit(&gs_handle);
93 
94  return 1;
95  }
96 
97 #if SYN6988_BASIC_SEND_CONFIG != 0
98  /* set defalut synthesis volume */
100  if (res != 0)
101  {
102  syn6988_interface_debug_print("syn6988: set synthesis volume failed.\n");
103  (void)syn6988_deinit(&gs_handle);
104 
105  return 1;
106  }
107 
108  /* set defalut synthesis speed */
110  if (res != 0)
111  {
112  syn6988_interface_debug_print("syn6988: set synthesis speed failed.\n");
113  (void)syn6988_deinit(&gs_handle);
114 
115  return 1;
116  }
117 
118  /* set defalut synthesis language */
120  if (res != 0)
121  {
122  syn6988_interface_debug_print("syn6988: set synthesis language failed.\n");
123  (void)syn6988_deinit(&gs_handle);
124 
125  return 1;
126  }
127 #endif
128 
129  return 0;
130 }
131 
140 uint8_t syn6988_basic_synthesis(const char *const fmt, ...)
141 {
142  uint8_t res;
143  syn6988_status_t status;
144 
145  /* get status */
146  res = syn6988_get_status(&gs_handle, &status);
147  if (res != 0)
148  {
149  return 1;
150  }
151 
152  /* check status */
153  if (status == SYN6988_STATUS_BUSY)
154  {
155  return 1;
156  }
157 
158  /* synthesis text */
159  if (syn6988_synthesis_text(&gs_handle, fmt) != 0)
160  {
161  return 1;
162  }
163 
164  return 0;
165 }
166 
174 uint8_t syn6988_basic_sync(void)
175 {
176  uint8_t res;
177  syn6988_status_t status;
178 
179  status = SYN6988_STATUS_BUSY;
180  while (status == SYN6988_STATUS_BUSY)
181  {
183  res = syn6988_get_status(&gs_handle, &status);
184  if (res != 0)
185  {
186  return 1;
187  }
188  }
189 
190  return 0;
191 }
192 
200 uint8_t syn6988_basic_deinit(void)
201 {
202  /* deinit syn6988 */
203  if (syn6988_deinit(&gs_handle) != 0)
204  {
205  return 1;
206  }
207 
208  return 0;
209 }
210 
218 uint8_t syn6988_basic_stop(void)
219 {
220  /* stop */
221  if (syn6988_stop(&gs_handle) != 0)
222  {
223  return 1;
224  }
225 
226  return 0;
227 }
228 
236 uint8_t syn6988_basic_pause(void)
237 {
238  /* pause */
239  if (syn6988_pause(&gs_handle) != 0)
240  {
241  return 1;
242  }
243 
244  return 0;
245 }
246 
254 uint8_t syn6988_basic_resume(void)
255 {
256  /* resume */
257  if (syn6988_resume(&gs_handle) != 0)
258  {
259  return 1;
260  }
261 
262  return 0;
263 }
264 
273 {
274  /* standby */
275  if (syn6988_standby(&gs_handle) != 0)
276  {
277  return 1;
278  }
279 
280  return 0;
281 }
282 
291 {
292  /* wake up */
293  if (syn6988_wake_up(&gs_handle) != 0)
294  {
295  return 1;
296  }
297 
298  return 0;
299 }
driver syn6988 basic header file
uint8_t syn6988_stop(syn6988_handle_t *handle)
stop the chip
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
uint8_t syn6988_wake_up(syn6988_handle_t *handle)
wake up the chip
uint8_t syn6988_pause(syn6988_handle_t *handle)
pause the chip
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
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
@ SYN6988_STATUS_BUSY
uint8_t syn6988_basic_wake_up(void)
basic example wake up
#define SYN6988_BASIC_DEFAULT_SYNTHESIS_LANGUAGE
uint8_t syn6988_basic_synthesis(const char *const fmt,...)
basic example synthesis
#define SYN6988_BASIC_DEFAULT_SYNTHESIS_VOLUME
uint8_t syn6988_basic_stop(void)
basic example stop
uint8_t syn6988_basic_init(syn6988_interface_t interface)
basic example init
uint8_t syn6988_basic_deinit(void)
basic example deinit
uint8_t syn6988_basic_resume(void)
basic example resume
#define SYN6988_BASIC_DEFAULT_TEXT_TYPE
syn6988 basic example default definition
#define SYN6988_BASIC_DEFAULT_SYNTHESIS_SPEED
uint8_t syn6988_basic_standby(void)
basic example standby
uint8_t syn6988_basic_sync(void)
basic example sync
uint8_t syn6988_basic_pause(void)
basic example pause
uint8_t syn6988_interface_spi_init(void)
interface spi init
uint8_t syn6988_interface_gpio_ready_read(uint8_t *value)
interface gpio ready read
uint8_t syn6988_interface_uart_init(void)
interface uart init
uint8_t syn6988_interface_gpio_ready_init(void)
interface gpio ready init
uint8_t syn6988_interface_spi_deinit(void)
interface spi deinit
uint8_t syn6988_interface_uart_flush(void)
interface uart flush
void syn6988_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t syn6988_interface_gpio_ready_deinit(void)
interface gpio ready deinit
uint16_t syn6988_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read
void syn6988_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t syn6988_interface_uart_write(uint8_t *buf, uint16_t len)
interface uart write
uint8_t syn6988_interface_uart_deinit(void)
interface uart deinit
uint8_t syn6988_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len)
interface spi transmit
syn6988 handle structure definition