首页 > 其他分享 >can总线相关内容

can总线相关内容

时间:2023-12-18 11:22:32浏览次数:31  
标签:ARR 总线 uint8 canNo 内容 GPIO 相关 BIT uint32

can总线是一种串行通讯总线。具有多主控制的特点,及在总线空闲时,所有单元都可以开始发送消息,最先访问总线的单元可以获得发送权。多个单元同时访问总线时,发送高优先级id消息的单元可以优先访问。

can总线中利用id标识各个节点。在节点发送数据时,发送的报文帧中也应含有节点的id信息。

 

// can总线相关抽象结构体定义
typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef;

 

 

 

// 这是要用到的一些宏定义
#define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) #define READ_BIT(REG, BIT) ((REG) & (BIT)) #define CLEAR_REG(REG) ((REG) = (0x0)) #define WRITE_REG(REG, VAL) ((REG) = (VAL)) #define READ_REG(REG) ((REG)) #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))

 

//======================================================================
//文件名称:can.c
//功能概要:uart底层驱动构件源文件
//版权所有:苏州大学嵌入式系统与物联网研究所(sumcu.suda.edu.cn)
//更新记录:2021-02-03 V1.0  JJL
//======================================================================
#include "can.h"

CAN_TypeDef *CAN_ARR[] = {(CAN_TypeDef*)CAN1_BASE};
IRQn_Type table_irq_can[2] = {CAN1_RX0_IRQn, CAN1_RX1_IRQn};

uint8_t can_send_once(uint8_t canNo, uint32_t DestID, uint16_t len ,uint8_t* buff);
uint8_t CAN_HWInit(uint8_t CANChannel);
uint8_t CAN_SWInit_Entry(uint8_t canNo);
void CAN_SWInit_CTLMode(uint8_t canNo);
void CAN_SWInit_BT(uint8_t canNo, uint32_t CANMode, uint32_t Prescaler);
uint8_t CAN_SWInit_Quit(uint8_t canNo);
uint8_t CANFilterConfig(uint8_t canNo, uint32_t canID, uint32_t FilterBank, uint32_t Can_Rx_FifoNo, uint8_t IsActivate, uint32_t FilterMode, uint32_t FilterScale);

//=====================================================================
//函数名称:can_init
//函数返回:无
//参数说明:canNo:模块号,本芯片只有CAN_1
//            canID:自身CAN节点的唯一标识,例如按照CANopen协议给出
//          BitRate:位速率
//功能概要:初始化CAN模块
//=====================================================================
void can_init(uint8_t canNo, uint32_t canID, uint32_t BitRate)
{
    //声明Init函数使用的局部变量
    uint32_t CANMode;
    uint32_t CANFilterBank;
    uint32_t CANFiltermode;
    uint32_t CAN_Filterscale;

    //给Init函数使用的局部变量赋初值
    CANMode = CAN_MODE_NORMAL;
    CANFilterBank = CANFilterBank0;
    CANFiltermode = CAN_FILTERMODE_IDMASK;
    CAN_Filterscale = CAN_FILTERSCALE_32BIT;

    //(1)CAN总线硬件初始化
    CAN_HWInit(CAN_CHANNEL);
    //(2)CAN总线进入软件初始化模式
    CAN_SWInit_Entry(canNo);
    //(3)CAN总线模式设置
    CAN_SWInit_CTLMode(canNo);
    //(4)CAN总线位时序配置
    CAN_SWInit_BT(canNo,CANMode,BitRate);
    //(5)CAN总线过滤器初始化
    CANFilterConfig(canNo, canID, CANFilterBank, CAN_RX_FIFO0, 1, CANFiltermode, CAN_Filterscale);
    //(6)CAN总线退出软件初始化模式,进入正常模式
    CAN_SWInit_Quit(canNo);
}

