1use crate::error;
2use crate::gpio;
3use core::pin;
4use core::task;
5use nrf52840_hal::gpio as hal_gpio;
6use nrf52840_hal::gpio::p0;
7
8#[derive(Clone, Copy, Debug)]
9pub struct I2c;
10
11#[derive(Clone, Copy, Debug)]
12pub struct I2cRead {}
13
14#[derive(Clone, Copy, Debug)]
15pub struct I2cWrite {}
16
17#[derive(Clone, Copy, Debug)]
18pub struct I2cMapping<SDA, SCL>(SDA, SCL);
19
20impl
21 embedded_platform::i2c::I2cBusMapping<
22 gpio::Pin<p0::P0_26<hal_gpio::Input<hal_gpio::Floating>>>,
23 gpio::Pin<p0::P0_27<hal_gpio::Input<hal_gpio::Floating>>>,
24 >
25 for I2cMapping<
26 gpio::Pin<p0::P0_26<hal_gpio::Input<hal_gpio::Floating>>>,
27 gpio::Pin<p0::P0_27<hal_gpio::Input<hal_gpio::Floating>>>,
28 >
29{
30 type Error = error::Error;
31 type Bus = I2c;
32
33 fn poll_initialize(
34 self: pin::Pin<&mut Self>,
35 cx: &mut task::Context<'_>,
36 sda: &mut gpio::Pin<p0::P0_26<hal_gpio::Input<hal_gpio::Floating>>>,
37 scl: &mut gpio::Pin<p0::P0_27<hal_gpio::Input<hal_gpio::Floating>>>,
38 ) -> task::Poll<Result<Self::Bus, Self::Error>>
39 where
40 Self: Sized,
41 {
42 unimplemented!()
43 }
44}
45
46impl embedded_platform::i2c::I2cRead for I2c {
47 type Error = error::Error;
48 type Read = I2cRead;
49
50 fn poll_begin_read(
51 self: pin::Pin<&mut Self>,
52 cx: &mut task::Context<'_>,
53 addr: u8,
54 ) -> task::Poll<Result<Self::Read, Self::Error>> {
55 unimplemented!()
56 }
57}
58
59impl embedded_platform::io::Read for I2cRead {
60 type Error = error::Error;
61
62 fn poll_read(
63 self: pin::Pin<&mut Self>,
64 cx: &mut task::Context<'_>,
65 buffer: &mut [u8],
66 ) -> task::Poll<Result<usize, Self::Error>> {
67 unimplemented!()
68 }
69}
70
71impl embedded_platform::i2c::I2cWrite for I2c {
72 type Error = error::Error;
73 type Write = I2cWrite;
74
75 fn poll_begin_write(
76 self: pin::Pin<&mut Self>,
77 cx: &mut task::Context<'_>,
78 addr: u8,
79 ) -> task::Poll<Result<Self::Write, Self::Error>> {
80 unimplemented!()
81 }
82}
83
84impl embedded_platform::io::Write for I2cWrite {
85 type Error = error::Error;
86
87 fn poll_write(
88 self: pin::Pin<&mut Self>,
89 cx: &mut task::Context<'_>,
90 bytes: &[u8],
91 ) -> task::Poll<Result<usize, Self::Error>> {
92 unimplemented!()
93 }
94
95 fn poll_shutdown(
96 self: pin::Pin<&mut Self>,
97 cx: &mut task::Context<'_>,
98 ) -> task::Poll<Result<(), Self::Error>> {
99 unimplemented!()
100 }
101}