Exemple #1
0
void fc_deinit()
{
    fc_meas_timer.Stop();

    if (fc.flight.state == FLIGHT_FLIGHT)
        fc_landing();

    eeprom_busy_wait();
    //store altimeter settings
    eeprom_update_float(&config_ee.altitude.QNH1, config.altitude.QNH1);
    eeprom_update_float(&config_ee.altitude.QNH2, config.altitude.QNH2);

    if (config.connectivity.use_bt)
        bt_stop();

    if (config.connectivity.use_gps)
        gps_stop();

    for (uint8_t i=0; i<NUMBER_OF_ALTIMETERS; i++)
    {
        eeprom_update_word((uint16_t *)&config_ee.altitude.altimeter[i].delta, config.altitude.altimeter[i].delta);
    }

    mems_power_off();
}
	void reset ()
	{
		eeprom_update_float (TELEMETRY_EEPROM_MIN_CELL_VOLTAGE, BATTERY_MIN_CELL_VOLTAGE);
		eeprom_update_float (TELEMETRY_EEPROM_NOM_CELL_VOLTAGE, BATTERY_NOM_CELL_VOLTAGE);
		eeprom_update_float (TELEMETRY_EEPROM_MAX_CELL_VOLTAGE, BATTERY_MAX_CELL_VOLTAGE);
		eeprom_update_float (TELEMETRY_EEPROM_LOW_VOLTAGE, BATTERY_LOW_CELL_VOLTAGE);
	}
void reset ()
{
	eeprom_update_byte (ADC_BATTERY_EEPROM_CURRENT_SENSOR, ADC_BATTERY_DEFAULT_CURRENT_SENSOR);
	eeprom_update_float (ADC_BATTERY_EEPROM_VOLTAGE_MULTIPLIER, ADC_BATTERY_DEFAULT_VOLTAGE_MULTIPLIER);
	eeprom_update_float (ADC_BATTERY_EEPROM_CURRENT_MULTIPLIER, ADC_BATTERY_DEFAULT_CURRENT_MULTIPLIER);
	eeprom_update_word (ADC_BATTERY_EEPROM_UPDATE_INTERVAL, ADC_BATTERY_DEFAULT_UPDATE_INTERVAL);
	eeprom_update_byte (ADC_BATTERY_EEPROM_VOLTAGE_CHANNEL, ADC_BATTERY_DEFAULT_VOLTAGE_CHANNEL);
	eeprom_update_byte (ADC_BATTERY_EEPROM_CURRENT_CHANNEL, ADC_BATTERY_DEFAULT_CURRENT_CHANNEL);
}
Exemple #4
0
/**
 * Writes the PID variables to the EEPROM
 */
