當前位置: 首頁>>代碼示例>>C++>>正文


C++ CAN_FilterInit函數代碼示例

本文整理匯總了C++中CAN_FilterInit函數的典型用法代碼示例。如果您正苦於以下問題:C++ CAN_FilterInit函數的具體用法?C++ CAN_FilterInit怎麽用?C++ CAN_FilterInit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CAN_FilterInit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: PIOS_CAN_Init

/**
 * Initialize the CAN driver and return an opaque id
 * @param[out]   id the CAN interface handle
 * @param[in]    cfg the configuration structure
 * @return 0 if successful, negative otherwise
 */
int32_t PIOS_CAN_Init(uintptr_t *can_id, const struct pios_can_cfg *cfg)
{
	PIOS_DEBUG_Assert(can_id);
	PIOS_DEBUG_Assert(cfg);

	can_dev = (struct pios_can_dev *) PIOS_CAN_alloc();
	if (!can_dev) goto out_fail;

	/* Bind the configuration to the device instance */
	can_dev->cfg = cfg;

	/* Configure the CAN device */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);

	/* Map pins to CAN function */
	if (can_dev->cfg->remap) {
		if (can_dev->cfg->rx.gpio != 0)
			GPIO_PinAFConfig(can_dev->cfg->rx.gpio,
				can_dev->cfg->rx.pin_source,
				can_dev->cfg->remap);
		if (can_dev->cfg->tx.gpio != 0)
			GPIO_PinAFConfig(can_dev->cfg->tx.gpio,
				can_dev->cfg->tx.pin_source,
				can_dev->cfg->remap);
	}

	/* Initialize the CAN Rx and Tx pins */
	if (can_dev->cfg->rx.gpio != 0)
		GPIO_Init(can_dev->cfg->rx.gpio, (GPIO_InitTypeDef *)&can_dev->cfg->rx.init);
	if (can_dev->cfg->tx.gpio != 0)
		GPIO_Init(can_dev->cfg->tx.gpio, (GPIO_InitTypeDef *)&can_dev->cfg->tx.init);

	*can_id = (uintptr_t)can_dev;

	CAN_DeInit(can_dev->cfg->regs);
	CAN_Init(can_dev->cfg->regs, (CAN_InitTypeDef *)&can_dev->cfg->init);

	/* CAN filter init */
	CAN_FilterInitTypeDef CAN_FilterInitStructure;
	CAN_FilterInitStructure.CAN_FilterNumber = 0;
	CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
	CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
	CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
	CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;  
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 1;

	CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);

	// Enable the receiver IRQ
 	NVIC_Init((NVIC_InitTypeDef*) &can_dev->cfg->rx_irq.init);
 	NVIC_Init((NVIC_InitTypeDef*) &can_dev->cfg->tx_irq.init);

	return(0);

out_fail:
	return(-1);
}
開發者ID:EvalZero,項目名稱:TauLabs,代碼行數:66,代碼來源:pios_can.c

示例2: can_init

void can_init(can_t* can_filters)
{

  gpio_clock_init(GPIOA);
  can_clock_init(CAN1);

  GPIO_InitTypeDef GPIO_InitStructure =
    {
      .GPIO_Pin   = CAN_RX_PIN,
      .GPIO_Speed = GPIO_Speed_50MHz,
      .GPIO_Mode  = GPIO_Mode_IN_FLOATING,
    };
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = CAN_TX_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  CAN_InitTypeDef CAN_InitStructure;
  CAN_StructInit(&CAN_InitStructure);
  CAN_InitStructure.CAN_Prescaler = 1;
  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
  CAN_InitStructure.CAN_SJW = CAN_SJW_4tq;
  CAN_InitStructure.CAN_BS1 = CAN_BS1_11tq;
  CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
  CAN_InitStructure.CAN_ABOM = ENABLE;
  CAN_InitStructure.CAN_RFLM = ENABLE;
  CAN_Init(CAN1, &CAN_InitStructure);

  CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);
  CAN_ITConfig(CAN1, CAN_IT_FMP1, ENABLE);

  NVIC_InitTypeDef NVIC_InitStructure =
    {
      .NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn,
      .NVIC_IRQChannelPreemptionPriority = 7,
      .NVIC_IRQChannelSubPriority = 0,
      .NVIC_IRQChannelCmd = ENABLE,
    };
  NVIC_Init(&NVIC_InitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX1_IRQn;
  NVIC_Init(&NVIC_InitStructure);

  for (int i = 0; i < can_filters->n_filters; i++)
    CAN_FilterInit(can_filters->CAN_filterInit + i);

  xCAN_receive_queue0 = xQueueCreate(10, sizeof(CanRxMsg));
  xCAN_receive_queue1 = xQueueCreate(10, sizeof(CanRxMsg));

}

