当前位置: 首页>>代码示例>>C++>>正文


C++ CAN_Init函数代码示例

本文整理汇总了C++中CAN_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ CAN_Init函数的具体用法?C++ CAN_Init怎么用?C++ CAN_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CAN_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: c_entry

/*********************************************************************//**
 * @brief       c_entry: Main CAN program body
 * @param[in]   none
 * @return      none
 **********************************************************************/
void c_entry(void)
{
    /* Initialize debug via UART0
     * – 115200bps
     * – 8 data bit
     * – No parity
     * – 1 stop bit
     * – No flow control
     */
    debug_frmwrk_init();
    print_menu();

    /* Initialize CAN1 peripheral
     * Note: Self-test mode doesn't require pin selection
     */
    CAN_Init(_USING_CAN_NO, 125000);

    //Enable self-test mode
    CAN_ModeConfig(_USING_CAN_NO, CAN_SELFTEST_MODE, ENABLE);

    //Enable Interrupt
    CAN_IRQCmd(_USING_CAN_NO, CANINT_RIE, ENABLE);
    CAN_IRQCmd(_USING_CAN_NO, CANINT_TIE1, ENABLE);

    //Enable CAN Interrupt
    NVIC_EnableIRQ(CAN_IRQn);

    CAN_SetAFMode(CAN_ACC_BP);

    CAN_InitMessage();

    _DBG_("Transmitted buffer:");

    PrintMessage(&TXMsg);

    /** To test Bypass Mode: we send infinite messages to CAN2 and check
     * receive process via COM1
     */
    CAN_SendMsg(_USING_CAN_NO, &TXMsg);

#if (_USING_CAN_NO == CAN_1)
    LPC_CAN1->CMR |=(1<<4); //Self Reception Request
#else
    LPC_CAN2->CMR |=(1<<4);
#endif

    while (1);
}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:53,代码来源:Can_Selftest.c

示例2: SetupHardware

/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	USB_Init();

	CAN_Init();
}
开发者ID:saeugetier,项目名称:usb2can,代码行数:17,代码来源:USB2Can.c

示例3: main

int main()
{
	int i=0;
	int err=0;
	signal(SIGTERM, signal_handler);
	signal(SIGINT, signal_handler);

	mlockall(MCL_CURRENT | MCL_FUTURE);

	can_handle = CAN_Open(HW_PCI, 1);
	CAN_Init(can_handle, CAN_BAUD_1M, CAN_INIT_TYPE_EX);
	printf("Status = %i\n", CAN_Status(can_handle));

	err=rt_task_create(&test_task, "test", 0, 99, T_JOINABLE);
	if (err) {
      		printf("receivetest: Failed to create rt task, code %d\n",errno);
      	return err;
	}
 	rt_task_start(&test_task, test, NULL);
	if (err) {
      		printf("receivetest: Failed to start rt task, code %d\n",errno);
      	return errno;
    	}
	rt_task_join(&test_task);

	for (i = 0; i < 5; i++)
	{
		printf(
			"Frame = %08lx %02x %02x %02x %02x %02x %02x %02x %02x, Time diff = %llu ns\n",
			(unsigned long) can_msg[i].Msg.ID,
			can_msg[i].Msg.DATA[0],
			can_msg[i].Msg.DATA[1],
			can_msg[i].Msg.DATA[2],
			can_msg[i].Msg.DATA[3],
			can_msg[i].Msg.DATA[4],
			can_msg[i].Msg.DATA[5],
			can_msg[i].Msg.DATA[6],
			can_msg[i].Msg.DATA[7],
			i == 0 ? 0 :
				(can_msg[i].dwTime*(unsigned long long)1000+can_msg[i].wUsec)*1000-
				(can_msg[i-1].dwTime*(unsigned long long)1000+can_msg[i-1].wUsec)*1000
		);
	}

	CAN_Close(can_handle);
	return 0;
}
开发者ID:AaronMR,项目名称:AaronMR_Robotic_Stack,代码行数:47,代码来源:xenomai_receive_test.c

示例4: CAN_Com_LoopBack

