os/hal/boards/ARDUINO_DUE/board.c
/**
 * @brief   Early initialization code.
 * @details This initialization must be performed just after stack setup
 *          and before any other initialization.
 */
@brief   Early initialization code.
@details This initialization must be performed just after stack setup
and before any other initialization.
@brief Early initialization code . @details This initialization must be performed just after stack setup and before any other initialization .
void __early_init(void) {
  EFC0->EEFC_FMR = EEFC_FMR_FWS(4);
  EFC1->EEFC_FMR = EEFC_FMR_FWS(4);
  if (!(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL)) {
    PMC->CKGR_MOR = SYS_CKGR_MOR_KEY_VALUE |
                    SYS_BOARD_OSCOUNT |
                    CKGR_MOR_MOSCRCEN |
                    CKGR_MOR_MOSCXTEN;
    while (!(PMC->PMC_SR & PMC_SR_MOSCXTS)) {
    }
  }
  PMC->CKGR_MOR = SYS_CKGR_MOR_KEY_VALUE |
                  SYS_BOARD_OSCOUNT |
                  CKGR_MOR_MOSCRCEN |
                  CKGR_MOR_MOSCXTEN |
                  CKGR_MOR_MOSCSEL;
  while (!(PMC->PMC_SR & PMC_SR_MOSCSELS)) {
  }
  PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) |
                   PMC_MCKR_CSS_MAIN_CLK;
  while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {
  }
  PMC->CKGR_PLLAR = SYS_BOARD_PLLAR;
  while (!(PMC->PMC_SR & PMC_SR_LOCKA)) {
  }
  PMC->PMC_MCKR = (SYS_BOARD_MCKR & ~PMC_MCKR_CSS_Msk) |
                   PMC_MCKR_CSS_MAIN_CLK;
  while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {
  }
  PMC->PMC_MCKR = SYS_BOARD_MCKR;
  while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {
  }
}
void __early_init ( void ) { EFC0 -> EEFC_FMR = EEFC_FMR_FWS ( 4 ) ; EFC1 -> EEFC_FMR = EEFC_FMR_FWS ( 4 ) ; if ( ! ( PMC -> CKGR_MOR & CKGR_MOR_MOSCSEL ) ) { PMC -> CKGR_MOR = SYS_CKGR_MOR_KEY_VALUE | SYS_BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN ; while ( ! ( PMC -> PMC_SR & PMC_SR_MOSCXTS ) ) { } } PMC -> CKGR_MOR = SYS_CKGR_MOR_KEY_VALUE | SYS_BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL ; while ( ! ( PMC -> PMC_SR & PMC_SR_MOSCSELS ) ) { } PMC -> PMC_MCKR = ( PMC -> PMC_MCKR & ~ ( uint32_t ) PMC_MCKR_CSS_Msk ) | PMC_MCKR_CSS_MAIN_CLK ; while ( ! ( PMC -> PMC_SR & PMC_SR_MCKRDY ) ) { } PMC -> CKGR_PLLAR = SYS_BOARD_PLLAR ; while ( ! ( PMC -> PMC_SR & PMC_SR_LOCKA ) ) { } PMC -> PMC_MCKR = ( SYS_BOARD_MCKR & ~ PMC_MCKR_CSS_Msk ) | PMC_MCKR_CSS_MAIN_CLK ; while ( ! ( PMC -> PMC_SR & PMC_SR_MCKRDY ) ) { } PMC -> PMC_MCKR = SYS_BOARD_MCKR ; while ( ! ( PMC -> PMC_SR & PMC_SR_MCKRDY ) ) { } }
@brief   Early initialization code.
@brief Early initialization code .
/* Set FWS according to SYS_BOARD_MCKR configuration */ /* Initialize main oscillator */ /* Switch to 3-20MHz Xtal oscillator */ /* Initialize PLLA */ /* Switch to main clock */ /* Switch to PLLA */