void USB_LP_CAN1_RX0_IRQHandler()
{
  CanRxMsg RxMessage;
  portBASE_TYPE resch = pdFALSE;
  CAN_Receive(CAN1, CAN_FIFO0,&RxMessage);
  xQueueSendFromISR(xCAN_receive_queue0, &RxMessage, &resch);
  portEND_SWITCHING_ISR(resch);
}
開發者ID:RoseWheel,項目名稱:RoseWheel,代碼行數:60,代碼來源:can.c

示例3: CAN_config_init

void CAN_config_init(void)
{
  CAN_InitTypeDef        CAN_InitStructure;
  CAN_FilterInitTypeDef  CAN_FilterInitStructure;
 
  CAN_DeInit(CAN1);
  CAN_StructInit(&CAN_InitStructure);
    // 36M 250k速率
  CAN_InitStructure.CAN_TTCM=DISABLE;
  CAN_InitStructure.CAN_ABOM=DISABLE;
  CAN_InitStructure.CAN_AWUM=DISABLE;
  CAN_InitStructure.CAN_NART=DISABLE;
  CAN_InitStructure.CAN_RFLM=DISABLE;
  CAN_InitStructure.CAN_TXFP=ENABLE;
  //CAN_InitStructure.CAN_Mode=CAN_Mode_LoopBack;
	CAN_InitStructure.CAN_Mode=CAN_Mode_Normal;
  CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
  CAN_InitStructure.CAN_BS1=CAN_BS1_2tq;
  CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;
  CAN_InitStructure.CAN_Prescaler=12;
  CAN_Init(CAN1, &CAN_InitStructure);
  CAN_OperatingModeRequest( CAN1, CAN_OperatingMode_Normal);
  CAN_FilterInitStructure.CAN_FilterNumber=0;
  CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
  CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
  CAN_FilterInit(&CAN_FilterInitStructure); 
}
開發者ID:EasternRise,項目名稱:AGV,代碼行數:33,代碼來源:canljx.c

示例4: CAN2_Init

void CAN2_Init(void)
{
	CAN_InitTypeDef CAN_Struct;
	CAN_FilterInitTypeDef CAN_FilterStruct;

	CAN2_GPIO_Init();
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN2,ENABLE);
	CAN_Struct.CAN_TTCM=DISABLE;
	CAN_Struct.CAN_ABOM=DISABLE;
	CAN_Struct.CAN_AWUM=DISABLE;
	CAN_Struct.CAN_NART=DISABLE;
	CAN_Struct.CAN_RFLM=DISABLE;
	CAN_Struct.CAN_TXFP=DISABLE;
	CAN_Struct.CAN_Mode=CAN_Mode_LoopBack;
	CAN_Struct.CAN_SJW=CAN_SJW_1tq;
	CAN_Struct.CAN_BS1=CAN_BS1_8tq;
	CAN_Struct.CAN_BS2=CAN_BS2_7tq;
	CAN_Struct.CAN_Prescaler=5;
	CAN_Init(CAN2,&CAN_Struct);

	CAN_FilterStruct.CAN_FilterNumber=0;
	CAN_FilterStruct.CAN_FilterMode=CAN_FilterMode_IdMask;
	CAN_FilterStruct.CAN_FilterScale=CAN_FilterScale_32bit;
	CAN_FilterStruct.CAN_FilterIdHigh=0x0000;
	CAN_FilterStruct.CAN_FilterIdLow=0x0000;
	CAN_FilterStruct.CAN_FilterMaskIdHigh=0x0000;
	CAN_FilterStruct.CAN_FilterMaskIdLow=0x0000;
	CAN_FilterStruct.CAN_FilterFIFOAssignment=0;
	CAN_FilterStruct.CAN_FilterActivation=ENABLE;
	CAN_FilterInit(&CAN_FilterStruct);
}   
開發者ID:RTOS-Developers,項目名稱:TRTOS,代碼行數:31,代碼來源:Can2_Driver.c

