Beispiel #1
0
/* Enable the peripheral clock if the specified bit is set in the value. */
static void stm32_rcc_periph_enable(
                    Stm32Rcc *s,
                    uint32_t new_value,
                    bool init,
                    int periph,
                    uint32_t bit_pos)
{
    if(s->PERIPHCLK[periph] == NULL)
    {
        stm32_hw_warn("Attempted to enable clock that isn't set: %s", stm32_periph_name(periph));
        return;
    }
    if(new_value & BIT(bit_pos))
    {
        if(!clktree_is_enabled(s->PERIPHCLK[periph]))
            DPRINT("Enabling periphial %s\n", stm32_periph_name(periph));
    }
    else
    {
        if(clktree_is_enabled(s->PERIPHCLK[periph]))
            DPRINT("Disabling periphial %s\n", stm32_periph_name(periph));
    }

    clktree_set_enabled(s->PERIPHCLK[periph], new_value & BIT(bit_pos));
}
Beispiel #2
0
void stm32_rcc_check_periph_clk(Stm32Rcc *s, stm32_periph_t periph)
{
    Clk clk = s->PERIPHCLK[periph];

    assert(clk != NULL);

    if(!clktree_is_enabled(clk)) {
        /* I assume writing to a peripheral register while the peripheral clock
         * is disabled is a bug and give a warning to unsuspecting programmers.
         * When I made this mistake on real hardware the write had no effect.
         */
        hw_error("Warning: You are attempting to use the %s peripheral while "
                 "its clock is disabled.\n", stm32_periph_name(periph));
    }
}