mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-02 14:44:32 +00:00
Merge pull request #4267 from melvdlin/stm32-qspi-from
convert embassy-stm32::qspi::enums `Into` impls into equivalant `From` impls
This commit is contained in:
commit
9b8d6d6f22
@ -9,9 +9,9 @@ pub(crate) enum QspiMode {
|
|||||||
MemoryMapped,
|
MemoryMapped,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for QspiMode {
|
impl From<QspiMode> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: QspiMode) -> Self {
|
||||||
match self {
|
match val {
|
||||||
QspiMode::IndirectWrite => 0b00,
|
QspiMode::IndirectWrite => 0b00,
|
||||||
QspiMode::IndirectRead => 0b01,
|
QspiMode::IndirectRead => 0b01,
|
||||||
QspiMode::AutoPolling => 0b10,
|
QspiMode::AutoPolling => 0b10,
|
||||||
@ -34,9 +34,9 @@ pub enum QspiWidth {
|
|||||||
QUAD,
|
QUAD,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for QspiWidth {
|
impl From<QspiWidth> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: QspiWidth) -> Self {
|
||||||
match self {
|
match val {
|
||||||
QspiWidth::NONE => 0b00,
|
QspiWidth::NONE => 0b00,
|
||||||
QspiWidth::SING => 0b01,
|
QspiWidth::SING => 0b01,
|
||||||
QspiWidth::DUAL => 0b10,
|
QspiWidth::DUAL => 0b10,
|
||||||
@ -55,9 +55,9 @@ pub enum FlashSelection {
|
|||||||
Flash2,
|
Flash2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<bool> for FlashSelection {
|
impl From<FlashSelection> for bool {
|
||||||
fn into(self) -> bool {
|
fn from(val: FlashSelection) -> Self {
|
||||||
match self {
|
match val {
|
||||||
FlashSelection::Flash1 => false,
|
FlashSelection::Flash1 => false,
|
||||||
FlashSelection::Flash2 => true,
|
FlashSelection::Flash2 => true,
|
||||||
}
|
}
|
||||||
@ -94,9 +94,9 @@ pub enum MemorySize {
|
|||||||
Other(u8),
|
Other(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for MemorySize {
|
impl From<MemorySize> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: MemorySize) -> Self {
|
||||||
match self {
|
match val {
|
||||||
MemorySize::_1KiB => 9,
|
MemorySize::_1KiB => 9,
|
||||||
MemorySize::_2KiB => 10,
|
MemorySize::_2KiB => 10,
|
||||||
MemorySize::_4KiB => 11,
|
MemorySize::_4KiB => 11,
|
||||||
@ -138,9 +138,9 @@ pub enum AddressSize {
|
|||||||
_32bit,
|
_32bit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for AddressSize {
|
impl From<AddressSize> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: AddressSize) -> Self {
|
||||||
match self {
|
match val {
|
||||||
AddressSize::_8Bit => 0b00,
|
AddressSize::_8Bit => 0b00,
|
||||||
AddressSize::_16Bit => 0b01,
|
AddressSize::_16Bit => 0b01,
|
||||||
AddressSize::_24bit => 0b10,
|
AddressSize::_24bit => 0b10,
|
||||||
@ -163,9 +163,9 @@ pub enum ChipSelectHighTime {
|
|||||||
_8Cycle,
|
_8Cycle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for ChipSelectHighTime {
|
impl From<ChipSelectHighTime> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: ChipSelectHighTime) -> Self {
|
||||||
match self {
|
match val {
|
||||||
ChipSelectHighTime::_1Cycle => 0,
|
ChipSelectHighTime::_1Cycle => 0,
|
||||||
ChipSelectHighTime::_2Cycle => 1,
|
ChipSelectHighTime::_2Cycle => 1,
|
||||||
ChipSelectHighTime::_3Cycle => 2,
|
ChipSelectHighTime::_3Cycle => 2,
|
||||||
@ -216,9 +216,9 @@ pub enum FIFOThresholdLevel {
|
|||||||
_32Bytes,
|
_32Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for FIFOThresholdLevel {
|
impl From<FIFOThresholdLevel> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: FIFOThresholdLevel) -> Self {
|
||||||
match self {
|
match val {
|
||||||
FIFOThresholdLevel::_1Bytes => 0,
|
FIFOThresholdLevel::_1Bytes => 0,
|
||||||
FIFOThresholdLevel::_2Bytes => 1,
|
FIFOThresholdLevel::_2Bytes => 1,
|
||||||
FIFOThresholdLevel::_3Bytes => 2,
|
FIFOThresholdLevel::_3Bytes => 2,
|
||||||
@ -293,9 +293,9 @@ pub enum DummyCycles {
|
|||||||
_31,
|
_31,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for DummyCycles {
|
impl From<DummyCycles> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(val: DummyCycles) -> Self {
|
||||||
match self {
|
match val {
|
||||||
DummyCycles::_0 => 0,
|
DummyCycles::_0 => 0,
|
||||||
DummyCycles::_1 => 1,
|
DummyCycles::_1 => 1,
|
||||||
DummyCycles::_2 => 2,
|
DummyCycles::_2 => 2,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user