⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_can.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 4 页
字号:
    671          
    672            /* Sleep mode entering request */
    673            CAN->MCR |= CAN_MCR_SLEEP;
    674            SleepStatus = CANSLEEPOK;
    675          
    676            /* Sleep mode status */
    677            if ((CAN->MCR&CAN_MCR_SLEEP) == 0)
    678            {
    679              /* Sleep mode not entered */
    680              SleepStatus = CANSLEEPFAILED;
    681            }
    682          
    683            /* At this step, sleep mode status */
    684            return SleepStatus;
    685          }
    686          
    687          /*******************************************************************************
    688          * Function Name  : CAN_WakeUp
    689          * Description    : Wakes the CAN up.
    690          * Input          : None.
    691          * Output         : None.
    692          * Return         : CANWAKEUPOK if sleep mode left, CANWAKEUPFAILED in an other
    693          *                  case.
    694          *******************************************************************************/
    695          u8 CAN_WakeUp(void)
    696          {
    697            u8 WakeUpStatus = 0;
    698          
    699            /* Wake up request */
    700            CAN->MCR &= ~CAN_MCR_SLEEP;
    701            WakeUpStatus = CANWAKEUPFAILED;
    702          
    703            /* Sleep mode status */
    704            if ((CAN->MCR&CAN_MCR_SLEEP) == 0)
    705            {
    706              /* Sleep mode exited */
    707              WakeUpStatus = CANWAKEUPOK;
    708            }
    709          
    710            /* At this step, sleep mode status */
    711            return WakeUpStatus;
    712          }
    713          
    714          /*******************************************************************************
    715          * Function Name  : CAN_GetFlagStatus
    716          * Description    : Checks whether the specified CAN flag is set or not.
    717          * Input          : CAN_FLAG: specifies the flag to check.
    718          *                  This parameter can be: CAN_FLAG_EWG, CAN_FLAG_EPV or
    719          *                                         CAN_FLAG_BOF.
    720          * Output         : None.
    721          * Return         : The new state of CAN_FLAG (SET or RESET).
    722          *******************************************************************************/
    723          FlagStatus CAN_GetFlagStatus(u32 CAN_FLAG)
    724          {
    725            FlagStatus bitstatus = RESET;
    726          
    727            /* Check the parameters */
    728            assert_param(IS_CAN_FLAG(CAN_FLAG));
    729          
    730            /* Check the status of the specified CAN flag */
    731            if ((CAN->ESR & CAN_FLAG) != (u32)RESET)
    732            {
    733              /* CAN_FLAG is set */
    734              bitstatus = SET;
    735            }
    736            else
    737            {
    738              /* CAN_FLAG is reset */
    739              bitstatus = RESET;
    740            }
    741            /* Return the CAN_FLAG status */
    742            return  bitstatus;
    743          }
    744          
    745          /*******************************************************************************
    746          * Function Name  : CAN_ClearFlag
    747          * Description    : Clears the CAN's pending flags.
    748          * Input          : CAN_FLAG: specifies the flag to clear.
    749          * Output         : None.
    750          * Return         : None.
    751          *******************************************************************************/
    752          void CAN_ClearFlag(u32 CAN_FLAG)
    753          {
    754            /* Check the parameters */
    755            assert_param(IS_CAN_FLAG(CAN_FLAG));
    756          
    757            /* Clear the selected CAN flags */
    758            CAN->ESR &= ~CAN_FLAG;
    759          }
    760          
    761          /*******************************************************************************
    762          * Function Name  : CAN_GetITStatus
    763          * Description    : Checks whether the specified CAN interrupt has occurred or 
    764          *                  not.
    765          * Input          : CAN_IT: specifies the CAN interrupt source to check.
    766          *                  This parameter can be: CAN_IT_RQCP0, CAN_IT_RQCP1, CAN_IT_RQCP2,
    767          *                                         CAN_IT_FF0, CAN_IT_FOV0, CAN_IT_FF1,
    768          *                                         CAN_IT_FOV1, CAN_IT_EWG, CAN_IT_EPV, 
    769          *                                         CAN_IT_BOF, CAN_IT_WKU or CAN_IT_SLK.
    770          * Output         : None.
    771          * Return         : The new state of CAN_IT (SET or RESET).
    772          *******************************************************************************/
    773          ITStatus CAN_GetITStatus(u32 CAN_IT)
    774          {
    775            ITStatus pendingbitstatus = RESET;
    776          
    777            /* Check the parameters */
    778            assert_param(IS_CAN_ITStatus(CAN_IT));
    779          
    780            switch (CAN_IT)
    781            {
    782              case CAN_IT_RQCP0:
    783                pendingbitstatus = CheckITStatus(CAN->TSR, CAN_TSR_RQCP0);
    784                break;
    785              case CAN_IT_RQCP1:
    786                pendingbitstatus = CheckITStatus(CAN->TSR, CAN_TSR_RQCP1);
    787                break;
    788              case CAN_IT_RQCP2:
    789                pendingbitstatus = CheckITStatus(CAN->TSR, CAN_TSR_RQCP2);
    790                break;
    791              case CAN_IT_FF0:
    792                pendingbitstatus = CheckITStatus(CAN->RF0R, CAN_RF0R_FULL0);
    793                break;
    794              case CAN_IT_FOV0:
    795                pendingbitstatus = CheckITStatus(CAN->RF0R, CAN_RF0R_FOVR0);
    796                break;
    797              case CAN_IT_FF1:
    798                pendingbitstatus = CheckITStatus(CAN->RF1R, CAN_RF1R_FULL1);
    799                break;
    800              case CAN_IT_FOV1:
    801                pendingbitstatus = CheckITStatus(CAN->RF1R, CAN_RF1R_FOVR1);
    802                break;
    803              case CAN_IT_EWG:
    804                pendingbitstatus = CheckITStatus(CAN->ESR, CAN_ESR_EWGF);
    805                break;
    806              case CAN_IT_EPV:
    807                pendingbitstatus = CheckITStatus(CAN->ESR, CAN_ESR_EPVF);
    808                break;
    809              case CAN_IT_BOF:
    810                pendingbitstatus = CheckITStatus(CAN->ESR, CAN_ESR_BOFF);
    811                break;
    812              case CAN_IT_SLK:
    813                pendingbitstatus = CheckITStatus(CAN->MSR, CAN_MSR_SLAKI);
    814                break;
    815              case CAN_IT_WKU:
    816                pendingbitstatus = CheckITStatus(CAN->MSR, CAN_MSR_WKUI);
    817                break;
    818          
    819              default :
    820                pendingbitstatus = RESET;
    821                break;
    822            }
    823          
    824            /* Return the CAN_IT status */
    825            return  pendingbitstatus;
    826          }
    827          
    828          /*******************************************************************************
    829          * Function Name  : CAN_ClearITPendingBit
    830          * Description    : Clears the CAN抯 interrupt pending bits.
    831          * Input          : CAN_IT: specifies the interrupt pending bit to clear.
    832          * Output         : None.
    833          * Return         : None.
    834          *******************************************************************************/
    835          void CAN_ClearITPendingBit(u32 CAN_IT)
    836          {
    837            /* Check the parameters */
    838            assert_param(IS_CAN_ITStatus(CAN_IT));
    839          
    840            switch (CAN_IT)
    841            {
    842              case CAN_IT_RQCP0:
    843                CAN->TSR = CAN_TSR_RQCP0; /* rc_w1*/
    844                break;
    845              case CAN_IT_RQCP1:
    846                CAN->TSR = CAN_TSR_RQCP1; /* rc_w1*/
    847                break;
    848              case CAN_IT_RQCP2:
    849                CAN->TSR = CAN_TSR_RQCP2; /* rc_w1*/
    850                break;
    851              case CAN_IT_FF0:
    852                CAN->RF0R = CAN_RF0R_FULL0; /* rc_w1*/
    853                break;
    854              case CAN_IT_FOV0:
    855                CAN->RF0R = CAN_RF0R_FOVR0; /* rc_w1*/
    856                break;
    857              case CAN_IT_FF1:
    858                CAN->RF1R = CAN_RF1R_FULL1; /* rc_w1*/
    859                break;
    860              case CAN_IT_FOV1:
    861                CAN->RF1R = CAN_RF1R_FOVR1; /* rc_w1*/
    862                break;
    863              case CAN_IT_EWG:
    864                CAN->ESR &= ~ CAN_ESR_EWGF; /* rw */
    865                break;
    866              case CAN_IT_EPV:
    867                CAN->ESR &= ~ CAN_ESR_EPVF; /* rw */
    868                break;
    869              case CAN_IT_BOF:
    870                CAN->ESR &= ~ CAN_ESR_BOFF; /* rw */
    871                break;
    872              case CAN_IT_WKU:
    873                CAN->MSR = CAN_MSR_WKUI;  /* rc_w1*/
    874                break;
    875              case CAN_IT_SLK:
    876                CAN->MSR = CAN_MSR_SLAKI;  /* rc_w1*/
    877                break;
    878              default :
    879                break;
    880            }
    881          }
    882          
    883          /*******************************************************************************
    884          * Function Name  : CheckITStatus
    885          * Description    : Checks whether the CAN interrupt has occurred or not.
    886          * Input          : CAN_Reg: specifies the CAN interrupt register to check.
    887          *                  It_Bit: specifies the interrupt source bit to check.
    888          * Output         : None.
    889          * Return         : The new state of the CAN Interrupt (SET or RESET).
    890          *******************************************************************************/
    891          static ITStatus CheckITStatus(u32 CAN_Reg, u32 It_Bit)
    892          {
    893            ITStatus pendingbitstatus = RESET;
    894          
    895            if ((CAN_Reg & It_Bit) != (u32)RESET)
    896            {
    897              /* CAN_IT is set */
    898              pendingbitstatus = SET;
    899            }
    900            else
    901            {
    902              /* CAN_IT is reset */
    903              pendingbitstatus = RESET;
    904            }
    905          
    906            return pendingbitstatus;
    907          }
    908          
    909          /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

Errors: 18
Warnings: none

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -