Beispiel #1
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
}
Beispiel #2
0
int board_can_initialize(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)
        {
          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;
        }

      /* Now we are initialized */

      initialized = true;
    }

  return OK;
}
Beispiel #3
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
}
Beispiel #4
0
int canlib_setsilent(int fd, bool silent)
{
  int ret;
  struct canioc_connmodes_s connmodes;

  ret = ioctl(fd, CANIOC_GET_CONNMODES, (unsigned long)&connmodes);
  if (ret != OK)
    {
      canerr("CANIOC_GET_CONNMODES failed, errno=%d\n", errno);
      return ret;
    }

  connmodes.bm_silent = !!silent;

  ret = ioctl(fd, CANIOC_SET_CONNMODES, (unsigned long)&connmodes);
  if (ret != OK)
    {
      canerr("CANIOC_SET_CONNMODES failed, errno=%d\n", errno);
    }

  return ret;
}