Ejemplo n.º 1
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_HAL_GetOutDiv
 * Description   : Get all clock out dividers setting at the same time
 * This function will get the setting for all clock out dividers.
 *
 *END**************************************************************************/
void CLOCK_HAL_GetOutDiv(SIM_Type* base,
                         uint8_t *outdiv1,
                         uint8_t *outdiv2,
                         uint8_t *outdiv3,
                         uint8_t *outdiv4)
{
    *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base);
    *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base);
    *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base);
}
Ejemplo n.º 2
0
void init_hardware(void)
{
    // Disable the MPU otherwise USB cannot access the bus
    MPU->CESR = 0;

    // Enable all the ports
    SIM->SCGC5 |= ( SIM_SCGC5_PORTA_MASK
                  | SIM_SCGC5_PORTB_MASK
                  | SIM_SCGC5_PORTC_MASK
                  | SIM_SCGC5_PORTD_MASK
                  | SIM_SCGC5_PORTE_MASK );

    // Update SystemCoreClock. FOPT bits set the OUTDIV1 value.
    SystemCoreClock /= (SIM_BRD_CLKDIV1_OUTDIV1(SIM) + 1);
}
Ejemplo n.º 3
0
uint32_t get_bus_clock(void)
{
    uint32_t busClockDivider = SIM_BRD_CLKDIV1_OUTDIV2(SIM) + 1;
    uint32_t coreClockDivider = SIM_BRD_CLKDIV1_OUTDIV1(SIM) + 1;
    return (SystemCoreClock * coreClockDivider / busClockDivider);
}