diff options
Diffstat (limited to 'embassy-net-enc28j60/src/common.rs')
| -rw-r--r-- | embassy-net-enc28j60/src/common.rs | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/embassy-net-enc28j60/src/common.rs b/embassy-net-enc28j60/src/common.rs new file mode 100644 index 000000000..ef339dd2a --- /dev/null +++ b/embassy-net-enc28j60/src/common.rs | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | #[allow(dead_code)] | ||
| 2 | #[derive(Clone, Copy)] | ||
| 3 | pub enum Register { | ||
| 4 | ECON1 = 0x1f, | ||
| 5 | ECON2 = 0x1e, | ||
| 6 | EIE = 0x1b, | ||
| 7 | EIR = 0x1c, | ||
| 8 | ESTAT = 0x1d, | ||
| 9 | } | ||
| 10 | |||
| 11 | impl Register { | ||
| 12 | pub(crate) fn addr(&self) -> u8 { | ||
| 13 | *self as u8 | ||
| 14 | } | ||
| 15 | |||
| 16 | pub(crate) fn is_eth_register(&self) -> bool { | ||
| 17 | match *self { | ||
| 18 | Register::ECON1 => true, | ||
| 19 | Register::ECON2 => true, | ||
| 20 | Register::EIE => true, | ||
| 21 | Register::EIR => true, | ||
| 22 | Register::ESTAT => true, | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | impl Into<super::Register> for Register { | ||
| 28 | fn into(self) -> super::Register { | ||
| 29 | super::Register::Common(self) | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | register!(EIE, 0, u8, { | ||
| 34 | #[doc = "Receive Error Interrupt Enable bit"] | ||
| 35 | rxerie @ 0, | ||
| 36 | #[doc = "Transmit Error Interrupt Enable bit"] | ||
| 37 | txerie @ 1, | ||
| 38 | #[doc = "Transmit Enable bit"] | ||
| 39 | txie @ 3, | ||
| 40 | #[doc = "Link Status Change Interrupt Enable bit"] | ||
| 41 | linkie @ 4, | ||
| 42 | #[doc = "DMA Interrupt Enable bit"] | ||
| 43 | dmaie @ 5, | ||
| 44 | #[doc = "Receive Packet Pending Interrupt Enable bit"] | ||
| 45 | pktie @ 6, | ||
| 46 | #[doc = "Global INT Interrupt Enable bit"] | ||
| 47 | intie @ 7, | ||
| 48 | }); | ||
| 49 | |||
| 50 | register!(EIR, 0, u8, { | ||
| 51 | #[doc = "Receive Error Interrupt Flag bit"] | ||
| 52 | rxerif @ 0, | ||
| 53 | #[doc = "Transmit Error Interrupt Flag bit"] | ||
| 54 | txerif @ 1, | ||
| 55 | #[doc = "Transmit Interrupt Flag bit"] | ||
| 56 | txif @ 3, | ||
| 57 | #[doc = "Link Change Interrupt Flag bit"] | ||
| 58 | linkif @ 4, | ||
| 59 | #[doc = "DMA Interrupt Flag bit"] | ||
| 60 | dmaif @ 5, | ||
| 61 | #[doc = "Receive Packet Pending Interrupt Flag bit"] | ||
| 62 | pktif @ 6, | ||
| 63 | }); | ||
| 64 | |||
| 65 | register!(ESTAT, 0, u8, { | ||
| 66 | #[doc = "Clock Ready bit"] | ||
| 67 | clkrdy @ 0, | ||
| 68 | #[doc = "Transmit Abort Error bit"] | ||
| 69 | txabrt @ 1, | ||
| 70 | #[doc = "Receive Busy bit"] | ||
| 71 | rxbusy @ 2, | ||
| 72 | #[doc = "Late Collision Error bit"] | ||
| 73 | latecol @ 4, | ||
| 74 | #[doc = "Ethernet Buffer Error Status bit"] | ||
| 75 | bufer @ 6, | ||
| 76 | #[doc = "INT Interrupt Flag bit"] | ||
| 77 | int @ 7, | ||
| 78 | }); | ||
| 79 | |||
| 80 | register!(ECON2, 0b1000_0000, u8, { | ||
| 81 | #[doc = "Voltage Regulator Power Save Enable bit"] | ||
| 82 | vrps @ 3, | ||
| 83 | #[doc = "Power Save Enable bit"] | ||
| 84 | pwrsv @ 5, | ||
| 85 | #[doc = "Packet Decrement bit"] | ||
| 86 | pktdec @ 6, | ||
| 87 | #[doc = "Automatic Buffer Pointer Increment Enable bit"] | ||
| 88 | autoinc @ 7, | ||
| 89 | }); | ||
| 90 | |||
| 91 | register!(ECON1, 0, u8, { | ||
| 92 | #[doc = "Bank Select bits"] | ||
| 93 | bsel @ 0..1, | ||
| 94 | #[doc = "Receive Enable bi"] | ||
| 95 | rxen @ 2, | ||
| 96 | #[doc = "Transmit Request to Send bit"] | ||
| 97 | txrts @ 3, | ||
| 98 | #[doc = "DMA Checksum Enable bit"] | ||
| 99 | csumen @ 4, | ||
| 100 | #[doc = "DMA Start and Busy Status bit"] | ||
| 101 | dmast @ 5, | ||
| 102 | #[doc = "Receive Logic Reset bit"] | ||
| 103 | rxrst @ 6, | ||
| 104 | #[doc = "Transmit Logic Reset bit"] | ||
| 105 | txrst @ 7, | ||
| 106 | }); | ||
