Use unborrow for CRC constructor
sort feature gates fix repetition in CRC config names
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
use crate::pac::CRC as PAC_CRC;
|
||||
use crate::peripherals::CRC;
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
use embassy_hal_common::unborrow;
|
||||
use embassy::util::Unborrow;
|
||||
|
||||
|
||||
pub struct Crc {
|
||||
_peripheral: CRC,
|
||||
@ -8,12 +11,14 @@ pub struct Crc {
|
||||
|
||||
impl Crc {
|
||||
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
||||
pub fn new(peripheral: CRC) -> Self {
|
||||
pub fn new(peripheral: impl Unborrow<Target= CRC>) -> Self {
|
||||
// Note: enable and reset come from RccPeripheral.
|
||||
// enable CRC clock in RCC.
|
||||
CRC::enable();
|
||||
// Reset CRC to default values.
|
||||
CRC::reset();
|
||||
// Unborrow the peripheral
|
||||
unborrow!(peripheral);
|
||||
let mut instance = Self {
|
||||
_peripheral: peripheral,
|
||||
};
|
||||
|
Reference in New Issue
Block a user