LibDriver ISD17XX
Loading...
Searching...
No Matches
driver_isd17xx_play_record_test.c
Go to the documentation of this file.
1
36
38
39static isd17xx_handle_t gs_handle;
40
50{
51 uint8_t res;
52 uint8_t status2;
53 uint16_t status1;
54 isd17xx_info_t info;
55
56 /* link function */
68
69 /* get information */
70 res = isd17xx_info(&info);
71 if (res != 0)
72 {
73 isd17xx_interface_debug_print("isd17xx: get info failed.\n");
74
75 return 1;
76 }
77 else
78 {
79 /* print chip info */
80 isd17xx_interface_debug_print("isd17xx: chip is %s.\n", info.chip_name);
81 isd17xx_interface_debug_print("isd17xx: manufacturer is %s.\n", info.manufacturer_name);
82 isd17xx_interface_debug_print("isd17xx: interface is %s.\n", info.interface);
83 isd17xx_interface_debug_print("isd17xx: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
84 isd17xx_interface_debug_print("isd17xx: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
85 isd17xx_interface_debug_print("isd17xx: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
86 isd17xx_interface_debug_print("isd17xx: max current is %0.2fmA.\n", info.max_current_ma);
87 isd17xx_interface_debug_print("isd17xx: max temperature is %0.1fC.\n", info.temperature_max);
88 isd17xx_interface_debug_print("isd17xx: min temperature is %0.1fC.\n", info.temperature_min);
89 }
90
91 /* start play record test */
92 isd17xx_interface_debug_print("isd17xx: start play record test.\n");
93
94 /* set the type */
95 res = isd17xx_set_type(&gs_handle, type);
96 if (res != 0)
97 {
98 isd17xx_interface_debug_print("isd17xx: set type failed.\n");
99
100 return 1;
101 }
102
103 /* init */
104 res = isd17xx_init(&gs_handle);
105 if (res != 0)
106 {
107 isd17xx_interface_debug_print("isd17xx: init failed.\n");
108
109 return 1;
110 }
111
112 /* power up */
113 res = isd17xx_power_up(&gs_handle);
114 if (res != 0)
115 {
116 isd17xx_interface_debug_print("isd17xx: power up failed.\n");
117 (void)isd17xx_deinit(&gs_handle);
118
119 return 1;
120 }
121
122 /* register control volume */
124 if (res != 0)
125 {
126 isd17xx_interface_debug_print("isd17xx: set volume control failed.\n");
127 (void)isd17xx_deinit(&gs_handle);
128
129 return 1;
130 }
131
132 /* max volume */
133 res = isd17xx_set_volume(&gs_handle, 0x00);
134 if (res != 0)
135 {
136 isd17xx_interface_debug_print("isd17xx: set volume failed.\n");
137 (void)isd17xx_deinit(&gs_handle);
138
139 return 1;
140 }
141
142 /* disable monitor input */
144 if (res != 0)
145 {
146 isd17xx_interface_debug_print("isd17xx: set monitor input failed.\n");
147 (void)isd17xx_deinit(&gs_handle);
148
149 return 1;
150 }
151
152 /* disable mix input */
153 res = isd17xx_set_mix_input(&gs_handle, ISD17XX_BOOL_FALSE);
154 if (res != 0)
155 {
156 isd17xx_interface_debug_print("isd17xx: set mix input failed.\n");
157 (void)isd17xx_deinit(&gs_handle);
158
159 return 1;
160 }
161
162 /* enable sound effect editing */
164 if (res != 0)
165 {
166 isd17xx_interface_debug_print("isd17xx: set sound effect editing failed.\n");
167 (void)isd17xx_deinit(&gs_handle);
168
169 return 1;
170 }
171
172 /* disable spi ft */
173 res = isd17xx_set_spi_ft(&gs_handle, ISD17XX_BOOL_FALSE);
174 if (res != 0)
175 {
176 isd17xx_interface_debug_print("isd17xx: set spi ft failed.\n");
177 (void)isd17xx_deinit(&gs_handle);
178
179 return 1;
180 }
181
182 /* set analog output aud */
184 if (res != 0)
185 {
186 isd17xx_interface_debug_print("isd17xx: set analog output failed.\n");
187 (void)isd17xx_deinit(&gs_handle);
188
189 return 1;
190 }
191
192 /* enable pwm speaker */
194 if (res != 0)
195 {
196 isd17xx_interface_debug_print("isd17xx: set pwm speaker failed.\n");
197 (void)isd17xx_deinit(&gs_handle);
198
199 return 1;
200 }
201
202 /* enable power up analog output */
204 if (res != 0)
205 {
206 isd17xx_interface_debug_print("isd17xx: set power up analog output failed.\n");
207 (void)isd17xx_deinit(&gs_handle);
208
209 return 1;
210 }
211
212 /* disable v alert */
213 res = isd17xx_set_v_alert(&gs_handle, ISD17XX_BOOL_FALSE);
214 if (res != 0)
215 {
216 isd17xx_interface_debug_print("isd17xx: set v alert failed.\n");
217 (void)isd17xx_deinit(&gs_handle);
218
219 return 1;
220 }
221
222 /* disable eom */
223 res = isd17xx_set_eom(&gs_handle, ISD17XX_BOOL_FALSE);
224 if (res != 0)
225 {
226 isd17xx_interface_debug_print("isd17xx: set eom failed.\n");
227 (void)isd17xx_deinit(&gs_handle);
228
229 return 1;
230 }
231
232 /* check the memory */
233 res = isd17xx_check_memory(&gs_handle);
234 if (res != 0)
235 {
236 isd17xx_interface_debug_print("isd17xx: check memory failed.\n");
237 (void)isd17xx_deinit(&gs_handle);
238
239 return 1;
240 }
241
242 /* start global erase */
243 isd17xx_interface_debug_print("isd17xx: start global erase.\n");
244
245 /* start global erase */
246 res = isd17xx_global_erase(&gs_handle);
247 if (res != 0)
248 {
249 isd17xx_interface_debug_print("isd17xx: erase failed.\n");
250 (void)isd17xx_deinit(&gs_handle);
251
252 return 1;
253 }
254
255 /* wait */
256 while (1)
257 {
258 /* get status */
259 res = isd17xx_get_status(&gs_handle, &status1, &status2);
260 if (res != 0)
261 {
262 isd17xx_interface_debug_print("isd17xx: get status failed.\n");
263 (void)isd17xx_deinit(&gs_handle);
264
265 return 1;
266 }
267
268 /* check erase */
270 {
271 break;
272 }
273
274 /* delay 200ms */
276 }
277
278 /* start erase */
279 isd17xx_interface_debug_print("isd17xx: start erase.\n");
280
281 /* set erase */
282 res = isd17xx_set_erase(&gs_handle, 0x10, 0xFF);
283 if (res != 0)
284 {
285 isd17xx_interface_debug_print("isd17xx: set erase failed.\n");
286 (void)isd17xx_deinit(&gs_handle);
287
288 return 1;
289 }
290
291 /* start erase */
292 res = isd17xx_erase(&gs_handle);
293 if (res != 0)
294 {
295 isd17xx_interface_debug_print("isd17xx: erase failed.\n");
296 (void)isd17xx_deinit(&gs_handle);
297
298 return 1;
299 }
300
301 /* wait */
302 while (1)
303 {
304 /* get status */
305 res = isd17xx_get_status(&gs_handle, &status1, &status2);
306 if (res != 0)
307 {
308 isd17xx_interface_debug_print("isd17xx: get status failed.\n");
309 (void)isd17xx_deinit(&gs_handle);
310
311 return 1;
312 }
313
314 /* check erase */
316 {
317 break;
318 }
319
320 /* delay 200ms */
322 }
323
324 /* please speak */
325 isd17xx_interface_debug_print("isd17xx: please speak...\n");
326
327 /* set record */
328 res = isd17xx_set_record(&gs_handle, 0x10, 0xFF);
329 if (res != 0)
330 {
331 isd17xx_interface_debug_print("isd17xx: set record failed.\n");
332 (void)isd17xx_deinit(&gs_handle);
333
334 return 1;
335 }
336
337 /* start record */
338 res = isd17xx_record(&gs_handle);
339 if (res != 0)
340 {
341 isd17xx_interface_debug_print("isd17xx: record failed.\n");
342 (void)isd17xx_deinit(&gs_handle);
343
344 return 1;
345 }
346
347 /* wait */
348 while (1)
349 {
350 /* get status */
351 res = isd17xx_get_status(&gs_handle, &status1, &status2);
352 if (res != 0)
353 {
354 isd17xx_interface_debug_print("isd17xx: get status failed.\n");
355 (void)isd17xx_deinit(&gs_handle);
356
357 return 1;
358 }
359
360 /* check the rec */
361 if ((status2 & ISD17XX_STATUS2_REC) != ISD17XX_STATUS2_REC)
362 {
363 break;
364 }
365
366 /* delay 200ms */
368 }
369
370
371 /* start play */
372 isd17xx_interface_debug_print("isd17xx: start play.\n");
373
374 /* set play */
375 res = isd17xx_set_play(&gs_handle, 0x10, 0xFF);
376 if (res != 0)
377 {
378 isd17xx_interface_debug_print("isd17xx: set play failed.\n");
379 (void)isd17xx_deinit(&gs_handle);
380
381 return 1;
382 }
383
384 /* start play */
385 res = isd17xx_play(&gs_handle);
386 if (res != 0)
387 {
388 isd17xx_interface_debug_print("isd17xx: play failed.\n");
389 (void)isd17xx_deinit(&gs_handle);
390
391 return 1;
392 }
393
394 while (1)
395 {
396 /* get status */
397 res = isd17xx_get_status(&gs_handle, &status1, &status2);
398 if (res != 0)
399 {
400 isd17xx_interface_debug_print("isd17xx: get status failed.\n");
401 (void)isd17xx_deinit(&gs_handle);
402
403 return 1;
404 }
405
406 /* check the play */
408 {
409 break;
410 }
411
412 /* delay 200ms */
414 }
415
416 /* goto next */
417 isd17xx_interface_debug_print("isd17xx: goto next.\n");
418
419 /* goto the next */
420 res = isd17xx_next(&gs_handle);
421 if (res != 0)
422 {
423 isd17xx_interface_debug_print("isd17xx: next failed.\n");
424 (void)isd17xx_deinit(&gs_handle);
425
426 return 1;
427 }
428
429 /* finish play record test */
430 isd17xx_interface_debug_print("isd17xx: finish play record test.\n");
431 (void)isd17xx_deinit(&gs_handle);
432
433 return 0;
434}
driver isd17xx play record test header file
uint8_t isd17xx_global_erase(isd17xx_handle_t *handle)
global erase
uint8_t isd17xx_set_record(isd17xx_handle_t *handle, uint16_t start_addr, uint16_t end_addr)
set the record point
uint8_t isd17xx_info(isd17xx_info_t *info)
get chip's information
uint8_t isd17xx_set_mix_input(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable the mix input
uint8_t isd17xx_set_spi_ft(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable spi ft
uint8_t isd17xx_power_up(isd17xx_handle_t *handle)
power up
uint8_t isd17xx_set_volume(isd17xx_handle_t *handle, uint8_t vol)
set the volume
uint8_t isd17xx_set_type(isd17xx_handle_t *handle, isd17xx_type_t type)
set the chip type
uint8_t isd17xx_set_sound_effect_editing(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable sound effect editing
uint8_t isd17xx_next(isd17xx_handle_t *handle)
next
uint8_t isd17xx_get_status(isd17xx_handle_t *handle, uint16_t *status1, uint8_t *status2)
get the status
uint8_t isd17xx_set_erase(isd17xx_handle_t *handle, uint16_t start_addr, uint16_t end_addr)
set the erase point
uint8_t isd17xx_set_play(isd17xx_handle_t *handle, uint16_t start_addr, uint16_t end_addr)
set the play point
uint8_t isd17xx_record(isd17xx_handle_t *handle)
record
uint8_t isd17xx_set_power_up_analog_output(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable power up analog output
uint8_t isd17xx_init(isd17xx_handle_t *handle)
initialize the chip
uint8_t isd17xx_check_memory(isd17xx_handle_t *handle)
check memory
uint8_t isd17xx_set_analog_output(isd17xx_handle_t *handle, isd17xx_analog_output_t output)
set the analog output type
struct isd17xx_info_s isd17xx_info_t
isd17xx information structure definition
uint8_t isd17xx_set_v_alert(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable v alert
uint8_t isd17xx_erase(isd17xx_handle_t *handle)
erase
uint8_t isd17xx_set_monitor_input(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable the monitor input
uint8_t isd17xx_set_pwm_speaker(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable pwm speaker
struct isd17xx_handle_s isd17xx_handle_t
isd17xx handle structure definition
uint8_t isd17xx_set_eom(isd17xx_handle_t *handle, isd17xx_bool_t enable)
enable or disable eom stop playing
uint8_t isd17xx_set_volume_control(isd17xx_handle_t *handle, isd17xx_vol_control_t control)
set the volume control type
isd17xx_type_t
isd17xx type enumeration definition
uint8_t isd17xx_deinit(isd17xx_handle_t *handle)
close the chip
uint8_t isd17xx_play(isd17xx_handle_t *handle)
play
@ ISD17XX_STATUS2_REC
@ ISD17XX_STATUS2_PLAY
@ ISD17XX_STATUS2_ERASE
@ ISD17XX_BOOL_TRUE
@ ISD17XX_BOOL_FALSE
@ ISD17XX_VOL_CONTROL_REG
@ ISD17XX_ANALOG_OUTPUT_AUD
void isd17xx_interface_debug_print(const char *const fmt,...)
interface print format data
void isd17xx_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t isd17xx_interface_gpio_reset_deinit(void)
interface gpio reset deinit
uint8_t isd17xx_interface_gpio_reset_write(uint8_t value)
interface gpio reset write
uint8_t isd17xx_interface_spi_transmit(uint8_t *tx, uint8_t *rx, uint16_t len)
interface spi bus transmit
uint8_t isd17xx_interface_gpio_reset_init(void)
interface gpio reset init
uint8_t isd17xx_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t isd17xx_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t isd17xx_interface_spi_deinit(void)
interface spi bus deinit
uint8_t isd17xx_interface_spi_init(void)
interface spi bus init
uint8_t isd17xx_play_record_test(isd17xx_type_t type)
play record test
uint32_t driver_version
char manufacturer_name[32]