Exemplo n.º 1
0
void stm32_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

  /* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not
   * disabled, and 3) the weak function stm32_usbdev_initialize() has been brought
   * into the build.
   */

#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBDEV)
  if (stm32_usbdev_initialize)
    {
      stm32_usbdev_initialize();
    }
#endif

  /* Configure on-board LEDs (unconditionally). */

  stm32_ledinit();
}
Exemplo n.º 2
0
void stm32_boardinitialize(void)
{
    /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
     * stm32_spiinitialize() has been brought into the link.
     */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
    if (stm32_spiinitialize)
    {
        stm32_spiinitialize();
    }
#endif

    /* Initialize USB if the 1) USB device controller is in the configuration and 2)
     * disabled, and 3) the weak function stm32_usbinitialize() has been brought
     * into the build. Presumeably either CONFIG_USBDEV is also selected.
     */

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

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

#ifdef CONFIG_ARCH_LEDS
    up_ledinit();
#endif
}
Exemplo n.º 3
0
__END_DECLS

/****************************************************************************
 * Protected Functions
 ****************************************************************************/

/****************************************************************************
 * Public Functions
 ****************************************************************************/

/************************************************************************************
 * Name: stm32_boardinitialize
 *
 * Description:
 *   All STM32 architectures must provide the following entry point.  This entry point
 *   is called early in the intitialization -- after all memory has been configured
 *   and mapped but before any devices have been initialized.
 *
 ************************************************************************************/

__EXPORT void stm32_boardinitialize(void)
{
	/* configure always-on ADC pins */
	stm32_configgpio(GPIO_ADC1_IN10);
	stm32_configgpio(GPIO_ADC1_IN11);

	/* configure SPI interfaces */
	stm32_spiinitialize();

	/* configure LEDs (empty call to NuttX' ) */
	board_autoled_initialize();
}
Exemplo n.º 4
0
void stm32_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

   /* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not
    * disabled, and 3) the weak function stm32_usbinitialize() has been brought
    * into the build.
    */

#if defined(CONFIG_USBDEV) && defined(CONFIG_STM32_USB)
  if (stm32_usbinitialize)
    {
      stm32_usbinitialize();
    }
#endif

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

#ifdef CONFIG_ARCH_LEDS
  up_ledinit();
#endif
}
Exemplo n.º 5
0
__END_DECLS

/****************************************************************************
 * Protected Functions
 ****************************************************************************/

/****************************************************************************
 * Public Functions
 ****************************************************************************/

/************************************************************************************
 * Name: stm32_boardinitialize
 *
 * Description:
 *   All STM32 architectures must provide the following entry point.  This entry point
 *   is called early in the intitialization -- after all memory has been configured
 *   and mapped but before any devices have been initialized.
 *
 ************************************************************************************/

__EXPORT void stm32_boardinitialize(void)
{
	/* configure LEDs */

	board_autoled_initialize();

	/* turn sensors on */
	stm32_configgpio(GPIO_VDD_5V_SENSORS_EN);

	/* configure SPI interfaces */
	stm32_spiinitialize();

}
Exemplo n.º 6
0
__EXPORT void board_spi_reset(int ms)
{
	/* disable SPI bus 1  DRDY */

	stm32_configgpio(GPIO_DRDY_OFF_PORTD_PIN15);
	stm32_configgpio(GPIO_DRDY_OFF_PORTC_PIN14);
	stm32_configgpio(GPIO_DRDY_OFF_PORTE_PIN12);

	stm32_gpiowrite(GPIO_DRDY_OFF_PORTD_PIN15, 0);
	stm32_gpiowrite(GPIO_DRDY_OFF_PORTC_PIN14, 0);
	stm32_gpiowrite(GPIO_DRDY_OFF_PORTE_PIN12, 0);

	/* disable SPI bus 1  CS */

	stm32_configgpio(GPIO_SPI1_CS_OFF_PORTC_PIN2);
	stm32_configgpio(GPIO_SPI1_CS_OFF_PORTC_PIN15);
	stm32_configgpio(GPIO_SPI1_CS_OFF_PORTE_PIN15);

	stm32_gpiowrite(GPIO_SPI1_CS_OFF_PORTC_PIN2, 0);
	stm32_gpiowrite(GPIO_SPI1_CS_OFF_PORTC_PIN15, 0);
	stm32_gpiowrite(GPIO_SPI1_CS_OFF_PORTE_PIN15, 0);

	/* disable SPI bus 1*/

	stm32_configgpio(GPIO_SPI1_SCK_OFF);
	stm32_configgpio(GPIO_SPI1_MISO_OFF);
	stm32_configgpio(GPIO_SPI1_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI1_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MOSI_OFF, 0);


	/* N.B we do not have control over the SPI 2 buss powered devices
	 * so the the ms5611 is not resetable.
	 */


	/* set the sensor rail off (default) */
	stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN);

	/* wait for the sensor rail to reach GND */
	usleep(ms * 1000);
	warnx("reset done, %d ms", ms);

	/* re-enable power */

	/* switch the sensor rail back on */
	stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1);

	/* wait a bit before starting SPI, different times didn't influence results */
	usleep(100);

	stm32_spiinitialize(PX4_SPI_BUS_SENSORS);
	stm32_configgpio(GPIO_SPI1_SCK);
	stm32_configgpio(GPIO_SPI1_MISO);
	stm32_configgpio(GPIO_SPI1_MOSI);


}
Exemplo n.º 7
0
__END_DECLS

/****************************************************************************
 * Protected Functions
 ****************************************************************************/

/****************************************************************************
 * Public Functions
 ****************************************************************************/

