示例#1
0
void weak_function stm32_spidev_initialize(void)
{
#ifdef CONFIG_STM32_SPI1
  (void)stm32_configgpio(GPIO_MEMS_CS);    /* MEMS chip select */
  (void)stm32_configgpio(GPIO_MEMS_INT1);  /* MEMS interrupts */
  (void)stm32_configgpio(GPIO_MEMS_INT2);
#endif
}
示例#2
0
/*
 * Initialise the timer we are going to use.
 */
void PWMIN::_timer_init(void)
{
	/* run with interrupts disabled in case the timer is already
	 * setup. We don't want it firing while we are doing the setup */
	irqstate_t flags = irqsave();

	/* configure input pin */
	stm32_configgpio(GPIO_PWM_IN);
	/* configure reset pin */
	stm32_configgpio(GPIO_VDD_RANGEFINDER_EN);

	/* claim our interrupt vector */
	irq_attach(PWMIN_TIMER_VECTOR, pwmin_tim_isr);

	/* Clear no bits, set timer enable bit.*/
	modifyreg32(PWMIN_TIMER_POWER_REG, 0, PWMIN_TIMER_POWER_BIT);

	/* disable and configure the timer */
	rCR1 = 0;
	rCR2 = 0;
	rSMCR = 0;
	rDIER = DIER_PWMIN_A;
	rCCER = 0;		/* unlock CCMR* registers */
	rCCMR1 = CCMR1_PWMIN;
	rCCMR2 = CCMR2_PWMIN;
	rSMCR = SMCR_PWMIN_1;	/* Set up mode */
	rSMCR = SMCR_PWMIN_2;	/* Enable slave mode controller */
	rCCER = CCER_PWMIN;
	rDCR = 0;

	/* for simplicity scale by the clock in MHz. This gives us
	 * readings in microseconds which is typically what is needed
	 * for a PWM input driver */
	uint32_t prescaler = PWMIN_TIMER_CLOCK / 1000000UL;

	/*
	 * define the clock speed. We want the highest possible clock
	 * speed that avoids overflows.
	 */
	rPSC = prescaler - 1;

	/* run the full span of the counter. All timers can handle
	 * uint16 */
	rARR = UINT16_MAX;

	/* generate an update event; reloads the counter, all registers */
	rEGR = GTIM_EGR_UG;

	/* enable the timer */
	rCR1 = GTIM_CR1_CEN;

	/* enable interrupts */
	up_enable_irq(PWMIN_TIMER_VECTOR);

	irqrestore(flags);

	_timer_started = true;
}
示例#3
0
void stm32_ledinit(void)
{
   /* Configure LED1-4 GPIOs for output */

   stm32_configgpio(GPIO_LED1);
   stm32_configgpio(GPIO_LED2);
   stm32_configgpio(GPIO_LED3);
   stm32_configgpio(GPIO_LED4);
}
示例#4
0
void stm32_led_initialize(void)
{
  /* Configure LED1-4 GPIOs for output.  Initial state is OFF */

  stm32_configgpio(GPIO_LED1);
  stm32_configgpio(GPIO_LED2);
  stm32_configgpio(GPIO_LED3);
  stm32_configgpio(GPIO_LED4);
}
示例#5
0
void board_autoled_initialize(void)
{
   /* Configure LED1-4 GPIOs for output */

   stm32_configgpio(GPIO_LED1);
   stm32_configgpio(GPIO_LED2);
   stm32_configgpio(GPIO_LED3);
   stm32_configgpio(GPIO_LED4);
}
示例#6
0
__END_DECLS

