Example #1
0
int zkit_can_setup(void)
{
#if defined(CONFIG_LPC17_CAN1) || defined(CONFIG_LPC17_CAN2)
  struct can_dev_s *can;
  int ret;

#ifdef CONFIG_LPC17_CAN1
  /* Call lpc17_caninitialize() to get an instance of the CAN1 interface */

  can = lpc17_caninitialize(CAN_PORT1);
  if (can == NULL)
    {
      canerr("ERROR:  Failed to get CAN1 interface\n");
      return -ENODEV;
    }

  /* Register the CAN1 driver at "/dev/can0" */

  ret = can_register("/dev/can0", can);
  if (ret < 0)
    {
      canerr("ERROR: CAN1 register failed: %d\n", ret);
      return ret;
    }
#endif

#ifdef CONFIG_LPC17_CAN2
  /* Call lpc17_caninitialize() to get an instance of the CAN2 interface */

  can = lpc17_caninitialize(CAN_PORT2);
  if (can == NULL)
    {
      canerr("ERROR:  Failed to get CAN2 interface\n");
      return -ENODEV;
    }

  /* Register the CAN2 driver at "/dev/can1" */

  ret = can_register("/dev/can1", can);
  if (ret < 0)
    {
      canerr("ERROR: CAN2 register failed: %d\n", ret);
      return ret;
    }
#endif

  return OK;
#else
  return -ENODEV;
#endif
}
Example #2
0
int can_devinit(void)
{
	static bool initialized = false;
	struct can_dev_s *can;
	int ret;

	/* Check if we have already initialized */

	if (!initialized) {
		/* Call stm32_caninitialize() to get an instance of the CAN interface */

		can = stm32_caninitialize(CAN_PORT);

		if (can == NULL) {
			candbg("ERROR:  Failed to get CAN interface\n");
			return -ENODEV;
		}

		/* Register the CAN driver at "/dev/can0" */

		ret = can_register("/dev/can0", can);

		if (ret < 0) {
			candbg("ERROR: can_register failed: %d\n", ret);
			return ret;
		}

		/* Now we are initialized */

		initialized = true;
	}

	return OK;
}
Example #3
0
int stm32_can_setup(void)
{
#if defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)
  struct can_dev_s *can;
  int ret;

  /* Call stm32_caninitialize() to get an instance of the CAN interface */

  can = stm32_caninitialize(CAN_PORT);
  if (can == NULL)
    {
      canerr("ERROR:  Failed to get CAN interface\n");
      return -ENODEV;
    }

  /* Register the CAN driver at "/dev/can0" */

  ret = can_register("/dev/can0", can);
  if (ret < 0)
    {
      canerr("ERROR: can_register failed: %d\n", ret);
      return ret;
    }

  return OK;
#else
  return -ENODEV;
#endif
}