我正在尝试将https://github.com/japaric/blue-pill与不同的微控制器包(https://github.com/nikhilkalige/stm32f411)一起使用。当我尝试这样做时,我遇到了构建错误。
unsafe impl TIM for TIM3 {
| ^^^ expected struct `stm32f411::tim3::RegisterBlock`, found struct `stm32f411::tim2::RegisterBlock`
|
= note: expected type `stm32f411::tim3::RegisterBlock`
found type `stm32f411::tim2::RegisterBlock`
= note: required by `timer::TIM`
我很难理解为什么在不改变微控制器包的情况下使用它时会首先编译。特征实现如下
/// IMPLEMENTATION DETAIL
pub unsafe trait TIM: Deref<Target = tim2::RegisterBlock> {
/// IMPLEMENTATION DETAIL
type GPIO: Deref<Target = gpioa::RegisterBlock>;
}
unsafe impl TIM for TIM2 {
type GPIO = GPIOA;
}
unsafe impl TIM for TIM3 {
type GPIO = GPIOA;
}
unsafe impl TIM for TIM4 {
type GPIO = GPIOB;
}
因此,当您为TIM
实施TIM3
时,它是否应该访问tim3::RegisterBlock
?和type GPIO = GPIOB