You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#ifdef cplusplus
|
|
extern "C" {
|
|
#endif
|
|
/**
|
|
* @brief 上报48k音频数据32位音频数据
|
|
*
|
|
* @param data 音频数据
|
|
* @param len 音频数据长度
|
|
*
|
|
*/
|
|
typedef void (*spisound_cb_t)(int32_t *data, uint32_t len);
|
|
|
|
typedef enum {
|
|
ksp_success,
|
|
ksp_module_not_inited,
|
|
ksp_module_has_started,
|
|
ksp_create_thread_fail,
|
|
ksp_init_spi_cs_pin_open_fail,
|
|
ksp_init_spi_error_open_fail,
|
|
ksp_init_spi_error_set_speed_fail,
|
|
ksp_init_spi_error_set_nbits_fail,
|
|
ksp_init_spi_error_set_mode_fail,
|
|
} error_code_t;
|
|
|
|
static inline const char *error_code_to_string(error_code_t code) {
|
|
switch (code) {
|
|
case ksp_success:
|
|
return "success";
|
|
case ksp_module_not_inited:
|
|
return "module not inited";
|
|
case ksp_module_has_started:
|
|
return "module has started";
|
|
case ksp_create_thread_fail:
|
|
return "create thread fail";
|
|
case ksp_init_spi_cs_pin_open_fail:
|
|
return "init spi cs pin open fail";
|
|
case ksp_init_spi_error_open_fail:
|
|
return "init spi error open fail";
|
|
case ksp_init_spi_error_set_speed_fail:
|
|
return "init spi error set speed fail";
|
|
case ksp_init_spi_error_set_nbits_fail:
|
|
return "init spi error set nbits fail";
|
|
case ksp_init_spi_error_set_mode_fail:
|
|
return "init spi error set mode fail";
|
|
default:
|
|
return "unknown error";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief 初始化声音采集模块
|
|
*
|
|
* @param deviceName
|
|
* @param callback
|
|
*/
|
|
error_code_t spisound_init(const char *deviceName, int csgpionId, spisound_cb_t callback);
|
|
error_code_t spisound_start_capture(void);
|
|
const char *spisound_libversion();
|
|
|
|
void spisound_dump_last_error();
|
|
#ifdef cplusplus
|
|
}
|
|
#endif
|