diff options
| author | elagil <[email protected]> | 2024-08-24 20:16:00 +0200 |
|---|---|---|
| committer | elagil <[email protected]> | 2024-08-24 20:16:00 +0200 |
| commit | 87e97fb69d31606456ddbf9e3308364773648929 (patch) | |
| tree | d82cbb79b30e8bdb8f42e3df4ba3deb7b9cea1e8 | |
| parent | b88dc137e766d89eca5472bfa6f3bb78cfd1f7e0 (diff) | |
feat: add function to check if SAI is muted
| -rw-r--r-- | embassy-stm32/src/sai/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs index c48d81b5f..6bf184dd8 100644 --- a/embassy-stm32/src/sai/mod.rs +++ b/embassy-stm32/src/sai/mod.rs | |||
| @@ -987,6 +987,21 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> { | |||
| 987 | ch.cr2().modify(|w| w.set_mute(value)); | 987 | ch.cr2().modify(|w| w.set_mute(value)); |
| 988 | } | 988 | } |
| 989 | 989 | ||
| 990 | /// Determine the mute state of the receiver. | ||
| 991 | /// | ||
| 992 | /// Clears the mute state flag in the status register. | ||
| 993 | pub fn is_muted(&self) -> Result<bool, Error> { | ||
| 994 | match &self.ring_buffer { | ||
| 995 | RingBuffer::Readable(_) => { | ||
| 996 | let ch = T::REGS.ch(self.sub_block as usize); | ||
| 997 | let mute_state = ch.sr().read().mutedet(); | ||
| 998 | ch.clrfr().write(|w| w.set_cmutedet(true)); | ||
| 999 | Ok(mute_state) | ||
| 1000 | } | ||
| 1001 | _ => Err(Error::NotAReceiver), | ||
| 1002 | } | ||
| 1003 | } | ||
| 1004 | |||
| 990 | /// Write data to the SAI ringbuffer. | 1005 | /// Write data to the SAI ringbuffer. |
| 991 | /// | 1006 | /// |
| 992 | /// This appends the data to the buffer and returns immediately. The | 1007 | /// This appends the data to the buffer and returns immediately. The |