/************************************************************************************
 * Name: stm32_boardinitialize
 *
 * Description:
 *   All STM32 architectures must provide the following entry point.  This entry point
 *   is called early in the intitialization -- after all memory has been configured
 *   and mapped but before any devices have been initialized.
 *
 ************************************************************************************/

__EXPORT void stm32_boardinitialize(void)
{
	/* enable sys logs */
	//syslog_enable(true);

	/* configure SPI interfaces */
	stm32_spiinitialize();

}
Exemplo n.º 8
0
__EXPORT void stm32_boardinitialize(void)
{
	/* configure SPI interfaces */
	stm32_spiinitialize();

	/* configure LEDs */
	up_ledinit();
}
Exemplo n.º 9
0
void stm32_boardinitialize(void)
{
  /* Configure SPI interfaces */

  stm32_spiinitialize();

  /* Configure LEDs */

  board_led_initialize();
}
Exemplo n.º 10
0
__END_DECLS

/****************************************************************************
 * Protected Functions
 ****************************************************************************/

/****************************************************************************
 * Public Functions
 ****************************************************************************/

/************************************************************************************
 * Name: stm32_boardinitialize
 *
 * Description:
 *   All STM32 architectures must provide the following entry point.  This entry point
 *   is called early in the intitialization -- after all memory has been configured
 *   and mapped but before any devices have been initialized.
 *
 ************************************************************************************/

__EXPORT void stm32_boardinitialize(void)
{
	/* Hold power state */

	board_pwr_init(0);

	/* TEMP ctrl Off (active high, init is clear) */

	stm32_configgpio(GPIO_TEMP_CONT);


	/* Select 0 */

	stm32_configgpio(GPIO_S0);
	stm32_configgpio(GPIO_S1);
	stm32_configgpio(GPIO_S2);

	/* Radio Off (active low, init is set) */

	stm32_configgpio(GPIO_PCON_RADIO);


	/* configure always-on ADC pins */

	stm32_configgpio(GPIO_ADC1_IN10);


	/* configure SPI interfaces */

	stm32_spiinitialize();

	/* configure LEDs (empty call to NuttX' ledinit) */

	up_ledinit();
}
Exemplo n.º 11
0
__EXPORT void
stm32_boardinitialize(void)
{
	stm32_configgpio(GPIO_FORCE_BOOTLOADER);
	_bootloader_force_pin_callback(0, NULL);

	/* configure SPI interfaces */
	stm32_spiinitialize();

	/* configure LEDs */
	up_ledinit();
}
Exemplo n.º 12
0
void stm32_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

  /* Configure on-board LEDs (unconditionally). */

  stm32_ledinit();
}
Exemplo n.º 13
0
__EXPORT void
stm32_boardinitialize(void)
{
	/* configure LEDs */
	board_autoled_initialize();

	/* configure ADC pins */
	//todo:Revisit! ADC3 etc
	stm32_configgpio(GPIO_ADC1_IN2);	/* BATT_VOLTAGE_SENS */
	stm32_configgpio(GPIO_ADC1_IN3);	/* BATT_CURRENT_SENS */
	stm32_configgpio(GPIO_ADC1_IN4);	/* VDD_5V_SENS */
	stm32_configgpio(GPIO_ADC1_IN11);	/* RSSI analog in */

	/* configure power supply control/sense pins */
	stm32_configgpio(GPIO_VDD_3V3_PERIPH_EN);
	stm32_configgpio(GPIO_VDD_BRICK_VALID);

	stm32_configgpio(GPIO_SBUS_INV);
	stm32_configgpio(GPIO_8266_GPIO0);
//	stm32_configgpio(GPIO_SPEKTRUM_PWR_EN);
	stm32_configgpio(GPIO_8266_PD);
	stm32_configgpio(GPIO_8266_RST);
	stm32_configgpio(GPIO_BTN_SAFETY);

#ifdef GPIO_RC_OUT
	stm32_configgpio(GPIO_RC_OUT);      /* Serial RC output pin */
	stm32_gpiowrite(GPIO_RC_OUT, 1);    /* set it high to pull RC input up */
#endif

	/* configure the GPIO pins to outputs and keep them low */
	stm32_configgpio(GPIO_GPIO0_OUTPUT);
	stm32_configgpio(GPIO_GPIO1_OUTPUT);
	stm32_configgpio(GPIO_GPIO2_OUTPUT);
	stm32_configgpio(GPIO_GPIO3_OUTPUT);
	stm32_configgpio(GPIO_GPIO4_OUTPUT);
	stm32_configgpio(GPIO_GPIO5_OUTPUT);

	/* configure SPI interfaces */
	stm32_spiinitialize();

	stm32_usbinitialize();

}
Exemplo n.º 14
0
void stm32_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

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

#ifdef CONFIG_ARCH_LEDS
  board_led_initialize();