__EXPORT void led_init()
{
	/* Configure LED1-2 GPIOs for output */

	stm32_configgpio(GPIO_LED1);
	stm32_configgpio(GPIO_LED2);
}
示例#7
0
void up_buttoninit(void)
{
  /* Configure the GPIO pins as inputs.  NOTE that EXTI interrupts are 
   * configured for some pins but NOT used in this file
   */

  stm32_configgpio(GPIO_BTN_KEY1);
  stm32_configgpio(GPIO_BTN_KEY2);
}
示例#8
0
void
interface_init(void)
{
	debug("i2c init");

	/* allocate DMA handles and initialise DMA */
	rx_dma = stm32_dmachannel(DMACHAN_I2C1_RX);
	i2c_rx_setup();
	tx_dma = stm32_dmachannel(DMACHAN_I2C1_TX);
	i2c_tx_setup();

	/* enable the i2c block clock and reset it */
	modifyreg32(STM32_RCC_APB1ENR, 0, RCC_APB1ENR_I2C1EN);
	modifyreg32(STM32_RCC_APB1RSTR, 0, RCC_APB1RSTR_I2C1RST);
	modifyreg32(STM32_RCC_APB1RSTR, RCC_APB1RSTR_I2C1RST, 0);

	/* configure the i2c GPIOs */
	stm32_configgpio(GPIO_I2C1_SCL);
	stm32_configgpio(GPIO_I2C1_SDA);

	/* soft-reset the block */
	rCR1 |= I2C_CR1_SWRST;
	rCR1 = 0;

	/* set for DMA operation */
	rCR2 |= I2C_CR2_ITEVFEN |I2C_CR2_ITERREN | I2C_CR2_DMAEN;

	/* set the frequency value in CR2 */
	rCR2 &= ~I2C_CR2_FREQ_MASK;
	rCR2 |= STM32_PCLK1_FREQUENCY / 1000000;

	/* set divisor and risetime for fast mode */
	uint16_t result = STM32_PCLK1_FREQUENCY / (400000 * 25);
	if (result < 1)
		result = 1;
	result = 3;
	rCCR &= ~I2C_CCR_CCR_MASK;
	rCCR |= I2C_CCR_DUTY | I2C_CCR_FS | result;
	rTRISE = (uint16_t)((((STM32_PCLK1_FREQUENCY / 1000000) * 300) / 1000) + 1);

	/* set our device address */
	rOAR1 = 0x1a << 1;

	/* enable event interrupts */
	irq_attach(STM32_IRQ_I2C1EV, i2c_interrupt);
	irq_attach(STM32_IRQ_I2C1ER, i2c_interrupt);
	up_enable_irq(STM32_IRQ_I2C1EV);
	up_enable_irq(STM32_IRQ_I2C1ER);

	/* and enable the I2C port */
	rCR1 |= I2C_CR1_ACK | I2C_CR1_PE;

#ifdef DEBUG
	i2c_dump();
#endif
}
示例#9
0
void weak_function stm32_spiinitialize(void)
{
#ifdef CONFIG_STM32_SPI1
  (void)stm32_configgpio(GPIO_CS_MEMS);
#endif
#ifdef CONFIG_LCD_UG2864AMBAG01
  (void)stm32_configgpio(GPIO_OLED_CS);    /* OLED chip select */
  (void)stm32_configgpio(GPIO_OLED_A0);    /* OLED Command/Data */
#endif
}
示例#10
0
void board_pwr(bool on_not_off)
{
	if (on_not_off) {
		stm32_configgpio(POWER_ON_GPIO);

	} else {

		stm32_configgpio(POWER_OFF_GPIO);
	}
}
示例#11
0
__EXPORT void weak_function stm32_spiinitialize(void)
{
#ifdef CONFIG_STM32_SPI1
	stm32_configgpio(GPIO_SPI_CS_GYRO);
	stm32_configgpio(GPIO_SPI_CS_ACCEL_MAG);
	stm32_configgpio(GPIO_SPI_CS_BARO);
	stm32_configgpio(GPIO_SPI_CS_MPU);

	/* De-activate all peripherals,
	 * required for some peripheral
	 * state machines
	 */
	stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
	stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1);
	stm32_gpiowrite(GPIO_SPI_CS_BARO, 1);
	stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);

	stm32_configgpio(GPIO_EXTI_GYRO_DRDY);
	stm32_configgpio(GPIO_EXTI_MAG_DRDY);
	stm32_configgpio(GPIO_EXTI_ACCEL_DRDY);
	stm32_configgpio(GPIO_EXTI_MPU_DRDY);
#endif

#ifdef CONFIG_STM32_SPI2
	stm32_configgpio(GPIO_SPI_CS_FRAM);
	stm32_gpiowrite(GPIO_SPI_CS_FRAM, 1);
