diff --git a/include/mic/mic.h b/include/mic/mic.h new file mode 100644 index 00000000..1a56fe37 --- /dev/null +++ b/include/mic/mic.h @@ -0,0 +1,90 @@ +#pragma once +#include "wut.h" + +/** + * \defgroup mic Microphone + * \ingroup mic + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int MICHandle; + +typedef struct MICWorkMemory MICWorkMemory; +typedef struct MICStatus MICStatus; + +typedef enum MICError +{ + MIC_ERROR_OK = 0, + MIC_ERROR_NOT_OPENED = -1, + MIC_ERROR_INVALID_HANDLE = -2, + MIC_ERROR_INIT = -5, + MIC_ERROR_ALREADY_CLOSED = -7, + MIC_ERROR_INVALID_INSTANCE = -8, +} MICError; + +typedef enum MICInstance +{ + MIC_INSTANCE_0 = 0, + MIC_INSTANCE_1 = 1 +} MICInstance; + +struct MICWorkMemory +{ + //! Maximum amount of samples at a time must be at least 0x2800. + size_t sampleMaxCount; + + //! A 0x40 aligned buffer of size sampleMaxCount * 2. + void *sampleBuffer; +}; +WUT_CHECK_OFFSET(MICWorkMemory, 0x00, sampleMaxCount); +WUT_CHECK_OFFSET(MICWorkMemory, 0x04, sampleBuffer); +WUT_CHECK_SIZE(MICWorkMemory, 0x08); + +struct MICStatus +{ + int state; // 1 << 1 = Open + int availableData; + int bufferPos; +}; +WUT_CHECK_OFFSET(MICStatus, 0x00, state); +WUT_CHECK_OFFSET(MICStatus, 0x04, availableData); +WUT_CHECK_OFFSET(MICStatus, 0x08, bufferPos); +WUT_CHECK_SIZE(MICStatus, 0x0C); + +/** + * The second parameter to MICInit is unused, any value is valid. + */ +MICHandle +MICInit(MICInstance instance, int unused, MICWorkMemory *workMemory, + MICError *outError); + +MICError +MICOpen(MICHandle handle); + +MICError +MICGetState(MICHandle handle, int state, uint32_t *outStateVal); + +MICError +MICSetState(MICHandle handle, int state, uint32_t stateVal); + +MICError +MICGetStatus(MICHandle handle, MICStatus *outStatus); + +MICError +MICSetDataConsumed(MICHandle handle, int dataAmountConsumed); + +MICError +MICClose(MICHandle handle); + +MICError +MICUninit(MICHandle handle); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/tests/test_compile_headers_common/test_compile_headers_list.h b/tests/test_compile_headers_common/test_compile_headers_list.h index 9e68eabc..466df21c 100644 --- a/tests/test_compile_headers_common/test_compile_headers_list.h +++ b/tests/test_compile_headers_common/test_compile_headers_list.h @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include