GPIO端口包括 4 个 32 位配置寄存器(GPIOx_MODER、GPIOx_OTYPER、GPIOx_OSPEEDR 和 GPIOx_PUPDR)、2 个 32 位数据寄存器(GPIOx_IDR 和 GPIOx_ODR)、1 个 32 位置位/复位寄存器 (GPIOx_BSRR)、1 个 32 位锁定寄存器 (GPIOx_LCKR) 和 2 个 32 位复用功能选择寄存器(GPIOx_AFRH 和 GPIOx_AFRL)。
* @note This functions uses GPIOx_BSRR register to allow atomic read/modify * accesses. In this way, there is no risk of an IRQ occurring between * the read and the modify access. * @param GPIOx: where x can be (A..I) to select the GPIO peripheral. ...
可以只更改一个或多个位。这是通过对“置位/复位寄存器”(GPIOx_BSRR,复位是GPIOx_BRR)中想要更改的位写’1’来实现的。没被选择的位将不被更改。置位/复位寄存器GPIOx_BSRR 16位的复位寄存器GPIOx_BRR 5.1.3外部中断/唤醒线 所有端口都有外部中断能力。为了使用外部中断线,端口必须配置成输入模式。
impl<MODE> OutputPin for $PXx<Output<MODE>> { type Error = Infallible;fn set_high(&mut self) -> Result<(), Self::Error> { // NOTE(unsafe) atomic write to a stateless register unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << self.i)) };...