示例5: CAN_Filter_Configs

void CAN_Filter_Configs(uint16 LocalAddr,BOOL Host)
{
	if(Host)
	{
	CAN_FilterInitTypeDef  CAN_FilterInitStructure;
		DeBug("Configs Filter For Master",Infor_Infor);
	CAN_FilterInitStructure.CAN_FilterNumber=0;	 
	CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;	 // 標識符屏蔽位模式
	CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;   // 32位過濾器
	CAN_FilterInitStructure.CAN_FilterIdHigh=0x00;			// id高位包含
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;		// 過濾器屏蔽標識符
	CAN_FilterInitStructure.CAN_FilterIdLow=(uint16)(CAN_GROUP<<3)|CAN_RTR_DATA|CAN_ID_EXT;;		//id低位包含		
	CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xffff;
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;	 // FIFO0指向過濾器
	CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);
	}
	else
	{
		
	CAN_FilterInitTypeDef  CAN_FilterInitStructure;
		DeBug("Configs Filter For Slave Addr=0x%x",LocalAddr,Infor_Infor);
	CAN_FilterInitStructure.CAN_FilterNumber=0;	 
	CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;	 // 標識符屏蔽位模式
	CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;   // 32位過濾器
	CAN_FilterInitStructure.CAN_FilterIdHigh=LocalAddr;			
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xffff;		// 掩碼
	
	CAN_FilterInitStructure.CAN_FilterIdLow=(uint16)(CAN_GROUP<<3)|CAN_RTR_DATA|CAN_ID_EXT;		//id低位包含		
	CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xffff;   //掩碼
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;	 // FIFO0指向過濾器
	CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);
	
	CAN_FilterInitStructure.CAN_FilterNumber=1;	 
	CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;	 // 標識符屏蔽位模式
	CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;   // 32位過濾器
	CAN_FilterInitStructure.CAN_FilterIdHigh=0xffff;			// 設備可以接到廣播地址
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xffff;		// 掩碼
	
	CAN_FilterInitStructure.CAN_FilterIdLow=(uint16)(CAN_GROUP<<3)|CAN_RTR_DATA|CAN_ID_EXT;		//id低位包含		
	CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xffff;   //掩碼
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;	 // FIFO0指向過濾器
	CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);
	}
}
開發者ID:RTOS-Developers,項目名稱:TRTOS,代碼行數:47,代碼來源:Can_Driver.c

示例6: CAN_Config

