Example #1
0
File: ui.c Project: JustgeekDE/fact
uint32_t ui_getDelay(void){
	uint8_t factor = 0;

	uint16_t delay = (1023 - sensor_read(UI_POT_DELAY_CHANNEL));
	uint8_t jumperA = (sensor_read(UI_JUMPER_A_CHANNEL) != 0) ? 0x01 : 0x00;
	uint8_t jumperB = (sensor_read(UI_JUMPER_B_CHANNEL) != 0) ? 0x02 : 0x00;

	factor = (jumperA | jumperB);

	switch (factor) {
		case 0:
			delay = delay >> 3;
			break;

		case 1:
			delay = delay >> 1;
			break;

		case 2:
			delay = delay << 1;
			break;

		case 3:
			delay = delay << 3;
			break;

		default:
			break;
	}
	return delay;
}
Example #2
0
static int sensor_identify(struct cmos_subdev *sd)
{
	uint32_t data = 0;

	data |= (sensor_read(sd, 0xfc) & 0xff) << 8;
	data |= (sensor_read(sd, 0xfd) & 0xff);

	return (data == sd->id) ? 0 : -EINVAL;
}
static int sensor_ae_transfer(struct i2c_client *client)
{
	//unsigned int prev_line_len,cap_line_len,shutter;
	struct generic_sensor *sensor = to_generic_sensor(client);
	struct specific_sensor *spsensor = to_specific_sensor(sensor);
	int preview_ae_integration, capture_ae_integration;
	int capture_pixel;
	u8 ret_h,ret_l;
	int val_h, val_l;
	
	mdelay(100);
	
	sensor_read(client, 0x3200, &ret_h);
	val_h=ret_h;
    sensor_write(client, 0x3200, ret_h&0xfd); 
	sensor_read(client, 0x3201, &ret_l);
	val_l=ret_l;
    sensor_write(client, 0x3201, ret_l&0xdf);  //stop ae awb
	
	sensor_read(client,0x300a, &ret_h);
	sensor_read(client,0x300b, &ret_l);
	capture_pixel = (ret_l&0x0F) | ((ret_h<<8)&0xF0);
	preview_ae_integration = spsensor->parameter.preview_exposure*spsensor->parameter.PreviewDummyPixels;
	capture_ae_integration = preview_ae_integration/capture_pixel;
	
	//write back ae
	sensor_write(client,0x3012,(capture_ae_integration>>8)&0x0F);
	sensor_write(client,0x3013,capture_ae_integration&0x0F);
		
	//write back AGC Gain for preview
	sensor_write(client,0x3014, spsensor->parameter.preview_gain_dr);
	sensor_write(client,0x3015, spsensor->parameter.preview_gain_ar);
	sensor_write(client,0x3016, spsensor->parameter.preview_gain_dgr);
	sensor_write(client,0x3017, spsensor->parameter.preview_gain_agr);
	sensor_write(client,0x3018, spsensor->parameter.preview_gain_dgb);
	sensor_write(client,0x3019, spsensor->parameter.preview_gain_agb);
	sensor_write(client,0x301a, spsensor->parameter.preview_gain_db);
	sensor_write(client,0x301b, spsensor->parameter.preview_gain_ab);
	sensor_write(client,0x301c, spsensor->parameter.preview_gain_dglobal);
	sensor_write(client,0x301d, spsensor->parameter.preview_gain_aglobal);

	#if 0
	sensor_write(client,0x3290, (spsensor->parameter.preview_awb_r>>8)&0x01);
	sensor_write(client,0x3291, spsensor->parameter.preview_awb_r&0x0F);
	sensor_write(client,0x3296, (spsensor->parameter.preview_awb_b>>8)&0x01 );
	sensor_write(client,0x3297, spsensor->parameter.preview_awb_b&0x0F );
	#endif

    //sensor_write(client, 0x3200, val_h); 
    //sensor_write(client, 0x3201, val_l);  //enable ae awb
	return 0;
}
Example #4
0
static void measures_printMeasures(char *buf, size_t len)
{
	float humidity = sensor_read(ADC_HUMIDITY);
	float ext_t = sensor_read(ADC_T1);

	/*
	 * Honeywell HIH-5030/5031 humidity sensor temperature compensation.
	 * See page 2, http://http://sensing.honeywell.com/index.php?ci_id=49692
	 */
	humidity /= (1.0546 - 0.00216 * ext_t);

	snprintf(buf, len, "%ld;%.1f;%.1f;%.0f;%.0f;%.1f;%.2f;%.2f;%.2f;%.0f;%.2f;%.2f;%.2f;%d",
		gps_info()->altitude,
		ext_t,
		sensor_read(ADC_T2),
		sensor_read(ADC_PRESS),
		humidity,
		measures_intTemp(),
		sensor_read(ADC_VIN),
		sensor_read(ADC_5V),
		sensor_read(ADC_3V3),
		sensor_read(ADC_CURR),
		measures_acceleration(MMA_X),
		measures_acceleration(MMA_Y),
		measures_acceleration(MMA_Z),
		hadarp_read()
	);

	buf[len - 1] = '\0';
}
PROCESS_THREAD(node_timeout_process, ev, data)
{
	PROCESS_BEGIN();
	
	while (1)
	{
		static struct etimer timeout;
		int16_t sensor_value = 0;
		static char message[3];

		etimer_set(&timeout, CLOCK_SECOND * SLEEP_TIMEOUT);
		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timeout));

		etimer_set(&timeout, CLOCK_SECOND/16);
		leds_on(LEDS_ALL);
		sensor_init();
		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timeout));
		sensor_value = sensor_read() - my_noise;
		sensor_uinit();
		itoa(sensor_value, message, 10);
		strcat(message, "!\0");
	
		transmit_runicast(message, SINK_NODE);
		leds_off(LEDS_ALL);
	}
	
	PROCESS_END();
}	
PROCESS_THREAD(node_read_process, ev, data)
{
	PROCESS_BEGIN();
	
	static struct etimer etimer;
	static int16_t sensor_value = 0;
	static char message[3];
	
	etimer_set(&etimer, CLOCK_SECOND * sleep_time);
	PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etimer));

	etimer_set(&etimer, CLOCK_SECOND/16);
	leds_on(LEDS_ALL);
	sensor_init();
	PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etimer));
	sensor_value = sensor_read() - my_noise;
	sensor_uinit();
	itoa(sensor_value, message, 10);
	strcat(message, "!\0");

	transmit_runicast(message, SINK_NODE);
	leds_off(LEDS_ALL);
	
