LibDriver WT588E02B
Loading...
Searching...
No Matches
driver_wt588e02b_play_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static wt588e02b_handle_t gs_handle;
41
50uint8_t wt588e02b_play_test(uint8_t ind)
51{
52 uint8_t res;
53 uint8_t list[2];
54 wt588e02b_bool_t enable;
56
57 /* link driver */
77
78 /* get information */
79 res = wt588e02b_info(&info);
80 if (res != 0)
81 {
82 wt588e02b_interface_debug_print("wt588e02b: get info failed.\n");
83
84 return 1;
85 }
86 else
87 {
88 /* print chip info */
89 wt588e02b_interface_debug_print("wt588e02b: chip is %s.\n", info.chip_name);
90 wt588e02b_interface_debug_print("wt588e02b: manufacturer is %s.\n", info.manufacturer_name);
91 wt588e02b_interface_debug_print("wt588e02b: interface is %s.\n", info.interface);
92 wt588e02b_interface_debug_print("wt588e02b: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
93 wt588e02b_interface_debug_print("wt588e02b: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
94 wt588e02b_interface_debug_print("wt588e02b: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
95 wt588e02b_interface_debug_print("wt588e02b: max current is %0.2fmA.\n", info.max_current_ma);
96 wt588e02b_interface_debug_print("wt588e02b: max temperature is %0.1fC.\n", info.temperature_max);
97 wt588e02b_interface_debug_print("wt588e02b: min temperature is %0.1fC.\n", info.temperature_min);
98 }
99
100 /* start play test */
101 wt588e02b_interface_debug_print("wt588e02b: start play test.\n");
102
103 /* init */
104 res = wt588e02b_init(&gs_handle);
105 if (res != 0)
106 {
107 wt588e02b_interface_debug_print("wt588e02b: init failed.\n");
108
109 return 1;
110 }
111
112 /* stop */
113 res = wt588e02b_stop(&gs_handle);
114 if (res != 0)
115 {
116 wt588e02b_interface_debug_print("wt588e02b: stop failed.\n");
117 (void)wt588e02b_deinit(&gs_handle);
118
119 return 1;
120 }
121
122 /* delay 1000ms */
124
125 /* set vol */
126 res = wt588e02b_set_vol(&gs_handle, 0x3F);
127 if (res != 0)
128 {
129 wt588e02b_interface_debug_print("wt588e02b: set vol failed.\n");
130 (void)wt588e02b_deinit(&gs_handle);
131
132 return 1;
133 }
134
135 /* play test */
136 wt588e02b_interface_debug_print("wt588e02b: play test.\n");
137
138 /* play */
139 res = wt588e02b_play(&gs_handle, ind);
140 if (res != 0)
141 {
142 wt588e02b_interface_debug_print("wt588e02b: play failed.\n");
143 (void)wt588e02b_stop(&gs_handle);
144 (void)wt588e02b_deinit(&gs_handle);
145
146 return 1;
147 }
148
149 /* check busy */
150 enable = WT588E02B_BOOL_TRUE;
151 while (enable == WT588E02B_BOOL_TRUE)
152 {
153 /* delay 100ms */
155
156 res = wt588e02b_check_busy(&gs_handle, &enable);
157 if (res != 0)
158 {
159 wt588e02b_interface_debug_print("wt588e02b: check busy failed.\n");
160 (void)wt588e02b_stop(&gs_handle);
161 (void)wt588e02b_deinit(&gs_handle);
162
163 return 1;
164 }
165 }
166
167 /* play list test */
168 wt588e02b_interface_debug_print("wt588e02b: play list test.\n");
169
170 /* play list */
171 list[0] = 2;
172 list[1] = 3;
173 res = wt588e02b_play_list(&gs_handle, list, 2);
174 if (res != 0)
175 {
176 wt588e02b_interface_debug_print("wt588e02b: play list failed.\n");
177 (void)wt588e02b_stop(&gs_handle);
178 (void)wt588e02b_deinit(&gs_handle);
179
180 return 1;
181 }
182
183 /* check busy */
184 enable = WT588E02B_BOOL_TRUE;
185 while (enable == WT588E02B_BOOL_TRUE)
186 {
187 /* delay 100ms */
189
190 res = wt588e02b_check_busy(&gs_handle, &enable);
191 if (res != 0)
192 {
193 wt588e02b_interface_debug_print("wt588e02b: check busy failed.\n");
194 (void)wt588e02b_stop(&gs_handle);
195 (void)wt588e02b_deinit(&gs_handle);
196
197 return 1;
198 }
199 }
200
201 /* play loop test */
202 wt588e02b_interface_debug_print("wt588e02b: play loop test.\n");
203
204 /* play loop */
205 res = wt588e02b_play_loop(&gs_handle, ind);
206 if (res != 0)
207 {
208 wt588e02b_interface_debug_print("wt588e02b: play loop failed.\n");
209 (void)wt588e02b_stop(&gs_handle);
210 (void)wt588e02b_deinit(&gs_handle);
211
212 return 1;
213 }
214
215 /* delay 10000ms */
217
218 /* stop */
219 res = wt588e02b_stop(&gs_handle);
220 if (res != 0)
221 {
222 wt588e02b_interface_debug_print("wt588e02b: stop failed.\n");
223 (void)wt588e02b_deinit(&gs_handle);
224
225 return 1;
226 }
227
228 /* delay 1000ms */
230
231 /* play loop advance test */
232 wt588e02b_interface_debug_print("wt588e02b: play loop advance test.\n");
233
234 /* play loop advance */
235 res = wt588e02b_play_loop_advance(&gs_handle, ind);
236 if (res != 0)
237 {
238 wt588e02b_interface_debug_print("wt588e02b: play loop advance failed.\n");
239 (void)wt588e02b_stop(&gs_handle);
240 (void)wt588e02b_deinit(&gs_handle);
241
242 return 1;
243 }
244
245 /* delay 10000ms */
247
248 /* stop */
249 res = wt588e02b_stop(&gs_handle);
250 if (res != 0)
251 {
252 wt588e02b_interface_debug_print("wt588e02b: stop failed.\n");
253 (void)wt588e02b_deinit(&gs_handle);
254
255 return 1;
256 }
257
258 /* delay 1000ms */
260
261 /* play loop all test */
262 wt588e02b_interface_debug_print("wt588e02b: play loop all test.\n");
263
264 /* play loop all */
265 res = wt588e02b_play_loop_all(&gs_handle);
266 if (res != 0)
267 {
268 wt588e02b_interface_debug_print("wt588e02b: play loop all failed.\n");
269 (void)wt588e02b_stop(&gs_handle);
270 (void)wt588e02b_deinit(&gs_handle);
271
272 return 1;
273 }
274
275 /* delay 10000ms */
277
278 /* stop */
279 res = wt588e02b_stop(&gs_handle);
280 if (res != 0)
281 {
282 wt588e02b_interface_debug_print("wt588e02b: stop failed.\n");
283 (void)wt588e02b_deinit(&gs_handle);
284
285 return 1;
286 }
287
288 /* delay 1000ms */
290
291 /* finish play test */
292 wt588e02b_interface_debug_print("wt588e02b: finish play test.\n");
293 (void)wt588e02b_deinit(&gs_handle);
294
295 return 0;
296}
driver wt588e02b play test header file
struct wt588e02b_info_s wt588e02b_info_t
wt588e02b information structure definition
struct wt588e02b_handle_s wt588e02b_handle_t
wt588e02b handle structure definition
uint8_t wt588e02b_play(wt588e02b_handle_t *handle, uint8_t ind)
play audio
uint8_t wt588e02b_play_loop(wt588e02b_handle_t *handle, uint8_t ind)
play loop
uint8_t wt588e02b_info(wt588e02b_info_t *info)
get chip's information
uint8_t wt588e02b_deinit(wt588e02b_handle_t *handle)
deinit the chip
uint8_t wt588e02b_check_busy(wt588e02b_handle_t *handle, wt588e02b_bool_t *enable)
check chip busy
uint8_t wt588e02b_play_loop_advance(wt588e02b_handle_t *handle, uint8_t ind)
play loop advance
wt588e02b_bool_t
wt588e02b bool enumeration definition
uint8_t wt588e02b_set_vol(wt588e02b_handle_t *handle, uint8_t vol)
set the volume
uint8_t wt588e02b_init(wt588e02b_handle_t *handle)
initialize the chip
uint8_t wt588e02b_play_loop_all(wt588e02b_handle_t *handle)
play loop all
uint8_t wt588e02b_play_list(wt588e02b_handle_t *handle, uint8_t *list, uint8_t len)
play list
uint8_t wt588e02b_stop(wt588e02b_handle_t *handle)
stop audio
@ WT588E02B_BOOL_TRUE
void wt588e02b_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t wt588e02b_interface_bin_read(uint32_t addr, uint16_t size, uint8_t *buffer)
interface bin read
void wt588e02b_interface_delay_us(uint32_t us)
interface delay us
uint8_t wt588e02b_interface_sclk_gpio_init(void)
interface sclk gpio init
uint8_t wt588e02b_interface_cs_gpio_init(void)
interface cs gpio init
uint8_t wt588e02b_interface_miso_gpio_deinit(void)
interface miso gpio deinit
uint8_t wt588e02b_interface_cs_gpio_deinit(void)
interface cs gpio init
uint8_t wt588e02b_interface_cs_gpio_write(uint8_t data)
interface cs gpio write
uint8_t wt588e02b_interface_sclk_gpio_deinit(void)
interface sclk gpio deinit
uint8_t wt588e02b_interface_miso_gpio_init(void)
interface miso gpio init
uint8_t wt588e02b_interface_sclk_gpio_write(uint8_t data)
interface sclk gpio write
uint8_t wt588e02b_interface_mosi_gpio_init(void)
interface mosi gpio init
uint8_t wt588e02b_interface_mosi_gpio_deinit(void)
interface mosi gpio deinit
void wt588e02b_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t wt588e02b_interface_miso_gpio_read(uint8_t *data)
interface miso_gpio_read
uint8_t wt588e02b_interface_mosi_gpio_write(uint8_t data)
interface mosi gpio write
uint8_t wt588e02b_interface_bin_read_deinit(void)
interface bin read deinit
uint8_t wt588e02b_interface_bin_read_init(char *name, uint32_t *size)
interface bin read init
uint8_t wt588e02b_play_test(uint8_t ind)
play test