int main(int argc, char **argv) { globals_init(); parse_args(argc, argv); event_init(); server_init(); event_loop(0); return 0; }
void cmd_set(char* params){ uint8_t name = (uint8_t) params[0]; if (name == 100){ globals_init(); return; } float value; memcpy(&value, ¶ms[1], 4); globals_set(name, value); cmd_send_debug16('W', (uint16_t) ( (float) value * 1000.0)); cmd_ackset(name); }
int main(void) { printf("Welcome to FUNK " "Use ctrl-c to exit.\n"); globals_init(); while (1) { printf("f> "); print(eval(read(stdin), GlobalEnvironment)); printf("\n"); } return 0; }
int main(int argc,char **argv) { bool success; /* initialize global variables */ globals_init(argv[0]); /* initialize modules */ modules_init(); /* parse command line */ success = parse_main(argc,argv); return (success) ? ST_EXIT_SUCCESS : ST_EXIT_ERROR; }
int main(int argc, char **argv) { r_dev_list_t *rdev_list; globals_init(); parse_args(argc, argv); rdev_list = config_parse(config); event_init(); connections_init(rdev_list); if (run_daemon) daemonize("/tmp"); event_loop(0); return 0; }
int main(int argc, char **argv) { int ret, i; struct event_base *base; thrash_client_t *lc; globals_init(); ret = parse_args(argc, argv); argv += ret; argc -= ret; if (!argc) { printf("%s\n", help); exit(1); } base = event_base_new(); lc = init_thrash_client(base); lc->evbase = base; lc->resp_cb = resp_callback; lc->port = thrashd_port; thrash_client_sethost(lc, thrashd_host); thrash_client_settype(lc, pkt_type); thrash_client_connect(lc); for (i = 0; i < argc; i++) { printf("%s\n", argv[i]); thrash_client_lookup(lc, inet_addr(argv[i]), query); event_base_loop(base, 0); } return 0; }
AST_COMPAT_STATIC int load_module(void) { int res = 0; apr_hash_index_t *hi; if (apr_initialized == 0) { if (apr_initialize() != APR_SUCCESS) { ast_log(LOG_ERROR, "Unable to initialize APR\n"); apr_terminate(); apr_initialized = 0; return AST_MODULE_LOAD_DECLINE; } else { ast_log(LOG_DEBUG, "APR initialized\n"); apr_initialized = 1; } } /* Initialize globals. */ if (globals_init() != 0) { ast_log(LOG_DEBUG, "Unable to initialize globals\n"); apr_terminate(); apr_initialized = 0; return AST_MODULE_LOAD_DECLINE; } /* Load the configuration file mrcp.conf. */ #if AST_VERSION_AT_LEAST(1,6,0) struct ast_flags config_flags = { 0 }; struct ast_config *cfg = ast_config_load(MRCP_CONFIG, config_flags); #else struct ast_config *cfg = ast_config_load(MRCP_CONFIG); #endif if (!cfg) { ast_log(LOG_WARNING, "No such configuration file %s\n", MRCP_CONFIG); globals_destroy(); apr_terminate(); apr_initialized = 0; return AST_MODULE_LOAD_DECLINE; } if (load_mrcp_config(cfg) != 0) { ast_log(LOG_DEBUG, "Unable to load configuration\n"); globals_destroy(); apr_terminate(); apr_initialized = 0; return AST_MODULE_LOAD_DECLINE; } /* Link UniMRCP logs to Asterisk. */ ast_log(LOG_NOTICE, "UniMRCP log level = %s\n", globals.unimrcp_log_level); apt_log_priority_e log_priority = apt_log_priority_translate(globals.unimrcp_log_level); if (apt_log_instance_create(APT_LOG_OUTPUT_NONE, log_priority, globals.pool) == FALSE) { /* Already created. */ apt_log_priority_set(log_priority); } apt_log_ext_handler_set(unimrcp_log); /* Create the MRCP client. */ if ((globals.mrcp_client = mod_unimrcp_client_create(globals.pool)) == NULL) { ast_log(LOG_ERROR, "Failed to create MRCP client\n"); if (!apt_log_instance_destroy()) ast_log(LOG_WARNING, "Unable to destroy UniMRCP logger instance\n"); globals_destroy(); apr_terminate(); apr_initialized = 0; return AST_MODULE_LOAD_DECLINE; } /* Load the applications. */ load_mrcpsynth_app(); load_mrcprecog_app(); load_synthandrecog_app(); /* Start the client stack. */ if (!mrcp_client_start(globals.mrcp_client)) { ast_log(LOG_ERROR, "Failed to start MRCP client stack processing\n"); if (!mrcp_client_destroy(globals.mrcp_client)) ast_log(LOG_WARNING, "Unable to destroy MRCP client stack\n"); else ast_log(LOG_DEBUG, "MRCP client stack destroyed\n"); globals.mrcp_client = NULL; if (!apt_log_instance_destroy()) ast_log(LOG_WARNING, "Unable to destroy UniMRCP logger instance\n"); globals_destroy(); apr_terminate(); apr_initialized = 0; return AST_MODULE_LOAD_DECLINE; } /* Register the applications. */ for (hi = apr_hash_first(NULL, globals.apps); hi; hi = apr_hash_next(hi)) { const void *key; void *val; const char *name; ast_mrcp_application_t *application; apr_hash_this(hi, &key, NULL, &val); name = (const char *) key; application = (ast_mrcp_application_t *) val; #if AST_VERSION_AT_LEAST(1,6,2) res |= ast_register_application_xml(name, application->exec); #else res |= ast_register_application(name, application->exec, application->synopsis, application->description); #endif } return res; }
int main( void ){ DDRC = 0xDB; //PORTC = 0x7E;; PORTC = 0xE7; uint8_t error; Packet packet; Queue* packets; packets = Packets_getQueue(); // initialize globals globals_init(); // initialize Time time_init(); TimeResult tr; uint32_t previous = 0; uint32_t watchdog = 0; // initialize usart usart_init(); // initialize motors motors_init(); motors_set(MOTORS_LEFT, 0); motors_set(MOTORS_RIGHT, 0); // initialize analog input analoginput_init(); // enable interrupts sei(); // loop forever while(1){ error = Packets_getError(); if (error){ Packets_sendError(ERROR_PACKETS, error); continue; } if (packets->count > 0){ error = 0x00; packet = Packets_getNext(); error = Queue_getError(packets); if (error){ Packets_sendError(ERROR_QUEUE, error); continue; } handle_packet(packet); watchdog = time_get_time(); } tr = time_get_time_delta(previous); // every 20ms, calculate rpm if (get_time_in_ms(tr.delta) > 20){ previous = tr.previous; motors_tick(); send_status(); } tr = time_get_time_delta(watchdog); if (get_time_in_ms(tr.delta) > 500){ motors_set(MOTORS_LEFT, 0); motors_set(MOTORS_RIGHT, 0); } } }
int main(int argc, char *argv[], char *envp[]) { #ifdef LISP_FEATURE_WIN32 /* Exception handling support structure. Evil Win32 hack. */ struct lisp_exception_frame exception_frame; #endif /* the name of the core file we're to execute. Note that this is * a malloc'ed string which should be freed eventually. */ char *core = 0; char **sbcl_argv = 0; os_vm_offset_t embedded_core_offset = 0; char *runtime_path = 0; /* other command line options */ boolean noinform = 0; boolean end_runtime_options = 0; boolean disable_lossage_handler_p = 0; lispobj initial_function; const char *sbcl_home = getenv("SBCL_HOME"); interrupt_init(); block_blockable_signals(0, 0); setlocale(LC_ALL, ""); runtime_options = NULL; /* Check early to see if this executable has an embedded core, * which also populates runtime_options if the core has runtime * options */ runtime_path = os_get_runtime_executable_path(); if (runtime_path) { os_vm_offset_t offset = search_for_embedded_core(runtime_path); if (offset != -1) { embedded_core_offset = offset; core = runtime_path; } else { free(runtime_path); } } /* Parse our part of the command line (aka "runtime options"), * stripping out those options that we handle. */ if (runtime_options != NULL) { dynamic_space_size = runtime_options->dynamic_space_size; thread_control_stack_size = runtime_options->thread_control_stack_size; sbcl_argv = argv; } else { int argi = 1; runtime_options = successful_malloc(sizeof(struct runtime_options)); while (argi < argc) { char *arg = argv[argi]; if (0 == strcmp(arg, "--script")) { /* This is both a runtime and a toplevel option. As a * runtime option, it is equivalent to --noinform. * This exits, and does not increment argi, so that * TOPLEVEL-INIT sees the option. */ noinform = 1; end_runtime_options = 1; disable_lossage_handler_p = 1; lose_on_corruption_p = 1; break; } else if (0 == strcmp(arg, "--noinform")) { noinform = 1; ++argi; } else if (0 == strcmp(arg, "--core")) { if (core) { lose("more than one core file specified\n"); } else { ++argi; if (argi >= argc) { lose("missing filename for --core argument\n"); } core = copied_string(argv[argi]); ++argi; } } else if (0 == strcmp(arg, "--help")) { /* I think this is the (or a) usual convention: upon * seeing "--help" we immediately print our help * string and exit, ignoring everything else. */ print_help(); exit(0); } else if (0 == strcmp(arg, "--version")) { /* As in "--help" case, I think this is expected. */ print_version(); exit(0); } else if (0 == strcmp(arg, "--dynamic-space-size")) { ++argi; if (argi >= argc) lose("missing argument for --dynamic-space-size"); errno = 0; dynamic_space_size = strtol(argv[argi++], 0, 0) << 20; if (errno) lose("argument to --dynamic-space-size is not a number"); # ifdef MAX_DYNAMIC_SPACE_END if (!((DYNAMIC_SPACE_START < DYNAMIC_SPACE_START+dynamic_space_size) && (DYNAMIC_SPACE_START+dynamic_space_size <= MAX_DYNAMIC_SPACE_END))) lose("specified --dynamic-space-size too large"); # endif } else if (0 == strcmp(arg, "--control-stack-size")) { ++argi; if (argi >= argc) lose("missing argument for --control-stack-size"); errno = 0; thread_control_stack_size = strtol(argv[argi++], 0, 0) << 20; if (errno) lose("argument to --control-stack-size is not a number"); } else if (0 == strcmp(arg, "--debug-environment")) { int n = 0; printf("; Commandline arguments:\n"); while (n < argc) { printf("; %2d: \"%s\"\n", n, argv[n]); ++n; } n = 0; printf(";\n; Environment:\n"); while (ENVIRON[n]) { printf("; %2d: \"%s\"\n", n, ENVIRON[n]); ++n; } ++argi; } else if (0 == strcmp(arg, "--disable-ldb")) { disable_lossage_handler_p = 1; ++argi; } else if (0 == strcmp(arg, "--lose-on-corruption")) { lose_on_corruption_p = 1; ++argi; } else if (0 == strcmp(arg, "--end-runtime-options")) { end_runtime_options = 1; ++argi; break; } else { /* This option was unrecognized as a runtime option, * so it must be a toplevel option or a user option, * so we must be past the end of the runtime option * section. */ break; } } /* This is where we strip out those options that we handle. We * also take this opportunity to make sure that we don't find * an out-of-place "--end-runtime-options" option. */ { char *argi0 = argv[argi]; int argj = 1; /* (argc - argi) for the arguments, one for the binary, and one for the terminating NULL. */ sbcl_argv = successful_malloc((2 + argc - argi) * sizeof(char *)); sbcl_argv[0] = argv[0]; while (argi < argc) { char *arg = argv[argi++]; /* If we encounter --end-runtime-options for the first * time after the point where we had to give up on * runtime options, then the point where we had to * give up on runtime options must've been a user * error. */ if (!end_runtime_options && 0 == strcmp(arg, "--end-runtime-options")) { lose("bad runtime option \"%s\"\n", argi0); } sbcl_argv[argj++] = arg; } sbcl_argv[argj] = 0; } } /* Align down to multiple of page_table page size, and to the appropriate * stack alignment. */ dynamic_space_size &= ~(PAGE_BYTES-1); thread_control_stack_size &= ~(CONTROL_STACK_ALIGNMENT_BYTES-1); /* Preserve the runtime options for possible future core saving */ runtime_options->dynamic_space_size = dynamic_space_size; runtime_options->thread_control_stack_size = thread_control_stack_size; /* KLUDGE: os_vm_page_size is set by os_init(), and on some * systems (e.g. Alpha) arch_init() needs need os_vm_page_size, so * it must follow os_init(). -- WHN 2000-01-26 */ os_init(argv, envp); arch_init(); gc_init(); validate(); /* If no core file was specified, look for one. */ if (!core) { core = search_for_core(); } /* Make sure that SBCL_HOME is set and not the empty string, unless loading an embedded core. */ if (!(sbcl_home && *sbcl_home) && embedded_core_offset == 0) { char *envstring, *copied_core, *dir; char *stem = "SBCL_HOME="; copied_core = copied_string(core); dir = dirname(copied_core); envstring = (char *) calloc(strlen(stem) + strlen(dir) + 1, sizeof(char)); sprintf(envstring, "%s%s", stem, dir); putenv(envstring); free(copied_core); } if (!noinform && embedded_core_offset == 0) { print_banner(); fflush(stdout); } #if defined(SVR4) || defined(__linux__) tzset(); #endif define_var("nil", NIL, 1); define_var("t", T, 1); if (!disable_lossage_handler_p) enable_lossage_handler(); globals_init(); initial_function = load_core_file(core, embedded_core_offset); if (initial_function == NIL) { lose("couldn't find initial function\n"); } #ifdef LISP_FEATURE_HPUX /* -1 = CLOSURE_FUN_OFFSET, 23 = SIMPLE_FUN_CODE_OFFSET, we are * not in LANGUAGE_ASSEMBLY so we cant reach them. */ return_from_lisp_stub = (void *) ((char *)*((unsigned long *) ((char *)initial_function + -1)) + 23); #endif gc_initialize_pointers(); arch_install_interrupt_handlers(); #ifndef LISP_FEATURE_WIN32 os_install_interrupt_handlers(); #else /* wos_install_interrupt_handlers(handler); */ wos_install_interrupt_handlers(&exception_frame); #endif /* Pass core filename and the processed argv into Lisp. They'll * need to be processed further there, to do locale conversion. */ core_string = core; posix_argv = sbcl_argv; FSHOW((stderr, "/funcalling initial_function=0x%lx\n", (unsigned long)initial_function)); #ifdef LISP_FEATURE_WIN32 fprintf(stderr, "\n\ This is experimental prerelease support for the Windows platform: use\n\ at your own risk. \"Your Kitten of Death awaits!\"\n"); fflush(stdout); fflush(stderr); #endif create_initial_thread(initial_function); lose("CATS. CATS ARE NICE.\n"); return 0; }
void initialize(void) { PIEZO_DDR |= _BV(PIEZO_LOW_BIT); PIEZO_DDR |= _BV(PIEZO_HIGH_BIT); PIEZO_LOW_OFF; PIEZO_HIGH_OFF; // Set buttons as inputs BUTTON_DDR &= ~(_BV(BUTTON1_BIT)); BUTTON_DDR &= ~(_BV(BUTTON2_BIT)); SWITCH_DDR &= ~(_BV(SWITCH_BIT)); // Enable pullups for buttons BUTTON_PORT |= _BV(BUTTON1_BIT); BUTTON_PORT |= _BV(BUTTON2_BIT); SWITCH_PORT |= _BV(SWITCH_BIT); LED_DDR |= _BV(LED_BIT); // indicator led for (int i = 0; i < 5; i++) { LED_HIGH; _delay_ms(100); LED_LOW; _delay_ms(100); } sei(); twi_init_master(); rtc_init(); rtc_set_ds1307(); //rtc_set_time_s(16, 59, 50); //rtc_set_alarm_s(17,0,0); piezo_init(); beep(440, 1); globals_init(); display_init(g_brightness); g_alarm_switch = get_alarm_switch(); #ifdef FEATURE_FLW g_has_eeprom = has_eeprom(); // if (!g_has_eeprom) beep(440,2); // debug if (!g_has_eeprom) g_flw_enabled = false; if (tm_ && g_has_eeprom) seed_random(tm_->Hour * 10000 + tm_->Minute + 100 + tm_->Second); #endif beep(1320, 1); menu_init(); // must come after display, flw init rtc_get_alarm_s(&alarm_hour, &alarm_min, &alarm_sec); // set up interrupt for alarm switch PCICR |= (1 << PCIE2); PCMSK2 |= (1 << PCINT18); #ifdef FEATURE_WmGPS // setup uart for GPS gps_init(g_gps_enabled); #endif #ifdef FEATURE_AUTO_DST if (g_DST_mode) DSTinit(tm_, g_DST_Rules); // re-compute DST start, end #endif }
int main(void) { #ifndef NO_DEBUG uart_init(); stdout = &uart_stdout; banner(); #endif shared_memory_init(); system_init(); sram_init(); pwm_init(); irq_init(); boot_startup_rom(50); globals_init(); pwm_stop(); usbInit(); usb_connect(); sei(); while (1) { system_set_bus_avr(); system_set_wr_disable(); while (usb_trans.req_state != REQ_STATUS_SNES) { usbPoll(); #if DO_SHELL #ifndef NO_DEBUG shell_run(); #endif #endif } #if DO_SHM shared_memory_write(SHARED_MEM_TX_CMD_TERMINATE, 0); #endif #if DO_SHM_SCRATCHPAD shared_memory_scratchpad_region_tx_restore(); shared_memory_scratchpad_region_rx_restore(); #endif #if DO_CRC_CHECK info_P(PSTR("-->CRC Check\n")); crc_check_bulk_memory(0x000000, usb_trans.req_bank_size * usb_trans.req_bank_cnt, usb_trans.req_bank_size); #endif system_set_rom_mode(&usb_trans); system_set_wr_disable(); system_set_bus_snes(); system_send_snes_reset(); irq_stop(); while ((usb_trans.req_state != REQ_STATUS_AVR)) { usbPoll(); #if DO_SHELL #ifndef NO_DEBUG shell_run(); #endif #endif } info_P(PSTR("-->Switch TO AVR\n")); shared_memory_init(); irq_init(); if (usb_trans.loader_enabled) { boot_startup_rom(50); } else { system_set_bus_avr(); system_send_snes_reset(); } globals_init(); } return 0; }