int bmp_open(struct sampler **sampler, const char *filename) { struct sampler *s; int ret; s = malloc(sizeof(*s)); if (!s) return -ENOMEM; ret = sampler_init(s, filename); if (ret < 0) { free(s); return ret; } s->bits = 8; s->close = bmp_close; ret = parse_bmp_header(s); if (ret < 0) { free(s); return ret; } *sampler = s; return 0; }
void reset_all_systems (void) { init_eventtab (); #ifdef WITH_PPC uae_ppc_reset(is_hardreset()); #endif #ifdef PICASSO96 picasso_reset (); #endif #ifdef SCSIEMU scsi_reset (); scsidev_reset (); scsidev_start_threads (); #endif #ifdef A2065 a2065_reset (); #endif #ifdef SANA2 netdev_reset (); netdev_start_threads (); #endif #ifdef WITH_PCI pci_reset(); #endif #ifdef FILESYS filesys_prepare_reset (); filesys_reset (); #endif init_shm (); memory_reset (); #if defined (BSDSOCKET) bsdlib_reset (); #endif #ifdef FILESYS filesys_start_threads (); hardfile_reset (); #endif #ifdef UAESERIAL uaeserialdev_reset (); uaeserialdev_start_threads (); #endif #ifdef PARALLEL_PORT initparallel (); #endif native2amiga_reset (); dongle_reset (); sampler_init (); uae_int_requested = 0; }
void reset_all_systems (void) { init_eventtab (); #ifdef PICASSO96 picasso_reset (); #endif #ifdef SCSIEMU scsi_reset (); scsidev_reset (); scsidev_start_threads (); #endif #ifdef A2065 a2065_reset (); #endif #ifdef SANA2 netdev_reset (); netdev_start_threads (); #endif #ifdef FILESYS filesys_prepare_reset (); filesys_reset (); #endif #ifdef NATMEM_OFFSET init_shm (); #endif memory_reset (); #if defined (BSDSOCKET) bsdlib_reset (); #endif #ifdef FILESYS filesys_start_threads (); hardfile_reset (); #endif #ifdef UAESERIAL uaeserialdev_reset (); uaeserialdev_start_threads (); #endif #if defined (PARALLEL_PORT) initparallel (); #endif native2amiga_reset (); dongle_reset (); #ifdef SAMPLER sampler_init (); #endif }
void init() { #if 0 tft::init(); tftout = tft::devout(); #endif #if 1 uart0_init(); stdout = uart0_fd(); stdin = uart0_fd(); #endif _delay_ms(1000); rfm12_init(); _delay_ms(1000); sei(); sampler_init(); pwm2_init(); sampler_enable(1); pwm2_enable(1); }
static void finalize_instance(conf_object_t *self) { int err; uart_sampler_t *s = (uart_sampler_t *)self; uart_sampler_conf_t *c = (uart_sampler_conf_t *)s->conf; err = sampler_init(&s->sampler); E_IF(err, "sampler_init", E_VOID); s->sampler.usf_base_path = c->file_base_name; s->sampler.sample_period = c->sample_period; s->sampler.burst_period = c->burst_period; s->sampler.burst_size = c->burst_size; s->sampler.line_size_lg2 = c->line_size_lg2; s->sampler.seed = 0; if (!strncmp(c->burst_rnd_type, "const", 5)) { s->sampler.burst_rnd = sampler_rnd_const; } else { s->sampler.burst_rnd = sampler_rnd_exp; } if (!strncmp(c->sample_rnd_type, "const", 5)) { s->sampler.sample_rnd = sampler_rnd_const; } else { s->sampler.sample_rnd = sampler_rnd_exp; } if (!s->sampler.burst_size) { err = sampler_burst_begin(&s->sampler, 0); E_IF(err, "sampler_burst_begin", E_VOID); } if (!c->master) { SIM_hap_add_callback("Uart_Sampler_Burst_Begin", hap_cb_begin, s); SIM_hap_add_callback("Uart_Sampler_Burst_End", hap_cb_end, s); } }
static int my_sampler_init(sampler_t *sampler, args_t *args) { int err; err = sampler_init(sampler); if (err) return err; sampler->usf_base_path = args->o_file_name; sampler->sample_period = args->sample_period; sampler->burst_period = args->burst_period; sampler->burst_size = args->burst_size; sampler->line_size_lg2 = args->line_size_lg2; sampler->seed = args->random_seed; sampler->log_level = args->log_level; srand((unsigned int)sampler->seed); if (!strncmp(args->burst_rnd, "const", 5)) { sampler->burst_rnd = sampler_rnd_const; } else { sampler->burst_rnd = sampler_rnd_exp; } if (!strncmp(args->sample_rnd, "const", 5)) { sampler->sample_rnd = sampler_rnd_const; } else { sampler->sample_rnd = sampler_rnd_exp; } if (!sampler->burst_size) { err = sampler_burst_begin(sampler, 0); if (err) return err; } return 0; }
int main(int argc, char *argv[]){ WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer P1DIR |= 0x01;// Set P1.0 to output direction P1OUT = 0x01;// Toggle P1.0 using exclusive-OR if( *whichTrainingExample < 0 || *whichTrainingExample > NUM_SAMPLES * NUM_FEATURES ){ *whichTrainingExample = 0; } ACCEL_setup(); ACCEL_SetReg(0x2D,0x02); P4DIR |= BIT5;// Set P4.5 to output direction unsigned tmpx = ACCEL_getX(); unsigned tmpy = ACCEL_getY(); unsigned tmpz = ACCEL_getZ(); /*newFeaturizableData allocates memory -- assume this is in NV*/ featurizableData *X = (featurizableData*)newFeaturizableData();//Defined in Accelerometer featureVector *features = newFeatureVector(NUM_FEATURES);//Defined in FeatureVector createModel(NUM_CLASSES, NUM_FEATURES);//in NormalDistributionModel unsigned sampleTimer = SAMPLE_INTERVAL; while(1){ if( P4IN & BIT6 ){ /*pushbutton on 4.6 is pressed. This should be interrupt driven, but it's like this for now*/ P4OUT |= BIT5; sampler_init(); P4OUT &= ~BIT5; } getNextSample(X);//in Accelerometer if(samplesReady(X)){ featurize(X,features); //in CUEAR -- Accelerometer and CUEAR agree on this if( --sampleTimer == 0 ){ sampleTimer = SAMPLE_INTERVAL; /*Do this for the first 1000 samples*/ if( *whichTrainingExample < NUM_SAMPLES * features->numFeatures ){ int i; for(i = 0; i < features->numFeatures; i++){ trainingExamples[ (*whichTrainingExample) + i ] = features->features[i]; } *whichTrainingExample = *whichTrainingExample + features->numFeatures; }else{ P1OUT &= ~(0x01);//LED off means sampling is done } } } } }