//	process_start(&node_timeout_process, NULL);
	
	PROCESS_END();
}
Example #7
0
/* Timer driven function to sample ADC and emit signal if bounds call for it */
void gpio_sensor::adc_read(void) {
    int adc_reading = sensor_read();
//    qDebug() << time_since_start.elapsed() << adc_reading;

    /* in_bounds means emit a signal if value is inside bounds */
    if (in_bounds) {
//        qDebug() << "signaling if in_bounds";
        if ((adc_reading > low_bound) && (adc_reading < high_bound)) {
            if (was_out_last_time) {
                emit (adc_signal(adc_reading));
            } /* endif */
            was_out_last_time = false;
        } else {
            was_out_last_time = true;
        } /* endif */
    } else { /* Otherwise, emit a signal if value is outside bounds */
//        qDebug() << "out_bounds";
        if ((adc_reading < low_bound) || (adc_reading > high_bound)) {
            if (!was_out_last_time) {
                emit (adc_signal(adc_reading));
            } /* endif */
            was_out_last_time = true;
        } else {
            was_out_last_time = false;
        } /* endif */
    } /* endif */
} /* adc_read */
Example #8
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_change_detect_process, ev, data)
{
	static struct etimer etimer;

	PROCESS_BEGIN();
	
	leds_init();
	while(1) {
		sensor_init();
		etimer_set(&etimer, CLOCK_SECOND / 4);
		PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
		sample = sensor_read();
		sensor_uinit();
		printf("sample = %d\n",sample);
		
		if(abs_sub(sample, sample_mean) > (sample_std_dev * NUM_DEVS)) {
			// Change detected, turn on LED(s)?
			leds_on(LEDS_RED);
		} else {
			// Turn off LED(s).
			leds_off(LEDS_RED);
		}
	}

	PROCESS_END();
}
Example #9
0
static int sensor_flip_cb(struct i2c_client *client, int flip)
{
	char val;
	int err = 0;	

	SENSOR_DG("flip: %d",flip);
	if (flip) {
		
		sensor_write(client, 0xfe, 0);
		err = sensor_read(client, 0x17, &val);
		val-=4;
		if (err == 0) {
			if((val & 0x2) == 0){
				err = sensor_write(client, 0x17, ((val |0x2)+4));
				}
			else {
				err = sensor_write(client, 0x17, ((val & 0xfc)+4));
				}
		}
	} else {
		//do nothing
	}

	return err;    
}
static void sensor_poll_work(struct work_struct *work)
{
	int ret;
	int delay;
	u8 val;
	struct sensor_data *data = container_of(to_delayed_work(work),
					struct sensor_data, work_ps);

	SENSOR_DBG(DBG_LEVEL1, "%s", data->client->name);

	mutex_lock(&data->lock);

	if ((data->state & PS_STATE_FLAG) != PS_ENABLE)
		goto out;

	/*exit when get far event*/
	ret = sensor_read(data, REG_PROX_DATA, 1, &val);
	if (ret < 0)
		goto out;
	if (val <= data->ps_threshold) {
		SENSOR_DBG(DBG_LEVEL2, "PS far %02x", val);

		input_report_abs(data->input_ps, ABS_X, 1);
		input_sync(data->input_ps);

		sensor_write(data, REG_PROX_HT, data->ps_threshold);
		goto out;
	}

	delay = msecs_to_jiffies(data->interval);
	schedule_delayed_work(&data->work_ps, delay);
out:
	mutex_unlock(&data->lock);
}
Example #11
0
void vTestKernel(void *pvAddress)
{
    char line[BUF_SIZE];
    long type, id;
    while (1) {
        inet_printf("Input type and id for sensor reading.\r\n");
        inet_gets(line, BUF_SIZE);
        sscanf(line, "%d %d", &type, &id);
        term_printf("sensor reading is: %d\r\n", sensor_read(type, id));
    }
}
Example #12
0
void AR0330_Debug(void)
{
#if DEBUG_ENABLE
	uint16_t tempaddr = 0x3000;
	int i;
	for (i = 0; i < 256; i += 4) {
		CyU3PDebugPrint(4, "DEBUG: 0x%x:  ", tempaddr);
		int j;
		for (j = 0; j < 4; ++j, tempaddr += 2) {
			uint16_t d;
			sensor_read(tempaddr, &d);
			CyU3PDebugPrint(4, "0x%x%x%x%x ",
					 (d >> 12) & 0x0f,
					 (d >>  8) & 0x0f,
					 (d >>  4) & 0x0f,
					 (d >>  0) & 0x0f);
		}
		CyU3PDebugPrint(4, "\r\n");
	}

	static const uint16_t addresses[] = {
		0x3780,
		0x301A  // reset status
//		0x3ED0,  0x3ED2,  0x3ED4,  0x3ED6,
//		0x3ED8,  0x3EDA,  0x3EDC,  0x3EDE,
//		0x3EE0,                    0x3EE6,
//		0x3EE8,  0x3EEA,
//		0x3F06,
	};

	for (i = 0; i < SIZE_OF_ARRAY(addresses); ++i) {
		tempaddr = addresses[i];
		uint16_t tempdata;
		sensor_read(tempaddr, &tempdata);
		CyU3PDebugPrint(4, "DEBUG: read address = 0x%x data = 0x%x\r\n", tempaddr, tempdata);
	}

	// report if MIPI is active
	CyU3PDebugPrint(4, "DEBUG: MIPI active = %d\r\n", CyU3PMipicsiCheckBlockActive());
#endif
}
Example #13
0
/**************************************************
* Function name	:
* Created by	:
* Date created	:
* Description	:
* Notes		:
***************************************************/
void main (void)
{
    SS_DDR_1 = HIGH;
    SS_DDR_2 = HIGH;
    SS_DDR_3 = HIGH;
    SS_DDR_4 = HIGH;
    SPI_init (SPI_MASTER + SPI_IDLE_SCK_LOW + SPI_SAMPLE_SETUP + SPI_MSB, 128);
    TIMER0_HW_API_init (timer_cb);

    sensor_read (CONFIGURATION);
    __enable_interrupt();

    while(1)
    {
        if(flag == 1)
        {
            flag = 0;
            sensor_read (DATA);
        }
    };
}
Example #14
0
/**************************************************
* Function name	:
* Created by	:
* Date created	:
* Description	:
* Notes		:
***************************************************/
void check_number(void)
{
    if(DIS_number < 3)
    {
        DIS_number++;
        sensor_read(DIS_command);
    }
    else
    {
        DIS_number = 0x00;
        configuration_flag = 0x01;
    }
}
static int sensor_mirror_cb (struct i2c_client *client, int mirror)
{
	char val;
	int err = 0;
    
    SENSOR_DG("mirror: %d",mirror);
	if (mirror) {
		err = sensor_read(client, 0x3022, &val);
		if (err == 0) {
			val |= 0x02;
			err = sensor_write(client, 0x3022, val);
		}
	} else {
		err = sensor_read(client, 0x3022, &val);
		if (err == 0) {
			val &= 0xfd;
			err = sensor_write(client, 0x3022, val);
		}
	}

	return err;    
}
Example #16
0
static int sensor_flip_cb(struct i2c_client *client, int flip)
{
	char val1,val2,val3;
	int err = 0;	

	SENSOR_DG("flip: %d",flip);
	if (flip) {
			sensor_write(client, 0xf0, 0);
			err = sensor_read(client,0x0f,&val1);
			err = sensor_read(client,0x45,&val2);
			err = sensor_read(client,0x47,&val3);
			if(err ==0){
				if((val1 == 0xb2) && (val2 == 0x27) && (val3 == 0x2c)){//normal
					err = sensor_write(client, 0x0f, 0x92);
					err = sensor_write(client, 0x45, 0x25);
					err = sensor_write(client, 0x47, 0x24);
				}else if((val1 == 0xa2) && (val2 == 0x26) && (val3 == 0x28)){//h_mir
					err = sensor_write(client, 0x0f, 0x82);
					err = sensor_write(client, 0x45, 0x24);
					err = sensor_write(client, 0x47, 0x20);
				}else if((val1 == 0x92) && (val2 == 0x25) && (val3 == 0x24)){//v_flip
					err = sensor_write(client, 0x0f, 0xb2);
					err = sensor_write(client, 0x45, 0x27);
					err = sensor_write(client, 0x47, 0x2c);
				}else if((val1 == 0x82) && (val2 == 0x24) && (val3 == 0x20)){//h_v_mir
					err = sensor_write(client, 0x0f, 0xa2);
					err = sensor_write(client, 0x45, 0x26);
					err = sensor_write(client, 0x47, 0x28);
				}
	
			}
			
		} else {
			//do nothing
		}

	return err;    
}
Example #17
0
int nuvoton_vin_probe(struct nuvoton_vin_device* cam)
{
	int i,ret = 0;
	__u8 SensorID[4];
	struct OV_RegValue *psRegValue;
	ENTRY();	
	nuvoton_vin_attach_sensor(cam, &ov7725);
	
	// if i2c module isn't loaded at this time
	if(!sensor_inited)
		return -1;
		
	psRegValue=RegValue;
	for(i=0;i<_REG_TABLE_SIZE(RegValue); i++, psRegValue++)
	{
		int32_t ret;
		printk(".");		
		ret = sensor_write((psRegValue->uRegAddr), (psRegValue->uValue));
		if(ret<0)
		{
			VDEBUG("Wrong to write register addr = 0x%x, write data = 0x%x , ret = %d\n", (psRegValue->uRegAddr), (psRegValue->uValue), ret);					
		}	
	} 	
	//----------Read sensor id-------------------------------------	        
	SensorID[0]=sensor_read(0x0A);  /* PID 0x77 */		
	SensorID[1]=sensor_read(0x0B);  /* VER 0x21 */
	SensorID[2]=sensor_read(0x1C);  /* Manufacturer ID Byte - High  0x7F */	
	SensorID[3]=sensor_read(0x1D);  /* Manufacturer ID Byte - Low   0xA2 */
	printk("Sensor PID = 0x%02x(0x77) VER = 0x%02x(0x21) MIDH = 0x%02x(0x7F) MIDL = 0x%02x(0xA2)\n", SensorID[0],SensorID[1],SensorID[2],SensorID[3]);	
	//-------------------------------------------------------------		
	printk("\n");
	if(ret>=0)
		printk("driver i2c initial done\n");
	else
		printk("driver i2c initial fail\n");	
	LEAVE();		
	return ret;	
}
Example #18
0
void measures_logFormat(char *buf, size_t len)
{
	struct tm *t;
	time_t tim;
	udegree_t lat, lon;
	int32_t altitude;


	bool fix = gps_fixed();
	if (fix)
	{
		lat = gps_info()->latitude;
		lon = gps_info()->longitude;
		altitude = gps_info()->altitude;
	}
	else
	{
		lat = 0;
		lon = 0;
		altitude = 0;
	}

	tim = gps_time();
	t = gmtime(&tim);

	snprintf(buf, len, "%02d:%02d:%02d;%s;%02ld.%.06ld;%03ld.%.06ld;%ld;%.1f;%.1f;%.0f;%.0f;%.1f;%.2f;%.2f;%.2f;%.0f;%.2f;%.2f;%.2f;%d",
		t->tm_hour, t->tm_min, t->tm_sec,
		fix ? "FIX" : "NOFIX",
		lat/1000000, ABS(lat)%1000000,
		lon/1000000, ABS(lon)%1000000,
		altitude,
		sensor_read(ADC_T1),
		sensor_read(ADC_T2),
		sensor_read(ADC_PRESS),
		sensor_read(ADC_HUMIDITY),
		measures_intTemp(),
		sensor_read(ADC_VIN),
		sensor_read(ADC_5V),
		sensor_read(ADC_3V3),
		sensor_read(ADC_CURR),
		measures_acceleration(MMA_X),
		measures_acceleration(MMA_Y),
		measures_acceleration(MMA_Z),
		hadarp_read()
	);

	buf[len - 1] = '\0';
}
Example #19
0
void measures_aprsFormat(char *buf, size_t len)
{
	const char *lat, *lon;
	if (gps_fixed())
	{
		lat = gps_aprsLat();
		lon = gps_aprsLon();
	}
	else
	{
		lat = "0000.00N";
		lon = "00000.00W";
	}

	float x = measures_acceleration(MMA_X);
	float y = measures_acceleration(MMA_Y);
	float z = measures_acceleration(MMA_Z);

	float acc = sqrt(x * x + y * y + z * z);

	char time[7];
	radio_time(time, sizeof(time));

	snprintf(buf, len, "/%.6sh%s/%s>%ld;%.1f;%.0f;%.0f;%.1f;%.2f;%.2f;%d",
		time,
		lat, lon,
		gps_info()->altitude,
		sensor_read(ADC_T1),
		sensor_read(ADC_PRESS),
		sensor_read(ADC_HUMIDITY),
		measures_intTemp(),
		sensor_read(ADC_VIN),
		acc,
		hadarp_read()
	);

	buf[len - 1] = '\0';
}
/**
 * @brief Get sensor hardware device ID.
 *
 * This routine returns device-specific sensor hardware identification
 * and, optionally, version values.  Unimplemented values will be set
 * to zero.  For example, devices supporting a dedicated ID register, but
 * not a version register, will set "id" to the ID value and "ver" to zero.
 *
 * @param   sensor  The address of an initialized sensor descriptor.
 * @param   id      An address where the device ID is returned.
 * @param   ver     An address where the device version is returned.
 * @return  bool    true if the call succeeds, else false is returned.
 */