void CAN_Config(void) {
    CAN_InitTypeDef CAN_InitStruct;
    CAN_FilterInitTypeDef CAN_FilterInitStruct;
    NVIC_InitTypeDef NVIC_InitStruct;
    GPIO_InitTypeDef GPIO_InitStruct;

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

    GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_9);
    GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_9);

    GPIO_StructInit(&GPIO_InitStruct);
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStruct);


    // can peripherial
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);

    CAN_StructInit(&CAN_InitStruct);
    CAN_InitStruct.CAN_ABOM = DISABLE;
    CAN_InitStruct.CAN_AWUM = DISABLE;
    CAN_InitStruct.CAN_NART = DISABLE;
    CAN_InitStruct.CAN_RFLM = DISABLE;
    CAN_InitStruct.CAN_TTCM = DISABLE;
    CAN_InitStruct.CAN_TXFP = DISABLE;
    CAN_InitStruct.CAN_Prescaler = 18; // 125000 Baud rate assuimg CAN speed 36MHz
    CAN_InitStruct.CAN_SJW = CAN_SJW_1tq;
    CAN_InitStruct.CAN_BS1 = CAN_BS1_13tq;
    CAN_InitStruct.CAN_BS2 = CAN_BS2_2tq;
    CAN_InitStruct.CAN_Mode = CAN_Mode_Normal;
    CAN_Init(CAN1, &CAN_InitStruct);

    // can filter
    CAN_FilterInitStruct.CAN_FilterNumber = 0;
    CAN_FilterInitStruct.CAN_FilterMode = CAN_FilterMode_IdMask;
    CAN_FilterInitStruct.CAN_FilterScale = CAN_FilterScale_32bit;
    CAN_FilterInitStruct.CAN_FilterActivation = ENABLE;
    CAN_FilterInitStruct.CAN_FilterFIFOAssignment = CAN_FIFO0;
    CAN_FilterInitStruct.CAN_FilterIdHigh = 0;
    CAN_FilterInitStruct.CAN_FilterIdLow = 0;
    CAN_FilterInitStruct.CAN_FilterMaskIdHigh = 0;
    CAN_FilterInitStruct.CAN_FilterMaskIdLow = 0;
    CAN_FilterInit(&CAN_FilterInitStruct);

    // can interrupt
    CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

    NVIC_InitStruct.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
    NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
    NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
    NVIC_Init(&NVIC_InitStruct);
}
開發者ID:kitaev,項目名稱:can,代碼行數:58,代碼來源:main.c

示例7: RCC_AHB1PeriphClockCmd

void DST_CAN_1::CAN_Configuration_Init(void)
{
	GPIO_InitTypeDef				GPIO_InitStructure;	
	CAN_InitTypeDef			 		CAN_InitStructure;
 	CAN_FilterInitTypeDef 	CAN_FilterInitStructure;
	NVIC_InitTypeDef 				NVIC_InitStructure;

 //使能相關時鍾
	RCC_AHB1PeriphClockCmd(RCC_CAN_1, ENABLE);//使能PORTA時鍾	                   											 

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);//使能CAN1時鍾	

	//初始化GPIO
	GPIO_InitStructure.GPIO_Pin = CAN_1_TX | CAN_1_RX;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//複用功能
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽輸出
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
	GPIO_Init(GPIO_CAN_1, &GPIO_InitStructure);//初始化CAN_1_TX,CAN_1_RX

	//引腳複用映射配置
	GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_CAN1); //GPIOD1複用為CAN1_TX
	GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_CAN1); //GPIOD0複用為CAN1_RX

	//CAN單元設置
	CAN_InitStructure.CAN_TTCM=DISABLE;	//非時間觸發通信模式   
	CAN_InitStructure.CAN_ABOM=DISABLE;	//軟件自動離線管理	  
	CAN_InitStructure.CAN_AWUM=DISABLE;//睡眠模式通過軟件喚醒(清除CAN->MCR的SLEEP位)
	CAN_InitStructure.CAN_NART=ENABLE;	//禁止報文自動傳送 
	CAN_InitStructure.CAN_RFLM=DISABLE;	//報文不鎖定,新的覆蓋舊的  
	CAN_InitStructure.CAN_TXFP=DISABLE;	//優先級由報文標識符決定 
	CAN_InitStructure.CAN_Mode= CAN_Mode_Normal;	 //模式設置 
	CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;	//重新同步跳躍寬度(Tsjw)為tsjw+1個時間單位 CAN_SJW_1tq~CAN_SJW_4tq
	CAN_InitStructure.CAN_BS1=CAN_BS1_9tq; //Tbs1範圍CAN_BS1_1tq ~CAN_BS1_16tq
	CAN_InitStructure.CAN_BS2=CAN_BS2_4tq;//Tbs2範圍CAN_BS2_1tq ~	CAN_BS2_8tq
	CAN_InitStructure.CAN_Prescaler=3;  //分頻係數(Fdiv)為brp+1	
	CAN_Init(CAN1, &CAN_InitStructure);   // 初始化CAN1 
	
	//配置過濾器
	CAN_FilterInitStructure.CAN_FilterNumber=0;	  //過濾器0
	CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask; 
	CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32位 
	CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;////32位ID
	CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//32位MASK
	CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;//過濾器0關聯到FIFO0
	CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //激活過濾器0
	CAN_FilterInit(&CAN_FilterInitStructure);//濾波器初始化
	
	CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);//★FIFO0★消息掛號中斷允許.		    

	NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;     // 主優先級為1
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;            // 次優先級為0
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);
}
開發者ID:wms124,項目名稱:DST_RoboMaster,代碼行數:58,代碼來源:DST_CAN_1.cpp