void CAN_Com_LoopBack(void)
{
  /* initialize the CAN at a standard bitrate, interrupts disabled */
  CAN_InitStructure.CAN_ConfigParameters=0x0;
  CAN_InitStructure.CAN_Bitrate=CAN_BITRATE_1M;
  CAN_Init(&CAN_InitStructure);

  /* switch into Loopback+Silent mode (self-test) */
  CAN_EnterTestMode(CAN_TESTR_LBACK | CAN_TESTR_SILENT);

  /* configure the message objects */
  CAN_InvalidateAllMsgObj();
  CAN_SetTxMsgObj(CAN_TX_MSGOBJ, CAN_STD_ID);
  CAN_SetRxMsgObj(CAN_RX_MSGOBJ, CAN_STD_ID, 0, CAN_LAST_STD_ID, TRUE);

  /* Send the pre-defined answer */
  CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg[1]);

  /* wait until end of transmission */
  CAN_WaitEndOfTx();

  /* wait for reception of a data frame */
  while (!CAN_ReceiveMessage(CAN_RX_MSGOBJ, FALSE, &RxCanMsg))
  {
    /*Add Timer*/
  }


  /* Test Received Msg */
  if((RxCanMsg.IdType == CAN_STD_ID)&&(RxCanMsg.Id == 0x321)&&(RxCanMsg.Dlc == 4)
    &&(RxCanMsg.Data[0]==0xAA)&&(RxCanMsg.Data[1]==0x55)&&(RxCanMsg.Data[2]==0xAA)&&(RxCanMsg.Data[3]==0x55)){
    /*Received Msg OK*/
    LED_ON(LD2);
  } else {
    /*Received Msg KO*/
    LED_ON(LD4);
  }


  /* release the message objects */
  CAN_ReleaseTxMessage(CAN_TX_MSGOBJ);
  CAN_ReleaseRxMessage(CAN_RX_MSGOBJ);

  /* switch back into Normal mode */
  CAN_LeaveTestMode();

}
开发者ID:LupusDei,项目名称:8LU-DSP,代码行数:47,代码来源:main.c

示例5: CAN_Initialise

void CAN_Initialise()
{
	CAN_InitTypeDef CAN_InitStruct;
    CAN_FilterInitTypeDef  CAN_FilterInitStructure;
	
	void GPIO_Initialise();
	
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1,ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN2,ENABLE);
	
	/* CAN register init */
	CAN_DeInit(CAN2);
	
	/* CAN cell init */
	CAN_InitStruct.CAN_TTCM = DISABLE;
	CAN_InitStruct.CAN_ABOM = DISABLE;
	CAN_InitStruct.CAN_AWUM = DISABLE;
	CAN_InitStruct.CAN_NART = DISABLE;
	CAN_InitStruct.CAN_RFLM = DISABLE;
	CAN_InitStruct.CAN_TXFP = DISABLE;
	CAN_InitStruct.CAN_Mode = CAN_Mode_Normal;
	CAN_InitStruct.CAN_SJW = CAN_SJW_3tq;

    //Bus length 3-5m.
    
	/* CAN Baudrate = 500 KBps (CAN clocked at 42 MHz) */
	CAN_InitStruct.CAN_BS1 = CAN_BS1_4tq;
	CAN_InitStruct.CAN_BS2 = CAN_BS2_2tq;
	CAN_InitStruct.CAN_Prescaler = (42000000 / 7) / 500000; //12
	CAN_Init(CAN2, &CAN_InitStruct);

	/* 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);

	/* Enable FIFO 0 message pending Interrupt */
	CAN_ITConfig(CAN2, CAN_IT_FMP0, ENABLE);

}
开发者ID:fwjensen,项目名称:STM32_init,代码行数:47,代码来源:CAN.c

示例6: _roboveroConfig

/*
 * Configure the pins according to their intended default function
 */