//=====================================================================
//函数名称:can_send_once
//函数返回:0=正常,1=错误
//参数说明:canNo:模块号,本芯片只有CAN_1
//          DestID:目标CAN节点的唯一标识,例如按照CANopen协议给出
//          len:待发送数据的字节数
//          buff:待发送数据发送缓冲区首地址
//功能概要:CAN模块发送一次数据
//=====================================================================
uint8_t can_send_once(uint8_t canNo, uint32_t DestID, uint16_t len ,uint8_t* buff)
{
    //(1)定义Can发送函数所需要用到的变量
    uint32_t transmit_mailbox;
    uint32_t register_tsr;
    uint32_t rtr;
    rtr = CAN_RTR_DATA;
    register_tsr = READ_REG(CAN_ARR[canNo-1]->TSR);

    //(2)判断3个邮箱中是否有空闲邮箱,若有,选取其中一个进行发送,选取顺序为1,2,3
    if (((register_tsr & CAN_TSR_TME0) != 0U) ||
        ((register_tsr & CAN_TSR_TME1) != 0U) ||
        ((register_tsr & CAN_TSR_TME2) != 0U))
    {
        transmit_mailbox = (register_tsr & CAN_TSR_CODE) >> CAN_TSR_CODE_Pos;
        if(transmit_mailbox > 2U)
        {
            return 1;
        }

        //(2.1)判断并设置发送帧为标准帧还是扩展帧
        if(DestID <= 0x7FFU)
        {
            CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TIR = ((DestID << CAN_TI0R_STID_Pos)|CAN_ID_STD|rtr);
        }
        else
        {
            CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TIR = ((DestID << CAN_TI0R_EXID_Pos)|CAN_ID_EXT|rtr);
        }
        //(2.2)设置发送帧的数据长度
        CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TDTR = len;
        //SET_BIT(CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TDTR, CAN_TDT0R_TGT);
        //(2.3)设置发送帧的数据
        WRITE_REG(CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TDHR,
                  ((uint32_t)buff[7] << CAN_TDH0R_DATA7_Pos) |
                  ((uint32_t)buff[6] << CAN_TDH0R_DATA6_Pos) |
                  ((uint32_t)buff[5] << CAN_TDH0R_DATA5_Pos) |
                  ((uint32_t)buff[4] << CAN_TDH0R_DATA4_Pos));
        WRITE_REG(CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TDLR,
                  ((uint32_t)buff[3] << CAN_TDL0R_DATA3_Pos) |
                  ((uint32_t)buff[2] << CAN_TDL0R_DATA2_Pos) |
                  ((uint32_t)buff[1] << CAN_TDL0R_DATA1_Pos) |
                  ((uint32_t)buff[0] << CAN_TDL0R_DATA0_Pos));
        //(2.4)发送Can数据报
        SET_BIT(CAN_ARR[canNo-1]->sTxMailBox[transmit_mailbox].TIR, CAN_TI0R_TXRQ);
        return 0;
    }
    else
    {
        return 1;
    }
}

 

