Subversion Repositories FlightCtrl

Rev

Rev 2122 | Rev 2143 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef _EEPROM_H
#define _EEPROM_H

#include <inttypes.h>
#include "configuration.h"
#include "analog.h"

#define EEPROM_ADR_PARAM_BEGIN  0
#define EEPROM_CHECKSUMMED_BLOCK_OVERHEAD 3

#define PID_ACTIVE_SET                  0   // byte
//#define EEPROM_ADR_ACCOFFSET          1
//#define EEPROM_ADR_GYROOFFSET         (EEPROM_ADR_ACCOFFSET+sizeof(sensorOffset_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD)
//#define EEPROM_ADR_GYROAMPLIFIER      (EEPROM_ADR_GYROOFFSET+sizeof(sensorOffset_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD)
//#define EEPROM_ADR_CHANNELMAP             (EEPROM_ADR_GYROAMPLIFIER+sizeof(sensorOffset_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD)
//#define EEPROM_ADR_PARAMSET_BEGIN     (EEPROM_ADR_MIXER_TABLE+sizeof(mixerMatrix_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD)

#define EEPROM_ADR_AIRSPEEDOFFSET   16

#define EEPROM_ADR_GYROOFFSET           32
#define EEPROM_ADR_GYROAMPLIFIER    48
#define EEPROM_ADR_CHANNELMAP           64
#define EEPROM_ADR_RCTRIM           96
#define EEPROM_ADR_IMU_CONFIG       128
#define EEPROM_ADR_PARAMSET_BEGIN   256

#define CHANNELMAP_REVISION         1
#define EEPARAM_REVISION                100
#define EEMIXER_REVISION                0
#define SENSOROFFSET_REVISION       0
#define IMUCONFIG_REVISION          1

void paramSet_readOrDefault(void);
void channelMap_readOrDefault(void);
void rcTrim_readOrDefault(void);
void IMUConfig_readOrDefault(void);
void IMUConfig_writeToEEprom(void);

uint8_t paramSet_readFromEEProm(uint8_t setnumber);
void paramSet_writeToEEProm(uint8_t setnumber);

void channelMap_writeToEEProm(void);

uint8_t gyroOffset_readFromEEProm(void);
void gyroOffset_writeToEEProm(void);

uint8_t airpressureOffset_readFromEEProm(void);
void airpressureOffset_writeToEEProm(void);

//uint8_t accOffset_readFromEEProm(void);
//void accOffset_writeToEEProm(void);

uint8_t getParamByte(uint16_t param_id);
void setParamByte(uint16_t param_id, uint8_t value);

// We have only a single param set here.
// uint8_t getActiveParamSet(void);
// void setActiveParamSet(uint8_t setnumber);

#endif //_EEPROM_H