bool sensor_device_id(sensor_t *sensor, uint32_t *id, uint8_t *ver)
{
	sensor_data_t dev_data;
	bool status = false;

	status = sensor_read(sensor, SENSOR_READ_ID, &dev_data);

	if (status) {
		*id = dev_data.device.id;
		*ver = (uint8_t)dev_data.device.version;
	}

	return status;
}
static int sensor_flip_cb(struct i2c_client *client, int flip)
{
	char val;
	int err = 0;	


    SENSOR_DG("flip: %d",flip);
	if (flip) {
		err = sensor_read(client, 0x3022, &val);
		if (err == 0) {
			val |= 0x01;
			err = sensor_write(client, 0x3022, val);
		}
	} else {
		err = sensor_read(client, 0x3022, &val);
		if (err == 0) {
			val &= 0xfe;
			err = sensor_write(client, 0x3022, val);
		}
	}

	return err;       
}
Example #22
0
void main(void)
{
	
    //WDTCTL = WDTPW | WDTHOLD;           // Stop watchdog timer

    /* Halting WDT and disabling master interrupts */
    MAP_WDT_A_holdTimer();
    MAP_Interrupt_disableMaster();

    startup_MSP432();
    while(1)
    accelz = sensor_read(MPU9150_ACCEL_ZOUT_H,MPU9150_ACCEL_ZOUT_L);

	
}
Example #23
0
void collect_run(const char* sensor, const char* file, unsigned dt)
{
    void* sensor_handle = sensor_wire(sensor);
    void* logw_handle = logw_wire(file);
	void* timer_handle = timer_wire();

    uint32_t now = timer_getNow(timer_handle);
    while (true) {
        timer_sleep(timer_handle, now + dt);
        now += dt;

        sensor_val_t val;
		error_t res = sensor_read(sensor_handle, &val);
		assert (res == SUCCESS);

        log_to(logw_handle, &val, sizeof(sensor_val_t));
    }
}
Example #24
0
static void NORETURN curr_process(void)
{
	while (1)
	{
		if (!curr_override && sensor_read(ADC_CURR) > curr_limit)
		{
			power_enable(false);
			if (!curr_logged)
			{
				radio_printf("Current overrange!\n");
				radio_printf("Switching OFF aux power\n");
				curr_logged = true;
			}
		}

		timer_delay(1000);
	}
}
Example #25
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_sample_stats_process, ev, data) {

	static uint16_t data_sam[NUM_SAM]; 
	uint16_t sum = 0;
	uint16_t sqsum = 0;
	static struct etimer etimer;

	PROCESS_BEGIN();

	// Gather NUM_SAM samples over 1 second of time
	sensor_init();
	printf("Gathering data... ");
	for(counter = 0;counter < NUM_SAM;counter++) {
		// Get data for no change analysis.
		etimer_set(&etimer, CLOCK_SECOND / NUM_SAM);
		PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
		data_sam[counter] = sensor_read();
	}
	printf("done!\n");
	sensor_uinit();

	// Sum the no change data
	sum = 0;
	for(counter = 0;counter < NUM_SAM;counter++) {
		sum = sum + data_sam[counter];
	}
	sample_mean = 0;
	printf("sum = %d\n",sum);
	sample_mean = sum/NUM_SAM;
	printf("sample_mean = %d\n",sample_mean);

	// Caclulate sample_std_dev
	sqsum = 0;
	for(counter = 0;counter < NUM_SAM;counter++) {
		sqsum = sqsum + mypow2(abs_sub(data_sam[counter], sample_mean));
	}
	sample_std_dev = 0;
	sample_std_dev = sqsum/NUM_SAM;
	sample_std_dev = mysqrt(sample_std_dev);
	printf("std_dev = %d\n",sample_std_dev);

	PROCESS_END();
}
Example #26
0
static int sensor_s_vflip(struct cmos_subdev *sd, int value)
{
	int data;

	data = sensor_read(sd, 0x14);

	switch (value) {
	case 0:
		data &= ~0x02;
		break;
	case 1:
		data |= 0x02;
		break;
	default:
		return -EINVAL;
	}

	return sensor_write(sd, 0x14, data);
}
PROCESS_THREAD(shell_sleepy_trilat_start_process, ev, data)
{
	PROCESS_BEGIN();

	open_runicast();
	my_node = rimeaddr_node_addr.u8[0];

	if (my_node != SINK_NODE)
	{	
		static struct etimer etimer0;
		static char message[4];
		static int i = 0;
		
		etimer_set(&etimer0, CLOCK_SECOND/16);
		sensor_init();
//		leds_on(LEDS_ALL);
		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etimer0));
		for (i = 1; i <= 100; i++)
		{
			etimer_set(&etimer0, CLOCK_SECOND/50);
			PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etimer0));			
			my_noise = sensor_read() + my_noise;
		}
		sensor_uinit();
		my_noise = my_noise / 100; 
		
		etimer_set(&etimer0, CLOCK_SECOND * (my_node - FIRST_NODE + 1));
		leds_on(LEDS_ALL);
		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&etimer0));
		leds_off(LEDS_ALL);	

		itoa(my_noise, message, 10);
		strcat(message, "!\0");

		transmit_runicast(message, SINK_NODE);

