static inline void SysCtl_disablePeripheral(SysCtl_PeripheralPCLOCKCR peripheral) { uint16_t regIndex; // 定义寄存器的索引变量 uint16_t bitIndex; // 定义位序号的变量

//
// Decode the peripheral variable. 解码外设变量,将其转换为寄存器和位序号
//
regIndex = (uint16_t)2U * ((uint16_t)peripheral &
                           (uint16_t)SYSCTL_PERIPH_REG_M);
bitIndex = ((uint16_t)peripheral & SYSCTL_PERIPH_BIT_M) >>
           SYSCTL_PERIPH_BIT_S;

EALLOW; // 开启对于系统控制寄存器的访问

//
// Turn off the module clock. 关闭模块的时钟
//
HWREG(CPUSYS_BASE + SYSCTL_O_PCLKCR0 + regIndex) &=
    ~((uint32_t)1U << bitIndex); // 将对应位的时钟控制寄存器清零
EDIS; // 禁止对于系统控制寄存器的访问

原文地址: http://www.cveoy.top/t/topic/fesc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录