void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); /* Init board clock */ BOARD_ClockInit(); configure_lpuart_pins(0); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); /* Init board clock */ BOARD_ClockInit(); // Change clock mode, core clock = 48MHz, bus clock = 24MHz. CLOCK_HAL_SetFeeMode(MCG, kMcgOscselRtc, 0U, kMcgDmx32Fine, kMcgDcoRangeSelMid, fllStableDelay); CLOCK_SYS_SetOutDiv(0U, 0U, 0U, 1U); configure_lpuart_pins(BOARD_DEBUG_UART_INSTANCE); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); //Configure flexio clock src and pin mux CLOCK_SYS_SetFlexioSrc(0,(clock_flexio_src_t)1); configure_flexio_pins(0,5); /*FLEXIO pin 5 simulated as UART TX*/ configure_flexio_pins(0,4); /*FLEXIO pin 4 simulated as UART RX*/ //Configure lpuart pin mux configure_lpuart_pins(1); }
/*! * \cond DOXYGEN_PRIVATE * \brief Pre initialization - initializing requested modules for basic run of MQX. */ int _bsp_pre_init(void) { uint32_t result; /****************************************************************************** Init gpio platform pins for LEDs, setup board clock source ******************************************************************************/ /* Macro PEX_MQX_KSDK used by PEX team */ #ifndef PEX_MQX_KSDK hardware_init(); /* Configure PINS for default UART instance */ #if defined(BOARD_USE_LPSCI) configure_lpsci_pins(BOARD_DEBUG_UART_INSTANCE); #elif defined(BOARD_USE_LPUART) configure_lpuart_pins(BOARD_DEBUG_UART_INSTANCE); #elif defined(BOARD_USE_UART) configure_uart_pins(BOARD_DEBUG_UART_INSTANCE); #else #error Default serial module is unsupported or undefined. #endif #endif #if MQX_EXIT_ENABLED extern void _bsp_exit_handler(void); /* Set the bsp exit handler, called by _mqx_exit */ _mqx_set_exit_handler(_bsp_exit_handler); #endif result = _psp_int_init(BSP_FIRST_INTERRUPT_VECTOR_USED, BSP_LAST_INTERRUPT_VECTOR_USED); if (result != MQX_OK) { return result; } /****************************************************************************** Init MQX tick timer ******************************************************************************/ /* Initialize , set and run system hwtimer */ result = HWTIMER_SYS_Init(&systimer, &BSP_SYSTIMER_DEV, BSP_SYSTIMER_ID, NULL); if (kStatus_OSA_Success != result) { return MQX_INVALID_POINTER; } /* Set isr for timer*/ if (NULL == OSA_InstallIntHandler(BSP_SYSTIMER_INTERRUPT_VECTOR, HWTIMER_SYS_SystickIsrAction)) { return kHwtimerRegisterHandlerError; } /* Set interrupt priority */ NVIC_SetPriority(BSP_SYSTIMER_INTERRUPT_VECTOR, MQX_TO_NVIC_PRIOR(BSP_SYSTIMER_ISR_PRIOR)); /* Disable interrupts to ensure ticks are not active until call of _sched_start_internal */ _int_disable(); result = HWTIMER_SYS_SetPeriod(&systimer, BSP_ALARM_PERIOD); if (kStatus_OSA_Success != result) { HWTIMER_SYS_Deinit(&systimer); return MQX_INVALID_POINTER; } result = HWTIMER_SYS_RegisterCallback(&systimer,(hwtimer_callback_t)_time_notify_kernel, NULL); if (kStatus_OSA_Success != result) { HWTIMER_SYS_Deinit(&systimer); return MQX_INVALID_POINTER; } result = HWTIMER_SYS_Start(&systimer); if (kStatus_OSA_Success != result) { HWTIMER_SYS_Deinit(&systimer); return MQX_INVALID_POINTER; } /* Initialize the system ticks */ _time_set_ticks_per_sec(BSP_ALARM_FREQUENCY); _time_set_hwticks_per_tick(HWTIMER_SYS_GetModulo(&systimer)); _time_set_hwtick_function(_bsp_get_hwticks, (void *)NULL); return MQX_OK; }