static int bt_eisa_attach(device_t dev) { struct bt_softc *bt = device_get_softc(dev); /* Allocate resources */ bt_eisa_alloc_resources(dev); /* Allocate a dmatag for our SCB DMA maps */ /* XXX Should be a child of the PCI bus dma tag */ if (bus_dma_tag_create( /* parent */ NULL, /* alignment */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_32BIT, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg, */ NULL, &bt->parent_dmat) != 0) { bt_eisa_release_resources(dev); return (ENOMEM); } /* * Now that we know we own the resources we need, do the full * card initialization. */ if (bt_probe(dev) || bt_fetch_adapter_info(dev) || bt_init(dev)) { bt_eisa_release_resources(dev); return (ENXIO); } /* Attach sub-devices - always succeeds (sets up intr) */ bt_attach(dev); return 0; }
void bt_malloc(sgmnt_addrs *csa) { unsigned int n; sgmnt_data_ptr_t csd; csd = csa->hdr; /* check that the file header is quad word aligned */ if ((-(SIZEOF(uint4) * 2) & (sm_long_t)csd) != (sm_long_t)csd) GTMASSERT; if ((-(SIZEOF(uint4) * 2) & SIZEOF_FILE_HDR(csd)) != SIZEOF_FILE_HDR(csd)) GTMASSERT; csa->nl->bt_header_off = (n = (uint4)(SIZEOF_FILE_HDR(csd))); csa->nl->th_base_off = (n += csd->bt_buckets * SIZEOF(bt_rec)); /* hash table */ csa->nl->th_base_off += SIZEOF(que_ent); /* tnque comes after fl and bl of blkque */ csa->nl->bt_base_off = (n += SIZEOF(bt_rec)); /* th_queue anchor referenced above */ assert((n += (csd->n_bts * SIZEOF(bt_rec))) == (SIZEOF_FILE_HDR(csd)) + (BT_SIZE(csd))); /* DON'T use n after this */ bt_init(csa); bt_refresh(csa, TRUE); return; }
int main(int argc, char **argv) { bt_config_t config; bt_init(&config, argc, argv); DPRINTF(DEBUG_INIT, "Starting peer.c ...\n"); config.identity = 1; strcpy(config.chunk_file, "chunkfile"); strcpy(config.has_chunk_file, "haschunks"); bt_parse_command_line(&config); bt_dump_config(&config); init(&config); peer_run(&config); return 0; }
int main(int argc, char **argv) { bt_init(&config, argc, argv); DPRINTF(DEBUG_INIT, "peer.c main beginning\n"); #ifdef TESTING config.identity = 1; // your group number here strcpy(config.chunk_file, "chunkfile"); strcpy(config.has_chunk_file, "haschunks"); #endif bt_parse_command_line(&config); #ifdef DEBUG if (debug & DEBUG_INIT) { bt_dump_config(&config); } #endif peer_run(&config); return 0; }
int main (void) { init_pins(); char* bt_data = bt_init(); pacer_init (LOOP_POLL_RATE); pio_output_set(PIO_AUX_ENABLE, 0); short aux_power = 0; while (1) { pacer_wait (); pio_output_set(PIO_LED_G, bt_connected()); if (bt_read()) { process_command(bt_data); } } }
int main(void) { out(DEBUGLED); for(uint8_t i=0; i<5; i++) { toggle(DEBUGLED); _delay_ms(100); } off(DEBUGLED); bt_init(); irmp_init(); timer1_init(); pwm_init(); IRMP_DATA irmp_data; sei(); // polling mode while(1) { checkIR(&irmp_data); checkBT(); } }//end main
static int bt_mca_attach (device_t dev) { struct bt_softc * bt = device_get_softc(dev); int error = 0; /* Allocate resources */ if ((error = bt_mca_alloc_resources(dev, BT_MCA_ATTACH))) { device_printf(dev, "Unable to allocate resources in bt_mca_attach()\n"); return (error); } isa_dmacascade(rman_get_start(bt->drq)); /* Allocate a dmatag for our CCB DMA maps */ if (bus_dma_tag_create( /* parent */ NULL, /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_24BIT, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ btvlbouncefilter, /* filterarg */ bt, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->parent_dmat) != 0) { bt_mca_release_resources(dev); return (ENOMEM); } if (bt_init(dev)) { bt_mca_release_resources(dev); return (ENOMEM); } /* DMA tag for our sense buffers */ if (bus_dma_tag_create( /* parent */ bt->parent_dmat, /* alignment */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ bt->max_ccbs * sizeof(struct scsi_sense_data), /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->sense_dmat) != 0) { bt_mca_release_resources(dev); return (ENOMEM); } bt->init_level++; /* Allocation of sense buffers */ if (bus_dmamem_alloc(bt->sense_dmat, (void **)&bt->sense_buffers, BUS_DMA_NOWAIT, &bt->sense_dmamap) != 0) { bt_mca_release_resources(dev); return (ENOMEM); } bt->init_level++; /* And permanently map them */ bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap, bt->sense_buffers, bt->max_ccbs * sizeof(*bt->sense_buffers), btmapsensebuffers, bt, /*flags*/0); bt->init_level++; if ((error = bt_attach(dev))) { bt_mca_release_resources(dev); return (error); } return (0); }
/* * Attach all the sub-devices we can find */ static int bt_isa_attach(device_t dev) { struct bt_softc *bt = device_get_softc(dev); bus_dma_filter_t *filter; void *filter_arg; bus_addr_t lowaddr; int error, drq; /* Initialise softc */ error = bt_isa_alloc_resources(dev, 0, ~0); if (error) { device_printf(dev, "can't allocate resources in bt_isa_attach\n"); return error; } /* Program the DMA channel for external control */ if ((drq = isa_get_drq(dev)) != -1) isa_dmacascade(drq); /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; lowaddr = BUS_SPACE_MAXADDR_24BIT; if (bt->model[0] == '4') { /* * This is a VL adapter. Typically, VL devices have access * to the full 32bit address space. On BT-445S adapters * prior to revision E, there is a hardware bug that causes * corruption of transfers to/from addresses in the range of * the BIOS modulo 16MB. The only properly functioning * BT-445S Host Adapters have firmware version 3.37. * If we encounter one of these adapters and the BIOS is * installed, install a filter function for our bus_dma_map * that will catch these accesses and bounce them to a safe * region of memory. */ if (bt->bios_addr != 0 && strcmp(bt->model, "445S") == 0 && strcmp(bt->firmware_ver, "3.37") < 0) { filter = btvlbouncefilter; filter_arg = bt; } else { lowaddr = BUS_SPACE_MAXADDR_32BIT; } } /* XXX Should be a child of the ISA or VL bus dma tag */ if (bus_dma_tag_create( /* parent */ bus_get_dma_tag(dev), /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ lowaddr, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ filter, /* filterarg */ filter_arg, /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->parent_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } error = bt_init(dev); if (error) { bt_isa_release_resources(dev); return (ENOMEM); } if (lowaddr != BUS_SPACE_MAXADDR_32BIT) { /* DMA tag for our sense buffers */ if (bus_dma_tag_create( /* parent */ bt->parent_dmat, /* alignment */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ bt->max_ccbs * sizeof(struct scsi_sense_data), /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, /* lockfunc */ NULL, /* lockarg */ NULL, &bt->sense_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } bt->init_level++; /* Allocation of sense buffers */ if (bus_dmamem_alloc(bt->sense_dmat, (void **)&bt->sense_buffers, BUS_DMA_NOWAIT, &bt->sense_dmamap) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } bt->init_level++; /* And permanently map them */ bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap, bt->sense_buffers, bt->max_ccbs * sizeof(*bt->sense_buffers), btmapsensebuffers, bt, /*flags*/0); bt->init_level++; } error = bt_attach(dev); if (error) { bt_isa_release_resources(dev); return (error); } return (0); }
void fc_init() { DEBUG(" *** Flight computer init ***\n"); //start values active_page = config.gui.last_page; if (active_page >= config.gui.number_of_pages) active_page = 0; //reset flight status fc_reset(); //using fake data #ifdef FAKE_ENABLE return; #endif //temperature state machine fc.temp.step = 0; //init DMA DMA_PWR_ON; //init calculators vario_init(); audio_init(); logger_init(); protocol_init(); wind_init(); gps_init(); if (config.connectivity.use_gps) gps_start(); bt_init(); if (config.connectivity.use_bt) bt_module_init(); //VCC to baro, acc/mag gyro + i2c pull-ups mems_power_on(); //init and test i2c //HW_REW_1504 have two mems enable pins, both have to be enabled! //HW_REW_1506 have standalone ldo for mems, hence only one pin is needed if (!mems_i2c_init()) { DEBUG("ERROR I2C, Wrong board rev? (%02X)\n", hw_revision); hw_revision = HW_REW_1504; eeprom_busy_wait(); eeprom_update_byte(&config_ro.hw_revision, hw_revision); eeprom_busy_wait(); mems_power_init(); io_init(); mems_power_on(); assert(mems_i2c_init()); } else { if (hw_revision == HW_REW_UNKNOWN) { hw_revision = HW_REW_1506; eeprom_busy_wait(); eeprom_update_byte(&config_ro.hw_revision, hw_revision); eeprom_busy_wait(); mems_power_init(); io_init(); mems_power_on(); mems_i2c_init(); } } if (!mems_i2c_init()) { DEBUG("I2C error!\nUnable to init flight computer!\n"); return; } //Barometer ms5611.Init(&mems_i2c, MS5611_ADDRESS_CSB_LO); //Magnetometer + Accelerometer lsm303d_settings lsm_cfg; lsm_cfg.enabled = true; lsm_cfg.accOdr = lsm_acc_1600Hz; lsm_cfg.accScale = lsm_acc_16g; lsm_cfg.magOdr = lsm_mag_100Hz; lsm_cfg.magScale = lsm_mag_4g; lsm_cfg.magHiRes = true; lsm_cfg.tempEnable = false; //Acceleration calculation init accel_calc_init(); //Magnetic field calculation init mag_calc_init(); //Gyro l3gd20_settings l3g_cfg; l3g_cfg.enabled = true; l3g_cfg.bw = l3g_50Hz; l3g_cfg.odr = l3g_760Hz; l3g_cfg.scale = l3g_2000dps; //SHT21 sht21_settings sht_cfg; sht_cfg.rh_enabled = true; sht_cfg.temp_enabled = true; //XXX: do self-test? lsm303d.Init(&mems_i2c, lsm_cfg); lsm303d.Start(); l3gd20.Init(&mems_i2c, l3g_cfg); l3gd20.Start(); sht21.Init(&mems_i2c, sht_cfg); //Measurement timer FC_MEAS_TIMER_PWR_ON; fc_meas_timer.Init(FC_MEAS_TIMER, timer_div1024); fc_meas_timer.SetInterruptPriority(MEDIUM); fc_meas_timer.EnableInterrupts(timer_overflow | timer_compareA | timer_compareB | timer_compareC); //tight timing! 1 tick 0.032 ms //MS pressure conversion 9.040 ms // temperature conversion 0.600 ms //MAG read 0.152 ms //ACC read 1.600 ms //Gyro read 1.000 ms fc_meas_timer.SetTop(313); // == 10ms fc_meas_timer.SetCompare(timer_A, 27); // == 0.78 ms fc_meas_timer.SetCompare(timer_B, 70); // == 2 ms fc_meas_timer.SetCompare(timer_C, 200); // == 6 ms ms5611.StartTemperature(); lsm303d.StartReadMag(); //it takes 152us to transfer _delay_ms(1); fc_meas_timer.Start(); DEBUG(" *** FC init done ***\n"); }
void fc_init() { DEBUG(" *** Flight computer init ***\n"); //load configuration cfg_load(); //start values eeprom_busy_wait(); active_page = eeprom_read_byte(&config.gui.last_page); fc.epoch_flight_start = 0; fc.autostart_state = false; fc.temp_step = 0; //init calculators vario_init(); audio_init(); gps_init(); if (fc.use_gps) gps_start(); bt_init(); // if (fc.use_flage & ENABLE_BT) // bt_module_init(); //VCC to baro, acc/mag gyro MEMS_POWER_ON; GpioSetDirection(IO0, OUTPUT); GpioWrite(IO0, HIGH); //init and test i2c if (!mems_i2c_init()) { DEBUG("ERROR I2C\n"); led_set(0xFF, 0, 0); } //Barometer ms5611.Init(&mems_i2c, MS5611_ADDRESS_CSB_LO); //Magnetometer + Accelerometer lsm303d_settings lsm_cfg; lsm_cfg.enabled = true; lsm_cfg.accOdr = lsm_acc_1600Hz; lsm_cfg.accScale = lsm_acc_16g; lsm_cfg.magOdr = lsm_mag_100Hz; lsm_cfg.magScale = lsm_mag_4g; lsm_cfg.magHiRes = true; lsm_cfg.tempEnable = false; //Gyro l3gd20_settings l3g_cfg; l3g_cfg.enabled = true; l3g_cfg.bw = l3g_50Hz; l3g_cfg.odr = l3g_760Hz; l3g_cfg.scale = l3g_2000dps; sht21_settings sht_cfg; sht_cfg.rh_enabled = true; sht_cfg.temp_enabled = true; //XXX: do self-test? lsm303d.Init(&mems_i2c, lsm_cfg); lsm303d.Start(); l3gd20.Init(&mems_i2c, l3g_cfg); l3gd20.Start(); sht21.Init(&mems_i2c, sht_cfg); //Measurement timer FC_MEAS_TIMER_PWR_ON; fc_meas_timer.Init(FC_MEAS_TIMER, timer_div256); //125 == 1ms fc_meas_timer.SetInterruptPriority(MEDIUM); fc_meas_timer.EnableInterrupts(timer_overflow | timer_compareA | timer_compareB | timer_compareC); fc_meas_timer.SetTop(125 * 10); // == 10ms fc_meas_timer.SetCompare(timer_A, 100); // == 0.64ms fc_meas_timer.SetCompare(timer_B, 430); // == 2.7ms fc_meas_timer.SetCompare(timer_C, 555); // == 3.7ms fc_meas_timer.Start(); DEBUG(" *** FC init done ***\n"); }
int main(void) { bt_init(BAUD_RATE); Sonar_init(CONTINUOUS); Servo_init(MANUAL, SCAN_AND_LOCK); motorDriverInit(); while(1){ bt_getStr( tab ); // Get string from buffer if(strlen( tab )){ // If isn't empty... //bt_sendStr( tab ); // ...send it back. if ( strcmp(tab, "w") == 0 ) { driveForward(speed); } else if ( strcmp(tab, "s") == 0) { driveReverse(speed); } else if ( strcmp(tab, " ") == 0) { stop(); } else if ( strcmp(tab, "a") == 0) { driveReverseLeftTrack(40); driveForwardRightTrack(40); } else if ( strcmp(tab, "d") == 0) { driveForwardLeftTrack(40); driveReverseRightTrack(40); } else if ( strcmp(tab, "ServoScanAndLock") == 0) { ServoChangeMode(SWEEP); ServoChangeSweepMode(SCAN_AND_LOCK); } else if ( strcmp(tab, "ServoScanAndGo") == 0) { ServoChangeMode(SWEEP); ServoChangeSweepMode(SCAN_AND_GO); } else if ( strcmp(tab, "ServoCenter") == 0) { ServoChangeMode(MANUAL); ServoMoveByDegree(0); } else if ( strncmp(tab, "SonarStartMeas",14) == 0) { int new_deg = ParseIntNumber(tab,14,3); SonarStartMeas(new_deg); } else if ( strncmp(tab, "SonarGetDistance",16) == 0) { char buffor[12]; int new_deg = ParseIntNumber(tab,16,3); sprintf(buffor, "%04d,%04hu\n",new_deg,SonarGetDistance(new_deg)); bt_sendStr(buffor); } else if ( strcmp(tab, "e") == 0) { if (speed<=90){ speed+=10; } } else if ( strcmp(tab, "q") == 0) { if (speed>=10){ speed-=10; } } else if (strncmp(tab, "speed",5) == 0){ int new_speed = ParseIntNumber(tab,5,3); if (new_speed >= 0 && new_speed <= 100){ speed = new_speed; } } else if ( strncmp(tab, "SonarLockRange",14) == 0) { int new_range = ParseIntNumber(tab,14,3); ServoChangeLockRange(new_range); } } } };
void on_nble_up(void) { BT_DBG("%s", __FUNCTION__); if (bt_ready_cb) bt_ready_cb(bt_init()); }
int fb_init() { bt_error_t status; /* Bit 3 library error return type */ char devname[BT_MAX_DEV_NAME]; /* Device to open */ bt_devdata_t flag; /* Open the device in A24 space */ bt_gen_name(0, BT_DEV_A24, devname, BT_MAX_DEV_NAME); status = bt_open(&btd, devname, BT_RDWR); if (status != BT_SUCCESS) { cm_msg(MERROR, "fb_init", "Cannot open Bit3 device driver"); return FALSE; } bt_init(btd); bt_clrerr(btd); /* map SFI memory */ status = bt_mmap(btd, &_sfi, SFI_ADDRESS, SFI_SIZE, BT_RDWR, BT_SWAP_DEFAULT); if (status != BT_SUCCESS) { cm_msg(MERROR, "fb_init", "Cannot map VME memory"); bt_close(btd); return FALSE; } /* Open the device in local memory */ bt_gen_name(0, BT_DEV_LM, devname, BT_MAX_DEV_NAME); status = bt_open(&btd_lm, devname, BT_RDWR); if (status != BT_SUCCESS) { cm_msg(MERROR, "fb_init", "Cannot open Bit3 device for local memory"); return FALSE; } bt_clrerr(btd_lm); /* map local memory */ status = bt_mmap(btd_lm, &remote_ram_buffer, 0, REMOTE_RAM_SIZE, BT_RDWR, BT_SWAP_DEFAULT); if (status != BT_SUCCESS) { cm_msg(MERROR, "fb_init", "Cannot map local memory"); bt_close(btd); return FALSE; } /* clear local memory */ memset(remote_ram_buffer, 0, REMOTE_RAM_SIZE); /* force D32 mode */ bt_get_info(btd, BT_INFO_MMAP_AMOD, &flag); flag = BT_AMOD_A24_SD; bt_set_info(btd, BT_INFO_MMAP_AMOD, flag); /* sequencer reset */ SFI_OUT(SFI_SEQUENCER_RESET, 0); /* arbitration level */ // SFI_OUT(SFI_FASTBUS_ARBITRATION_LEVEL_REGISTER, 0x15); SFI_OUT(SFI_FASTBUS_ARBITRATION_LEVEL_REGISTER, 0xBF); /* timeout */ SFI_OUT(SFI_FASTBUS_TIMEOUT_REGISTER, 0x73); /* sequencer enable */ SFI_OUT(SFI_SEQUENCER_ENABLE, 0); /* switch off all output */ SFI_OUT(SFI_CLEAR_BOTH_LCA1_TEST_REGISTER, 0); /* clear registers */ SFI_OUT(SFI_RESET_REGISTER_GROUP_LCA2, 0); return SUCCESS; }
/** * <EN> * @brief Launch a recognition process instance. * * This function will create an recognition process instance * using the given SEARCH configuration, and launch recognizer for * the search. Then the created instance will be installed to the * engine instance. The sconf should be registered to the global * jconf before calling this function. * * </EN> * * <JA> * @brief 認識処理インスタンスを立ち上げる. * * この関数は,与えられた SEARCH 設定に従って 認識処理インスタンスを生成し, * 対応する音声認識器を構築します.その後,その生成された認識処理インスタンスは * 新たにエンジンインスタンスに登録されます.SEARCH設定はこの関数を * 呼ぶ前にあらかじめ全体設定jconfに登録されている必要があります. * * </JA> * * @param recog [i/o] engine instance * @param sconf [in] SEARCH configuration to launch * * @return TRUE on success, or FALSE on error. * * @callgraph * @callergraph * @ingroup instance * */ boolean j_launch_recognition_instance(Recog *recog, JCONF_SEARCH *sconf) { RecogProcess *p; PROCESS_AM *am; PROCESS_LM *lm; jlog("STAT: composing recognizer instance SR%02d %s (AM%02d %s, LM%02d %s)\n", sconf->id, sconf->name, sconf->amconf->id, sconf->amconf->name, sconf->lmconf->id, sconf->lmconf->name); /* allocate recognition instance */ p = j_recogprocess_new(recog, sconf); /* assign corresponding AM instance and LM instance to use */ for(lm=recog->lmlist;lm;lm=lm->next) { if (sconf->lmconf == lm->config) { for(am=recog->amlist;am;am=am->next) { if (sconf->amconf == am->config) { p->am = am; p->lm = lm; } } } } if (p->config->sw.triphone_check_flag && p->am->hmminfo->is_triphone) { /* go into interactive triphone HMM check mode */ hmm_check(p); } /******************************************/ /******** set work area and flags *********/ /******************************************/ /* copy values of sub instances for handly access during recognition */ /* set lm type */ p->lmtype = p->lm->lmtype; p->lmvar = p->lm->lmvar; p->graphout = p->config->graph.enabled; /* set flag for context dependent handling */ if (p->config->force_ccd_handling) { p->ccd_flag = p->config->ccd_handling; } else { if (p->am->hmminfo->is_triphone) { p->ccd_flag = TRUE; } else { p->ccd_flag = FALSE; } } /* iwsp prepare */ if (p->lm->config->enable_iwsp) { if (p->am->hmminfo->multipath) { /* find short-pause model */ if (p->am->hmminfo->sp == NULL) { jlog("ERROR: iwsp enabled but no short pause model \"%s\" in hmmdefs\n", p->am->config->spmodel_name); return FALSE; } p->am->hmminfo->iwsp_penalty = p->am->config->iwsp_penalty; } else { jlog("ERROR: \"-iwsp\" needs multi-path mode\n"); jlog("ERROR: you should use multi-path AM, or specify \"-multipath\" with \"-iwsp\"\n"); return FALSE; } } /* for short-pause segmentation */ if (p->config->successive.enabled) { if (p->config->successive.pausemodelname) { /* pause model name string specified, divide it and store to p */ char *s; int n; p->pass1.pausemodelnames = (char*)mymalloc(strlen(p->config->successive.pausemodelname)+1); strcpy(p->pass1.pausemodelnames, p->config->successive.pausemodelname); n = 0; for (s = strtok(p->pass1.pausemodelnames, " ,"); s; s = strtok(NULL, " ,")) { n++; } p->pass1.pausemodelnum = n; p->pass1.pausemodel = (char **)mymalloc(sizeof(char *) * n); strcpy(p->pass1.pausemodelnames, p->config->successive.pausemodelname); n = 0; for (s = strtok(p->pass1.pausemodelnames, " ,"); s; s = strtok(NULL, " ,")) { p->pass1.pausemodel[n++] = s; } } else { p->pass1.pausemodel = NULL; } /* check if pause word exists on dictionary */ { WORD_ID w; boolean ok_p; ok_p = FALSE; for(w=0;w<p->lm->winfo->num;w++) { if (is_sil(w, p)) { ok_p = TRUE; break; } } if (!ok_p) { #ifdef SPSEGMENT_NAIST jlog("Error: no pause word in dictionary needed for decoder-based VAD\n"); #else jlog("Error: no pause word in dictionary needed for short-pause segmentation\n"); #endif jlog("Error: you should have at least one pause word in dictionary\n"); jlog("Error: you can specify pause model names by \"-pausemodels\"\n"); return FALSE; } } } /**********************************************/ /******** set model-specific defaults *********/ /**********************************************/ if (p->lmtype == LM_PROB) { /* set default lm parameter if not specified */ if (!p->config->lmp.lmp_specified) { if (p->am->hmminfo->is_triphone) { p->config->lmp.lm_weight = DEFAULT_LM_WEIGHT_TRI_PASS1; p->config->lmp.lm_penalty = DEFAULT_LM_PENALTY_TRI_PASS1; } else { p->config->lmp.lm_weight = DEFAULT_LM_WEIGHT_MONO_PASS1; p->config->lmp.lm_penalty = DEFAULT_LM_PENALTY_MONO_PASS1; } } if (!p->config->lmp.lmp2_specified) { if (p->am->hmminfo->is_triphone) { p->config->lmp.lm_weight2 = DEFAULT_LM_WEIGHT_TRI_PASS2; p->config->lmp.lm_penalty2 = DEFAULT_LM_PENALTY_TRI_PASS2; } else { p->config->lmp.lm_weight2 = DEFAULT_LM_WEIGHT_MONO_PASS2; p->config->lmp.lm_penalty2 = DEFAULT_LM_PENALTY_MONO_PASS2; } } if (p->config->lmp.lmp_specified != p->config->lmp.lmp2_specified) { jlog("WARNING: m_fusion: only -lmp or -lmp2 specified, LM weights may be unbalanced\n"); } } /****************************/ /******* build wchmm ********/ /****************************/ if (p->lmtype == LM_DFA) { /* execute generation of global grammar and build of wchmm */ multigram_build(p); /* some modification occured if return TRUE */ } if (p->lmtype == LM_PROB) { /* build wchmm with N-gram */ p->wchmm = wchmm_new(); p->wchmm->lmtype = p->lmtype; p->wchmm->lmvar = p->lmvar; p->wchmm->ccd_flag = p->ccd_flag; p->wchmm->category_tree = FALSE; p->wchmm->hmmwrk = &(p->am->hmmwrk); /* assign models */ p->wchmm->ngram = p->lm->ngram; if (p->lmvar == LM_NGRAM_USER) { /* register LM functions for 1st pass here */ p->wchmm->uni_prob_user = p->lm->lmfunc.uniprob; p->wchmm->bi_prob_user = p->lm->lmfunc.biprob; } p->wchmm->winfo = p->lm->winfo; p->wchmm->hmminfo = p->am->hmminfo; if (p->wchmm->category_tree) { if (p->config->pass1.old_tree_function_flag) { if (build_wchmm(p->wchmm, p->lm->config) == FALSE) { jlog("ERROR: m_fusion: error in bulding wchmm\n"); return FALSE; } } else { if (build_wchmm2(p->wchmm, p->lm->config) == FALSE) { jlog("ERROR: m_fusion: error in bulding wchmm\n"); return FALSE; } } } else { if (build_wchmm2(p->wchmm, p->lm->config) == FALSE) { jlog("ERROR: m_fusion: error in bulding wchmm\n"); return FALSE; } } /* 起動時 -check でチェックモードへ */ if (p->config->sw.wchmm_check_flag) { wchmm_check_interactive(p->wchmm); } /* set beam width */ /* guess beam width from models, when not specified */ p->trellis_beam_width = set_beam_width(p->wchmm, p->config->pass1.specified_trellis_beam_width); /* initialize cache for factoring */ max_successor_cache_init(p->wchmm); } /* backtrellis initialization */ p->backtrellis = (BACKTRELLIS *)mymalloc(sizeof(BACKTRELLIS)); bt_init(p->backtrellis); /* prepare work area for 2nd pass */ wchmm_fbs_prepare(p); jlog("STAT: SR%02d %s composed\n", sconf->id, sconf->name); if (sconf->sw.start_inactive) { /* start inactive */ p->active = -1; } else { /* book activation for the recognition */ p->active = 1; } if (p->lmtype == LM_DFA) { if (p->lm->winfo == NULL || (p->lmvar == LM_DFA_GRAMMAR && p->lm->dfa == NULL)) { /* make this instance inactive */ p->active = -1; } } return TRUE; }
int main (void) { /* accelerometer readings fifo */ TFifoEntry acc_lowpass; TFifoEntry fifo_buf[FIFO_DEPTH]; int fifo_pos; TFifoEntry *fifo; uint32_t SSPdiv; uint16_t oid_last_seen; uint8_t cmd_buffer[64], cmd_pos, c; uint8_t volatile *uart; int x, y, z, moving; volatile int t; int i; /* wait on boot - debounce */ for (t = 0; t < 2000000; t++); /* Initialize GPIO (sets up clock) */ GPIOInit (); /* initialize pins */ pin_init (); /* fire up LED 1 */ GPIOSetValue (1, 1, 1); /* initialize SPI */ spi_init (); /* read device UUID */ bzero (&device_uuid, sizeof (device_uuid)); iap_read_uid (&device_uuid); tag_id = crc16 ((uint8_t *) & device_uuid, sizeof (device_uuid)); random_seed = device_uuid[0] ^ device_uuid[1] ^ device_uuid[2] ^ device_uuid[3]; /************ IF Plugged to computer upon reset ? ******************/ if (GPIOGetValue (0, 3)) { /* wait some time till Bluetooth is off */ for (t = 0; t < 2000000; t++); /* Init 3D acceleration sensor */ acc_init (1); /* Init Flash Storage with USB */ storage_init (TRUE, tag_id); g_storage_items = storage_items (); /* Init Bluetooth */ bt_init (TRUE, tag_id); /* switch to LED 2 */ GPIOSetValue (1, 1, 0); GPIOSetValue (1, 2, 1); /* set command buffer to empty */ cmd_pos = 0; /* spin in loop */ while (1) { /* reset after USB unplug */ if (!GPIOGetValue (0, 3)) NVIC_SystemReset (); /* if UART rx send to menue */ if (UARTCount) { /* blink LED1 upon Bluetooth command */ GPIOSetValue (1, 1, 1); /* execute menue command with last character received */ /* scan through whole UART buffer */ uart = UARTBuffer; for (i = UARTCount; i > 0; i--) { UARTCount--; c = *uart++; if ((c < ' ') && cmd_pos) { /* if one-character command - execute */ if (cmd_pos == 1) main_menue (cmd_buffer[0]); else { cmd_buffer[cmd_pos] = 0; debug_printf ("Unknown command '%s' - please press H+[Enter] for help\n# ", cmd_buffer); } /* set command buffer to empty */ cmd_pos = 0; } else if (cmd_pos < (sizeof (cmd_buffer) - 2)) cmd_buffer[cmd_pos++] = c; } /* reset UART buffer */ UARTCount = 0; /* un-blink LED1 */ GPIOSetValue (1, 1, 0); } } } /* End of if plugged to computer*/ /***************** IF UNPLUGGED TO PC ........********/ /* Init Bluetooth */ bt_init (FALSE, tag_id); /* shut down up LED 1 */ GPIOSetValue (1, 1, 0); /* Init Flash Storage without USB */ storage_init (FALSE, tag_id); /* get current FLASH storage write postition */ g_storage_items = storage_items (); /* initialize power management */ pmu_init (); /* blink once to show initialized flash */ blink (1); /* Init 3D acceleration sensor */ acc_init (0); blink (2); /* Initialize OpenBeacon nRF24L01 interface */ if (!nRFAPI_Init(CONFIG_TRACKER_CHANNEL, broadcast_mac, sizeof (broadcast_mac), 0)) for (;;) { GPIOSetValue (1, 2, 1); pmu_sleep_ms (500); GPIOSetValue (1, 2, 0); pmu_sleep_ms (500); } /* set tx power power to high */ nRFCMD_Power (1); /* blink three times to show flash initialized RF interface */ blink (3); /* blink LED for 1s to show readyness */ GPIOSetValue (1, 1, 0); GPIOSetValue (1, 2, 1); pmu_sleep_ms (1000); GPIOSetValue (1, 2, 0); /* disable unused jobs */ SSPdiv = LPC_SYSCON->SSPCLKDIV; i = 0; oid_last_seen = 0; /* reset proximity buffer */ prox_head = prox_tail = 0; bzero (&prox, sizeof (prox)); /*initialize FIFO */ fifo_pos = 0; bzero (&acc_lowpass, sizeof (acc_lowpass)); bzero (&fifo_buf, sizeof (fifo_buf)); moving = 0; g_sequence = 0; while (1) { pmu_sleep_ms (500); LPC_SYSCON->SSPCLKDIV = SSPdiv; acc_power (1); pmu_sleep_ms (20); acc_xyz_read (&x, &y, &z); acc_power (0); fifo = &fifo_buf[fifo_pos]; if (fifo_pos >= (FIFO_DEPTH - 1)) fifo_pos = 0; else fifo_pos++; acc_lowpass.x += x - fifo->x; fifo->x = x; acc_lowpass.y += y - fifo->y; fifo->y = y; acc_lowpass.z += z - fifo->z; fifo->z = z; nRFAPI_SetRxMode (0); bzero (&g_Beacon, sizeof (g_Beacon)); g_Beacon.pkt.proto = RFBPROTO_BEACONTRACKER_EXT; g_Beacon.pkt.flags = moving ? RFBFLAGS_MOVING : 0; g_Beacon.pkt.oid = htons (tag_id); g_Beacon.pkt.p.tracker.strength = (i & 1) + TX_STRENGTH_OFFSET; g_Beacon.pkt.p.tracker.seq = htonl (LPC_TMR32B0->TC); g_Beacon.pkt.p.tracker.oid_last_seen = oid_last_seen; g_Beacon.pkt.p.tracker.time = htons ((uint16_t)g_sequence++); g_Beacon.pkt.p.tracker.battery = 0; g_Beacon.pkt.crc = htons ( crc16(g_Beacon.byte, sizeof (g_Beacon) - sizeof (g_Beacon.pkt.crc)) ); nRFCMD_Power (0); nRF_tx (g_Beacon.pkt.p.tracker.strength); nRFCMD_Power (1); nRFAPI_PowerDown (); LPC_SYSCON->SSPCLKDIV = 0x00; blink (10); } return 0; }
int bt617_set_am(MVME_INTERFACE *vme, int am) { int i; BT617_TABLE *ptab; bt_error_t status; bt_devdata_t flag; for (i=0 ; i<MAX_BT617_TABLES ; i++) if (((BT617_TABLE *)vme->table)[i].am == am) break; if (((BT617_TABLE *)vme->table)[i].am == am) { vme->handle = i; ptab = ((BT617_TABLE *)vme->table)+i; bt_set_info(ptab->btd, BT_INFO_DMA_AMOD, am); bt_set_info(ptab->btd, BT_INFO_PIO_AMOD, am); bt_set_info(ptab->btd, BT_INFO_MMAP_AMOD, am); return MVME_SUCCESS; } /* search free slot */ for (i=0 ; i<MAX_BT617_TABLES ; i++) if (((BT617_TABLE *)vme->table)[i].am == 0) break; if (i==MAX_BT617_TABLES) return MVME_NO_MEM; /* mode not yet open, open it */ vme->handle = i; ptab = ((BT617_TABLE *)vme->table)+i; ptab->am = am; if (am == MVME_AM_A16_SD || am == MVME_AM_A16_ND) bt_gen_name(vme->index, BT_DEV_A16, ptab->devname, BT_MAX_DEV_NAME); else if (am == MVME_AM_A24_SB || am == MVME_AM_A24_SP || am == MVME_AM_A24_SD || am == MVME_AM_A24_NB || am == MVME_AM_A24_NP || am == MVME_AM_A24_ND || am == MVME_AM_A24_SMBLT || am == MVME_AM_A24_NMBLT || am == MVME_AM_A24 || am == MVME_AM_A24_D64) bt_gen_name(vme->index, BT_DEV_A24, ptab->devname, BT_MAX_DEV_NAME); else bt_gen_name(vme->index, BT_DEV_A32, ptab->devname, BT_MAX_DEV_NAME); status = bt_open(&ptab->btd, ptab->devname, BT_RDWR); if (status != BT_SUCCESS) { bt_perror(ptab->btd, status, "bt_open error"); return MVME_NO_INTERFACE; } bt_init(ptab->btd); bt_clrerr(ptab->btd); /* select swapping mode */ flag = BT_SWAP_NONE; bt_set_info(ptab->btd, BT_INFO_SWAP, flag); /* set data mode */ flag = BT_WIDTH_D16; bt_set_info(ptab->btd, BT_INFO_DATAWIDTH, flag); /* switch off block transfer */ flag = FALSE; bt_set_info(ptab->btd, BT_INFO_BLOCK, flag); /* set amod */ bt_set_info(ptab->btd, BT_INFO_DMA_AMOD, am); bt_set_info(ptab->btd, BT_INFO_PIO_AMOD, am); bt_set_info(ptab->btd, BT_INFO_MMAP_AMOD, am); return MVME_SUCCESS; }
/* * Attach all the sub-devices we can find */ static int bt_isa_attach(device_t dev) { struct bt_softc *bt = device_get_softc(dev); bus_dma_filter_t *filter; void *filter_arg; bus_addr_t lowaddr; int error, drq; /* Initialise softc */ error = bt_isa_alloc_resources(dev, 0, ~0); if (error) { device_printf(dev, "can't allocate resources in bt_isa_attach\n"); return error; } /* Program the DMA channel for external control */ if ((drq = isa_get_drq(dev)) != -1) isa_dmacascade(drq); /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; lowaddr = BUS_SPACE_MAXADDR_24BIT; /* XXX Should be a child of the ISA bus dma tag */ if (bus_dma_tag_create(/*parent*/NULL, /*alignemnt*/1, /*boundary*/0, lowaddr, /*highaddr*/BUS_SPACE_MAXADDR, filter, filter_arg, /*maxsize*/BUS_SPACE_MAXSIZE_32BIT, /*nsegments*/BUS_SPACE_UNRESTRICTED, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0, &bt->parent_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } error = bt_init(dev); if (error) { bt_isa_release_resources(dev); return (ENOMEM); } if (lowaddr != BUS_SPACE_MAXADDR_32BIT) { /* DMA tag for our sense buffers */ if (bus_dma_tag_create(bt->parent_dmat, /*alignment*/1, /*boundary*/0, /*lowaddr*/BUS_SPACE_MAXADDR, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, bt->max_ccbs * sizeof(struct scsi_sense_data), /*nsegments*/1, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0, &bt->sense_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } bt->init_level++; /* Allocation of sense buffers */ if (bus_dmamem_alloc(bt->sense_dmat, (void *)&bt->sense_buffers, BUS_DMA_NOWAIT, &bt->sense_dmamap) != 0) { bt_isa_release_resources(dev); return (ENOMEM); } bt->init_level++; /* And permanently map them */ bus_dmamap_load(bt->sense_dmat, bt->sense_dmamap, bt->sense_buffers, bt->max_ccbs * sizeof(*bt->sense_buffers), btmapsensebuffers, bt, /*flags*/0); bt->init_level++; } error = bt_attach(dev); if (error) { bt_isa_release_resources(dev); return (error); } return (0); }
int main (void) { int t, firstrun; volatile int i; /* Initialize GPIO (sets up clock) */ GPIOInit (); /* initialize pins */ pin_init (); /* setup SPI chipselect pins */ spi_init_pin (SPI_CS_NRF); /* blink as a sign of boot to detect crashes */ for (t = 0; t < 10; t++) { pin_led (GPIO_LED0); for (i = 0; i < 100000; i++); pin_led (GPIO_LEDS_OFF); for (i = 0; i < 100000; i++); } /* Init USB HID interface */ hid_init (); /* Init SPI */ spi_init (); /* Init OpenBeacon nRF24L01 interface */ nRFAPI_Init (81, broadcast_mac, sizeof (broadcast_mac), 0); /* Init 3D acceleration sensor */ acc_init (); /* Init Storage */ storage_init (); /* Init Bluetooth */ bt_init (); /* main loop */ t = 0; firstrun = 1; while (1) { /* blink LED0 on every 32th run - FIXME later with sleep */ if ((t++ & 0x1F) == 0) { pin_led (GPIO_LED0); for (i = 0; i < 100000; i++); pin_led (GPIO_LEDS_OFF); } for (i = 0; i < 200000; i++); if (UARTCount) { /* blink LED1 upon Bluetooth command */ pin_led (GPIO_LED1); /* show help screen upon Bluetooth connect */ if (firstrun) { debug_printf ("press 'H' for help...\n# "); firstrun = 0; } else /* execute menue command with last character received */ main_menue (UARTBuffer[UARTCount - 1]); /* LED1 off again */ pin_led (GPIO_LEDS_OFF); /* clear UART buffer */ UARTCount = 0; } } }