//===================================================================== //函数名称:can_send //函数返回:0=正常,1=错误 //参数说明:canNo:模块号,本芯片只有CAN_1 // DestID:目标CAN节点的唯一标识,例如按照CANopen协议给出 // len:待发送数据的字节数 // buff:待发送数据发送缓冲区首地址 //功能概要:CAN模块发送数据 //===================================================================== uint8_t can_send(uint8_t canNo, uint32_t DestID, uint16_t len ,uint8_t* buff) { if(DestID > 0x1FFFFFFFU) return 1; uint8_t send_length; for(int i = len; i > 0; i = i-8) { send_length = (i>8)?8:i; if(can_send_once(canNo,DestID,send_length,buff+len-i) == 1) { return 1; } } return 0; } //===================================================================== //函数名称:can_recv //函数返回:接收到的字节数 //参数说明:canNo:模块号,本芯片只有CAN_1 // buff:接收到的数据存放的内存区首地址 //功能概要:在CAN模块接收中断中调用本函数接收已经到达的数据 //===================================================================== uint8_t can_recv(uint8_t canNo, uint8_t *buff) { uint8_t len; uint32_t RxFifo = CAN_RX_FIFO0; //(1)判断哪个邮箱收到了报文信息 if(RxFifo == CAN_RX_FIFO0) { if ((CAN_ARR[canNo-1]->RF0R & CAN_RF0R_FMP0) == 0U) { return 1; } } else { if ((CAN_ARR[canNo-1]->RF1R & CAN_RF1R_FMP1) == 0U) { return 1; } } //(2)获取数据长度 len = (CAN_RDT0R_DLC & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDTR) >> CAN_RDT0R_DLC_Pos; //(3)获取数据帧中的数据 buff[0] = (uint8_t)((CAN_RDL0R_DATA0 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDLR) >> CAN_RDL0R_DATA0_Pos); buff[1] = (uint8_t)((CAN_RDL0R_DATA1 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDLR) >> CAN_RDL0R_DATA1_Pos); buff[2] = (uint8_t)((CAN_RDL0R_DATA2 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDLR) >> CAN_RDL0R_DATA2_Pos); buff[3] = (uint8_t)((CAN_RDL0R_DATA3 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDLR) >> CAN_RDL0R_DATA3_Pos); buff[4] = (uint8_t)((CAN_RDH0R_DATA4 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDHR) >> CAN_RDH0R_DATA4_Pos); buff[5] = (uint8_t)((CAN_RDH0R_DATA5 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDHR) >> CAN_RDH0R_DATA5_Pos); buff[6] = (uint8_t)((CAN_RDH0R_DATA6 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDHR) >> CAN_RDH0R_DATA6_Pos); buff[7] = (uint8_t)((CAN_RDH0R_DATA7 & CAN_ARR[canNo-1]->sFIFOMailBox[RxFifo].RDHR) >> CAN_RDH0R_DATA7_Pos); //(4)清除标志位,等待接收下一帧数据 if (RxFifo == CAN_RX_FIFO0) { SET_BIT(CAN_ARR[canNo-1]->RF0R, CAN_RF0R_RFOM0); } else { SET_BIT(CAN_ARR[canNo-1]->RF1R, CAN_RF1R_RFOM1); } return len; } //===================================================================== //函数名称:CAN_enable_re_int //函数返回:无 //参数说明:canNo:模块基地址号,Can_Rx_FifoNo:中断使用的邮箱号 //功能概要:CAN接收中断开启 //===================================================================== void can_enable_recv_int(uint8_t canNo) { uint8_t Can_Rx_FifoNo; Can_Rx_FifoNo = CAN_RX_FIFO0; if(Can_Rx_FifoNo == CAN_RX_FIFO0) SET_BIT(CAN_ARR[canNo-1]->IER, CAN_IER_FMPIE0); else SET_BIT(CAN_ARR[canNo-1]->IER,CAN_IER_FMPIE1); NVIC_EnableIRQ(table_irq_can[Can_Rx_FifoNo]); } //===================================================================== //函数名称:can_disable_recv_int //函数返回:无 //参数说明:canNo:模块号,本芯片只有CAN_1 //功能概要:关闭CAN接收中断 //===================================================================== void can_disable_recv_int (uint8_t canNo) { uint8_t Can_Rx_FifoNo; Can_Rx_FifoNo = CAN_RX_FIFO0; if(Can_Rx_FifoNo == CAN_RX_FIFO0) CLEAR_BIT(CAN_ARR[canNo-1]->IER, CAN_IER_FMPIE0); else CLEAR_BIT(CAN_ARR[canNo-1]->IER,CAN_IER_FMPIE1); NVIC_DisableIRQ(table_irq_can[Can_Rx_FifoNo]); } //===================================================================== //函数名称:CAN_HWInit //函数返回:0=正常,1=错误 //参数说明:CANChannel:硬件引脚组号,共有3组,分别为PTA11&PTA12(CAN_CHANNEL0),PTB8&PTB9(CAN_CHANNEL1),PTD0&PTD1(2) //功能概要:CAN模块引脚初始化 //===================================================================== uint8_t CAN_HWInit(uint8_t CANChannel) { if(CANChannel < 0 || CANChannel > 2) { return 1; } if(CANChannel == 0) { RCC->APB1ENR1 |= RCC_APB1ENR1_CAN1EN; RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN; GPIOA->MODER &= ~(GPIO_MODER_MODE11|GPIO_MODER_MODE12); GPIOA->MODER |= (GPIO_MODER_MODE11_1|GPIO_MODER_MODE12_1); GPIOA->AFR[1] &= ~(GPIO_AFRH_AFSEL11|GPIO_AFRH_AFSEL12); GPIOA->AFR[1] |= (GPIO_AFRH_AFSEL11_0|GPIO_AFRH_AFSEL11_3)|(GPIO_AFRH_AFSEL12_0|GPIO_AFRH_AFSEL12_3); } else if(CANChannel == 1) { RCC->APB1ENR1 |= RCC_APB1ENR1_CAN1EN; RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN; GPIOB->MODER &= ~(GPIO_MODER_MODE8|GPIO_MODER_MODE9); GPIOB->MODER |= (GPIO_MODER_MODE8_1|GPIO_MODER_MODE9_1); GPIOB->AFR[1] &= ~(GPIO_AFRH_AFSEL8|GPIO_AFRH_AFSEL9); GPIOB->AFR[1] |= ((GPIO_AFRH_AFSEL8_0|GPIO_AFRH_AFSEL8_3)| (GPIO_AFRH_AFSEL9_0|GPIO_AFRH_AFSEL9_3)); } else { RCC->APB1ENR1 |= RCC_APB1ENR1_CAN1EN; RCC->AHB2ENR |= RCC_AHB2ENR_GPIODEN; GPIOD->MODER &= ~(GPIO_MODER_MODE0|GPIO_MODER_MODE1); GPIOD->MODER |= (GPIO_MODER_MODE0_1|GPIO_MODER_MODE1_1); GPIOD->AFR[0] &= ~(GPIO_AFRL_AFSEL0|GPIO_AFRL_AFSEL1); GPIOD->AFR[0] |= ((GPIO_AFRL_AFSEL0_0 | GPIO_AFRL_AFSEL0_3)| (GPIO_AFRL_AFSEL1_0 | GPIO_AFRL_AFSEL1_3)); } return 0; } //===================================================================== //函数名称:CAN_SWInit_Entry //函数返回:0=正常,1=错误 //参数说明:canNo:模块基地址号,本芯片只有CAN_1, //功能概要:进入初始化模式 //===================================================================== uint8_t CAN_SWInit_Entry(uint8_t canNo) { int i; CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_SLEEP); i = 0; while ((CAN_ARR[canNo-1]->MSR & CAN_MSR_SLAK) != 0U) { if(i++ > 0x30000) { return 1; } } SET_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_INRQ); i = 0; while ((CAN_ARR[canNo-1]->MSR & CAN_MSR_INAK) == 0U) { if(i++ > 0x30000) { return 1; } } return 0; } //===================================================================== //函数名称:CAN_SWInit_CTLMode //函数返回:无 //参数说明:canNo:模块基地址号,本芯片只有CAN_1, //功能概要:CAN总线模式设置 //===================================================================== void CAN_SWInit_CTLMode(uint8_t canNo) { CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_TTCM); CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_ABOM); CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_AWUM); SET_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_NART); CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_RFLM); CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_TXFP); } //函数名称:CAN_SWInit_CTLMode //函数返回:无 //参数说明:canNo:模块基地址号,本芯片只有CAN_1, // CANMode:CAN总线工作模式,分别为正常模式(CAN_MODE_NORMAL)、回环模式(CAN_MODE_LOOPBACK)、 // 静默模式(CAN_MODE_SILENT)以及回环与静默组合模式(CAN_MODE_SILENT_LOOPBACK) //功能概要:CAN总线位时序配置 void CAN_SWInit_BT(uint8_t canNo, uint32_t CANMode, uint32_t Prescaler) { CAN_ARR[canNo-1]->BTR |= ((uint32_t)(Prescaler-1)|CAN_SJW_1TQ|CAN_BTR_TS1_1|CAN_BTR_TS1_0|CAN_BTR_TS2_2|CANMode); } //===================================================================== //函数名称:CAN_SWInit_Quit //函数返回:0=正常,1=错误 //参数说明:canNo:模块基地址号 //功能概要:退出初始化模式,进入正常模式 //===================================================================== uint8_t CAN_SWInit_Quit(uint8_t canNo) { int i; CLEAR_BIT(CAN_ARR[canNo-1]->MCR, CAN_MCR_INRQ); i = 0; while ((CAN_ARR[canNo-1]->MSR & CAN_MSR_INAK) != 0U) { if (i++ > 0x30000) { return 1; } } return 0; } //===================================================================== //函数名称: CANFilterConfig //函数返回:0=正常,1=错误 //参数说明: canNo:模块基地址号, // canID:自身CAN节点的唯一标识,例如按照CANopen协议给出 // Can_Rx_FifoNo:中断使用的邮箱号, // IsActivate:是否激活过滤器 // CANFilterBank:CAN总线过滤器组选择,共有28个,(CANFilterBank0~CANFilterBank27) // CANFiltermode:CAN总线过滤器模式,分别为掩码模式(CAN_FILTERMODE_IDMASK)和列表模式(CAN_FILTERMODE_IDLIST) // CAN_Filterscale:CAN总线过滤器位数,分别为32位(CAN_FILTERSCALE_32BIT)和16位(CAN_FILTERSCALE_16BIT) //功能概要:CAN接收中断开启 //===================================================================== uint8_t CANFilterConfig(uint8_t canNo, uint32_t CanID, uint32_t FilterBank, uint32_t Can_Rx_FifoNo, uint8_t IsActivate, uint32_t FilterMode, uint32_t FilterScale) { uint32_t FilterIdHigh, FilterIdLow, FilterMaskIdHigh, FilterMaskIdLow, filternbrbitpos; if(CanID <= 0x7FFU) CanID = CanID << CAN_TI0R_STID_Pos; FilterIdHigh = (CanID >> 16) & 0xFFFF; FilterIdLow = (CanID & 0xFFFF); FilterMaskIdHigh = 0xFFE0; FilterMaskIdLow = 0x0000; filternbrbitpos = (uint32_t)1 << (FilterBank & 0x1FU); //设置过滤器初始化模式 (FINIT=1),在此模式下可以进行过滤器初始化 SET_BIT(CAN_ARR[canNo-1]->FMR, CAN_FMR_FINIT); CLEAR_BIT(CAN_ARR[canNo-1]->FA1R, filternbrbitpos); if (FilterScale == CAN_FILTERSCALE_16BIT) { CLEAR_BIT(CAN_ARR[canNo-1]->FS1R, filternbrbitpos); CAN_ARR[canNo-1]->sFilterRegister[FilterBank].FR1 = ((0x0000FFFFU & (uint32_t)FilterMaskIdLow) << 16U) | (0x0000FFFFU & (uint32_t)FilterIdLow); CAN_ARR[canNo-1]->sFilterRegister[FilterBank].FR2 = ((0x0000FFFFU & (uint32_t)FilterMaskIdHigh) << 16U) | (0x0000FFFFU & (uint32_t)FilterIdHigh); } if (FilterScale == CAN_FILTERSCALE_32BIT) { SET_BIT(CAN_ARR[canNo-1]->FS1R, filternbrbitpos); CAN_ARR[canNo-1]->sFilterRegister[FilterBank].FR1 = ((0x0000FFFFU & (uint32_t)FilterIdHigh) << 16U) | (0x0000FFFFU & (uint32_t)FilterIdLow); CAN_ARR[canNo-1]->sFilterRegister[FilterBank].FR2 = ((0x0000FFFFU & (uint32_t)FilterMaskIdHigh) << 16U) | (0x0000FFFFU & (uint32_t)FilterMaskIdLow); } if (FilterMode == CAN_FILTERMODE_IDMASK) { CLEAR_BIT(CAN_ARR[canNo-1]->FM1R, filternbrbitpos); } else { SET_BIT(CAN_ARR[canNo-1]->FM1R, filternbrbitpos); } if (Can_Rx_FifoNo == CAN_FILTER_FIFO0) { CLEAR_BIT(CAN_ARR[canNo-1]->FFA1R, filternbrbitpos); } else { SET_BIT(CAN_ARR[canNo-1]->FFA1R, filternbrbitpos); } if (IsActivate == 1) { SET_BIT(CAN_ARR[canNo-1]->FA1R, filternbrbitpos); } //退出过滤器初始化模式 (FINIT=0) CLEAR_BIT(CAN_ARR[canNo-1]->FMR, CAN_FMR_FINIT); return 0; }

 