#endif
}
示例#12
0
文件: tap_pwr.c 项目: EugenSol/HippoC
void board_pwr_init(int stage)
{
	if (stage == 0) {
		stm32_configgpio(POWER_ON_GPIO);
		stm32_configgpio(KEY_AD_GPIO);
	}

	if (stage == 1) {
		stm32_gpiosetevent(KEY_AD_GPIO, true, true, true, board_button_irq);
	}
}
示例#13
0
__EXPORT void weak_function stm32_spiinitialize(void)
{
	stm32_configgpio(GPIO_SPI_CS_FLASH);
	stm32_configgpio(GPIO_SPI_CS_SDCARD);
	
	/* De-activate all peripherals,
	 * required for some peripheral
	 * state machines
	 */
	stm32_gpiowrite(GPIO_SPI_CS_FLASH, 1);
	stm32_gpiowrite(GPIO_SPI_CS_SDCARD, 1);
}
示例#14
0
__EXPORT bool px4_board_pwr(bool on_not_off)
{
	if (on_not_off) {
		stm32_configgpio(POWER_ON_GPIO);

	} else {

		stm32_configgpio(POWER_OFF_GPIO);
	}

	return true;
}
示例#15
0
void weak_function stm32_spidev_initialize(void)
{
  /* Setup CS */

#ifdef CONFIG_STM32_SPI1
  stm32_configgpio(USER_CSn);
#endif

#ifdef CONFIG_STM32_SPI2
  stm32_configgpio(MMCSD_CSn);
#endif
}
示例#16
0
文件: stm32_spi.c 项目: a1ien/nuttx
void weak_function stm32_spidev_initialize(void)
{
#ifdef CONFIG_STM32_SPI5
  (void)stm32_configgpio(GPIO_CS_MEMS);    /* MEMS chip select */
  (void)stm32_configgpio(GPIO_CS_LCD);     /* LCD chip select */
  (void)stm32_configgpio(GPIO_LCD_DC);     /* LCD Data/Command select */
  (void)stm32_configgpio(GPIO_LCD_ENABLE); /* LCD enable select */
#endif
#if defined(CONFIG_STM32_SPI4) && defined(CONFIG_MTD_SST25XX)
  (void)stm32_configgpio(GPIO_CS_SST25);   /* SST25 FLASH chip select */
#endif
}
示例#17
0
文件: up_usb.c 项目: 1015472/PX4NuttX
void stm32_usbinitialize(void)
{
  /* The OTG FS has an internal soft pull-up.  No GPIO configuration is required */

  /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */

#ifdef CONFIG_STM32_OTGFS
  stm32_configgpio(GPIO_OTGFS_VBUS);
  stm32_configgpio(GPIO_OTGFS_PWRON);
  stm32_configgpio(GPIO_OTGFS_OVER);
#endif
}
示例#18
0
void stm32_boardinitialize(void)
{
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spidev_initialize() has been brought into the link.
   */

  if (stm32_spidev_initialize)
    {
      stm32_spidev_initialize();
    }
#endif

#ifdef CONFIG_STM32_OTGFS
  /* Initialize USB if the 1) OTG FS controller is in the configuration and 2)
   * disabled, and 3) the weak function stm32_usbinitialize() has been brought
   * into the build. Presumably either CONFIG_USBDEV or CONFIG_USBHOST is also
   * selected.
   */

  if (stm32_usbinitialize)
    {
      stm32_usbinitialize();
    }
#endif

#ifdef HAVE_NETMONITOR
  /* Configure board resources to support networking. */

  if (stm32_netinitialize)
    {
      stm32_netinitialize();
    }
#endif

#ifdef CONFIG_CANUTILS_UAVCAN
  (void)stm32_configgpio(GPIO_CAN1_RX);
  (void)stm32_configgpio(GPIO_CAN1_TX);
#  if CONFIG_UAVCAN_STM32_NUM_IFACES > 1
  (void)stm32_configgpio(GPIO_CAN2_RX);
  (void)stm32_configgpio(GPIO_CAN2_TX);
#  endif
#endif

#ifdef CONFIG_ARCH_LEDS
  /* Configure on-board LEDs if LED support has been selected. */

  board_autoled_initialize();
#endif
}
示例#19
0
int
PX4IO_serial::init()
{

	/* allocate DMA */
	_tx_dma = stm32_dmachannel(PX4IO_SERIAL_TX_DMAMAP);
	_rx_dma = stm32_dmachannel(PX4IO_SERIAL_RX_DMAMAP);

	if ((_tx_dma == nullptr) || (_rx_dma == nullptr)) {
		return -1;
	}

	/* configure pins for serial use */
	stm32_configgpio(PX4IO_SERIAL_TX_GPIO);
	stm32_configgpio(PX4IO_SERIAL_RX_GPIO);

	/* reset & configure the UART */
	rCR1 = 0;
	rCR2 = 0;
	rCR3 = 0;

	/* eat any existing interrupt status */
	(void)rSR;
	(void)rDR;


	/* configure line speed */
	uint32_t usartdiv32 = PX4IO_SERIAL_CLOCK / (PX4IO_SERIAL_BITRATE / 2);
	uint32_t mantissa = usartdiv32 >> 5;
	uint32_t fraction = (usartdiv32 - (mantissa << 5) + 1) >> 1;
	rBRR = (mantissa << USART_BRR_MANT_SHIFT) | (fraction << USART_BRR_FRAC_SHIFT);

	/* attach serial interrupt handler */
	irq_attach(PX4IO_SERIAL_VECTOR, _interrupt);
	up_enable_irq(PX4IO_SERIAL_VECTOR);

	/* enable UART in DMA mode, enable error and line idle interrupts */
	rCR3 = USART_CR3_EIE;

	rCR1 = USART_CR1_RE | USART_CR1_TE | USART_CR1_UE | USART_CR1_IDLEIE;

	/* create semaphores */
	sem_init(&_completion_semaphore, 0, 0);
	sem_init(&_bus_semaphore, 0, 1);


	/* XXX this could try talking to IO */

	return 0;
}
示例#20
0
文件: spi.c 项目: MaEtUgR/Firmware
__EXPORT void stm32_spiinitialize(int mask)
{
#ifdef CONFIG_STM32_SPI1

	if (mask & PX4_SPI_BUS_SENSORS) {
		stm32_configgpio(GPIO_SPI1_CS_PORTC_PIN2);
		stm32_configgpio(GPIO_SPI1_CS_PORTC_PIN15);
		stm32_configgpio(GPIO_SPI1_CS_PORTE_PIN15);

		stm32_configgpio(GPIO_DRDY_PORTD_PIN15);
		stm32_configgpio(GPIO_DRDY_PORTC_PIN14);
		stm32_configgpio(GPIO_DRDY_PORTE_PIN12);
	}

#endif

#ifdef CONFIG_STM32_SPI2

	if (mask & (PX4_SPI_BUS_RAMTRON | PX4_SPI_BUS_BARO)) {
		stm32_configgpio(GPIO_SPI2_CS_MS5611);
		stm32_configgpio(GPIO_SPI2_CS_FRAM);
	}

#endif

}
示例#21
0
文件: spi.c 项目: ans10528/Firmware
void
interface_init(void)
{
    debug("spi init");
    
    pc_txns = perf_alloc(PC_ELAPSED, "txns");
    pc_errors = perf_alloc(PC_COUNT, "errors");
    pc_ore = perf_alloc(PC_COUNT, "overrun");
    pc_fe = perf_alloc(PC_COUNT, "framing");
    pc_ne = perf_alloc(PC_COUNT, "noise");
    pc_idle = perf_alloc(PC_COUNT, "idle");
    pc_badidle = perf_alloc(PC_COUNT, "badidle");
    pc_regerr = perf_alloc(PC_COUNT, "regerr");
    pc_crcerr = perf_alloc(PC_COUNT, "crcerr");

    /* allocate DMA handles and initialise DMA */
    rx_dma = stm32_dmachannel(DMACHAN_SPI3_RX);
    tx_dma = stm32_dmachannel(DMACHAN_SPI3_TX);
    
    /* enable the spi block clock and reset it */
    modifyreg32(STM32_RCC_APB1ENR, 0, RCC_APB1ENR_SPI3EN);
    modifyreg32(STM32_RCC_APB1RSTR, 0, RCC_APB1RSTR_SPI3RST);
    modifyreg32(STM32_RCC_APB1RSTR, RCC_APB1RSTR_SPI3RST, 0);
    
    /* configure the spi GPIOs */
    stm32_configgpio(RPI_SPI_NSS);
    stm32_configgpio(RPI_SPI_SCK);
    stm32_configgpio(RPI_SPI_MISO);
    stm32_configgpio(RPI_SPI_MOSI);
    
    /* reset and configure the SPI */
    rCR1 = SPI_CR1_CPHA | SPI_CR1_CPOL;
    
    /* set for DMA operation */
    rCR2 = SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN | SPI_CR2_ERRIE;
    
    /* enable event interrupts */
    irq_attach(STM32_IRQ_SPI3, spi_interrupt);
    up_enable_irq(STM32_IRQ_SPI3);
    
    /* configure RX DMA and return to listening state */
    dma_reset();
    
    /* and enable the SPI port */
    rCR1 |= SPI_CR1_SPE;

#ifdef DEBUG
	spi_dump();
#endif
}
示例#22
0
__EXPORT void stm32_spiinitialize(void)
{
#ifdef CONFIG_STM32_SPI1
	stm32_configgpio(GPIO_SPI_CS_MPU9250);
	stm32_configgpio(GPIO_SPI_CS_HMC5983);
	stm32_configgpio(GPIO_SPI_CS_MS5611);
	stm32_configgpio(GPIO_SPI_CS_ICM_20608_G);

	/* De-activate all peripherals,
	 * required for some peripheral
	 * state machines
	 */
	stm32_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
	stm32_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
	stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
	stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);

	stm32_configgpio(GPIO_DRDY_MPU9250);
	stm32_configgpio(GPIO_DRDY_HMC5983);
	stm32_configgpio(GPIO_DRDY_ICM_20608_G);
