而读写位的定义:
这里面的宏定义,在众多外设.h中都在调用。比如使能USART:
LL库使能USART:
- __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
- {
- SET_BIT(USARTx->CR1, USART_CR1_UE);
- }
标准外设库使能USART:
- void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState)
- {
- /* Check the parameters */
- assert_param(IS_USART_ALL_PERIPH(USARTx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Enable the selected USART by setting the UE bit in the CR1 register */
- USARTx->CR1 |= USART_CR1_UE;
- }
- else
- {
- /* Disable the selected USART by clearing the UE bit in the CR1 register */
- USARTx->CR1 &= (uint16_t)~((uint16_t)USART_CR1_UE);
- }
- }
通过对比,你会明显发现:LL库的执行效率更高。
|