/*================================================================================== * 函 数 名: Set_System * 参 数: None * 功能描述: 初始化系统 * 返 回 值: None * 备 注: * 作 者: gaodb * 创建时间: 2012.10 ==================================================================================*/ void Set_System(void) { rcc_init(); peri_clk_init(); NVIC_Configuration(); pins_init(); systick_init(); timer2_init(); timer4_init(); RAY12_ADC_Init(); LCD_Config(); DispInit(); uart1_init(BAUD_RATE_57600); uart2_init(BAUD_RATE_57600); dac1_init(); sys_variable_init(); }
int main(void) { rcc_init(); GPIO_init(); USART2_init(); USART_SendString("Hello World\n"); while (1) { if (USART_ReceiveChar() == 'g'){ USART_SendString("Received your message\r\n"); } } }
/** * @brief Main program. * @param None * @retval : None */ int main(void) { int i; stopwatch_reset(&stopwatch); /* * Enable peripherals */ rcc_init(); gpio_init(); nvic_init(); usart_init(); tim_init(); delay_ms(1000); iprintf(ANSI_CLRSCR ANSI_BOLD("STM32 Stopwatch") " rev %s, built on %s.\r\n", build_git_description, build_git_time); iprintf("(c) Sami Kujala, 2012. https://github.com/skujala/stm32-stopwatch\r\n"); iprintf("Initialization complete.\r\n"); LED_GPIO->BSRR = (1 << BLUE_LED_PIN); while (1) { if (stopwatch.counter == COUNTER_STOPPED){ for (i = 0; i < 10; i++) { LED_GPIO->ODR ^= (1 << BLUE_LED_PIN); delay_ms(50); } iprintf("Elapsed time: " ANSI_BOLD("%d") " ms.\r\n", TIMER_COUNTS_IN_MS(stopwatch.counts_elapsed)); stopwatch_reset(&stopwatch); } } return 0; }
int main (int argc, char *argv[]) { struct parameters params; lists_t_strs *deferred_overrides; lists_t_strs *args; #ifdef HAVE_UNAME_SYSCALL int rc; struct utsname uts; #endif #ifdef PACKAGE_REVISION logit ("This is Music On Console (revision %s)", PACKAGE_REVISION); #else logit ("This is Music On Console (version %s)", PACKAGE_VERSION); #endif #ifdef CONFIGURATION logit ("Configured:%s", CONFIGURATION); #endif #ifdef HAVE_UNAME_SYSCALL rc = uname (&uts); if (rc == 0) logit ("Running on: %s %s %s", uts.sysname, uts.release, uts.machine); #endif log_command_line (argc, argv); files_init (); if (get_home () == NULL) fatal ("Could not determine user's home directory!"); memset (¶ms, 0, sizeof(params)); options_init (); deferred_overrides = lists_strs_new (4); /* set locale according to the environment variables */ if (!setlocale(LC_ALL, "")) logit ("Could not set locale!"); args = process_command_line (argc, argv, ¶ms, deferred_overrides); if (params.dont_run_iface && params.only_server) fatal ("-c, -a and -p options can't be used with --server!"); if (!params.config_file) params.config_file = xstrdup (create_file_name ("config")); options_parse (params.config_file); if (params.config_file) free (params.config_file); params.config_file = NULL; process_deferred_overrides (deferred_overrides); lists_strs_free (deferred_overrides); deferred_overrides = NULL; check_moc_dir (); io_init (); rcc_init (); decoder_init (params.debug); srand (time(NULL)); if (!params.only_server && params.dont_run_iface) server_command (¶ms, args); else start_moc (¶ms, args); lists_strs_free (args); options_free (); decoder_cleanup (); io_cleanup (); rcc_cleanup (); files_cleanup (); compat_cleanup (); exit (EXIT_SUCCESS); }