示例8: InitCAN

void InitCAN(void)
{
	// Setup CAN Pins
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
	
	GPIO_InitTypeDef  GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Pin = CAN_RX_PIN | CAN_TX_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	// Alternate functions
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_CAN1);
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_CAN1);
	
	
	// Setup CAN-modules
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);

	/* CAN register init */
	CAN_DeInit(CAN1);

	/* CAN cell init */
	CAN_InitTypeDef CAN_InitStructure;
	CAN_InitStructure.CAN_TTCM = DISABLE;
	CAN_InitStructure.CAN_ABOM = DISABLE;
	CAN_InitStructure.CAN_AWUM = DISABLE;
	CAN_InitStructure.CAN_NART = DISABLE;
	CAN_InitStructure.CAN_RFLM = DISABLE;
	CAN_InitStructure.CAN_TXFP = DISABLE;
	CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
	CAN_InitStructure.CAN_SJW = CAN_SJW_3tq;

	/* CAN Baudrate = 500 KBps (CAN clocked at 42 MHz) */
	CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
	CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
	CAN_InitStructure.CAN_Prescaler = (42000000 / 7) / 500000;
	CAN_Init(CAN1, &CAN_InitStructure);

	/* CAN filter init */
	CAN_FilterInitTypeDef CAN_FilterInitStructure;
	CAN_FilterInitStructure.CAN_FilterNumber = 0;
	CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
	CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
	CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
	CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
	CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);

	/* Enable FIFO 0 message pending Interrupt */
	CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);
}
開發者ID:ION-Racing,項目名稱:Sikkerhetsmodul,代碼行數:57,代碼來源:CAN.c

示例9: TSVN_CAN_Init

void TSVN_CAN_Init(void)
{
	GPIO_InitTypeDef  GPIO_InitStructure;
	CAN_InitTypeDef CAN_InitStructure;
	CAN_FilterInitTypeDef CAN_FilterInitStructure;
	NVIC_InitTypeDef  NVIC_InitStructure;
	
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);  
  GPIO_PinRemapConfig(GPIO_Remap2_CAN1 , ENABLE);
  GPIO_PinRemapConfig(GPIO_Remap_PD01 , ENABLE);
	
	CAN_DeInit(CAN1);
	
	CAN_InitStructure.CAN_TTCM = DISABLE;
  CAN_InitStructure.CAN_ABOM = DISABLE;
  CAN_InitStructure.CAN_AWUM = DISABLE;
  CAN_InitStructure.CAN_NART = DISABLE;
  CAN_InitStructure.CAN_RFLM = DISABLE;
  CAN_InitStructure.CAN_TXFP = DISABLE;
  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
	
	CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
  CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;  //3
  CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;	//5
  CAN_InitStructure.CAN_Prescaler = 4;
	
	CAN_FilterInitStructure.CAN_FilterNumber = 0;
	CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
  CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
  CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
  CAN_FilterInit(&CAN_FilterInitStructure);
	CAN_ITConfig(CAN1,CAN_IT_FMP0, ENABLE);  
	CAN_Init(CAN1, &CAN_InitStructure);
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
	NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
	
}
開發者ID:NguyenTrongThinh,項目名稱:TestPIDAndSensor,代碼行數:57,代碼來源:AMES_CAN.c

