Beispiel #1
0
int
PX4FMU::ioctl(file *filp, int cmd, unsigned long arg)
{
	int ret;

	/* try it as a GPIO ioctl first */
	ret = gpio_ioctl(filp, cmd, arg);

	if (ret != -ENOTTY) {
		return ret;
	}

	/* if we are in valid PWM mode, try it as a PWM ioctl as well */
	switch (_mode) {
	case MODE_2PWM:
	case MODE_4PWM:
	case MODE_6PWM:
#ifdef CONFIG_ARCH_BOARD_AEROCORE
	case MODE_8PWM:
#endif
		ret = pwm_ioctl(filp, cmd, arg);
		break;

	default:
		DEVICE_DEBUG("not in a PWM mode");
		break;
	}

	/* if nobody wants it, let CDev have it */
	if (ret == -ENOTTY) {
		ret = CDev::ioctl(filp, cmd, arg);
	}

	return ret;
}
static RET_CODE i2c_gpio_open(lld_i2c_t *p_lld, struct i2c_cfg *p_cfg)
{
  i2c_gpio_priv_t *p_priv = NULL;
  drv_dev_t *p_dev = NULL;
  device_base_t *p_base = NULL;

  p_dev = DEV_FIND_BY_LLD(drv_dev_t, p_lld);
  p_base = p_dev->p_base;
  
  p_priv = (i2c_gpio_priv_t *)mtos_malloc(sizeof(i2c_gpio_priv_t));
  MT_ASSERT(NULL != p_priv);
  p_lld->p_priv = p_priv;

  MT_ASSERT(NULL != p_cfg);
  p_priv->clock_period = 500/p_cfg->bus_clk_khz; //500000/1000/cfg->bus_clk_khz
  p_priv->scl = p_cfg->scl;
  p_priv->sda = p_cfg->sda;
  if(p_base->lock_mode >= MAX_NUM_LOCK_MODE)
  {
    p_base->lock_mode = OS_MUTEX_LOCK;
  }
  else
  {
    p_base->lock_mode = p_cfg->lock_mode;
  }
  
  hal_pinmux_gpio_enable(p_priv->scl, TRUE);
  hal_pinmux_gpio_enable(p_priv->sda, TRUE);
  gpio_ioctl(GPIO_CMD_IO_ENABLE, p_priv->scl,1);
  gpio_ioctl(GPIO_CMD_IO_ENABLE, p_priv->sda,1);

  SET_SDA_HI(p_priv);
  SET_SCL_HI(p_priv);
  SET_SCL_OUT(p_priv);

  return SUCCESS;
}
Beispiel #3
0
int
PX4FMU::ioctl(file *filp, int cmd, unsigned long arg)
{
	int ret;

	// XXX disabled, confusing users
	//debug("ioctl 0x%04x 0x%08x", cmd, arg);

	/* try it as a GPIO ioctl first */
	ret = gpio_ioctl(filp, cmd, arg);

	if (ret != -ENOTTY)
		return ret;

	/* if we are in valid PWM mode, try it as a PWM ioctl as well */
	switch (_mode) {
	case MODE_2PWM:
	case MODE_4PWM:
	case MODE_6PWM:
#ifdef CONFIG_ARCH_BOARD_AEROCORE
	case MODE_8PWM:
#endif
		ret = pwm_ioctl(filp, cmd, arg);
		break;

	default:
		debug("not in a PWM mode");
		break;
	}

	/* if nobody wants it, let CDev have it */
	if (ret == -ENOTTY)
		ret = CDev::ioctl(filp, cmd, arg);

	return ret;
}
Beispiel #4
0
sint8 m2m_periph_gpio_set_val(uint8 u8GpioNum, uint8 u8GpioVal)
{
	return gpio_ioctl(GPIO_OP_SET, u8GpioNum, u8GpioVal, NULL);
}
Beispiel #5
0
sint8 m2m_periph_gpio_set_dir(uint8 u8GpioNum, uint8 u8GpioDir)
{
	return gpio_ioctl(GPIO_OP_DIR, u8GpioNum, u8GpioDir, NULL);
}
Beispiel #6
0
sint8 m2m_periph_gpio_get_val(uint8 u8GpioNum, uint8 * pu8GpioVal)
{
	return gpio_ioctl(GPIO_OP_GET, u8GpioNum, 0, pu8GpioVal);
}
Beispiel #7
0
sint8 m2m_periph_gpio_get_val(uint8 u8GpioNum, uint8 * pu8GpioVal)
{
	(void)u8GpioNum; // Silence "unused" warning

	return gpio_ioctl(GPIO_OP_GET, u8GpioNum, 0, pu8GpioVal);
}