forked from PAWPAW-Mirror/lib_xua
Very early cut of xua_lite app. Builds (4 threads + I2C) but not functional
This commit is contained in:
44
examples/xua_lite_example/src/audio_hub.xc
Normal file
44
examples/xua_lite_example/src/audio_hub.xc
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "i2s.h"
|
||||
#include "i2c.h"
|
||||
#include "gpio.h"
|
||||
#include "xua.h"
|
||||
|
||||
[[distributable]]
|
||||
void AudioHub(server i2s_frame_callback_if i2s,
|
||||
chanend c_aud,
|
||||
client i2c_master_if i2c,
|
||||
client output_gpio_if dac_reset)
|
||||
{
|
||||
int32_t samples[8] = {0}; // Array used for looping back samples
|
||||
while (1) {
|
||||
select {
|
||||
case i2s.init(i2s_config_t &?i2s_config, tdm_config_t &?tdm_config):
|
||||
i2s_config.mode = I2S_MODE_I2S;
|
||||
i2s_config.mclk_bclk_ratio = (MCLK_48/DEFAULT_FREQ)/64;
|
||||
|
||||
// Set CODECs in reset
|
||||
dac_reset.output(0);
|
||||
|
||||
// Allow reset to assert
|
||||
delay_milliseconds(1);
|
||||
|
||||
// Take CODECs out of reset
|
||||
dac_reset.output(1);
|
||||
|
||||
//reset_codecs(i2c);
|
||||
break;
|
||||
|
||||
case i2s.receive(size_t n_chans, int32_t in_samps[n_chans]):
|
||||
for (int i = 0; i < n_chans; i++) samples[i] = in_samps[i]; // copy samples
|
||||
break;
|
||||
|
||||
case i2s.send(size_t n_chans, int32_t out_samps[n_chans]):
|
||||
for (int i = 0; i < n_chans; i++) out_samps[i] = samples[i]; // copy samples
|
||||
break;
|
||||
|
||||
case i2s.restart_check() -> i2s_restart_t restart:
|
||||
restart = I2S_NO_RESTART; // Keep on looping
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user