int _roboveroConfig(uint8_t * args)
{
    int i;
    UART_CFG_Type UARTConfigStruct;
    PWM_TIMERCFG_Type PWMCfgDat;

    configAllPins();

    /*
     * Enable 7 analog inputs
     */
    ADC_Init(LPC_ADC, 200000);
    for (i = 0; i < 4; i++)
    		ADC_ChannelCmd(LPC_ADC, i, ENABLE); 
    for (i = 5; i < 8; i++)
        ADC_ChannelCmd(LPC_ADC, i, ENABLE);
    /*
     * Configure I2C0 for IMU communications
     */
    I2C_Init(LPC_I2C0, 100000);
    I2C_Cmd(LPC_I2C0, ENABLE);

    /*
     * Initialize CAN bus
     */
    CAN_Init(LPC_CAN1, 100000);

    /*
     * Initialize UART1 
     */
    UART_ConfigStructInit(&UARTConfigStruct);
    UARTConfigStruct.Baud_rate = 115200;
    UART_Init((LPC_UART_TypeDef*)LPC_UART1, &UARTConfigStruct);
    UART_TxCmd((LPC_UART_TypeDef*)LPC_UART1, ENABLE);

    /*
     * Initialize PWM
     *
     * Peripheral clock is 30MHz. Prescale by 30 cycles for 1us resolution.
     */    
    PWMCfgDat.PrescaleOption = PWM_TIMER_PRESCALE_TICKVAL;
    PWMCfgDat.PrescaleValue = 30;
    PWM_Init(LPC_PWM1, PWM_MODE_TIMER, &PWMCfgDat);

    return 0;
}
开发者ID:AutonomyLab,项目名称:Raymond,代码行数:49,代码来源:extras.c

示例7: CAN_Open

PcanPci::PcanPci(unsigned char port, unsigned short speed)
{
    std::cout << "Connecting to PCAN PCI... ";
    pcanHandle = CAN_Open(HW_PCI, port);

    if (pcanHandle == NULL)
        std::cout << "error!" << std::endl;
    else if (!CAN_Init(pcanHandle, speed, CAN_INIT_TYPE_ST) == 0)
        std::cout << "error!" << std::endl;
    else if (!resetMsgFilter())
        std::cout << "error!" << std::endl;
    else
    {
        emptyReadQueue();
        std::cout << "done!" << std::endl;
    }
}
开发者ID:nixz,项目名称:covise,代码行数:17,代码来源:PcanPci.cpp

示例8: _CAN1_Init

void _CAN1_Init()
{
	
	CAN_InitTypeDef CAN_InitStructure;
	CAN_FilterInitTypeDef  CAN_FilterInitStructure; 
	NVIC_InitTypeDef NVIC_InitStructure;	

	_CAN1_GPIO_Init();
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1,ENABLE);
	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_Mode=CAN_Mode_LoopBack;
	CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;/*重新同步跳宽*/
	CAN_InitStructure.CAN_BS1=CAN_BS1_4tq;/*时间段1*/
	CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;/*时间段2*/
	CAN_InitStructure.CAN_Prescaler=45;/*波特率预分频数*/
	CAN_Init(CAN1,&CAN_InitStructure);
	
	//允许所有报文通过
	CAN_FilterInitStructure.CAN_FilterNumber=0; //设置过滤器组0,范围为0~13
	CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;//指定过滤器被设置为标识符屏蔽模式
	CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;//给出过滤器位宽为32位
	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;//为过滤器分配缓存 此处到//fifo 因为 CAN_FilterInitStructure.CAN_FilterNumber=0;
	CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
	CAN_FilterInit(&CAN_FilterInitStructure);
	CAN_ITConfig(CAN1,CAN_IT_FMP0, ENABLE);
	
	NVIC_InitStructure.NVIC_IRQChannel=CAN1_RX1_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);	
}
开发者ID:RTOS-Developers,项目名称:TRTOS,代码行数:42,代码来源:Can2_Driver.c

示例9: switch

bool CANPeakSysUSB::initCAN() {
	int ret = CAN_ERR_OK;
	bool bRet = true;

	switch(m_iBaudrateVal)
	{
	case 0:
		ret = CAN_Init(m_handle, CAN_BAUD_1M, CAN_INIT_TYPE_ST);
		break;
	case 2:
		ret = CAN_Init(m_handle, CAN_BAUD_500K, CAN_INIT_TYPE_ST);
		break;
	case 4:
		ret = CAN_Init(m_handle, CAN_BAUD_250K, CAN_INIT_TYPE_ST);
		break;
	case 6:
		ret = CAN_Init(m_handle, CAN_BAUD_125K, CAN_INIT_TYPE_ST);
		break;
	case 9:
		ret = CAN_Init(m_handle, CAN_BAUD_50K, CAN_INIT_TYPE_ST);
		break;
	case 11:
		ret = CAN_Init(m_handle, CAN_BAUD_20K, CAN_INIT_TYPE_ST);
		break;
	case 13:
		ret = CAN_Init(m_handle, CAN_BAUD_10K, CAN_INIT_TYPE_ST);
		break;
	}

	if(ret)
	{
		std::cout << "CANPeakSysUSB::CANPeakSysUSB(), error in init" << std::endl;
		m_bInitialized = false;
		bRet = false;
	}
	else
	{
		std::cout << "CANPeakSysUSB::CanpeakSys(), init ok" << std::endl;
		m_bInitialized = true;
		bRet = true;
	}
	
	return bRet;
}
开发者ID:LucaLattanzi,项目名称:cob_driver,代码行数:44,代码来源:CanPeakSysUSB.cpp