//		process_start(&node_timeout_process, NULL);
	}

	PROCESS_END();
}
Example #28
0
static int 
sensor_querystd(
	struct v4l2_subdev *sd,
	v4l2_std_id *std
)
{
	int ret = 0;
	unsigned char value;
	ret = sensor_read(0x8c, &value);
	if (ret < 0) {
		ret = -EIO;
	}
	else {
		if (value & 0x06) {
			*std = V4L2_STD_PAL;
		}
		else {
			*std = V4L2_STD_NTSC;
		} 
	}
	return ret;
}
Example #29
0
void GYRO_Test()
{ 
	int value1=0,value2=0,value3=0; 
	value1= sensor_read(GYRO_address, OUT_X_H_G)*0x100 + sensor_read(GYRO_address, OUT_X_L_G); 

	if(value1 > 0x7FFF) 
		value1=value1-0x10000; 

	value2= sensor_read(GYRO_address, OUT_Y_H_G)*0x100 + sensor_read(GYRO_address, OUT_Y_L_G); 

	if(value2 > 0x7FFF) 
		value2=value2-0x10000; 

	value3= sensor_read(GYRO_address, OUT_Z_H_G)*0x100 + sensor_read(GYRO_address, OUT_Z_L_G); 

	if(value3 > 0x7FFF) 
		value3=value3-0x10000; 

	printf("gyro :%d %d %d   ",value1,value2,value3); 

}