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

📄 exercise1.lst

📁 一个CAN学习程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
                                               #include <p18f458.h>    // p18cxxx.h must have current processor             C:\CAN202A\can18xx8.c
                                                                       			// defined.                                       C:\CAN202A\can18xx8.c
                                           #endif                                                                           C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                           #if defined(HITECH_C18)                                                          C:\CAN202A\can18xx8.c
                                               #include <pic18.h>                                                           C:\CAN202A\can18xx8.c
                                           #endif                                                                           C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                           #if defined(MCHP_C18)                                                            C:\CAN202A\can18xx8.c
                                               #define RXB0CON_RX0DBEN     RXB0CONbits.RXB0DBEN                             C:\CAN202A\can18xx8.c
                                               #define BRGCON2_SAM         BRGCON2bits.SAM                                  C:\CAN202A\can18xx8.c
                                               #define BRGCON2_SEG2PHTS    BRGCON2bits.SEG2PHTS                             C:\CAN202A\can18xx8.c
                                               #define BRGCON3_WAKFIL      BRGCON3bits.WAKFIL                               C:\CAN202A\can18xx8.c
                                               #define PIR3_RXB0IF         PIR3bits.RXB0IF                                  C:\CAN202A\can18xx8.c
                                               #define COMSTAT_RX0OVFL     COMSTATbits.RXB0OVFL                             C:\CAN202A\can18xx8.c
                                               #define PIR3_RXB1IF         PIR3bits.RXB1IF                                  C:\CAN202A\can18xx8.c
                                               #define COMSTAT_RX1OVFL     COMSTATbits.RXB1OVFL                             C:\CAN202A\can18xx8.c
                                               #define RXB0DLC_RTR         (RXB0DLC & 0x40) // RXB0DLCbits.RTR              C:\CAN202A\can18xx8.c
                                               #define RXB0SIDL_EXID       RXB0SIDLbits.EXID                                C:\CAN202A\can18xx8.c
                                               #define PIR3_IRXIF          PIR3bits.IRXIF                                   C:\CAN202A\can18xx8.c
                                           #endif                                                                           C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                           #if defined(HITECH_C18)                                                          C:\CAN202A\can18xx8.c
                                               #define RXB0CON_RX0DBEN     RXB0DBEN                                         C:\CAN202A\can18xx8.c
                                               #define BRGCON2_SAM         SAM                                              C:\CAN202A\can18xx8.c
                                               #define BRGCON2_SEG2PHTS    SEG2PHTS                                         C:\CAN202A\can18xx8.c
                                               #define BRGCON3_WAKFIL      WAKFIL                                           C:\CAN202A\can18xx8.c
                                               #define PIR3_RXB0IF         RXB0IF                                           C:\CAN202A\can18xx8.c
                                               #define COMSTAT_RX0OVFL     RXB0OVFL                                         C:\CAN202A\can18xx8.c
                                               #define PIR3_RXB1IF         RXB1IF                                           C:\CAN202A\can18xx8.c
                                               #define COMSTAT_RX1OVFL     RXB1OVFL                                         C:\CAN202A\can18xx8.c
                                               #define RXB0DLC_RTR         RXB0RXRTR                                        C:\CAN202A\can18xx8.c
                                               #define RXB0SIDL_EXID       RXB0EXID                                         C:\CAN202A\can18xx8.c
                                               #define PIR3_IRXIF          IRXIF                                            C:\CAN202A\can18xx8.c
                                           #endif                                                                           C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                           /*                                                                               C:\CAN202A\can18xx8.c
                                            * Private helper functions to convert 32-bit CAN ID value into                  C:\CAN202A\can18xx8.c
                                            * corresponding PIC18CXX8 registers and vice-versa.                             C:\CAN202A\can18xx8.c
                                            */                                                                              C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                           static void CANIDToRegs(BYTE* ptr,                                               C:\CAN202A\can18xx8.c
                                                                   unsigned long val,                                       C:\CAN202A\can18xx8.c
                                                                   enum CAN_CONFIG_FLAGS type);                             C:\CAN202A\can18xx8.c
                                           static void RegsToCANID(BYTE* ptr,                                               C:\CAN202A\can18xx8.c
                                                                   unsigned long *val,                                      C:\CAN202A\can18xx8.c
                                                                   enum CAN_CONFIG_FLAGS type);                             C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                                                                                                            C:\CAN202A\can18xx8.c
                                           /*********************************************************************           C:\CAN202A\can18xx8.c
                                            * Function:        void CANInitialize(BYTE SJW,                                 C:\CAN202A\can18xx8.c
                                            *                                      BYTE BRP,                                C:\CAN202A\can18xx8.c
                                            *                                      BYTE PHSEG1,                             C:\CAN202A\can18xx8.c
                                            *                                      BYTE PHSEG2,                             C:\CAN202A\can18xx8.c
                                            *                                      BYTE PROPSEG,                            C:\CAN202A\can18xx8.c
                                            *                                      enum CAN_CONFIG_FLAGS flags)             C:\CAN202A\can18xx8.c
                                            *                                                                               C:\CAN202A\can18xx8.c
                                            * PreCondition:    MCU must be in Configuration mode or else these              C:\CAN202A\can18xx8.c
                                            *                  values will be ignored.                                      C:\CAN202A\can18xx8.c
                                            *                                                                               C:\CAN202A\can18xx8.c
                                            * Input:           SJW     - SJW value as defined in 18CXX8 datasheet           C:\CAN202A\can18xx8.c
                                            *                              (Must be between 1 thru 4)                       C:\CAN202A\can18xx8.c
                                            *                  BRP     - BRP value as defined in 18CXX8 datasheet           C:\CAN202A\can18xx8.c
                                            *                              (Must be between 1 thru 64)                      C:\CAN202A\can18xx8.c
                                            *                  PHSEG1  - PHSEG1 value as defined in 18CXX8                  C:\CAN202A\can18xx8.c
                                            *                            datasheet                                          C:\CAN202A\can18xx8.c
                                            *                              (Must be between 1 thru 8)                       C:\CAN202A\can18xx8.c
                                            *                  PHSEG2  - PHSEG2 value as defined in 18CXX8                  C:\CAN202A\can18xx8.c
                                            *                            datasheet                                          C:\CAN202A\can18xx8.c
                                            *                              (Must be between 1 thru 8)                       C:\CAN202A\can18xx8.c
                                            *                  PROPSEG - PROPSEG value as defined in 18CXX8                 C:\CAN202A\can18xx8.c
                                            *                            datasheet                                          C:\CAN202A\can18xx8.c
                                            *                              (Must be between 1 thru 8)                       C:\CAN202A\can18xx8.c
                                            *                  flags   - Value of type enum CAN_CONFIG_FLAGS                C:\CAN202A\can18xx8.c
                                            *                                                                               C:\CAN202A\can18xx8.c
                                            * Output:          CAN bit rate is set. All masks registers are set             C:\CAN202A\can18xx8.c
                                            *                  '0' to allow all messages.                                   C:\CAN202A\can18xx8.c
                                            *                  Filter registers are set according to flag value.            C:\CAN202A\can18xx8.c
                                            *                  If (config & CAN_CONFIG_VALID_XTD_MSG)                       C:\CAN202A\can18xx8.c
                                            *                      Set all filters to XTD_MSG                               C:\CAN202A\can18xx8.c
                                            *                  Else if (config & CONFIG_VALID_STD_MSG)                      C:\CAN202A\can18xx8.c
                                            *                      Set all filters to STD_MSG                               C:\CAN202A\can18xx8.c
                                            *                  Else                                                         C:\CAN202A\can18xx8.c
                                            *                      Set half of the filters to STD while rests to            C:\CAN202A\can18xx8.c
                                            *                      XTD_MSG.                                                 C:\CAN202A\can18xx8.c
                                            *                                                                               C:\CAN202A\can18xx8.c
                                            * Side Effects:    All pending transmissions are aborted.                       C:\CAN202A\can18xx8.c
                                            *                                                                               C:\CAN202A\can18xx8.c

⌨️ 快捷键说明

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