diff options
| author | kbleeke <[email protected]> | 2023-03-02 15:34:08 +0100 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-03-27 11:48:58 +0200 |
| commit | 6f547cf05ddd1a27c8ec4e107ac227f7f9520ba6 (patch) | |
| tree | e6e374b2b67ef4a1be8fa2a7cedbaf29d2c9cc9c /src/lib.rs | |
| parent | 5da6108bec0c977841df21ae4140c4ac61a5369f (diff) | |
asyncify outgoing events
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/lib.rs b/src/lib.rs index af8f74a6d..069ca40f4 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -11,17 +11,17 @@ mod bus; | |||
| 11 | mod consts; | 11 | mod consts; |
| 12 | mod countries; | 12 | mod countries; |
| 13 | mod events; | 13 | mod events; |
| 14 | mod ioctl; | ||
| 14 | mod structs; | 15 | mod structs; |
| 15 | 16 | ||
| 16 | mod control; | 17 | mod control; |
| 17 | mod nvram; | 18 | mod nvram; |
| 18 | mod runner; | 19 | mod runner; |
| 19 | 20 | ||
| 20 | use core::cell::Cell; | ||
| 21 | |||
| 22 | use embassy_net_driver_channel as ch; | 21 | use embassy_net_driver_channel as ch; |
| 23 | use embedded_hal_1::digital::OutputPin; | 22 | use embedded_hal_1::digital::OutputPin; |
| 24 | use events::EventQueue; | 23 | use events::EventQueue; |
| 24 | use ioctl::IoctlState; | ||
| 25 | 25 | ||
| 26 | use crate::bus::Bus; | 26 | use crate::bus::Bus; |
| 27 | pub use crate::bus::SpiBusCyw43; | 27 | pub use crate::bus::SpiBusCyw43; |
| @@ -30,12 +30,6 @@ pub use crate::runner::Runner; | |||
| 30 | 30 | ||
| 31 | const MTU: usize = 1514; | 31 | const MTU: usize = 1514; |
| 32 | 32 | ||
| 33 | #[derive(Clone, Copy)] | ||
| 34 | pub enum IoctlType { | ||
| 35 | Get = 0, | ||
| 36 | Set = 2, | ||
| 37 | } | ||
| 38 | |||
| 39 | #[allow(unused)] | 33 | #[allow(unused)] |
| 40 | #[derive(Clone, Copy, PartialEq, Eq)] | 34 | #[derive(Clone, Copy, PartialEq, Eq)] |
| 41 | enum Core { | 35 | enum Core { |
| @@ -106,26 +100,8 @@ const CHIP: Chip = Chip { | |||
| 106 | chanspec_ctl_sb_mask: 0x0700, | 100 | chanspec_ctl_sb_mask: 0x0700, |
| 107 | }; | 101 | }; |
| 108 | 102 | ||
| 109 | #[derive(Clone, Copy)] | ||
| 110 | enum IoctlState { | ||
| 111 | Idle, | ||
| 112 | |||
| 113 | Pending { | ||
| 114 | kind: IoctlType, | ||
| 115 | cmd: u32, | ||
| 116 | iface: u32, | ||
| 117 | buf: *mut [u8], | ||
| 118 | }, | ||
| 119 | Sent { | ||
| 120 | buf: *mut [u8], | ||
| 121 | }, | ||
| 122 | Done { | ||
| 123 | resp_len: usize, | ||
| 124 | }, | ||
| 125 | } | ||
| 126 | |||
| 127 | pub struct State { | 103 | pub struct State { |
| 128 | ioctl_state: Cell<IoctlState>, | 104 | ioctl_state: IoctlState, |
| 129 | ch: ch::State<MTU, 4, 4>, | 105 | ch: ch::State<MTU, 4, 4>, |
| 130 | events: EventQueue, | 106 | events: EventQueue, |
| 131 | } | 107 | } |
| @@ -133,7 +109,7 @@ pub struct State { | |||
| 133 | impl State { | 109 | impl State { |
| 134 | pub fn new() -> Self { | 110 | pub fn new() -> Self { |
| 135 | Self { | 111 | Self { |
| 136 | ioctl_state: Cell::new(IoctlState::Idle), | 112 | ioctl_state: IoctlState::new(), |
| 137 | ch: ch::State::new(), | 113 | ch: ch::State::new(), |
| 138 | events: EventQueue::new(), | 114 | events: EventQueue::new(), |
| 139 | } | 115 | } |
