stm32f1xx-hal icon indicating copy to clipboard operation
stm32f1xx-hal copied to clipboard

Rcc improvement

Open AndreySmirnov81 opened this issue 3 years ago • 6 comments

AndreySmirnov81 avatar Mar 14 '22 12:03 AndreySmirnov81

Sorry. @burrbull, please explain why "impairment"?

AndreySmirnov81 avatar Mar 14 '22 13:03 AndreySmirnov81

Because I don't see any "improvement".

  1. If you delete RCC dependency, you need mark enable & reset with unsafe
  2. What sense of &self requirement? (not sure about this)
  3. steal(). Again.

burrbull avatar Mar 14 '22 13:03 burrbull

@burrbull

  1. What is the reason unsafe? I think that after switching to using bit-banding, the need for &rcc disappeared.
  2. &self is needed so that only the owner of the corresponding peripheral can do enable and reset for it. This will help to avoid mistakes like this:
   pub fn initialize(
      ...
      tim2: pac::TIM2,
      ...
   ) -> Self {
      ...
      let rcc = unsafe { &(*pac::RCC::PTR) };
      pac::TIM1::enable(rcc);
      pac::TIM1::reset(rcc);
      ...
   }
  1. A temporary way out of the situation. In the future, it is necessary to make a similar change in the stm32-usbd create: Usb Peripheral::enable() -> UsbPeripheral::enable(&self). Is steal() acceptable here https://github.com/stm32-rs/stm32f3xx-hal/blob/565b43ceab7b8255c122e82f4f1f1f2b3e85f11b/src/serial.rs#L1270 ? I believe that using steal() in certain situations is quite acceptable.

AndreySmirnov81 avatar Mar 14 '22 13:03 AndreySmirnov81

Please review and merge.

AndreySmirnov81 avatar Mar 18 '22 07:03 AndreySmirnov81

@burrbull Do you agree with the changes?

AndreySmirnov81 avatar Sep 26 '22 13:09 AndreySmirnov81

@therealprof, @TheZoq2 Please review

AndreySmirnov81 avatar Oct 07 '22 08:10 AndreySmirnov81