示例10: switch

bool ros_for_can::initCAN() {
    int ret = CAN_ERR_OK;
    bool bRet = true;

    switch(m_iBaudrateVal)
    {
    case CANITFBAUD_1M:
        ret = CAN_Init(m_handle, CAN_BAUD_1M, CAN_INIT_TYPE_ST);
        break;
    case CANITFBAUD_500K:
        ret = CAN_Init(m_handle, CAN_BAUD_500K, CAN_INIT_TYPE_ST);
        break;
    case CANITFBAUD_250K:
        ret = CAN_Init(m_handle, CAN_BAUD_250K, CAN_INIT_TYPE_ST);
        break;
    case CANITFBAUD_125K:
        ret = CAN_Init(m_handle, CAN_BAUD_125K, CAN_INIT_TYPE_ST);
        break;
    case CANITFBAUD_50K:
        ret = CAN_Init(m_handle, CAN_BAUD_50K, CAN_INIT_TYPE_ST);
        break;
    case CANITFBAUD_20K:
        ret = CAN_Init(m_handle, CAN_BAUD_20K, CAN_INIT_TYPE_ST);
        break;
    case CANITFBAUD_10K:
        ret = CAN_Init(m_handle, CAN_BAUD_10K, CAN_INIT_TYPE_ST);
        break;
    }

    if(ret)
    {
        std::cout << "ros_for_can::ros_for_can(), error in init" << std::endl;
        m_bInitialized = false;
        bRet = false;
    }
    else
    {
        std::cout << "ros_for_can::CanpeakSys(), init ok" << std::endl;
        m_bInitialized = true;
        bRet = true;
    }

    return bRet;
}
开发者ID:karvindass,项目名称:yes-we-wheelchair,代码行数:44,代码来源:ros_for_can.cpp

示例11: CAN_Config

/**
  * @brief  Configures the CAN.
  * @param  None
  * @retval : None
  */
void CAN_Config(void)
{
  /* CAN register init */
  CAN_DeInit(CAN1);
  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_10tq;
  CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
  CAN_InitStructure.CAN_Prescaler = 2;
  CAN_Init(CAN1, &CAN_InitStructure);

  /* CAN filter init */
 /* 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);
  
   /* transmit */
  TxMessage.StdId = 0x321;
  TxMessage.ExtId = 0x01;
  TxMessage.RTR = CAN_RTR_DATA;
  TxMessage.IDE = CAN_ID_STD;
  TxMessage.DLC = 1;
  
}
开发者ID:jiesse,项目名称:time-meter,代码行数:46,代码来源:main.c

示例12: CAN_Mode_Config

/*
 * 函数名:CAN_Mode_Config
 * 描述  :CAN的模式 配置
 * 输入  :无
 * 输出  : 无
 * 调用  :内部调用
 */
static void CAN_Mode_Config(void)
{
   	CAN_InitTypeDef        CAN_InitStructure;
	 	/************************CAN通信参数设置**********************************/
	/*CAN寄存器初始化*/
	CAN_DeInit(CAN1);
	CAN_StructInit(&CAN_InitStructure);
	/*CAN单元初始化*/
	CAN_InitStructure.CAN_TTCM=DISABLE;			   //MCR-TTCM  时间触发通信模式使能
    CAN_InitStructure.CAN_ABOM=DISABLE;			   //MCR-ABOM  自动离线管理 
    CAN_InitStructure.CAN_AWUM=DISABLE;			   //MCR-AWUM  自动唤醒模式
    CAN_InitStructure.CAN_NART=DISABLE;			   //MCR-NART  禁止报文自动重传	  DISABLE-自动重传
    CAN_InitStructure.CAN_RFLM=DISABLE;			   //MCR-RFLM  接收FIFO 锁定模式  DISABLE-溢出时新报文会覆盖原有报文  
    CAN_InitStructure.CAN_TXFP=DISABLE;			   //MCR-TXFP  发送FIFO优先级 DISABLE-优先级取决于报文标示符 
    CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;  //正常发送模式
    CAN_InitStructure.CAN_SJW=CAN_SJW_2tq;		   //BTR-SJW 重新同步跳跃宽度 2个时间单元
    CAN_InitStructure.CAN_BS1=CAN_BS1_6tq;		   //BTR-TS1 时间段1 占用了6个时间单元
    CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;		   //BTR-TS1 时间段2 占用了3个时间单元
    CAN_InitStructure.CAN_Prescaler =4;		   ////BTR-BRP 波特率分频器  定义了时间单元的时间长度 36/(1+6+3)/4=0.8Mbps
	CAN_Init(CAN1, &CAN_InitStructure);
}
开发者ID:coderick,项目名称:WildFireExample,代码行数:28,代码来源:can.c

