为什么做can通信的函数中都有can_page的读取和最后的写入操作,不可以直接用PSR寄存器控制页面吗?
void CAN_ITConfig(CAN_IT_TypeDef CAN_IT, FunctionalState NewState)
{
uint8_t tmperrorinterrupt = 0;
CAN_Page_TypeDef can_page = CAN_GetSelectedPage();
/* Check the parameters */
assert_param(IS_CAN_IT_CONFIG_OK(CAN_IT));
assert_param(IS_FUNCTIONALSTATE_OK(NewState));
tmperrorinterrupt = (uint8_t)(((uint16_t)CAN_IT) >>7);
tmperrorinterrupt = (uint8_t)((uint8_t)((uint16_t)tmperrorinterrupt & 0xF0) |
(uint8_t)((uint8_t)((uint16_t)tmperrorinterrupt & 0x0F) >>1));
CAN->PSR = CAN_Page_Config;
if (NewState != DISABLE)
{
/* Enable the selected CAN interrupt */
CAN->IER |= (uint8_t)(CAN_IT);
CAN->Page.Config.EIER |= (uint8_t)(tmperrorinterrupt);
}
else
{
/* Disable the selected CAN interrupt */
CAN->IER &= (uint8_t)~(uint8_t)((uint16_t)CAN_IT);
CAN->Page.Config.EIER &= (uint8_t)~(tmperrorinterrupt);
}
/*Restore Last Page*/
CAN_SelectPage(can_page);
}
|