Example #1
0
static void display_clock_values
    (
        BSP_CLOCK_CONFIGURATION clock_configuration
    )
{
    printf("CLOCK_SOURCE_CORE     = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_CORE));
    printf("CLOCK_SOURCE_BUS      = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_BUS));
    printf("CLOCK_SOURCE_FLEXBUS  = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_FLEXBUS));
    printf("CLOCK_SOURCE_FLASH    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_FLASH));
    printf("CLOCK_SOURCE_USB      = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_USB));
    printf("CLOCK_SOURCE_PLLFLL   = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_PLLFLL));
    printf("CLOCK_SOURCE_MCGIR    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_MCGIR));
    printf("CLOCK_SOURCE_OSCER    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_OSCER));
    printf("CLOCK_SOURCE_ERCLK32K = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_ERCLK32K));
    printf("CLOCK_SOURCE_MCGFF    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_MCGFF));
}
Example #2
0
static void display_clock_values
(
    BSP_CLOCK_CONFIGURATION clock_configuration
)
{
    printf("CLOCK_SOURCE_CORE     = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_CORE));
    printf("CLOCK_SOURCE_BUS      = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_BUS));
#ifdef BSP_FLEXBUS_CLOCK          /* Some platforms do not support Flexbus */
    printf("CLOCK_SOURCE_FLEXBUS  = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_FLEXBUS));
#endif
    printf("CLOCK_SOURCE_FLASH    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_FLASH));
    printf("CLOCK_SOURCE_USB      = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_USB));
    printf("CLOCK_SOURCE_PLLFLL   = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_PLLFLL));
    printf("CLOCK_SOURCE_MCGIR    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_MCGIR));
    printf("CLOCK_SOURCE_OSCER    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_OSCER));
    printf("CLOCK_SOURCE_ERCLK32K = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_ERCLK32K));
    printf("CLOCK_SOURCE_MCGFF    = %d Hz\n",_cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_MCGFF));
}
Example #3
0
uint16_t _bsp_set_clock_configuration
(
    /* [IN] runtime clock configuration */
    const BSP_CLOCK_CONFIGURATION clock_configuration
)
{
    uint32_t    system_clock;
    uint16_t    cpu_error = ERR_OK;

    cpu_error = Cpu_SetClockConfiguration((uint8_t)clock_configuration);
    if (cpu_error != ERR_OK)    {
        return cpu_error;
    }

    /* Get system clock for active clock configuration */
    system_clock = _cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_CORE);

    systick_config(system_clock, BSP_ALARM_FREQUENCY);

    return ERR_OK;
}
Example #4
0
static void systick_init
(
        void
)
{

    /* Get system clock for active clock configuration */
    uint32_t system_clock = _cm_get_clock(_cm_get_clock_configuration(), CM_CLOCK_SOURCE_CORE);

#if BSP_ALARM_FREQUENCY == 0
    #error Wrong definition of BSP_ALARM_FREQUENCY
#endif

    systick_config(system_clock, BSP_ALARM_FREQUENCY);

    SYST_CSR = 7;

    /* SVCall priority*/
    SCB_SHPR2 |= 0x10000000;
    /* SysTick priority*/
    SCB_SHPR3 |= SCB_SHPR3_PRI_15(CORTEX_PRIOR(BSP_TIMER_INTERRUPT_PRIORITY));
}
Example #5
0
LPM_NOTIFICATION_RESULT _io_serial_int_clock_configuration_callback
    (
        /* [IN] Low power notification */
        LPM_NOTIFICATION_STRUCT_PTR   notification,

        /* [IN/OUT] Device specific data */
        pointer                       device_specific_data
    )
{
    IO_SERIAL_INT_DEVICE_STRUCT_PTR dev_ptr = device_specific_data;
    KUART_INIT_STRUCT_PTR           init_data = dev_ptr->DEV_INIT_DATA_PTR;
    uint_8                          flags;

    /* Get the device registers */
    UART_MemMapPtr sci_ptr = _bsp_get_serial_base_address (init_data->DEVICE);
    if (NULL == sci_ptr)
    {
        return LPM_NOTIFICATION_RESULT_ERROR;
    }

    if (LPM_NOTIFICATION_TYPE_PRE == notification->NOTIFICATION_TYPE)
    {
        /* Lock access from the higher level */
        _lwsem_wait (&(dev_ptr->LPM_INFO.LOCK));

        /* Enable module clocks to be able to write registers */
        _bsp_serial_io_init (init_data->DEVICE, IO_PERIPHERAL_CLOCK_ENABLE);

        /* Flush output if enabled */
        if (sci_ptr->C2 & UART_C2_TE_MASK)
        {
            while (! (sci_ptr->SFIFO & UART_SFIFO_TXEMPT_MASK))
                { };
            while (! (sci_ptr->S1 & UART_S1_TC_MASK))
                { };
        }

        /* Turn off module */
        _kuart_int_peripheral_disable (sci_ptr);
    }

    if (LPM_NOTIFICATION_TYPE_POST == notification->NOTIFICATION_TYPE)
    {
        /* Enable module clocks to be able to write registers */
        _bsp_serial_io_init (init_data->DEVICE, IO_PERIPHERAL_CLOCK_ENABLE);

        /* Setup same baudrate for new clock frequency */
        _kuart_change_baudrate (sci_ptr, _cm_get_clock (notification->CLOCK_CONFIGURATION, init_data->CLOCK_SOURCE), init_data->BAUD_RATE);

        /* Turn on module if requested */
        flags = init_data->OPERATION_MODE[notification->OPERATION_MODE].FLAGS;
        if ((flags & IO_PERIPHERAL_MODULE_ENABLE) && (dev_ptr->COUNT > 0))
        {
            _kuart_int_peripheral_enable (sci_ptr);
        }

        /* Disable module clocks if required */
        if (flags & IO_PERIPHERAL_CLOCK_DISABLE)
        {
            _bsp_serial_io_init (init_data->DEVICE, IO_PERIPHERAL_CLOCK_DISABLE);
        }

        /* Unlock */
        _lwsem_post (&(dev_ptr->LPM_INFO.LOCK));
    }
    return LPM_NOTIFICATION_RESULT_OK;
}