Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hdw-mic.c File Reference

Functions

void initMic (gpio_num_t gpio)
 Initialize the ADC which continuously samples the microphone.
 
void deinitMic (void)
 Deinitialize the ADC which continuously samples the microphone.
 
void powerDownMic (void)
 Power down the ADC (microphone)
 
void powerUpMic (void)
 Power up the ADC (microphone)
 
void startMic (void)
 Start sampling the microphone's ADC.
 
uint32_t loopMic (uint16_t *outSamples, uint32_t outSamplesMax)
 Attempt to read a block of 12-bit samples from the ADC in continuous mode. This may return fewer than expected samples (or zero samples) if the task rate is faster than the sampling rate.
 
void stopMic (void)
 Stop sampling the microphone's ADC.
 

Function Documentation

◆ initMic()

void initMic ( gpio_num_t gpio)

Initialize the ADC which continuously samples the microphone.

This does not start sampling, so startMic() must be called afterwards.

Parameters
gpioThe GPIO the microphone is attached to

◆ deinitMic()

void deinitMic ( void )

Deinitialize the ADC which continuously samples the microphone.

◆ powerDownMic()

void powerDownMic ( void )

Power down the ADC (microphone)

◆ powerUpMic()

void powerUpMic ( void )

Power up the ADC (microphone)

◆ startMic()

void startMic ( void )

Start sampling the microphone's ADC.

◆ loopMic()

uint32_t loopMic ( uint16_t * outSamples,
uint32_t outSamplesMax )

Attempt to read a block of 12-bit samples from the ADC in continuous mode. This may return fewer than expected samples (or zero samples) if the task rate is faster than the sampling rate.

Parameters
[out]outSamplesA pointer to write 12-bit samples from the ADC
[in]outSamplesMaxThe maximum number of samples that can be written to outSamples
Returns
The number of samples which were actually written to outSamples

◆ stopMic()

void stopMic ( void )

Stop sampling the microphone's ADC.