Minor changes
This commit is contained in:
parent
d2e8794f29
commit
17857bc18f
@ -327,6 +327,7 @@ impl<'d, T: Instance> I2S<'d, T> {
|
||||
pub fn start(&self) -> &Self {
|
||||
let r = T::regs();
|
||||
self.enable();
|
||||
trace!("START");
|
||||
r.tasks_start.write(|w| unsafe { w.bits(1) });
|
||||
self
|
||||
}
|
||||
@ -487,8 +488,8 @@ impl<'d, T: Instance> I2sOutput<'d, T> {
|
||||
let s = T::state();
|
||||
|
||||
let seq = s.seq.fetch_add(1, Ordering::Relaxed);
|
||||
if r.events_txptrupd.read().bits() != 0 && seq > 0 {
|
||||
info!("XRUN!");
|
||||
if r.events_txptrupd.read().bits() != 0 && seq > 1 {
|
||||
warn!("XRUN!");
|
||||
loop {}
|
||||
}
|
||||
|
||||
@ -505,8 +506,8 @@ impl<'d, T: Instance> I2sOutput<'d, T> {
|
||||
});
|
||||
|
||||
trace!("[{}] PTR", s.seq.load(Ordering::Relaxed));
|
||||
r.txd.ptr.write(|w| unsafe { w.ptr().bits(ptr as u32) });
|
||||
r.rxtxd.maxcnt.write(|w| unsafe { w.bits(maxcnt) });
|
||||
r.txd.ptr.write(|w| unsafe { w.ptr().bits(ptr as u32) });
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
|
||||
@ -517,7 +518,7 @@ impl<'d, T: Instance> I2sOutput<'d, T> {
|
||||
r.events_txptrupd.reset();
|
||||
r.intenset.write(|w| w.txptrupd().set());
|
||||
let overruns = s.overruns.fetch_sub(1, Ordering::Relaxed);
|
||||
if overruns - 1 != 0 {
|
||||
if overruns != 0 {
|
||||
warn!("XRUN: {}", overruns);
|
||||
s.overruns.store(0, Ordering::Relaxed)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) {
|
||||
let irq = interrupt::take!(I2S);
|
||||
let mut i2s = i2s::I2S::new(p.I2S, irq, p.P0_28, p.P0_29, p.P0_31, p.P0_11, p.P0_30, config);
|
||||
|
||||
const BUF_SAMPLES: usize = 250;
|
||||
const BUF_SAMPLES: usize = 500;
|
||||
const BUF_SIZE: usize = BUF_SAMPLES * 2;
|
||||
let mut buf = AlignedBuffer([0i16; BUF_SIZE]);
|
||||
|
||||
@ -56,7 +56,6 @@ async fn main(_spawner: Spawner) {
|
||||
// modulator.set_frequency(0.01, inv_sample_rate);
|
||||
// modulator.set_amplitude(0.2);
|
||||
|
||||
let mut lastf = 0.0;
|
||||
let mut generate = |buf: &mut [i16]| {
|
||||
for sample in buf.as_mut().chunks_mut(2) {
|
||||
let signal = carrier.generate();
|
||||
@ -71,12 +70,14 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
generate(buf.as_mut().as_mut_slice());
|
||||
|
||||
if let Err(err) = i2s.tx(buf.as_ref().as_slice()).await {
|
||||
error!("{}", err);
|
||||
}
|
||||
|
||||
i2s.set_tx_enabled(true);
|
||||
i2s.start();
|
||||
|
||||
loop {
|
||||
// info!("--");
|
||||
|
||||
generate(buf.as_mut().as_mut_slice());
|
||||
|
||||
if let Err(err) = i2s.tx(buf.as_ref().as_slice()).await {
|
||||
|
Loading…
Reference in New Issue
Block a user