#endif
}
Exemplo n.º 15
0
__EXPORT void
stm32_boardinitialize(void)
{
	/* configure ADC pins */

	stm32_configgpio(GPIO_ADC1_IN10);	/* used by battery sense */
	stm32_configgpio(GPIO_ADC1_IN11);	/* J1 breakout */
	stm32_configgpio(GPIO_ADC1_IN12);	/* J1 breakout */
	stm32_configgpio(GPIO_ADC1_IN13);	/* J1 breakout */

	/* configure the power mux sense input */
	stm32_configgpio(GPIO_POWER_MUX_SENSE);

	/* configure spektrum power controller gpio */
	stm32_configgpio(GPIO_SPEKTRUM_PWR_EN);

	/* configure SPI interfaces */
	stm32_spiinitialize();

	/* configure LEDs */
	board_autoled_initialize();
}
Exemplo n.º 16
0
__EXPORT void
stm32_boardinitialize(void)
{
	/* configure LEDs */

	board_autoled_initialize();

	/* configure ADC pins */

	px4_arch_configgpio(GPIO_ADC1_IN2);	/* BATT_VOLTAGE_SENS */
	px4_arch_configgpio(GPIO_ADC1_IN3);	/* BATT_CURRENT_SENS */
	px4_arch_configgpio(GPIO_ADC1_IN4);	/* VDD_5V_SENS */
	px4_arch_configgpio(GPIO_ADC1_IN13);	/* FMU_AUX_ADC_1 */
	px4_arch_configgpio(GPIO_ADC1_IN14);	/* FMU_AUX_ADC_2 */
	px4_arch_configgpio(GPIO_ADC1_IN15);	/* PRESSURE_SENS */

	/* configure power supply control/sense pins */
	px4_arch_configgpio(GPIO_VDD_5V_PERIPH_EN);
	px4_arch_configgpio(GPIO_VDD_3V3_SENSORS_EN);
	px4_arch_configgpio(GPIO_VDD_BRICK_VALID);
	px4_arch_configgpio(GPIO_VDD_5V_PERIPH_OC);

	/* configure the GPIO pins to outputs and keep them low */
	px4_arch_configgpio(GPIO_GPIO0_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO1_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO2_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO3_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO4_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO5_OUTPUT);

	/* configure SPI interfaces */

	stm32_spiinitialize();

	/* configure USB interface */

	stm32_usbinitialize();

}
Exemplo n.º 17
0
void stm32_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

  /* If the FSMC is enabled, then enable SRAM access */

#ifdef CONFIG_STM32_FSMC
  stm32_selectsram();
#endif

  /* 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
   * the weak function stm32_usbinitialize() has been brought into the build.
   * Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also selected.
   */

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

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

#ifdef CONFIG_ARCH_LEDS
  stm32_autoled_initialize();
#endif
}
Exemplo n.º 18
0
__EXPORT void
stm32_boardinitialize(void)
{
	board_on_reset(-1); /* Reset PWM first thing */

	/* configure LEDs */

	board_autoled_initialize();

	/* configure pins */

	const uint32_t gpio[] = PX4_GPIO_INIT_LIST;
	board_gpio_init(gpio, arraySize(gpio));

	/* configure SPI interfaces */

	stm32_spiinitialize();

	/* configure USB interfaces */

	stm32_usbinitialize();

}
Exemplo n.º 19
0
void stm32_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) ||\
	defined(CONFIG_STM32_SPI4) || defined(CONFIG_STM32_SPI5)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

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

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

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

#ifdef CONFIG_ARCH_LEDS
  board_led_initialize();
#endif

#ifdef CONFIG_STM32_FSMC
  stm32_enablefsmc();
#endif
}
Exemplo n.º 20
0
__EXPORT void
stm32_boardinitialize(void)
{
	/* configure LEDs */

	board_autoled_initialize();

	/* configure ADC pins */
	stm32_configgpio(GPIO_ADC1_IN2);	/* BATT_VOLTAGE_SENS */
	stm32_configgpio(GPIO_ADC1_IN3);	/* BATT_CURRENT_SENS */
	stm32_configgpio(GPIO_ADC1_IN4);	/* VDD_5V_SENS */
	stm32_configgpio(GPIO_ADC1_IN11);	/* RSSI analog in */

	/* configure power supply control/sense pins */
	stm32_configgpio(GPIO_PERIPH_3V3_EN);
	stm32_configgpio(GPIO_VDD_BRICK_VALID);

	stm32_configgpio(GPIO_SBUS_INV);
	stm32_configgpio(GPIO_8266_GPIO0);
	stm32_configgpio(GPIO_SPEKTRUM_PWR_EN);
	stm32_configgpio(GPIO_8266_PD);
	stm32_configgpio(GPIO_8266_RST);
	stm32_configgpio(GPIO_BTN_SAFETY);

	/* configure the GPIO pins to outputs and keep them low */
	stm32_configgpio(GPIO_GPIO0_OUTPUT);
	stm32_configgpio(GPIO_GPIO1_OUTPUT);
	stm32_configgpio(GPIO_GPIO2_OUTPUT);
	stm32_configgpio(GPIO_GPIO3_OUTPUT);
	stm32_configgpio(GPIO_GPIO4_OUTPUT);
	stm32_configgpio(GPIO_GPIO5_OUTPUT);

	/* configure SPI interfaces */
	stm32_spiinitialize();

}
Exemplo n.º 21
0
__END_DECLS

/****************************************************************************
 * Protected Functions
 ****************************************************************************/

#if defined(CONFIG_FAT_DMAMEMORY)

































/****************************************************************************
 * Public Functions
 ****************************************************************************/





















#else

# define dma_alloc_init()

#endif

/************************************************************************************
 * Name: stm32_boardinitialize
 *
 * Description:
 *   All STM32 architectures must provide the following entry point.  This entry point
 *   is called early in the intitialization -- after all memory has been configured
 *   and mapped but before any devices have been initialized.
 *
 ************************************************************************************/

