/** * Initializes the minimal system including CPU Clock, UART, and Flash accelerator * Be careful of the order of operations!!! */ void low_level_init(void) { rtc_init(); m_rtc_boot_time = rtc_gettime(); /** * Configure System Clock based on desired clock rate @ sys_config.h * Setup default interrupt priorities that will work with FreeRTOS */ sys_clock_configure(); configure_flash_acceleration(sys_get_cpu_clock()); configure_interrupt_priorities(); __enable_irq(); // Setup UART with minimum I/O functions uart0_init(UART0_DEFAULT_RATE_BPS); sys_set_outchar_func(uart0_putchar); sys_set_inchar_func(uart0_getchar); /** * If buffers are set to 0, so printf/scanf will behave correctly! * If not set, then printf/scanf will have weird buffering/flushing effects */ setvbuf(stdout, 0, _IONBF, 0); setvbuf(stdin, 0, _IONBF, 0); /** * Set the semaphore for the malloc lock. * Initialize newlib fopen() fread() calls support */ syscalls_init(); /** * Enable watchdog to allow us to recover in case of: * - We attempt to run an application and it's not there * - Application we ran crashes */ sys_watchdog_enable(); print_boot_info(); }
/** * Initializes the minimal system including CPU Clock, UART, and Flash accelerator * Be careful of the order of the operations!!! */ void low_level_init(void) { rtc_init(); g_rtc_boot_time = rtc_gettime(); /* Configure System Clock based on desired clock rate @ sys_config.h */ sys_clock_configure(); configure_flash_acceleration(sys_get_cpu_clock()); /* Setup default interrupt priorities that will work with FreeRTOS */ configure_interrupt_priorities(); /* These methods shouldn't be needed but doing it anyway to be safe */ NVIC_SetPriorityGrouping(0); __set_BASEPRI(0); __enable_fault_irq(); __enable_irq(); /* Setup UART with minimal I/O functions */ uart0_init(SYS_CFG_UART0_BPS); sys_set_outchar_func(uart0_putchar); sys_set_inchar_func(uart0_getchar); /** * Turn off I/O buffering otherwise sometimes printf/scanf doesn't behave * correctly due to strange buffering and/or flushing effects. */ setvbuf(stdout, 0, _IONBF, 0); setvbuf(stdin, 0, _IONBF, 0); /* Initialize newlib fopen() fread() calls support */ syscalls_init(); /* Enable the watchdog to allow us to recover in an event of system crash */ sys_watchdog_enable(); /* Uart and printf() are initialized, so print our boot-up message */ print_boot_info(); }
/** * Initializes the minimal system including CPU Clock, UART, and Flash accelerator * Be careful of the order of operations!!! */ void low_level_init(void) { rtc_init(); g_rtc_boot_time = rtc_gettime(); /** * Configure System Clock based on desired clock rate @ sys_config.h * Setup default interrupt priorities that will work with FreeRTOS */ sys_clock_configure(); configure_flash_acceleration(sys_get_cpu_clock()); configure_interrupt_priorities(); __enable_irq(); // Setup UART with minimum I/O functions uart0_init(UART0_DEFAULT_RATE_BPS); sys_set_outchar_func(uart0_putchar); sys_set_inchar_func(uart0_getchar); /** * Turn off I/O buffering otherwise sometimes printf/scanf doesn't behave * correctly due to strange buffering and/or flushing effects. */ setvbuf(stdout, 0, _IONBF, 0); setvbuf(stdin, 0, _IONBF, 0); // Initialize newlib fopen() fread() calls support syscalls_init(); /** * Enable watchdog to allow us to recover in case of: * - We attempt to run an application and it's not there * - Application we ran crashes */ sys_watchdog_enable(); print_boot_info(); }