Struct stm32_i2s_v12x::driver::I2sDriver
source · pub struct I2sDriver<I, MS, DIR, STD> { /* private fields */ }
Expand description
Driver of a SPI peripheral in I2S mode.
This is meant for advanced usage, for example using interrupt or DMA.
Implementations§
source§impl<I, MS, DIR, STD> I2sDriver<I, MS, DIR, STD>where
I: I2sPeripheral,
impl<I, MS, DIR, STD> I2sDriver<I, MS, DIR, STD>where
I: I2sPeripheral,
Constructors and Destructors
sourcepub fn new(i2s_peripheral: I, config: I2sDriverConfig<MS, DIR, STD>) -> Self
pub fn new(i2s_peripheral: I, config: I2sDriverConfig<MS, DIR, STD>) -> Self
Instantiate an i2s driver from an I2sPeripheral
object and a configuration.
§Panics
This method panics if an exact frequency is required by the configuration and that frequency cannot be set.
sourcepub fn reconfigure<NEW_MS, NEW_DIR, NEW_STD>(
self,
config: I2sDriverConfig<NEW_MS, NEW_DIR, NEW_STD>
) -> I2sDriver<I, NEW_MS, NEW_DIR, NEW_STD>
pub fn reconfigure<NEW_MS, NEW_DIR, NEW_STD>( self, config: I2sDriverConfig<NEW_MS, NEW_DIR, NEW_STD> ) -> I2sDriver<I, NEW_MS, NEW_DIR, NEW_STD>
Consume the driver and create a new one with the given configuration.
source§impl<I, MS, DIR, STD> I2sDriver<I, MS, DIR, STD>where
I: I2sPeripheral,
impl<I, MS, DIR, STD> I2sDriver<I, MS, DIR, STD>where
I: I2sPeripheral,
Methods available in any mode
sourcepub fn disable(&mut self)
pub fn disable(&mut self)
Immediately Disable the I2S peripheral.
Generated clocks aren’t reset, so a call to reset_clocks
may be required in master mode.
It’s up to the caller to not disable the peripheral in the middle of a frame.
sourcepub fn ws_is_high(&self) -> bool
👎Deprecated since 0.4.0: may removed in future, use ws_pin().is_high()
instead
pub fn ws_is_high(&self) -> bool
ws_pin().is_high()
insteadReturn true
if the level on the WS line is high.
sourcepub fn ws_is_low(&self) -> bool
👎Deprecated since 0.4.0: may removed in future, use ws_pin().is_low()
instead
pub fn ws_is_low(&self) -> bool
ws_pin().is_low()
insteadReturn true
if the level on the WS line is low.
sourcepub fn ws_pin_mut(&mut self) -> &mut I::WsPin
pub fn ws_pin_mut(&mut self) -> &mut I::WsPin
Get a mutable reference to the WS pin.
sourcepub fn data_register_address(&self) -> u32
pub fn data_register_address(&self) -> u32
Get the address of the data register for DMA setup.
source§impl<I, DIR, STD> I2sDriver<I, Master, DIR, STD>where
I: I2sPeripheral,
impl<I, DIR, STD> I2sDriver<I, Master, DIR, STD>where
I: I2sPeripheral,
Master-only methods
sourcepub fn reset_clocks(&mut self)
pub fn reset_clocks(&mut self)
Reset clocks generated by the peripheral, and clear status and data registers.
This allows immediately starting a new frame when an error occurs or before re-enabling the driver.
sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Get the actual sample rate imposed by the driver.
This allows client code to check deviation from the requested frequency.
source§impl<I, MS, STD> I2sDriver<I, MS, Transmit, STD>where
I: I2sPeripheral,
impl<I, MS, STD> I2sDriver<I, MS, Transmit, STD>where
I: I2sPeripheral,
Transmit-only methods
sourcepub fn write_data_register(&mut self, value: u16)
pub fn write_data_register(&mut self, value: u16)
Write a raw half word to the Tx buffer and delete the TXE flag in status register.
It’s up to the caller to write the content when the data register is empty.
sourcepub fn set_tx_interrupt(&mut self, enabled: bool)
pub fn set_tx_interrupt(&mut self, enabled: bool)
When set to true
, an interrupt is generated each time the Tx buffer is empty.
sourcepub fn set_tx_dma(&mut self, enabled: bool)
pub fn set_tx_dma(&mut self, enabled: bool)
When set to true
, a DMA request is generated each time the Tx buffer is empty.
source§impl<I, MS, STD> I2sDriver<I, MS, Receive, STD>where
I: I2sPeripheral,
impl<I, MS, STD> I2sDriver<I, MS, Receive, STD>where
I: I2sPeripheral,
Receive-only methods
sourcepub fn read_data_register(&mut self) -> u16
pub fn read_data_register(&mut self) -> u16
Read a raw value from the Rx buffer and delete the RXNE flag in status register.
sourcepub fn set_rx_interrupt(&mut self, enabled: bool)
pub fn set_rx_interrupt(&mut self, enabled: bool)
When set to true
, an interrupt is generated each time the Rx buffer contains a new data.
sourcepub fn set_rx_dma(&mut self, enabled: bool)
pub fn set_rx_dma(&mut self, enabled: bool)
When set to true
, a DMA request is generated each time the Rx buffer contains a new data.
source§impl<I, STD> I2sDriver<I, Master, Receive, STD>where
I: I2sPeripheral,
impl<I, STD> I2sDriver<I, Master, Receive, STD>where
I: I2sPeripheral,
Error interrupt, Master Receive Mode.
sourcepub fn set_error_interrupt(&mut self, enabled: bool)
pub fn set_error_interrupt(&mut self, enabled: bool)
When set to true
, an interrupt is generated each time an error occurs.
This is not available for Master Transmit because no error can occur in this mode.
source§impl<I, DIR, STD> I2sDriver<I, Slave, DIR, STD>where
I: I2sPeripheral,
impl<I, DIR, STD> I2sDriver<I, Slave, DIR, STD>where
I: I2sPeripheral,
Error interrupt, Slave Mode.
sourcepub fn set_error_interrupt(&mut self, enabled: bool)
pub fn set_error_interrupt(&mut self, enabled: bool)
When set to true
, an interrupt is generated each time an error occurs.
This is not available for Master Transmit because no error can occur in this mode.