__EXPORT void
stm32_boardinitialize(void)
{
	/* configure SPI interfaces */
	stm32_spiinitialize();

}
Exemplo n.º 22
0
__EXPORT int board_app_initialize(uintptr_t arg)
{

#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)

	/* run C++ ctors before we go any further */

	up_cxxinitialize();

#	if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
#  		error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
#	endif

#else
#  error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif

#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING)

	if (OK == determin_hw_version(&hw_version, & hw_revision)) {
		switch (hw_version) {
		default:
		case 0x8:
			break;

		case 0xE:
			hw_type[1]++;
			hw_type[2] = '0';
			break;

		case 0xA:
			hw_type[2] = 'M';
			break;
		}

		PX4_INFO("Ver 0x%1X : Rev %x %s", hw_version, hw_revision, hw_type);
	}

#endif // BOARD_HAS_SIMPLE_HW_VERSIONING

	/* Bring up the Sensor power */

	stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1);

	/* Ensure the power is on 1 ms before we drive the GPIO pins */

	usleep(1000);

	/* Now it is ok to drive the pins high so configure SPI GPIO */

	stm32_spiinitialize();


	/* configure the high-resolution time/callout interface */

	hrt_init();

	param_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION
	cpuload_initialize_once();
#endif

	/* set up the serial DMA polling */
	static struct hrt_call serial_dma_call;
	struct timespec ts;

	/*
	 * Poll at 1ms intervals for received bytes that have not triggered
	 * a DMA event.
	 */
	ts.tv_sec = 0;
	ts.tv_nsec = 1000000;

	hrt_call_every(&serial_dma_call,
		       ts_to_abstime(&ts),
		       ts_to_abstime(&ts),
		       (hrt_callout)stm32_serial_dma_poll,
		       NULL);

#if defined(CONFIG_STM32_BBSRAM)

	if (hardfault_check_status) {
		/* NB. the use of the console requires the hrt running
		 * to poll the DMA
		 */

		/* Using Battery Backed Up SRAM */

		int filesizes[CONFIG_STM32_BBSRAM_FILES + 1] = BSRAM_FILE_SIZES;

		stm32_bbsraminitialize(BBSRAM_PATH, filesizes);

#if defined(CONFIG_STM32_SAVE_CRASHDUMP)

		/* Panic Logging in Battery Backed Up Files */

		/*
		 * In an ideal world, if a fault happens in flight the
		 * system save it to BBSRAM will then reboot. Upon
		 * rebooting, the system will log the fault to disk, recover
		 * the flight state and continue to fly.  But if there is
		 * a fault on the bench or in the air that prohibit the recovery
		 * or committing the log to disk, the things are too broken to
		 * fly. So the question is:
		 *
		 * Did we have a hard fault and not make it far enough
		 * through the boot sequence to commit the fault data to
		 * the SD card?
		 */

		/* Do we have an uncommitted hard fault in BBSRAM?
		 *  - this will be reset after a successful commit to SD
		 */
		int hadCrash = hardfault_check_status("boot");

		if (hadCrash == OK) {

			message("[boot] There is a hard fault logged. Hold down the SPACE BAR," \
				" while booting to halt the system!\n");

			/* Yes. So add one to the boot count - this will be reset after a successful
			 * commit to SD
			 */

			int reboots = hardfault_increment_reboot("boot", false);

			/* Also end the misery for a user that holds for a key down on the console */

			int bytesWaiting;
			ioctl(fileno(stdin), FIONREAD, (unsigned long)((uintptr_t) &bytesWaiting));

			if (reboots > 2 || bytesWaiting != 0) {

				/* Since we can not commit the fault dump to disk. Display it
				 * to the console.
				 */

				hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false);

				message("[boot] There were %d reboots with Hard fault that were not committed to disk - System halted %s\n",
					reboots,
					(bytesWaiting == 0 ? "" : " Due to Key Press\n"));


				/* For those of you with a debugger set a break point on up_assert and
				 * then set dbgContinue = 1 and go.
				 */

				/* Clear any key press that got us here */

				static volatile bool dbgContinue = false;
				int c = '>';

				while (!dbgContinue) {

					switch (c) {

					case EOF:


					case '\n':
					case '\r':
					case ' ':
						continue;

					default:

						putchar(c);
						putchar('\n');

						switch (c) {

						case 'D':
						case 'd':
							hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false);
							break;

						case 'C':
						case 'c':
							hardfault_rearm("boot");
							hardfault_increment_reboot("boot", true);
							break;

						case 'B':
						case 'b':
							dbgContinue = true;
							break;

						default:
							break;
						} // Inner Switch

						message("\nEnter B - Continue booting\n" \
							"Enter C - Clear the fault log\n" \
							"Enter D - Dump fault log\n\n?>");
						fflush(stdout);

						if (!dbgContinue) {
							c = getchar();
						}

						break;

					} // outer switch
				} // for

			} // inner if
		} // outer if
	} // hardfault_check_status

#endif // CONFIG_STM32_SAVE_CRASHDUMP
#endif // CONFIG_STM32_BBSRAM

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);

	/* Configure SPI-based devices */

	spi1 = stm32_spibus_initialize(PX4_SPI_BUS_SENSORS);

	if (!spi1) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_SENSORS);
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI1 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi1, 10000000);
	SPI_SETBITS(spi1, 8);
	SPI_SETMODE(spi1, SPIDEV_MODE3);
	up_udelay(20);

	/* Get the SPI port for the FRAM */

	spi2 = stm32_spibus_initialize(PX4_SPI_BUS_RAMTRON);

	if (!spi2) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_RAMTRON);
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI2 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max)
	 * and de-assert the known chip selects. */

	// XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated
	SPI_SETFREQUENCY(spi2, 12 * 1000 * 1000);
	SPI_SETBITS(spi2, 8);
	SPI_SETMODE(spi2, SPIDEV_MODE3);

	spi4 = stm32_spibus_initialize(PX4_SPI_BUS_EXT);

	if (!spi4) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_EXT);
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI4 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi4, 10000000);
	SPI_SETBITS(spi4, 8);
	SPI_SETMODE(spi4, SPIDEV_MODE3);

