#define USART_IT_PE ((uint16_t)0x0028)
#define USART_IT_TXE ((uint16_t)0x0727)
#define USART_IT_TC ((uint16_t)0x0626)
#define USART_IT_RXNE ((uint16_t)0x0525)
#define USART_IT_IDLE ((uint16_t)0x0424)
#define USART_IT_LBD ((uint16_t)0x0846)
#define USART_IT_CTS ((uint16_t)0x096A)
#define USART_IT_ERR ((uint16_t)0x0060)
#define USART_IT_ORE ((uint16_t)0x0360)
#define USART_IT_NE ((uint16_t)0x0260)
#define USART_IT_FE ((uint16_t)0x0160)
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一开始也没有跟进函数里面去看,也看蒙了,进去一看就明白了;但发现LZ说的有点不对哦;比如:#define USART_IT_TC ((uint16_t)0x0626)
0x0626 对应的二进制为 0000 0110 0010 0110
/* Get the USART register index */
usartreg = (((uint8_t)USART_IT) >>0x05); 先将低8位右移5位,根据右移后的结果来判断中断标志位是在哪个控制寄存器, 0010 0110>>0x05=1,
if (usartreg == 0x01) /* The IT is in CR1 register */
{
usartxbase += 0x0C;
} 所以USART_IT_TC在CR1寄存器;
然后根据
/* Get the interrupt position */
itpos = USART_IT & IT_Mask; //#define IT_Mask ((uint16_t)0x001F)
itmask = (((uint32_t)0x01) << itpos); 得出USART_IT_TC在CR1寄存器的那一位。
itpos=0000 0110 0010 0110&0x001F=110=6;
itmask = (((uint32_t)0x01) <<6)
CR1的第6位为TCIE
按LZ的说法#define USART_IT_TC ((uint16_t)0x0626)确实可以找到TCIE,但是#define USART_IT_PE ((uint16_t)0x0028)这个呢?就找不到了
一周热门 更多>