mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add a static flag for interrupt hooking of the codec object
the init() function on this object may actually be called several times within a single boot context because the codec is powered down as a separate subsystem from the rest. however, the interrupt should still only be hooked exactly once. This flag tracks that state.
This commit is contained in:
parent
6ef684fd8c
commit
af982aef30
1 changed files with 6 additions and 1 deletions
|
|
@ -6,6 +6,9 @@ use susres::{RegManager, RegOrField, SuspendResume};
|
||||||
use llio::I2cStatus;
|
use llio::I2cStatus;
|
||||||
use crate::api::*;
|
use crate::api::*;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
use core::sync::atomic::{AtomicBool, Ordering::SeqCst};
|
||||||
|
|
||||||
|
static INTERRUPT_HOOKED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
pub const TLV320AIC3100_I2C_ADR: u8 = 0b0011_000;
|
pub const TLV320AIC3100_I2C_ADR: u8 = 0b0011_000;
|
||||||
const I2C_TIMEOUT: u32 = 50;
|
const I2C_TIMEOUT: u32 = 50;
|
||||||
|
|
@ -181,7 +184,8 @@ impl Codec {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&mut self) {
|
pub fn init(&mut self) {
|
||||||
if ! self.initialized {
|
// this should only be called once per reboot
|
||||||
|
if !INTERRUPT_HOOKED.swap(true, SeqCst) {
|
||||||
xous::claim_interrupt(
|
xous::claim_interrupt(
|
||||||
utra::audio::AUDIO_IRQ,
|
utra::audio::AUDIO_IRQ,
|
||||||
audio_handler,
|
audio_handler,
|
||||||
|
|
@ -196,6 +200,7 @@ impl Codec {
|
||||||
self.susres_manager.push(RegOrField::Reg(utra::audio::EV_ENABLE), None);
|
self.susres_manager.push(RegOrField::Reg(utra::audio::EV_ENABLE), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this may be called repeatedly, e.g if the code was put through suspend/resume
|
||||||
log::trace!("audio_clocks");
|
log::trace!("audio_clocks");
|
||||||
self.audio_clocks();
|
self.audio_clocks();
|
||||||
log::trace!("audio_ports");
|
log::trace!("audio_ports");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue