| 1 | // Note: This file is copied and modified from fdcan crate by Richard Meadows |
| 2 | #![allow (non_camel_case_types)] |
| 3 | #![allow (non_snake_case)] |
| 4 | #![allow (unused)] |
| 5 | |
| 6 | use super::enums::{ |
| 7 | BitRateSwitching, ErrorStateIndicator, FilterElementConfig, FilterType, FrameFormat, IdType, |
| 8 | RemoteTransmissionRequest, |
| 9 | }; |
| 10 | use super::generic; |
| 11 | |
| 12 | #[doc = "Reader of field `ID`" ] |
| 13 | pub type ID_R = generic::R<u32, u32>; |
| 14 | |
| 15 | #[doc = "Reader of field `RTR`" ] |
| 16 | pub type RTR_R = generic::R<bool, RemoteTransmissionRequest>; |
| 17 | impl RTR_R { |
| 18 | pub fn rtr(&self) -> RemoteTransmissionRequest { |
| 19 | match self.bits { |
| 20 | false => RemoteTransmissionRequest::TransmitDataFrame, |
| 21 | true => RemoteTransmissionRequest::TransmitRemoteFrame, |
| 22 | } |
| 23 | } |
| 24 | pub fn is_transmit_remote_frame(&self) -> bool { |
| 25 | *self == RemoteTransmissionRequest::TransmitRemoteFrame |
| 26 | } |
| 27 | pub fn is_transmit_data_frame(&self) -> bool { |
| 28 | *self == RemoteTransmissionRequest::TransmitDataFrame |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | #[doc = "Reader of field `XTD`" ] |
| 33 | pub type XTD_R = generic::R<bool, IdType>; |
| 34 | impl XTD_R { |
| 35 | pub fn id_type(&self) -> IdType { |
| 36 | match self.bits() { |
| 37 | false => IdType::StandardId, |
| 38 | true => IdType::ExtendedId, |
| 39 | } |
| 40 | } |
| 41 | pub fn is_standard_id(&self) -> bool { |
| 42 | *self == IdType::StandardId |
| 43 | } |
| 44 | pub fn is_exteded_id(&self) -> bool { |
| 45 | *self == IdType::ExtendedId |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | #[doc = "Reader of field `ESI`" ] |
| 50 | pub type ESI_R = generic::R<bool, ErrorStateIndicator>; |
| 51 | impl ESI_R { |
| 52 | pub fn error_state(&self) -> ErrorStateIndicator { |
| 53 | match self.bits() { |
| 54 | false => ErrorStateIndicator::ErrorActive, |
| 55 | true => ErrorStateIndicator::ErrorPassive, |
| 56 | } |
| 57 | } |
| 58 | pub fn is_error_active(&self) -> bool { |
| 59 | *self == ErrorStateIndicator::ErrorActive |
| 60 | } |
| 61 | pub fn is_error_passive(&self) -> bool { |
| 62 | *self == ErrorStateIndicator::ErrorPassive |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | #[doc = "Reader of field `DLC`" ] |
| 67 | pub type DLC_R = generic::R<u8, u8>; |
| 68 | |
| 69 | #[doc = "Reader of field `BRS`" ] |
| 70 | pub type BRS_R = generic::R<bool, BitRateSwitching>; |
| 71 | impl BRS_R { |
| 72 | pub fn bit_rate_switching(&self) -> BitRateSwitching { |
| 73 | match self.bits() { |
| 74 | true => BitRateSwitching::WithBRS, |
| 75 | false => BitRateSwitching::WithoutBRS, |
| 76 | } |
| 77 | } |
| 78 | pub fn is_with_brs(&self) -> bool { |
| 79 | *self == BitRateSwitching::WithBRS |
| 80 | } |
| 81 | pub fn is_without_brs(&self) -> bool { |
| 82 | *self == BitRateSwitching::WithoutBRS |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | #[doc = "Reader of field `FDF`" ] |
| 87 | pub type FDF_R = generic::R<bool, FrameFormat>; |
| 88 | impl FDF_R { |
| 89 | pub fn frame_format(&self) -> FrameFormat { |
| 90 | match self.bits() { |
| 91 | false => FrameFormat::Classic, |
| 92 | true => FrameFormat::Fdcan, |
| 93 | } |
| 94 | } |
| 95 | pub fn is_classic_format(&self) -> bool { |
| 96 | *self == FrameFormat::Classic |
| 97 | } |
| 98 | pub fn is_fdcan_format(&self) -> bool { |
| 99 | *self == FrameFormat::Fdcan |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | #[doc = "Reader of field `(X|S)FT`" ] |
| 104 | pub type ESFT_R = generic::R<u8, FilterType>; |
| 105 | impl ESFT_R { |
| 106 | #[doc = r"Gets the Filtertype" ] |
| 107 | #[inline (always)] |
| 108 | pub fn to_filter_type(&self) -> FilterType { |
| 109 | match self.bits() { |
| 110 | 0b00 => FilterType::RangeFilter, |
| 111 | 0b01 => FilterType::DualIdFilter, |
| 112 | 0b10 => FilterType::ClassicFilter, |
| 113 | 0b11 => FilterType::FilterDisabled, |
| 114 | _ => unreachable!(), |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | #[doc = "Reader of field `(E|S)FEC`" ] |
| 120 | pub type ESFEC_R = generic::R<u8, FilterElementConfig>; |
| 121 | impl ESFEC_R { |
| 122 | pub fn to_filter_element_config(&self) -> FilterElementConfig { |
| 123 | match self.bits() { |
| 124 | 0b000 => FilterElementConfig::DisableFilterElement, |
| 125 | 0b001 => FilterElementConfig::StoreInFifo0, |
| 126 | 0b010 => FilterElementConfig::StoreInFifo1, |
| 127 | 0b011 => FilterElementConfig::Reject, |
| 128 | 0b100 => FilterElementConfig::SetPriority, |
| 129 | 0b101 => FilterElementConfig::SetPriorityAndStoreInFifo0, |
| 130 | 0b110 => FilterElementConfig::SetPriorityAndStoreInFifo1, |
| 131 | _ => unimplemented!(), |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |