aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf
diff options
context:
space:
mode:
authorHenrik Alsér <[email protected]>2022-11-22 22:10:04 +0100
committerHenrik Alsér <[email protected]>2022-11-22 22:10:04 +0100
commitcf900a8a3f048428cc1209763f4188366818ab8a (patch)
treed5ba4b7de5e342f196c26bb9b5e91b5765c91af4 /examples/nrf
parent633ffe46aea29bb4c8eec030cbfd6b93867fe79c (diff)
Rename write to respond_to_read
Diffstat (limited to 'examples/nrf')
-rw-r--r--examples/nrf/src/bin/twis.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/nrf/src/bin/twis.rs b/examples/nrf/src/bin/twis.rs
index a34bb2711..54cba9494 100644
--- a/examples/nrf/src/bin/twis.rs
+++ b/examples/nrf/src/bin/twis.rs
@@ -22,20 +22,21 @@ async fn main(_spawner: Spawner) {
22 22
23 info!("Listening..."); 23 info!("Listening...");
24 loop { 24 loop {
25 let response = [1, 2, 3, 4, 5, 6, 7, 8];
26 // This buffer is used if the i2c master performs a Write or WriteRead
25 let mut buf = [0u8; 16]; 27 let mut buf = [0u8; 16];
26 let tx_buf = [1, 2, 3, 4, 5, 6, 7, 8];
27 match i2c.listen(&mut buf).await { 28 match i2c.listen(&mut buf).await {
28 Ok(Command::Read) => { 29 Ok(Command::Read) => {
29 info!("Got READ command. Writing back data:\n{:?}\n", tx_buf); 30 info!("Got READ command. Respond with data:\n{:?}\n", response);
30 if let Err(e) = i2c.write(&tx_buf).await { 31 if let Err(e) = i2c.respond_to_read(&response).await {
31 error!("{:?}", e); 32 error!("{:?}", e);
32 } 33 }
33 } 34 }
34 Ok(Command::Write(n)) => info!("Got WRITE command with data:\n{:?}\n", buf[..n]), 35 Ok(Command::Write(n)) => info!("Got WRITE command with data:\n{:?}\n", buf[..n]),
35 Ok(Command::WriteRead(n)) => { 36 Ok(Command::WriteRead(n)) => {
36 info!("Got WRITE/READ command with data:\n{:?}", buf[..n]); 37 info!("Got WRITE/READ command with data:\n{:?}", buf[..n]);
37 info!("Writing back data:\n{:?}\n", tx_buf); 38 info!("Respond with data:\n{:?}\n", response);
38 if let Err(e) = i2c.write(&tx_buf).await { 39 if let Err(e) = i2c.respond_to_read(&response).await {
39 error!("{:?}", e); 40 error!("{:?}", e);
40 } 41 }
41 } 42 }