LibDriver SYN6288  2.0.0
SYN6288 full-featured driver
driver_syn6288_advance.c
Go to the documentation of this file.
1 
38 #include "driver_syn6288_advance.h"
39 
40 static syn6288_handle_t gs_handle;
49 uint8_t syn6288_advance_init(void)
50 {
51  uint8_t res;
52 
53  /* link interface function */
62 
63  /* syn6288 init */
64  res = syn6288_init(&gs_handle);
65  if (res != 0)
66  {
67  syn6288_interface_debug_print("syn6288: init failed.\n");
68 
69  return 1;
70  }
71 #if (SYN6288_ADVANCE_SEND_CONFIG == 1)
72 
73  /* set defalut baud rate */
75  if (res != 0)
76  {
77  syn6288_interface_debug_print("syn6288: set baud rate failed.\n");
78  (void)syn6288_deinit(&gs_handle);
79 
80  return 1;
81  }
83 
84  /* set defalut mode */
86  if (res != 0)
87  {
88  syn6288_interface_debug_print("syn6288: set mode failed.\n");
89  (void)syn6288_deinit(&gs_handle);
90 
91  return 1;
92  }
94 
95  /* set defalut text type */
97  if (res != 0)
98  {
99  syn6288_interface_debug_print("syn6288: set text type failed.\n");
100  (void)syn6288_deinit(&gs_handle);
101 
102  return 1;
103  }
105 
106  /* set defalut synthesis volume */
108  if (res != 0)
109  {
110  syn6288_interface_debug_print("syn6288: set synthesis volume failed.\n");
111  (void)syn6288_deinit(&gs_handle);
112 
113  return 1;
114  }
116 
117  /* set defalut background volume */
119  if (res != 0)
120  {
121  syn6288_interface_debug_print("syn6288: set background volume failed.\n");
122  (void)syn6288_deinit(&gs_handle);
123 
124  return 1;
125  }
127 
128  /* set defalut synthesis speed */
130  if (res != 0)
131  {
132  syn6288_interface_debug_print("syn6288: set synthesis speed failed.\n");
133  (void)syn6288_deinit(&gs_handle);
134 
135  return 1;
136  }
138 #endif
139 
140  return 0;
141 }
142 
151 uint8_t syn6288_advance_synthesis(char *text)
152 {
153  uint8_t res;
154  syn6288_status_t status;
155 
156  /* get status */
157  res = syn6288_get_status(&gs_handle, &status);
158  if (res != 0)
159  {
160  return 1;
161  }
162 
163  /* check status */
164  if (status == SYN6288_STATUS_BUSY)
165  {
166  return 1;
167  }
168 
169  /* synthesis text */
170  if (syn6288_synthesis_text(&gs_handle, text) != 0)
171  {
172  return 1;
173  }
174  else
175  {
176  return 0;
177  }
178 }
179 
189 {
190  uint8_t res;
191  syn6288_status_t status;
192 
193  /* get status */
194  res = syn6288_get_status(&gs_handle, &status);
195  if (res != 0)
196  {
197  return 1;
198  }
199 
200  /* check status */
201  if (status == SYN6288_STATUS_BUSY)
202  {
203  return 1;
204  }
205 
206  /* synthesis sound */
207  if (syn6288_synthesis_sound(&gs_handle, sound) != 0)
208  {
209  return 1;
210  }
211  else
212  {
213  return 0;
214  }
215 }
216 
226 {
227  uint8_t res;
228  syn6288_status_t status;
229 
230  /* get status */
231  res = syn6288_get_status(&gs_handle, &status);
232  if (res != 0)
233  {
234  return 1;
235  }
236 
237  /* check status */
238  if (status == SYN6288_STATUS_BUSY)
239  {
240  return 1;
241  }
242 
243  /* synthesis message */
244  if (syn6288_synthesis_message(&gs_handle, message) != 0)
245  {
246  return 1;
247  }
248  else
249  {
250  return 0;
251  }
252 }
253 
263 {
264  uint8_t res;
265  syn6288_status_t status;
266 
267  /* get status */
268  res = syn6288_get_status(&gs_handle, &status);
269  if (res != 0)
270  {
271  return 1;
272  }
273 
274  /* check status */
275  if (status == SYN6288_STATUS_BUSY)
276  {
277  return 1;
278  }
279 
280  /* synthesis ring */
281  if (syn6288_synthesis_ring(&gs_handle, ring) != 0)
282  {
283  return 1;
284  }
285  else
286  {
287  return 0;
288  }
289 }
290 
299 {
300  /* pause syn6288 */
301  if (syn6288_pause(&gs_handle) != 0)
302  {
303  return 1;
304  }
305  else
306  {
307  return 0;
308  }
309 }
310 
319 {
320  /* resume syn6288 */
321  if (syn6288_resume(&gs_handle) != 0)
322  {
323  return 1;
324  }
325  else
326  {
327  return 0;
328  }
329 }
330 
338 uint8_t syn6288_advance_stop(void)
339 {
340  /* stop syn6288 */
341  if (syn6288_stop(&gs_handle) != 0)
342  {
343  return 1;
344  }
345  else
346  {
347  return 0;
348  }
349 }
350 
359 {
360  /* power on syn6288 */
361  if (syn6288_power_down(&gs_handle) != 0)
362  {
363  return 1;
364  }
365  else
366  {
367  return 0;
368  }
369 }
370 
379 {
380  /* deinit syn6288 */
381  if (syn6288_deinit(&gs_handle) != 0)
382  {
383  return 1;
384  }
385  else
386  {
387  return 0;
388  }
389 }
390 
398 uint8_t syn6288_advance_sync(void)
399 {
400  uint8_t res;
401  syn6288_status_t status;
402 
403  status = SYN6288_STATUS_BUSY;
404  while (status == SYN6288_STATUS_BUSY)
405  {
407  res = syn6288_get_status(&gs_handle, &status);
408  if (res != 0)
409  {
410  return 1;
411  }
412  }
413 
414  return 0;
415 }
driver syn6288 advance header file
uint8_t syn6288_set_background_volume(syn6288_handle_t *handle, uint8_t volume)
set the synthesis background volume
uint8_t syn6288_set_baud_rate(syn6288_handle_t *handle, syn6288_baud_rate_t rate)
set the baud rate
uint8_t syn6288_set_synthesis_volume(syn6288_handle_t *handle, uint8_t volume)
set the chip synthesis volume
uint8_t syn6288_set_synthesis_speed(syn6288_handle_t *handle, uint8_t speed)
set the synthesis speed
uint8_t syn6288_set_mode(syn6288_handle_t *handle, syn6288_mode_t mode)
set the chip mode
uint8_t syn6288_init(syn6288_handle_t *handle)
initialize the chip
uint8_t syn6288_power_down(syn6288_handle_t *handle)
power down the chip
uint8_t syn6288_synthesis_sound(syn6288_handle_t *handle, syn6288_sound_t sound)
synthesis the sound
uint8_t syn6288_stop(syn6288_handle_t *handle)
stop the chip
syn6288_ring_t
syn6288 ring enumeration definition
syn6288_status_t
syn6288 status enumeration definition
syn6288_sound_t
syn6288 sound enumeration definition
uint8_t syn6288_get_status(syn6288_handle_t *handle, syn6288_status_t *status)
get the current status
uint8_t syn6288_set_text_type(syn6288_handle_t *handle, syn6288_type_t type)
set the chip text type
uint8_t syn6288_synthesis_message(syn6288_handle_t *handle, syn6288_message_t message)
synthesis the message
uint8_t syn6288_deinit(syn6288_handle_t *handle)
close the chip
uint8_t syn6288_synthesis_text(syn6288_handle_t *handle, char *text)
synthesis the test
uint8_t syn6288_resume(syn6288_handle_t *handle)
resume the chip
syn6288_message_t
syn6288 message enumeration definition
uint8_t syn6288_synthesis_ring(syn6288_handle_t *handle, syn6288_ring_t ring)
synthesis the ring
uint8_t syn6288_pause(syn6288_handle_t *handle)
pause the chip
@ SYN6288_STATUS_BUSY
#define SYN6288_ADVANCE_DEFAULT_MODE
uint8_t syn6288_advance_message(syn6288_message_t message)
advance example play the message
uint8_t syn6288_advance_pause(void)
advance example pause
uint8_t syn6288_advance_ring(syn6288_ring_t ring)
advance example play the ring
uint8_t syn6288_advance_synthesis(char *text)
advance example synthesis
uint8_t syn6288_advance_sound(syn6288_sound_t sound)
advance example play the sound
uint8_t syn6288_advance_stop(void)
advance example stop
#define SYN6288_ADVANCE_DEFAULT_TEXT_TYPE
uint8_t syn6288_advance_resume(void)
advance example resume
#define SYN6288_ADVANCE_DEFAULT_SYNTHESIS_VOLUME
#define SYN6288_ADVANCE_DEFAULT_BAUD_RATE
syn6288 advance example default definition
#define SYN6288_ADVANCE_DEFAULT_BACKGROUND_VOLUME
uint8_t syn6288_advance_deinit(void)
advance example deinit
uint8_t syn6288_advance_init(void)
advance example init
#define SYN6288_ADVANCE_DEFAULT_SYNTHESIS_SPEED
uint8_t syn6288_advance_sync(void)
advance example sync
uint8_t syn6288_advance_power_down(void)
advance example power down
void syn6288_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t syn6288_interface_uart_flush(void)
interface uart flush
uint8_t syn6288_interface_uart_write(uint8_t *buf, uint16_t len)
interface uart write
uint16_t syn6288_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read
uint8_t syn6288_interface_uart_deinit(void)
interface uart deinit
void syn6288_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t syn6288_interface_uart_init(void)
interface uart init
syn6288 handle structure definition