示例10: can_efilt

/*note: there are 14 32bit filter bank, we separate it half for RFIFO0 and half for RFIFO1*/
int can_efilt(int rfifo, can_filter_t const *filter, int n)
{
	int i, j, ret = 0;
	short id0, id1, msk0, msk1;
	CAN_FilterInitTypeDef  CAN_FilterInitStructure;

	if ((n == 0) || (filter == NULL)) {
		/* CAN filter init */
		CAN_FilterInitStructure.CAN_FilterNumber = 0;
		CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; //default id mask mode
		CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit; //default id 16bit
		CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0;
		CAN_FilterInitStructure.CAN_FilterIdLow = 0x0;
		CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0;
		CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0;
		CAN_FilterInitStructure.CAN_FilterFIFOAssignment = (rfifo == 0) ? CAN_FilterFIFO0 : CAN_FilterFIFO1 ; //default fifo use 0
		CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
		CAN_FilterInit(&CAN_FilterInitStructure);
	} else {
		for(i = 0, j = (rfifo == 0) ? 0 : 7; i < n; j ++) {
			id0 = filter[i].id << 5;
			msk0 = filter[i].mask << 5;
			i ++;

			id1 = (i < n) ? filter[i].id << 5 : 0x0000;
			msk1 = (i < n) ? filter[i].mask << 5 : 0xffff;
			i ++;

			/* CAN filter init */
			CAN_FilterInitStructure.CAN_FilterNumber = j;
			CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; //default id mask mode
			CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit; //default id 16bit
			CAN_FilterInitStructure.CAN_FilterIdHigh = id0;
			CAN_FilterInitStructure.CAN_FilterIdLow = id1;
			CAN_FilterInitStructure.CAN_FilterMaskIdHigh = msk0;
			CAN_FilterInitStructure.CAN_FilterMaskIdLow = msk1;
			CAN_FilterInitStructure.CAN_FilterFIFOAssignment = (rfifo == 0) ? CAN_FilterFIFO0 : CAN_FilterFIFO1 ; //default fifo use 0
			CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
			CAN_FilterInit(&CAN_FilterInitStructure);
		}
	}

	return ret;
}
開發者ID:miaofng,項目名稱:ulp,代碼行數:45,代碼來源:can1_stm32.c

示例11: CAN_Configuration

void CAN_Configuration(void)
{
  
  /* CAN1 Periph clock enable */
  
  CAN_InitTypeDef        CAN_InitStructure;
  CAN_FilterInitTypeDef  CAN_FilterInitStructure;
  /* CAN register init */
  CAN_DeInit(CAN1);
  CAN_DeInit(CAN2);
  CAN_StructInit(&CAN_InitStructure);

  /* CAN cell init */ 
  CAN_InitStructure.CAN_TTCM = DISABLE;
  CAN_InitStructure.CAN_ABOM = DISABLE;
  CAN_InitStructure.CAN_AWUM = DISABLE;
  CAN_InitStructure.CAN_NART = DISABLE;
  CAN_InitStructure.CAN_RFLM = DISABLE;
  CAN_InitStructure.CAN_TXFP = DISABLE;
  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
  CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
  CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
  CAN_InitStructure.CAN_Prescaler = 16;//2 4=1m 8=500k
  CAN_Init(CAN1, &CAN_InitStructure);
  CAN_Init(CAN2, &CAN_InitStructure);
 /* CAN filter init */
 
  CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
  CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
  CAN_FilterInitStructure.CAN_FilterNumber=0;
  CAN_FilterInit(&CAN_FilterInitStructure);
  CAN_FilterInitStructure.CAN_FilterNumber=14;
  CAN_FilterInit(&CAN_FilterInitStructure);
 
  
}
開發者ID:mongolia19,項目名稱:detectorstm32,代碼行數:43,代碼來源:main.c