示例13: CAN1_Configuration

void CAN1_Configuration(void)
{
	CAN_InitTypeDef CAN_InitStructure;
	CAN_FilterInitTypeDef CAN_FilterInitStructure;
	
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1,ENABLE);    //注意,挂在APB1

	/************************模式与波特率设置*************/
	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=DISABLE;
	CAN_InitStructure.CAN_RFLM=DISABLE; 
	CAN_InitStructure.CAN_TXFP=DISABLE;
	
	CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;   //CAN_Mode_LoopBack:回环模式,CAN_Mode_Normal:正常模式
	CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
	CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
	CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; 
	CAN_InitStructure.CAN_Prescaler = 4;            //100K通信速度
	CAN_Init(CAN1,&CAN_InitStructure);
	
	/***********************过滤器设置********************/
	CAN_FilterInitStructure.CAN_FilterNumber = 0;    //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 = CAN_FIFO0;    //传入FIFO0
	CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; 
	CAN_FilterInit(&CAN_FilterInitStructure);
	
	CAN_ITConfig(CAN1,CAN_IT_FMP0, ENABLE);         //开启接收中断
	
}
开发者ID:haosir7,项目名称:----,代码行数:40,代码来源:CAN1.c

示例14: arm_caninit

/****************************************************************************
 * Name: arm_caninit(void)
 ****************************************************************************/
int arm_caninit(){

  /* Initialization of the CAN hardware is performed by logic external to
   * this test.
   */
    const char *szDeviceNode = DEFAULT_NODE;

    errno = 0;
  /* Open the CAN device for reading */
   // open the CAN port
   // please use what is appropriate
   // HW_DONGLE_SJA
   // HW_DONGLE_SJA_EPP
   // HW_ISA_SJA
   // HW_PCI
   h = LINUX_CAN_Open(szDeviceNode, O_RDWR);
   if (!h)
   {
     errno = nGetLastError();
     perror("bitratetest: CAN_Open()");
     return 0;
   }

   /*set the bitrate*/
    errno = CAN_Init(h,CAN_BAUD_1M,CAN_INIT_TYPE_ST);
    if(errno)
    {
        perror("set can speed error");
        CAN_Close(h);
        return 0;
    }

  /* Now loop the appropriate number of times, performing one loopback test
   * on each pass.
   */
       printf("can init is ok!\n");
   //return 1 is ok;
    return 1;
}
开发者ID:david715432279,项目名称:ArmIk,代码行数:42,代码来源:arm_joint.c

示例15: canOpen_driver

CAN_HANDLE canOpen_driver(s_BOARD *board)
{
  HANDLE fd0 = NULL;
  char busname[64];
  char* pEnd;
  int baudrate;
  
  if(strtol(board->busname, &pEnd,0) >= 0)
  {
    sprintf(busname,"/dev/pcan%s",board->busname);
    fd0 = LINUX_CAN_Open(busname, O_RDWR);
  }

  if(fd0 && (baudrate = TranslateBaudeRate(board->baudrate)))
  {
   	CAN_Init(fd0, baudrate, CAN_INIT_TYPE_ST);
  }else{
  	fprintf(stderr, "canOpen_driver (Peak_Linux) : error opening %s\n", busname);
  }

   return (CAN_HANDLE)fd0;
}
开发者ID:AubrCool,项目名称:canfestival,代码行数:22,代码来源:can_peak_linux.c


注:本文中的CAN_Init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。