#endif

#ifdef CONFIG_STM32_SPI2
	stm32_configgpio(GPIO_SPI_CS_FRAM);
	stm32_gpiowrite(GPIO_SPI_CS_FRAM, 1);
#endif

}
示例#23
0
void weak_function stm32_spidev_initialize(void)
{
  /* NOTE: Clocking for SPI3 was already provided in stm32_rcc.c.
   *       Configurations of SPI pins is performed in stm32_spi.c.
   *       Here, we only initialize chip select pins unique to the board
   *       architecture.
   */

  /* Configure ENCX24J600 SPI1 CS (also RESET and interrupt pins) */

#if defined(CONFIG_ENCX24J600) && defined(CONFIG_STM32_SPI3)
  stm32_configgpio(GPIO_ENCX24J600_CS);
  stm32_configgpio(GPIO_ENCX24J600_INTR);
#endif
}
示例#24
0
void
px4fmu_gpio_init(void)
{
	/* set up GPIOs */
	stm32_configgpio(GPIO_GPIO_DIR);
	stm32_configgpio(GPIO_GPIO0_INPUT);
	stm32_configgpio(GPIO_GPIO1_INPUT);
#ifdef CONFIG_PX4_UART2_RTS_CTS_AS_GPIO
	stm32_configgpio(GPIO_GPIO2_INPUT);
	stm32_configgpio(GPIO_GPIO3_INPUT);
#endif

	/* register the driver */
	register_driver("/dev/gpio", &px4fmu_gpio_fops, 0666, NULL);
}
示例#25
0
void weak_function stm32_spiinitialize(void)
{
  /* NOTE: Clocking for SPI1 and/or SPI2 and SPI3 was already provided in stm32_rcc.c.
   *       Configurations of SPI pins is performed in stm32_spi.c.
   *       Here, we only initialize chip select pins unique to the board architecture.
   */
   
#ifdef CONFIG_STM32_SPI2
    stm32_configgpio(GPIO_CC1101_CS);
#endif

#ifdef CONFIG_STM32_SPI3
    stm32_configgpio(GPIO_FRAM_CS);
#endif
}
示例#26
0
文件: bbot.cpp 项目: jonbinney/bbot
  void gpioReset(void)
  {
    /*
     * Setup default GPIO config - all pins as GPIOs, input if
     * possible otherwise output if possible.
     */
    for (unsigned gpio_i = 0; gpio_i < ngpio; gpio_i++) {
      if (gpio_tab[gpio_i].input != 0) {
        stm32_configgpio(gpio_tab[gpio_i].input);

      } else if (gpio_tab[gpio_i].output != 0) {
        stm32_configgpio(gpio_tab[gpio_i].output);
      }
    }
  }
