예제 #1
0
void sam_boardinitialize(void)
{
  /* Configure SPI chip selects if 1) SPI is enable, and 2) the weak function
   * sam_spiinitialize() has been brought into the link.
   */

#if defined(CONFIG_SAMA5_SPI0) || defined(CONFIG_SAMA5_SPI1)
  if (sam_spiinitialize)
    {
      sam_spiinitialize();
    }
#endif

#if defined(CONFIG_SAMA5_DDRCS) && !defined(CONFIG_SAMA5_BOOT_SDRAM)

  /* Configure SDRAM if (1) SDRAM has been enalbled in the NuttX configuration and
   * (2) if we are not currently running out of SDRAM.  If we are now running out
   * of SDRAM then we have to assume that some second level bootloader has properly
   * configured SDRAM for our use.
   */

  sam_sdram_config();

#endif

  /* Initialize USB if the 1) the HS host or device controller is in the
   * configuration and 2) the weak function sam_usbinitialize() has been brought
   * into the build. Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also
   * selected.
   */

#if defined(CONFIG_SAMA5_UHPHS) || defined(CONFIG_SAMA5_UDPHS)
  if (sam_usbinitialize)
    {
      sam_usbinitialize();
    }
#endif

  /* Configure board resources to support networkingif the 1) networking is enabled,
   * 2) the EMAC or GMAC module is enabled, and 2) the weak function
   * sam_netinitialize() has been brought into the build.
   */

#ifdef HAVE_NETWORK
  if (sam_netinitialize)
    {
      sam_netinitialize();
    }
#endif

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

  board_led_initialize();
#endif
}
예제 #2
0
void sam_boardinitialize(void)
{
#ifdef CONFIG_SCHED_TICKLESS
  uint32_t frequency;
  uint32_t actual;

  /* If Tickless mode is selected then enabled PCK6 as a possible clock
   * source for the timer/counters.  The ideal frequency could be:
   *
   *  frequency = 1,000,000 / CONFIG_USEC_PER_TICK
   *
   * The main crystal is selected as the frequency source.  The maximum
   * prescaler value is 256 so the minimum frequency is 46,875 Hz which
   * corresponds to a period of 21.3 microseconds.  A value of
   * CONFIG_USEC_PER_TICK=20, or 50KHz, would give an exact solution with
   * a divider of 240.
   */

  frequency = USEC_PER_SEC / CONFIG_USEC_PER_TICK;
  DEBUGASSERT(frequency >= (BOARD_MAINOSC_FREQUENCY / 256));

  actual = sam_pck_configure(PCK6, PCKSRC_MAINCK, frequency);

  /* We expect to achieve this frequency exactly */

  DEBUGASSERT(actual == frequency);
  UNUSED(actual);

  /* Enable PCK6 */

  (void)sam_pck_enable(PCK6, true);
#endif

#ifdef CONFIG_SAMV7_SDRAMC
  /* Configure SDRAM if it has been enabled in the NuttX configuration.
   * Here we assume, of course, that we are not running out SDRAM.
   */

  sam_sdram_config();
#endif

#ifdef CONFIG_SAMV7_SPI
  /* Configure SPI chip selects if SPI has been enabled */

  sam_spidev_initialize();
#endif

#ifdef HAVE_USB
  /* Setup USB-related GPIO pins for the SAME70-XPLD board. */

  sam_usbinitialize();
#endif

#ifdef HAVE_NETWORK
  /* Configure board resources to support networking if the 1) networking is
   * enabled, and 2) the EMAC module is enabled
   */

  sam_netinitialize();
#endif

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

#ifdef CONFIG_ARCH_LEDS
  board_autoled_initialize();
#endif
}