/** * \brief Enable the internal voltage regulator. * * \param p_supc Pointer to a SUPC instance. */ void supc_enable_voltage_regulator(Supc *p_supc) { #if (SAM3U || SAM3XA) uint32_t ul_mr = p_supc->SUPC_MR & (~(SUPC_MR_KEY_Msk | SUPC_MR_VDDIORDYONREG)); p_supc->SUPC_MR = SUPC_MR_KEY(SUPC_KEY) | ul_mr | SUPC_MR_VDDIORDYONREG; #else uint32_t ul_mr = p_supc->SUPC_MR & (~(SUPC_MR_KEY_Msk | SUPC_MR_ONREG)); p_supc->SUPC_MR = SUPC_MR_KEY(SUPC_KEY) | ul_mr | SUPC_MR_ONREG; #endif }
/** * \brief Switch slow clock source selection to external 32k (Xtal or Bypass) oscillator. * This function disables the PLLs. * * \note Switching sclk back to 32krc is only possible by shutting down the VDDIO power supply. * * \param ul_bypass 0 for Xtal, 1 for bypass. */ void supc_switch_sclk_to_32kxtal(Supc *p_supc, uint32_t ul_bypass) { /* Set Bypass mode if required */ if (ul_bypass == 1) { p_supc->SUPC_MR |= SUPC_MR_KEY(SUPC_KEY) | SUPC_MR_OSCBYPASS; } p_supc->SUPC_CR |= SUPC_CR_KEY(SUPC_KEY) | SUPC_CR_XTALSEL; }
void brick_enable_brownout_detection(void) { SUPC->SUPC_MR |= SUPC_MR_KEY(0xA5) | SUPC_MR_BODDIS_ENABLE; // SUPC->SUPC_SMMR |= SUPC_SMMR_SMSMPL_CSM | SUPC_SMMR_SMTH_3_2V | SUPC_SMMR_SMIEN_ENABLE; volatile uint32_t tmp = SUPC->SUPC_SR; // clear sms and smos NVIC_DisableIRQ(SUPC_IRQn); NVIC_ClearPendingIRQ(SUPC_IRQn); NVIC_SetPriority(SUPC_IRQn, 0); NVIC_EnableIRQ(SUPC_IRQn); }
/** * \brief Switch slow clock source selection to external 32k (Xtal or Bypass). * * \note This function disables the PLLs. * * \note Switching SCLK back to 32krc is only possible by shutting down the VDDIO * power supply. * * \param ul_bypass 0 for Xtal, 1 for bypass. */ void pmc_switch_sclk_to_32kxtal(uint32_t ul_bypass) { /* Set Bypass mode if required */ if (ul_bypass == 1) { SUPC->SUPC_MR |= SUPC_MR_KEY(SUPC_KEY_VALUE) | SUPC_MR_OSCBYPASS; } SUPC->SUPC_CR |= SUPC_CR_KEY(SUPC_KEY_VALUE) | SUPC_CR_XTALSEL; }
/** * \brief Disable the assertion of core reset signal when a brownout detection occurs. * * \param p_supc Pointer to a SUPC instance. */ void supc_disable_brownout_reset(Supc *p_supc) { uint32_t ul_mr = p_supc->SUPC_MR & (~(SUPC_MR_KEY_Msk | SUPC_MR_BODRSTEN)); p_supc->SUPC_MR = SUPC_MR_KEY(SUPC_KEY) | ul_mr; }
/** * \brief Disable the core brownout detector. * * \param p_supc Pointer to a SUPC instance. */ void supc_disable_brownout_detector(Supc *p_supc) { uint32_t ul_mr = p_supc->SUPC_MR & (~(SUPC_MR_KEY_Msk | SUPC_MR_BODDIS)); p_supc->SUPC_MR = SUPC_MR_KEY(SUPC_KEY) | ul_mr | SUPC_MR_BODDIS; }