/** * \brief Set SLCD power mode. * * \param p_supc Pointer to a SUPC instance. * \param mode The mode of SLCDC. */ void supc_set_slcd_power_mode(Supc *p_supc, enum slcdc_power_mode mode) { enum slcdc_power_mode pre_mode; uint32_t tmp; pre_mode = supc_get_slcd_power_mode(p_supc); if ((pre_mode == SLCDC_POWER_MODE_LCDON_EXTVR) && (mode == SLCDC_POWER_MODE_LCDON_INVR)) { return; } else if ((pre_mode == SLCDC_POWER_MODE_LCDON_INVR) && (mode == SLCDC_POWER_MODE_LCDON_EXTVR)) { return; } tmp = p_supc->SUPC_MR; tmp &= ~SUPC_MR_LCDMODE_Msk; tmp |= SUPC_MR_KEY_PASSWD | mode; p_supc->SUPC_MR = tmp; if (mode == SLCDC_POWER_MODE_LCDOFF) { while(supc_get_status(p_supc) & SUPC_SR_LCDS_ENABLED); } else { while(!(supc_get_status(p_supc) & SUPC_SR_LCDS_ENABLED)); } }
/** * \brief Test slow clock source switching. * * This test switches the slow clock on the crystal oscillator output. * * \param test Current test case. */ static void run_supc_test(const struct test_case *test) { uint32_t status = 0; uint32_t timeout = 0; /* Test: Switch the slow clock on the crystal oscillator output */ supc_switch_sclk_to_32kxtal(SUPC, 0); do { status = supc_get_status(SUPC); if (status & SUPC_SR_OSCSEL_CRYST) break; } while (timeout++ < SLOW_CLK_TIMEOUT); test_assert_true(test, (status & SUPC_SR_OSCSEL_CRYST) == SUPC_SR_OSCSEL_CRYST, "Test: switching slow clock source failed!"); }