示例#27
0
void
PX4FMU::gpio_set_function(uint32_t gpios, int function)
{
#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1)

	/*
	 * GPIOs 0 and 1 must have the same direction as they are buffered
	 * by a shared 2-port driver.  Any attempt to set either sets both.
	 */
	if (gpios & 3) {
		gpios |= 3;

		/* flip the buffer to output mode if required */
		if (GPIO_SET_OUTPUT == function)
			stm32_gpiowrite(GPIO_GPIO_DIR, 1);
	}

#endif

	/* configure selected GPIOs as required */
	for (unsigned i = 0; i < _ngpio; i++) {
		if (gpios & (1 << i)) {
			switch (function) {
			case GPIO_SET_INPUT:
				stm32_configgpio(_gpio_tab[i].input);
				break;

			case GPIO_SET_OUTPUT:
				stm32_configgpio(_gpio_tab[i].output);
				break;

			case GPIO_SET_ALT_1:
				if (_gpio_tab[i].alt != 0)
					stm32_configgpio(_gpio_tab[i].alt);

				break;
			}
		}
	}

#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1)

	/* flip buffer to input mode if required */
	if ((GPIO_SET_INPUT == function) && (gpios & 3))
		stm32_gpiowrite(GPIO_GPIO_DIR, 0);

#endif
}
示例#28
0
static void
pwm_channel_init(unsigned channel)
{
	unsigned timer = pwm_channels[channel].timer_index;

	/* configure the GPIO first */
	stm32_configgpio(pwm_channels[channel].gpio);

	/* configure the channel */
	switch (pwm_channels[channel].timer_channel) {
	case 1:
		rCCMR1(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR1_OC1M_SHIFT) | GTIM_CCMR1_OC1PE;
		rCCR1(timer) = pwm_channels[channel].default_value;
		rCCER(timer) |= GTIM_CCER_CC1E;
		break;

	case 2:
		rCCMR1(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR1_OC2M_SHIFT) | GTIM_CCMR1_OC2PE;
		rCCR2(timer) = pwm_channels[channel].default_value;
		rCCER(timer) |= GTIM_CCER_CC2E;
		break;

	case 3:
		rCCMR2(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR2_OC3M_SHIFT) | GTIM_CCMR2_OC3PE;
		rCCR3(timer) = pwm_channels[channel].default_value;
		rCCER(timer) |= GTIM_CCER_CC3E;
		break;

	case 4:
		rCCMR2(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR2_OC4M_SHIFT) | GTIM_CCMR2_OC4PE;
		rCCR4(timer) = pwm_channels[channel].default_value;
		rCCER(timer) |= GTIM_CCER_CC4E;
		break;
	}
}
示例#29
0
__EXPORT void led_init(void)
{
	/* Configure LED1-2 GPIOs for output */
	for (size_t l = 0; l < arraySize(g_ledmap); l++) {
		stm32_configgpio(g_ledmap[l]);
	}
}
示例#30
0
int stm32_adc_setup(void)
{
  static bool initialized = false;
  uint8_t channel[1] = {10};
  struct adc_dev_s *adc;
  int rv;

  if (initialized)
    {
      return OK;
    }

  ainfo("INFO: Initializing ADC12_IN10\n");
  stm32_configgpio(GPIO_ADC12_IN10);
  if ((adc = stm32_adcinitialize(1, channel, 1)) == NULL)
    {
      aerr("ERROR: Failed to get adc interface\n");
      return -ENODEV;
    }

  if ((rv = adc_register("/dev/adc0", adc)) < 0)
    {
      aerr("ERROR: adc_register failed: %d\n", rv);
      return rv;
    }

  initialized = true;
  ainfo("INFO: ADC12_IN10 initialized succesfully\n");
  return OK;
}