Struct embassy_nrf::twim::Twim
source · pub struct Twim<'d, T: Instance> { /* private fields */ }
Expand description
TWI driver.
Implementations§
source§impl<'d, T: Instance> Twim<'d, T>
impl<'d, T: Instance> Twim<'d, T>
sourcepub fn new(
twim: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
sda: impl Peripheral<P = impl GpioPin> + 'd,
scl: impl Peripheral<P = impl GpioPin> + 'd,
config: Config
) -> Self
pub fn new( twim: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, sda: impl Peripheral<P = impl GpioPin> + 'd, scl: impl Peripheral<P = impl GpioPin> + 'd, config: Config ) -> Self
Create a new TWI driver.
sourcepub fn blocking_write(
&mut self,
address: u8,
buffer: &[u8]
) -> Result<(), Error>
pub fn blocking_write( &mut self, address: u8, buffer: &[u8] ) -> Result<(), Error>
Write to an I2C slave.
The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub fn blocking_write_from_ram(
&mut self,
address: u8,
buffer: &[u8]
) -> Result<(), Error>
pub fn blocking_write_from_ram( &mut self, address: u8, buffer: &[u8] ) -> Result<(), Error>
Same as blocking_write
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub fn blocking_read(
&mut self,
address: u8,
buffer: &mut [u8]
) -> Result<(), Error>
pub fn blocking_read( &mut self, address: u8, buffer: &mut [u8] ) -> Result<(), Error>
Read from an I2C slave.
The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub fn blocking_write_read(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8]
) -> Result<(), Error>
pub fn blocking_write_read( &mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8] ) -> Result<(), Error>
Write data to an I2C slave, then read data from the slave without triggering a stop condition between the two.
The buffers must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub fn blocking_write_read_from_ram(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8]
) -> Result<(), Error>
pub fn blocking_write_read_from_ram( &mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8] ) -> Result<(), Error>
Same as blocking_write_read
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub fn blocking_write_timeout(
&mut self,
address: u8,
buffer: &[u8],
timeout: Duration
) -> Result<(), Error>
pub fn blocking_write_timeout( &mut self, address: u8, buffer: &[u8], timeout: Duration ) -> Result<(), Error>
Write to an I2C slave with timeout.
See [blocking_write
].
sourcepub fn blocking_write_from_ram_timeout(
&mut self,
address: u8,
buffer: &[u8],
timeout: Duration
) -> Result<(), Error>
pub fn blocking_write_from_ram_timeout( &mut self, address: u8, buffer: &[u8], timeout: Duration ) -> Result<(), Error>
Same as blocking_write
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub fn blocking_read_timeout(
&mut self,
address: u8,
buffer: &mut [u8],
timeout: Duration
) -> Result<(), Error>
pub fn blocking_read_timeout( &mut self, address: u8, buffer: &mut [u8], timeout: Duration ) -> Result<(), Error>
Read from an I2C slave.
The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub fn blocking_write_read_timeout(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8],
timeout: Duration
) -> Result<(), Error>
pub fn blocking_write_read_timeout( &mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8], timeout: Duration ) -> Result<(), Error>
Write data to an I2C slave, then read data from the slave without triggering a stop condition between the two.
The buffers must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub fn blocking_write_read_from_ram_timeout(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8],
timeout: Duration
) -> Result<(), Error>
pub fn blocking_write_read_from_ram_timeout( &mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8], timeout: Duration ) -> Result<(), Error>
Same as blocking_write_read
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub async fn read(
&mut self,
address: u8,
buffer: &mut [u8]
) -> Result<(), Error>
pub async fn read( &mut self, address: u8, buffer: &mut [u8] ) -> Result<(), Error>
Read from an I2C slave.
The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub async fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Error>
pub async fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Error>
Write to an I2C slave.
The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub async fn write_from_ram(
&mut self,
address: u8,
buffer: &[u8]
) -> Result<(), Error>
pub async fn write_from_ram( &mut self, address: u8, buffer: &[u8] ) -> Result<(), Error>
Same as write
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
sourcepub async fn write_read(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8]
) -> Result<(), Error>
pub async fn write_read( &mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8] ) -> Result<(), Error>
Write data to an I2C slave, then read data from the slave without triggering a stop condition between the two.
The buffers must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub async fn write_read_from_ram(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8]
) -> Result<(), Error>
pub async fn write_read_from_ram( &mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8] ) -> Result<(), Error>
Same as write_read
but will fail instead of copying data into RAM. Consult the module level documentation to learn more.
Trait Implementations§
source§impl<'d, T: Instance> I2c<u8> for Twim<'d, T>
impl<'d, T: Instance> I2c<u8> for Twim<'d, T>
source§fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error>
address
Read moresource§impl<'d, T: Instance> I2c<u8> for Twim<'d, T>
impl<'d, T: Instance> I2c<u8> for Twim<'d, T>
source§async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error>
async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error>
address
Read more