示例12: canFilterApply

void canFilterApply()
{
	int i;
	// setup can filters
	for (i = 0; i < FILTER_NUM; i++) {
		if (CAN_Filters[i].CAN_FilterActivation == DISABLE) 
			break;
		CAN_FilterInit(&CAN_Filters[i]);
	}
}
開發者ID:Farewellly,項目名稱:STM32,代碼行數:10,代碼來源:can.c

示例13: CAN_Configuration

 /**
  * @file   CAN_Configuration
  * @brief  Configures the CAN
  * @param  無
  * @retval 無
  */
void CAN_Configuration(void)
{
  CAN_InitTypeDef        CAN_InitStructure;
  CAN_FilterInitTypeDef  CAN_FilterInitStructure;

  GPIO_Configuration();
  /* CAN register init */
  CAN_DeInit(CAN1);
  CAN_StructInit(&CAN_InitStructure);

  /* CAN cell init */
  CAN_InitStructure.CAN_TTCM = DISABLE; /* 時間觸發禁止, 時間觸發:CAN硬件的內部定時器被激活,並且被用於產生時間戳 */
  CAN_InitStructure.CAN_ABOM = DISABLE; /* 自動離線禁止,自動離線:一旦硬件監控到128次11個隱性位,就自動退出離線狀態。在這裏要軟件設定後才能退出 */
  CAN_InitStructure.CAN_AWUM = DISABLE; /* 自動喚醒禁止,有報文來的時候自動退出休眠	*/
  CAN_InitStructure.CAN_NART = DISABLE; /* 報文重傳, 如果錯誤一直傳到成功止,否則隻傳一次 */
  CAN_InitStructure.CAN_RFLM = DISABLE; /* 接收FIFO鎖定, 1--鎖定後接收到新的報文摘不要,0--接收到新的報文則覆蓋前一報文	*/
  CAN_InitStructure.CAN_TXFP = ENABLE;  /* 發送優先級  0---由標識符決定  1---由發送請求順序決定	*/
  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal; /* 模式	*/
  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;      /* 重新同步跳寬,隻有can硬件處於初始化模式時才能訪問這個寄存器 */
  CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;      /* 時間段1 */
  CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;      /* 時間段2 */
  CAN_InitStructure.CAN_Prescaler = 45;         /* 波特率預分頻數 */  
 
  /* 波特率計算方法 */
  /* CANbps= Fpclk/((BRP+1)*((Tseg1+1)+(Tseg2+1)+1)  此處計算為  CANbps=36000000/(45*(4+3+1))=100kHz */   														  //此處Tseg1+1 = CAN_BS1_8tp
  /* 配置大方向: Tseg1>=Tseg2  Tseg2>=tq; Tseg2>=2TSJW */
    
  if (CAN_Init(CAN1,&CAN_InitStructure) == CANINITFAILED) 		
  {
    /* 初始化時先設置CAN_MCR的初始化位 */  														
    /* 然後查看硬件是否真的設置了CAN_MSR的初始化位來確認是否進入了初始化模式  */		 													                  
  }	
  /* 配置CAN過濾器 */
  /* 32位對應的id */
  /* stdid[10:0],extid[17:0],ide,rtr	*/
  /* 16位對應的id */
  /* stdid[10:0],ide,rtr,extid[17:15] */
  /* 一般使用屏蔽模式	*/
  /* 要注意的是fifo接收存滿了中斷,還有就是fifo的概念,即取的一直是最早那一個數據, 要釋放才能取下一個數據 */
  /* 常使用的中斷有 */
  /* 1,有信息中斷,即fifo掛號中斷 */
  /* 2,fifo滿中斷	*/
  /* 3,fifo滿之後又有信息來則中斷,即fifo溢出中斷	*/
  CAN_FilterInitStructure.CAN_FilterNumber=0;     /* 過濾器0 */
  CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;  /* 屏敝模式 */
  CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; /* 32位 */
  CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;  /* 以下四個都為0, 表明不過濾任何id */
  CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;  /* 能夠通過該過濾器的報文存到fifo0中 */
  CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
  CAN_ITConfig(CAN1,CAN_IT_FMP0, ENABLE);   /* 掛號中斷, 進入中斷後讀fifo的報文函數釋放報文清中斷標誌 */
  CAN_FilterInit(&CAN_FilterInitStructure);
}
開發者ID:pyjhhh,項目名稱:stm32_f1x,代碼行數:61,代碼來源:can.c

