コード例 #1
0
ファイル: thermal.c プロジェクト: EPiCS/reconos_v2
//! calibrates sensors. This function takes 3-4 minutes.
void reconos_calibrate_temperature_sensors(void){
    int i, f1, f2;
    sensor_array_int m1,m2;
    float diode1, diode2;

    // init
    for (i=0;i<NUM_SENSORS;i++){
         gradients[i] = 0;
         offsets[i]   = 0;
         m1[i]        = 0;
         m2[i]        = 0;
    }

    // measurement m1
    stop_heating();
    wait_for_stable_temperature(0.3, 20);
    diode1 = sysmon_temp_reg() * TEMPERATURE_FACTOR;
    diode1 -= 273.15;
#ifdef UPBDBG_RECONOS_DEBUG
    diag_printf("\nmake 1st calibration measurement...");
#endif
    sensor_measure();
#ifdef UPBDBG_RECONOS_DEBUG
    diag_printf("done\r\n");
#endif
    for(i = 0; i < NUM_SENSORS; i++){
        m1[i] = sensor[i];
    }

    // measurement m2
    start_heating();
    wait_for_stable_temperature(0.3, 20);
    diode2 = sysmon_temp_reg() * TEMPERATURE_FACTOR;
    diode2 -= 273.15;
#ifdef UPBDBG_RECONOS_DEBUG
    diag_printf("\nmake 2nd calibration measurement...");
#endif
    sensor_measure();
#ifdef UPBDBG_RECONOS_DEBUG
    diag_printf("done\n");
#endif
    for(i = 0; i < NUM_SENSORS; i++){
        m2[i] = sensor[i];
    }
    stop_heating();

#ifdef UPBDBG_RECONOS_DEBUG
    diag_printf("\nsensor calibration (T1=%d.%03d, T2=%d.%03d)\n", (int)diode1, ((int)(diode1*1000))%1000, (int)diode2, ((int)(diode2*1000))%1000);
#endif

    // self-calibration
    for(i = 0; i < NUM_SENSORS; i++){
        f1 = (int) m1[i];
        f2 = (int) m2[i];
        gradients[i]  = (diode2-diode1);
        gradients[i] /= (f2-f1);
        offsets[i]  = diode1;
        offsets[i] -= (gradients[i]*m1[i]);
    }
}
コード例 #2
0
static void sensor_work_func(struct work_struct *work)
{
	struct sensor_data *sensordata = container_of((struct delayed_work *)work, struct sensor_data, work);
	axes_t val;
	unsigned long delay;

	dbg_func_in();

	if(input_pdev == NULL) {
		cancel_delayed_work_sync(&sensordata->work);
	} else {
		sensor_measure(sensordata, &val);

		input_report_abs(input_pdev, ABS_X, (int)val.x);
		input_report_abs(input_pdev, ABS_Y, (int)val.y);
		input_report_abs(input_pdev, ABS_Z, (int)val.z);
		input_sync(input_pdev);

		mutex_lock(&sensordata->data_mutex);
		sensordata->lastval = val;
		mutex_unlock(&sensordata->data_mutex);

		delay = delay_to_jiffies(atomic_read(&sensordata->delay));
		schedule_delayed_work(&sensordata->work, delay);
	}

	dbg_func_out();
}
コード例 #3
0
static void sensor_work_func(struct work_struct *work)
{
	struct sensor_data *sensordata = container_of((struct delayed_work *)work, struct sensor_data, work);
	axes_t val;
	unsigned long delay;

	dbg_func_in();

	if(input_pdev == NULL) {
		cancel_delayed_work_sync(&sensordata->work);
	} else {
		sensor_measure(sensordata, &val);
		#if AT1_BDVER_GE(AT1_WS20)  //hhs veeapp read function add 20110316
        val_backup.x = val.x;
		val_backup.y = val.y;
		val_backup.z = val.z;
		#endif
		input_report_abs(input_pdev, ABS_X, (int)val.x);
		input_report_abs(input_pdev, ABS_Y, (int)val.y);
		input_report_abs(input_pdev, ABS_Z, (int)val.z);
		input_sync(input_pdev);

		mutex_lock(&sensordata->data_mutex);
		sensordata->lastval = val;
		mutex_unlock(&sensordata->data_mutex);

		delay = delay_to_jiffies(atomic_read(&sensordata->delay));
		schedule_delayed_work(&sensordata->work, delay);
	}

	dbg_func_out();
}
コード例 #4
0
ファイル: thermal.c プロジェクト: EPiCS/reconos_v2
//! triggers new temperature measurement
void reconos_make_temperature_measurement(void){
    sensor_measure();
}