void pid_eeprom_write(void) {
#ifdef EEPROM_AVAILABLE
    eeprom_update_float(&ee_pid_p, pid_p);
    eeprom_update_float(&ee_pid_i, pid_i);
    eeprom_update_float(&ee_pid_d, pid_d);
    eeprom_update_float(&ee_pid_max_error_sum, pid_max_error_sum);
    eeprom_update_float(&ee_pid_error_cap, pid_error_cap);
#endif /* EEPROM_AVAILABLE */
}
Exemple #5
0
void fc_deinit()
{
	eeprom_busy_wait();
	//store altimeter info
	eeprom_update_float(&config.altitude.QNH1, fc.QNH1);
	eeprom_update_float(&config.altitude.QNH2, fc.QNH2);


	for (uint8_t i=0; i<NUMBER_OF_ALTIMETERS; i++)
	{
		eeprom_update_word((uint16_t *)&config.altitude.altimeter[i].delta, fc.altimeter[i].delta);
	}

	MEMS_POWER_OFF;
	I2C_POWER_OFF;
}
Exemple #6
0
static void eepromUpdateFloatSafe(float *eepromVariable, float *shadowVariable, float newValue)
{
	float readValue;
	eeprom_busy_wait();
	eeprom_update_float(eepromVariable, newValue);
	printf("EEPROM written\n");
	eeprom_busy_wait();
	readValue = eeprom_read_float(eepromVariable);
	if (readValue != newValue) {
		eepromCorrupt();
	} else {
		*shadowVariable = newValue;
	}
}
Exemple #7
0
/**Calibrates the internal temperature sensor. This function assumes that the internal temperature sensor will be read in unipolar mode with the internal 1.17V reference.
*
*	CurrentTemp The current temperature of the device. This value should be entered as 10000 times the temperature in C. EX: 25.4812C would be 254812.
*	
*	Note: NV_AD7794_INTERNAL_TEMP_CAL is the zero intercept of the temperature calibration. The slope is given in the datasheet.
*/
uint8_t AD7794InternalTempCal(uint32_t CurrentTemp)
{
	uint8_t i;
	uint8_t SendData[2];
	uint32_t RunningSum = 0;
	
	double cal;
	double slope;
	double intercept;
	double TempInput;
	char OutputString[15];
	
	slope = 0.0001721912F;		//Deg C/count
	TempInput = (double)CurrentTemp/10000.0F;
	
	cal = eeprom_read_float(&NV_AD7794_INTERNAL_TEMP_CAL);
	dtostrf(cal, 9, 4, OutputString);
	printf_P(PSTR("Current calibrated zero is: %s\n"), OutputString);
	printf_P(PSTR("Taking 10 readings from internal temperature sensor...\n"));
	
	//Measure internal temperature
	SendData[1] = (AD7794_CRH_UNIPOLAR|AD7794_CRH_GAIN_1);
	SendData[0] = (AD7794_CRL_REF_INT|AD7794_CRL_REF_DETECT|AD7794_CRL_BUFFER_ON|AD7794_CRL_CHANNEL_TEMP);
	AD7794WriteReg(AD7794_CR_REG_CONFIG, SendData);
	SendData[1] = AD7794_MRH_MODE_CONTINUOUS;
	SendData[0] = (AD7794_MRL_CLK_INT_NOOUT | AD7794_MRL_UPDATE_RATE_10_HZ);
	AD7794WriteReg(AD7794_CR_REG_MODE, SendData);
	
	for(i=0;i<10;i++)
	{
		AD7794WaitReady();
		RunningSum += AD7794GetData();
		
	}

	RunningSum = RunningSum/i;
	printf_P(PSTR("Internal Temperature: %lu counts\n"), RunningSum);
	
	intercept = TempInput - slope*(double)RunningSum;
	dtostrf(intercept, 9, 4, OutputString);
	printf_P(PSTR("New calibration is: %s\n"), OutputString);
	
	//eeprom_update_block((const void *)&TempCalArray, (void *)NV_AD7794_INTERNAL_TEMP_CAL, 3);
	eeprom_update_float(&NV_AD7794_INTERNAL_TEMP_CAL, intercept);
	return 0;
}
void calibration_store(float nox, float noy, float noz, float nsx, float nsy, float nsz)
{
    ox = nox;
    eeprom_update_float(&nv_ox, ox);
    
    oy = noy;
    eeprom_update_float(&nv_oy, oy);
    
    oz = noz;
    eeprom_update_float(&nv_oz, oz);
    
    sx = nsx;
    eeprom_update_float(&nv_sx, sx);
    
    sy = nsy;
    eeprom_update_float(&nv_sy, sy);
    
    sz = nsz;
    eeprom_update_float(&nv_sz, sz);
    
    eeprom_update_byte(&nv_cal_check, 'c');
}
void storeCap (float cap1, double cap2){
	eeprom_busy_wait();
	eeprom_update_float((float*)&eeCap1Mem, cap1);
	eeprom_update_float((float*)&eeCap2Mem, cap2);

}
Exemple #10
0
	void reset ()
	{
		eeprom_update_byte (ADC_EEPROM_REF, ADC_DEFAULT_REF);
		eeprom_update_float (ADC_EEPROM_REF_VOLTAGE, ADC_DEFAULT_REF_VOLTAGE);
	}
Exemple #11
0
void set_surface_reflection_ratio(double ratio)
{
	surface_reflection_ratio = ratio;
	eeprom_update_float((float*)&eep_surface_reflection_ratio, surface_reflection_ratio);
}
Exemple #12
0
void set_robot_detected_angle_offset(double offset)
{
	robot_detected_angle_offset = offset;
	eeprom_update_float((float*)&eep_robot_detected_angle_offset, robot_detected_angle_offset); 
}