Use unborrow for CRC constructor

sort feature gates
fix repetition in CRC config names
This commit is contained in:
Joshua Salzedo
2021-09-27 10:38:55 -07:00
parent 7392e33ad5
commit 43ad28b9f9
3 changed files with 26 additions and 18 deletions

View File

@ -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,
};