#ifdef CONFIG_MMCSD
	/* First, get an instance of the SDIO interface */

	sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);

	if (!sdio) {
		message("[boot] Failed to initialize SDIO slot %d\n",
			CONFIG_NSH_MMCSDSLOTNO);
		return -ENODEV;
	}

	/* Now bind the SDIO interface to the MMC/SD driver */
	int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);

	if (ret != OK) {
		message("[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
		return ret;
	}

	/* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */
	sdio_mediachange(sdio, true);

#endif

	return OK;
}
Exemplo n.º 23
0
__END_DECLS

/****************************************************************************
 * Protected Functions
 ****************************************************************************/
/****************************************************************************
 * Public Functions
 ****************************************************************************/
/************************************************************************************
 * Name: stm32_boardinitialize
 *
 * Description:
 *   All STM32 architectures must provide the following entry point.  This entry point
 *   is called early in the intitialization -- after all memory has been configured
 *   and mapped but before any devices have been initialized.
 *
 ************************************************************************************/

__EXPORT void
stm32_boardinitialize(void)
{
	/* configure LEDs */

	board_autoled_initialize();

	/* configure ADC pins */

	px4_arch_configgpio(GPIO_ADC1_IN4);	/* VDD_5V_SENS */
	px4_arch_configgpio(GPIO_ADC1_IN10);	/* BATT_CURRENT_SENS */
	px4_arch_configgpio(GPIO_ADC1_IN12);	/* BATT_VOLTAGE_SENS */
	px4_arch_configgpio(GPIO_ADC1_IN11);	/* RSSI analog in */
	px4_arch_configgpio(GPIO_ADC1_IN13);	/* FMU_AUX_ADC_1 */
	px4_arch_configgpio(GPIO_ADC1_IN14);	/* FMU_AUX_ADC_2 */
	px4_arch_configgpio(GPIO_ADC1_IN15);	/* PRESSURE_SENS */

	/* configure power supply control/sense pins */

	px4_arch_configgpio(GPIO_SBUS_INV);
	px4_arch_configgpio(GPIO_FRSKY_INV);

	/* configure the GPIO pins to outputs and keep them low */
	px4_arch_configgpio(GPIO_GPIO0_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO1_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO2_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO3_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO4_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO5_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO6_OUTPUT);
	px4_arch_configgpio(GPIO_GPIO7_OUTPUT);

	/* configure SPI interfaces */

	stm32_spiinitialize();

	stm32_configgpio(GPIO_I2C2_SCL);
	stm32_configgpio(GPIO_I2C2_SDA);

	stm32_configgpio(GPIO_I2C1_SCL);
	stm32_configgpio(GPIO_I2C1_SDA);

}
Exemplo n.º 24
0
__EXPORT int board_app_initialize(uintptr_t arg)
{
	/* Ensure the power is on 1 ms before we drive the GPIO pins */
	usleep(1000);

	if (OK == determin_hw_version(&hw_version, & hw_revision)) {
		switch (hw_version) {
		case HW_VER_FMUV2_STATE:
			break;

		case HW_VER_FMUV3_STATE:
			hw_type[1]++;
			hw_type[2] = '0';

			/* Has CAN2 transceiver Remove pull up */

			stm32_configgpio(GPIO_CAN2_RX);

			break;

		case HW_VER_FMUV2MINI_STATE:

			/* Detection for a Pixhack3 */

			stm32_configgpio(HW_VER_PA8);
			up_udelay(10);
			bool isph3 = stm32_gpioread(HW_VER_PA8);
			stm32_configgpio(HW_VER_PA8_INIT);


			if (isph3) {

				/* Pixhack3 looks like a FMuV3 Cube */

				hw_version = HW_VER_FMUV3_STATE;
				hw_type[1]++;
				hw_type[2] = '0';
				message("\nPixhack V3 detected, forcing to fmu-v3");

			} else {

				/* It is a mini */

				hw_type[2] = 'M';
			}

			break;

		default:

			/* questionable px4_fmu-v2 hardware, try forcing regular FMUv2 (not much else we can do) */

			message("\nbad version detected, forcing to fmu-v2");
			hw_version = HW_VER_FMUV2_STATE;
			break;
		}

		message("\nFMUv2 ver 0x%1X : Rev %x %s\n", hw_version, hw_revision, hw_type);
	}

	/* configure SPI interfaces */
	stm32_spiinitialize();

	px4_platform_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* set up the serial DMA polling */
	static struct hrt_call serial_dma_call;
	struct timespec ts;

	/*
	 * Poll at 1ms intervals for received bytes that have not triggered
	 * a DMA event.
	 */
	ts.tv_sec = 0;
	ts.tv_nsec = 1000000;

	hrt_call_every(&serial_dma_call,
		       ts_to_abstime(&ts),
		       ts_to_abstime(&ts),
		       (hrt_callout)stm32_serial_dma_poll,
		       NULL);

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);

	if (board_hardfault_init(2, true) != 0) {
		led_on(LED_AMBER);
	}

	/* Configure SPI-based devices */

	spi1 = stm32_spibus_initialize(PX4_SPI_BUS_SENSORS);

	if (!spi1) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_SENSORS);
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI1 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi1, 10000000);
	SPI_SETBITS(spi1, 8);
	SPI_SETMODE(spi1, SPIDEV_MODE3);
	up_udelay(20);

	/* Get the SPI port for the FRAM */

	spi2 = stm32_spibus_initialize(PX4_SPI_BUS_RAMTRON);

	if (!spi2) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_RAMTRON);
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI2 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max)
	 * and de-assert the known chip selects. */

	// XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated
	SPI_SETFREQUENCY(spi2, 12 * 1000 * 1000);
	SPI_SETBITS(spi2, 8);
	SPI_SETMODE(spi2, SPIDEV_MODE3);

	spi4 = stm32_spibus_initialize(PX4_SPI_BUS_EXT);

	if (!spi4) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_EXT);
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI4 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi4, 10000000);
	SPI_SETBITS(spi4, 8);
	SPI_SETMODE(spi4, SPIDEV_MODE3);

