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 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§fn write_iter<B>(&mut self, _address: u8, _bytes: B) -> Result<(), Self::Error>where
B: IntoIterator<Item = u8>,
fn write_iter<B>(&mut self, _address: u8, _bytes: B) -> Result<(), Self::Error>where
B: IntoIterator<Item = u8>,
address
Read moresource§fn write_iter_read<B>(
&mut self,
_address: u8,
_bytes: B,
_buffer: &mut [u8]
) -> Result<(), Self::Error>where
B: IntoIterator<Item = u8>,
fn write_iter_read<B>(
&mut self,
_address: u8,
_bytes: B,
_buffer: &mut [u8]
) -> Result<(), Self::Error>where
B: IntoIterator<Item = u8>,
address
and then reads enough bytes to fill buffer
in a
single transaction Read moresource§fn write_read(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8]
) -> Result<(), Self::Error>
fn write_read(
&mut self,
address: u8,
wr_buffer: &[u8],
rd_buffer: &mut [u8]
) -> Result<(), Self::Error>
address
and then reads enough bytes to fill buffer
in a
single transaction Read moresource§fn transaction<'a>(
&mut self,
_address: u8,
_operations: &mut [Operation<'a>]
) -> Result<(), Self::Error>
fn transaction<'a>(
&mut self,
_address: u8,
_operations: &mut [Operation<'a>]
) -> Result<(), Self::Error>
source§fn transaction_iter<'a, O>(
&mut self,
_address: u8,
_operations: O
) -> Result<(), Self::Error>where
O: IntoIterator<Item = Operation<'a>>,
fn transaction_iter<'a, O>(
&mut self,
_address: u8,
_operations: O
) -> Result<(), Self::Error>where
O: IntoIterator<Item = Operation<'a>>,
source§impl<'d, T: Instance> I2c<u8> for Twim<'d, T>
impl<'d, T: Instance> I2c<u8> for Twim<'d, T>
source§async fn write<'a>(
&'a mut self,
address: u8,
bytes: &'a [u8]
) -> Result<(), Error>
async fn write<'a>(
&'a mut self,
address: u8,
bytes: &'a [u8]
) -> Result<(), Error>
address
Read more