示例14: CAN_Open

void CAN_Open() 
{
  CAN_InitTypeDef        CAN_InitStructure;
  CAN_FilterInitTypeDef  CAN_FilterInitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN, ENABLE);

  // Configure CAN pin: RX
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  // Configure CAN pin: TX
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* CAN register init */
  CAN_DeInit();
  CAN_StructInit(&CAN_InitStructure);

  /* CAN cell init */
  CAN_InitStructure.CAN_TTCM=DISABLE;
  CAN_InitStructure.CAN_ABOM=DISABLE;
  CAN_InitStructure.CAN_AWUM=DISABLE;
  //CAN_InitStructure.CAN_NART=DISABLE;
  CAN_InitStructure.CAN_NART=ENABLE; //no automatic retransmission
  CAN_InitStructure.CAN_RFLM=DISABLE;
  CAN_InitStructure.CAN_TXFP=DISABLE;

  CAN_InitStructure.CAN_Mode=CAN_Mode_Normal;
  
  //CAN block is clocked with Low Speed APB1 clock (PCLK1) = 36MHz
  CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
  CAN_InitStructure.CAN_BS1=CAN_BS1_9tq; //CAN_BS1_8tq @ 24mhz
  CAN_InitStructure.CAN_BS2=CAN_BS2_8tq; //CAN_BS2_7tq @24mhz
  CAN_InitStructure.CAN_Prescaler=4; //=3  [email protected]
  
  CAN_Init(&CAN_InitStructure);

  /* CAN filter init */
  CAN_FilterInitStructure.CAN_FilterNumber=0;
  CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
  CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
  CAN_FilterInit(&CAN_FilterInitStructure);
}
開發者ID:JacekGreniger,項目名稱:stm32-vagcanlogger,代碼行數:54,代碼來源:can.c

示例15: RCC_APB1PeriphClockCmd

/**
 * \brief Call this method to make the CANTestcase driver configure pins,
 * set up the CAN peripheral et cetera.
 */
void CANTestcase::setUp()
{
	// Enable CAN1 peripheral clock.
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1,ENABLE);
	// Enable GPIO clock of CAN_Tx and CAN_Rx pins.
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);

	/* Configure CAN pin: RX */
	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	/* Configure CAN pin: TX */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
	//GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	// Configure CAN peripheral:
	CAN_InitTypeDef        CAN_InitStructure;
	/* CAN register init */
	CAN_DeInit(CAN1);
	CAN_StructInit(&CAN_InitStructure);

	CAN_InitStructure.CAN_TTCM = DISABLE;
	CAN_InitStructure.CAN_ABOM = DISABLE;
	CAN_InitStructure.CAN_AWUM = DISABLE;
	CAN_InitStructure.CAN_NART = ENABLE;
	CAN_InitStructure.CAN_RFLM = DISABLE;
	CAN_InitStructure.CAN_TXFP = DISABLE;
	CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
	CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
	CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
	CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
	CAN_InitStructure.CAN_Prescaler = 20;
	CAN_Init(CAN1, &CAN_InitStructure);

	/* CAN filter init */
	CAN_FilterInitTypeDef  CAN_FilterInitStructure;
	CAN_FilterInitStructure.CAN_FilterNumber=0;
	CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
	CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
	CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
	CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
	CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
	CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
	CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);

}//eof
開發者ID:akaAP,項目名稱:akaAP_flight,代碼行數:57,代碼來源:CANTestcase.cpp


注:本文中的CAN_FilterInit函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。