标签:ARR,总线,uint8,canNo,内容,GPIO,相关,BIT,uint32
From: https://www.cnblogs.com/zk6696/p/17910584.html

相关文章

  • Qt 信号槽相关
    Qt中信号与槽的机制用于实现对象之间的通信,这种机制允许对象在特定事件发生时发送信号,而其他对象可以通过连接到这些信号的槽函数来响应这些事件。Qt官方的相关文档在此:https://doc.qt.io/qt-5/signalsandslots.html实现信号槽的功能首先需要两个(可以是同一个)对象,一个负责发送......
  • 数据库迁移方式和相关文档地址
    数据库迁移方式1、phpyiimigrate文档地址2、flyway文档地址3、liqiubase操作文档更多的其他迁移工具探索方式flywayalternatives迁移比较liqiubase操作(1)、在Java中的项目中使用1、在yml中配置相关的扫描springliquibase:change-log:classpath:db/c......
  • vmware 虚拟机相关问题
    ubuntu16.04配置固定ip无法联网参考https://www.snel.com/support/static-ip-configuration-ubuntu-16-04/#interfaces(5)fileusedbyifup(8)andifdown(8)autoloifaceloinetloopback#ifacetoinetloopback#autoens33#ifaceens33inetstatic#ad......
  • 12 17学习内容
    绘制完整的数据流图:大概去了解了一下数据流图的各种符号,但我发现跟学长所用的符号不一样,那就先以学长的符号作为标准画一下数据流图,本人感觉其实这个思路跟业务流程图差不多:   l然后学习类图画法:      ......
  • [刷题技巧] 堆的相关知识点汇总
    1.堆一、堆的引入现在我们想专门设计一种数据结构,用来存放整数,要求提供3个接口:添加元素获取最大值(或最小值)删除最大值(或最小值)有一种最优的数据结构就是堆。时间复杂度:获取最大值的:O(1)、删除最大值O(logn)、添加元素O(logn)二、堆的相关概念堆(Heap是一种树状......
  • Java-与斐波那契数列相关的变体问题
    变体问题指的是提问的方式不一样了,但是解决问题的方法还是用斐波那契数列来解。——写在前面的话。一、变体1-兔子问题1.问题描述第一个月,有一对未成熟的兔子第二个月上述的一对兔子成熟第三个月,他们能产下一对小兔子所有兔子遵循相同规律,求第n个月的兔子个数2.分析例子假设我要求......
  • 人工智能相关数学 - 极限
    函数f在x0处的极限为L数学语言记作:对于任意的正数ε>0,存在正数,使得任何满足的x,都有Definition(无穷小阶数)当 时,如果而且那么此时f(x)为n阶以上无穷小,记为当 时,如果而且 存在且不等于零,那么此时f(x)为n阶无穷小,记为为了方便,在不至于引起误解......
  • 右值引用相关整理
    前言 C++中有“移动语义、右值引用、引用折叠、万能引用、完美转发”等许多概念,本文尽量按照时间顺序,理清这些概念的由来,有什么关系,解决了什么问题。移动语义 首先介绍移动语义的概念。移动语义是C++11引入的,正如移动一词的含义:一个物体从地点A到地点B,从结果上看,物体位置发生......
  • 使用JS脚本修改页面内容
    在学习RPA时,我对使用JS脚本修改页面内容进行了深入学习。记录如下:获取元素的方法:1.document.getElementById("xxx")2.document.getElementsByClassName("xxx")3.document.getElementsByTagName("xxx")4.document.getElementsByName("xxx")5.document.querySele......
  • StarBlog - 2023年底更新内容一览
    前言先说一下我对StarBlog这个系列的文章的规划吧,在StarBlog的1.x版本,我会同步更新两个系列的文章博客前台+接口开发笔记(即当前已发布的这一系列文章)博客Vue后台开发笔记(后续开始持续发布)最近很久没有更新StarBlog系列的文章,事实上我之前已经把【博客Vue后台开发......