#ifdef CONFIG_MMCSD
	/* First, get an instance of the SDIO interface */

	sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);

	if (!sdio) {
		led_on(LED_AMBER);
		message("[boot] Failed to initialize SDIO slot %d\n", CONFIG_NSH_MMCSDSLOTNO);
		return -ENODEV;
	}

	/* Now bind the SDIO interface to the MMC/SD driver */
	int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);

	if (ret != OK) {
		led_on(LED_AMBER);
		message("[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
		return ret;
	}

	/* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */
	sdio_mediachange(sdio, true);

#endif

	return OK;
}
Exemplo n.º 25
0
void stm32_boardinitialize(void)
{
#ifdef BOARD_HAS_BOOTLOADER
  /* Check if IWDG is enabled by bootloader. This is the case when
   * CONFIG_BOOTLOADER_NOWD_BKREG has lowest bit cleared.
   */

  if ((getreg32(CONFIG_BOOTLOADER_NOWD_BKREG) & 1) == 0)
    {
      int i;

      /* Bootloader has enabled IWDG. This happens after POR-reset (since
       * backup-registers have been reset to zero) and after firmware update.
       *
       * Disabling IWDG is used as early boot firmware check (new firmware
       * started). We now enable NOWD flag and do reset loop with ADDR value
       * set to application firmware.
       *
       * If firmware does not manage to do early boot and gets stuck, IWDG will
       * reset device and bootloader will either attempt to flash backup
       * firmware or will reset loop by IWDG until 'current boot try count'
       * reaches threshold and bootloader boots device to DFU-mode.
       */

      for (i = 0; i < 4; i++)
        up_lowputc('>');

      /* Enable BKREG writing. */

      stm32_pwr_enablebkp(true);

      /* Make bootloader disable IWDG. */

      putreg32(1, CONFIG_BOOTLOADER_NOWD_BKREG);

      /* Setup bootloader to jump directly to firmware. */

      putreg32(BOARD_FIRMWARE_BASE_ADDR, CONFIG_BOOTLOADER_ADDR_BKREG);

      /* Disable BKREG writing. */

      stm32_pwr_enablebkp(false);

      /* Do system reset. */

      board_systemreset();
    }
#endif /* BOARD_HAS_BOOTLOADER */

#if defined(CONFIG_ASSERT_COUNT_BKREG)
  /* Check value of assert counter (note: does not enable/disable BKREG access
   * with argument==0). */

  if (up_add_assert_count(0) >= CONFIG_ASSERT_COUNT_TO_DFU_MODE)
    {
      const char *str = "\nToo many ASSERT resets; something wrong with software. Forcing DFU mode!\n";

      while (*str)
        up_lowputc(*str++);

      up_mdelay(500);
      up_reset_to_system_bootloader();
    }
#endif

  /* Setup GPIOs based on HW version. */

  up_configure_dynamic_gpios();

  /* Configure MCU so that debugging is possible in idle modes. */

#ifdef CONFIG_STM32_KEEP_CORE_CLOCK_ENABLED_IN_IDLE_MODES
  uint32_t cr = getreg32(STM32_DBGMCU_CR);

  cr |= DBGMCU_CR_STANDBY | DBGMCU_CR_STOP | DBGMCU_CR_SLEEP;
  putreg32(cr, STM32_DBGMCU_CR);
#endif

#ifdef CONFIG_BOARD_MCO_SYSCLK
  /* Output SYSCLK to MCO pin for clock measurements. */

  stm32_configgpio(GPIO_MCO);
  stm32_mcodivconfig(RCC_CFGR_MCOSEL_SYSCLK, RCC_CFGR_MCOPRE_DIV4);
#endif

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

#ifdef CONFIG_ARCH_LEDS
  board_led_initialize();
#endif

  /* Configure chip-select pins. */

  board_initialize_chipselects();

  /* Configure SDcard pins (needs to be after chip-select init, to pull SDcard
   * CS down). */

  gpio_initialize_sdcard_pins();

  /* Configure power control pins. */

  board_initialize_pwrctl_pins();

  /* Initialize modem gpios. */

  up_modem_initialize_gpios();

  /* Initialize unused gpio pads. */

  gpio_initialize_unused_pads();

  /* Enable BKREG writing. */

  stm32_pwr_enablebkp(true);

  /* Reset 'current boot try count' for bootloader. */

  putreg32(0, CONFIG_BOOTLOADER_CBTC_BKREG);

  /* Make bootloader disable IWDG. */

  putreg32(1, CONFIG_BOOTLOADER_NOWD_BKREG);

  /* Check if we need to enter standby/power-off mode. */

  up_boot_standby_mode();

  /* Disable BKREG writing. */

  stm32_pwr_enablebkp(false);

  /* Force enable capsense and 9-axis for duration
   * of I2C initialization. After bus initialization
   * is done, this is undone and drivers will take care
   * of requesting power for themselves.
   */

  board_pwrctl_get(PWRCTL_SWITCH_CAPSENSE_SENSOR);
  board_pwrctl_get(PWRCTL_SWITCH_9AXIS_INERTIAL_SENSOR);

  /* Flash mass-erase can leave option-bytes is bad shape, restore defaults if
   * needed. */

  up_check_and_restore_valid_optionbytes();

  /* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
   * stm32_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
  if (stm32_spiinitialize)
    {
      stm32_spiinitialize();
    }
#endif

  /* Give early information about reset reason. */

  print_reset_reason();
}
Exemplo n.º 26
0
__EXPORT void board_spi_reset(int ms)
{
	// TODO: DRDY
	///* disable SPI bus 1  DRDY */
	//stm32_configgpio(GPIO_DRDY_OFF_PORTD_PIN15);
	//stm32_configgpio(GPIO_DRDY_OFF_PORTC_PIN14);
	//stm32_configgpio(GPIO_DRDY_OFF_PORTE_PIN12);

	//stm32_gpiowrite(GPIO_DRDY_OFF_PORTD_PIN15, 0);
	//stm32_gpiowrite(GPIO_DRDY_OFF_PORTC_PIN14, 0);
	//stm32_gpiowrite(GPIO_DRDY_OFF_PORTE_PIN12, 0);

	/* disable SPI bus 1  CS */
	stm32_configgpio(GPIO_SPI1_CS_MEMS_OFF);
	stm32_gpiowrite(GPIO_SPI1_CS_MEMS_OFF, 0);

	/* disable SPI bus 2  CS */
	stm32_configgpio(GPIO_SPI2_CS_SDCARD_OFF);
	stm32_gpiowrite(GPIO_SPI2_CS_SDCARD_OFF, 0);

	/* disable SPI bus 3  CS */
	stm32_configgpio(GPIO_SPI3_CS_BARO_OFF);
	stm32_gpiowrite(GPIO_SPI3_CS_BARO_OFF, 0);
	stm32_configgpio(GPIO_SPI3_CS_OSD_OFF);
	stm32_gpiowrite(GPIO_SPI3_CS_OSD_OFF, 0);

	/* disable SPI bus 1*/
	stm32_configgpio(GPIO_SPI1_SCK_OFF);
	stm32_configgpio(GPIO_SPI1_MISO_OFF);
	stm32_configgpio(GPIO_SPI1_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI1_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MOSI_OFF, 0);

	/* disable SPI bus 2*/
	stm32_configgpio(GPIO_SPI2_SCK_OFF);
	stm32_configgpio(GPIO_SPI2_MISO_OFF);
	stm32_configgpio(GPIO_SPI2_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI2_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI2_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI2_MOSI_OFF, 0);

	/* disable SPI bus 3*/
	stm32_configgpio(GPIO_SPI3_SCK_OFF);
	stm32_configgpio(GPIO_SPI3_MISO_OFF);
	stm32_configgpio(GPIO_SPI3_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI3_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI3_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI3_MOSI_OFF, 0);

	/* wait a bit before starting SPI, different times didn't influence results */
	usleep(100);

	stm32_spiinitialize();

	stm32_configgpio(GPIO_SPI1_SCK);
	stm32_configgpio(GPIO_SPI1_MISO);
	stm32_configgpio(GPIO_SPI1_MOSI);

	// TODO: why do we not enable SPI2 here?

	stm32_configgpio(GPIO_SPI3_SCK);
	stm32_configgpio(GPIO_SPI3_MISO);
	stm32_configgpio(GPIO_SPI3_MOSI);
}
Exemplo n.º 27
0
void board_initialize(void)
{
  dbg("%d MHz\n", STM32_SYSCLK_FREQUENCY / 1000000);

#if defined(CONFIG_GPIO_CHIP_STM32)
  stm32_gpio_init();
#endif

#ifdef CONFIG_STM32_LPTIM1
  stm32_lptim1_on();
#endif

#ifdef CONFIG_STM32_SPI
  stm32_spiinitialize();
#endif

#ifdef CONFIG_MODS_DIET
  mods_init();
#endif

#ifndef CONFIG_BOARD_INITTHREAD
# error "Must enable INITTHREAD"
#endif

#ifdef CONFIG_DEVICE_CORE
  device_table_register(&muc_device_table);

#ifdef CONFIG_FUSB302
  fusb302_register(GPIO_MODS_FUSB302_INT_N, GPIO_MODS_VBUS_PWR_EN);
#endif
#ifdef CONFIG_FUSB302_USB_EXT
  extern struct device_driver fusb302_usb_ext_driver;
  device_register_driver(&fusb302_usb_ext_driver);
#endif
#ifdef CONFIG_FUSB302_EXT_POWER
  extern struct device_driver fusb302_ext_power_driver;
  device_register_driver(&fusb302_ext_power_driver);
#endif
#ifdef CONFIG_MODS_RAW
  extern struct device_driver mods_raw_driver;
  device_register_driver(&mods_raw_driver);
#endif
#ifdef CONFIG_MODS_RAW_BLINKY
  extern struct device_driver mods_raw_blinky_driver;
  device_register_driver(&mods_raw_blinky_driver);
#endif
#ifdef CONFIG_MODS_RAW_TERMAPP
  extern struct device_driver mods_raw_termapp_driver;
  device_register_driver(&mods_raw_termapp_driver);
#endif
#ifdef CONFIG_MODS_RAW_TEMPERATURE
  extern struct device_driver mods_raw_temperature_driver;
  device_register_driver(&mods_raw_temperature_driver);
#endif
#ifdef CONFIG_GREYBUS_MODS_PTP_DEVICE
  extern struct device_driver mods_ptp_driver;
  device_register_driver(&mods_ptp_driver);
#endif
#ifdef CONFIG_CHARGER_DEVICE_BQ24292
  extern struct device_driver bq24292_charger_driver;
  device_register_driver(&bq24292_charger_driver);
#endif
#ifdef CONFIG_CHARGER_DEVICE_BQ25896
  extern struct device_driver bq25896_charger_driver;
  device_register_driver(&bq25896_charger_driver);
#endif
#ifdef CONFIG_GREYBUS_MODS_PTP_CHG_DEVICE_SWITCH
  extern struct device_driver switch_ptp_chg_driver;
  device_register_driver(&switch_ptp_chg_driver);
#endif
#ifdef CONFIG_MAX17050_DEVICE
  extern struct device_driver batt_driver;
  device_register_driver(&batt_driver);
#endif
#ifdef CONFIG_BATTERY_TEMP_DEVICE_MAX17050
  extern struct device_driver max17050_battery_temp_driver;
  device_register_driver(&max17050_battery_temp_driver);
#endif
#ifdef CONFIG_BATTERY_LEVEL_DEVICE_MAX17050
  extern struct device_driver max17050_battery_level_driver;
  device_register_driver(&max17050_battery_level_driver);
#endif
#ifdef CONFIG_BATTERY_VOLTAGE_DEVICE_MAX17050
  extern struct device_driver max17050_battery_voltage_driver;
  device_register_driver(&max17050_battery_voltage_driver);
#endif
#ifdef CONFIG_MHB_APBE_CTRL_DEVICE
  extern struct device_driver apbe_pwrctrl_driver;
  device_register_driver(&apbe_pwrctrl_driver);
#endif
#ifdef CONFIG_BATTERY_GOOD_DEVICE_COMP
  extern struct device_driver comp_batt_good_driver;
  device_register_driver(&comp_batt_good_driver);
#endif
#ifdef CONFIG_GREYBUS_SENSORS_EXT_DUMMY_PRESSURE
  extern struct device_driver sensor_dummy_pressure_driver;
  device_register_driver(&sensor_dummy_pressure_driver);
#endif
#ifdef CONFIG_GREYBUS_SENSORS_EXT_DUMMY_ACCEL
  extern struct device_driver sensor_dummy_accel_driver;
  device_register_driver(&sensor_dummy_accel_driver);
#endif
#ifdef CONFIG_HDMI_DISPLAY
   extern struct device_driver hdmi_display_driver;
   device_register_driver(&hdmi_display_driver);
#endif
#ifdef CONFIG_STM32_UART_DEVICE
  extern struct device_driver stm32_uart_driver;
  device_register_driver(&stm32_uart_driver);
#endif
#if CONFIG_MHB_UART
   extern struct device_driver mhb_driver;
   device_register_driver(&mhb_driver);
#endif
#ifdef CONFIG_MHB_DSI_DISPLAY
   extern struct device_driver dsi_display_driver;
   device_register_driver(&dsi_display_driver);
#endif
#ifdef CONFIG_BACKLIGHT_DCS
   extern struct device_driver dcs_backlight_driver;
   device_register_driver(&dcs_backlight_driver);
#endif
#ifdef CONFIG_BACKLIGHT_ISL98611
   extern struct device_driver isl98611_backlight_driver;
   device_register_driver(&isl98611_backlight_driver);
#endif
#ifdef CONFIG_BACKLIGHT_LM27965
   extern struct device_driver lm27965_backlight_driver;
   device_register_driver(&lm27965_backlight_driver);
#endif
#if defined(CONFIG_MHB_CAMERA)
   extern struct device_driver cam_ext_mhb_driver;
   device_register_driver(&cam_ext_mhb_driver);
#endif
#if defined(CONFIG_CAMERA_IMX220)
    extern struct device_driver imx220_mhb_camera_driver;
    device_register_driver(&imx220_mhb_camera_driver);
#endif
#if defined(CONFIG_CAMERA_IMX230)
    extern struct device_driver imx230_mhb_camera_driver;
    device_register_driver(&imx230_mhb_camera_driver);
#endif
#ifdef CONFIG_MODS_AUDIO_TFA9890
  extern struct device_driver tfa9890_i2s_direct_driver;
  device_register_driver(&tfa9890_i2s_direct_driver);
  extern struct device_driver tfa9890_audio_dev_driver;
  device_register_driver(&tfa9890_audio_dev_driver);
#endif
#ifdef CONFIG_MODS_RAW_FACTORY
   extern struct device_driver display_mux_driver;
   device_register_driver(&display_mux_driver);
   extern struct device_driver mods_raw_factory_driver;
   device_register_driver(&mods_raw_factory_driver);
#endif
#endif
#if defined(CONFIG_CHARGER_BQ24292)
   (void)bq24292_driver_init(GPIO_MODS_CHG_INT_N, GPIO_MODS_CHG_PG_N);
#endif

#ifdef CONFIG_BATTERY_MAX17050
   struct i2c_dev_s *i2c = up_i2cinitialize(MAX17050_I2C_BUS);
   if (i2c) {
      g_battery = max17050_initialize(i2c, MAX17050_I2C_FREQ,
                  GPIO_MODS_CC_ALERT);
      if (!g_battery) {
         up_i2cuninitialize(i2c);
      }
   }
# if defined(CONFIG_BATTERY_STATE)
   /* Must be initialized after MAX17050 core driver has been initialized */
   battery_state_init();
# endif
#endif

#if !defined(CONFIG_GREYBUS_PTP_EXT_SUPPORTED)
   /* Set the power paths to be able to use USB VBUS as the system power and
    * to prevent applying voltage to VBUS pin on the Mod connector. Also,
    * prevent accepting power from the PCARD VBUS connection.
    */
   gpio_set_value(GPIO_MODS_CHG_VINA_EN, 1);
   gpio_set_value(GPIO_MODS_CHG_VINB_EN, 0);
#endif
}