read EEPROM

Dependencies:   mbed PQEEPROM

Committer:
tanahashi
Date:
Mon Mar 02 11:29:44 2020 +0000
Revision:
0:5aef3912ae57
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tanahashi 0:5aef3912ae57 1 #include "mbed.h"
tanahashi 0:5aef3912ae57 2
tanahashi 0:5aef3912ae57 3 #include "PQEEPROM.h"
tanahashi 0:5aef3912ae57 4
tanahashi 0:5aef3912ae57 5 Serial pc(USBTX, USBRX, 115200);
tanahashi 0:5aef3912ae57 6
tanahashi 0:5aef3912ae57 7 I2C i2c(p28, p27);
tanahashi 0:5aef3912ae57 8
tanahashi 0:5aef3912ae57 9 EEPROM eeprom(i2c);
tanahashi 0:5aef3912ae57 10
tanahashi 0:5aef3912ae57 11 char data[128];
tanahashi 0:5aef3912ae57 12
tanahashi 0:5aef3912ae57 13 char mission_timer_reset;
tanahashi 0:5aef3912ae57 14 int mission_time;
tanahashi 0:5aef3912ae57 15 int flight_time;
tanahashi 0:5aef3912ae57 16 char f_sd;
tanahashi 0:5aef3912ae57 17 char f_gps;
tanahashi 0:5aef3912ae57 18 char f_adxl;
tanahashi 0:5aef3912ae57 19 char f_ina_in;
tanahashi 0:5aef3912ae57 20 char f_ina_ex;
tanahashi 0:5aef3912ae57 21 char f_lps;
tanahashi 0:5aef3912ae57 22 char f_mpu;
tanahashi 0:5aef3912ae57 23 char f_mpu_ak;
tanahashi 0:5aef3912ae57 24 char phase;
tanahashi 0:5aef3912ae57 25 int utc_hour;
tanahashi 0:5aef3912ae57 26 int utc_min;
tanahashi 0:5aef3912ae57 27 float utc_sec;
tanahashi 0:5aef3912ae57 28 float lat;
tanahashi 0:5aef3912ae57 29 float lon;
tanahashi 0:5aef3912ae57 30 int sat;
tanahashi 0:5aef3912ae57 31 int fix;
tanahashi 0:5aef3912ae57 32 float hdop;
tanahashi 0:5aef3912ae57 33 float alt;
tanahashi 0:5aef3912ae57 34 float geoid;
tanahashi 0:5aef3912ae57 35 float high_accel[3];
tanahashi 0:5aef3912ae57 36 float voltage_in;
tanahashi 0:5aef3912ae57 37 float current_in;
tanahashi 0:5aef3912ae57 38 float voltage_ex;
tanahashi 0:5aef3912ae57 39 float current_ex;
tanahashi 0:5aef3912ae57 40 float press;
tanahashi 0:5aef3912ae57 41 float temp;
tanahashi 0:5aef3912ae57 42 float accel[3];
tanahashi 0:5aef3912ae57 43 float gyro[3];
tanahashi 0:5aef3912ae57 44 float mag[3];
tanahashi 0:5aef3912ae57 45
tanahashi 0:5aef3912ae57 46 int main()
tanahashi 0:5aef3912ae57 47 {
tanahashi 0:5aef3912ae57 48 for(int addr = 0x000000; addr < 0x07FFFF; addr += 0x80) {
tanahashi 0:5aef3912ae57 49 eeprom.read(addr, data, 128);
tanahashi 0:5aef3912ae57 50 mission_timer_reset = data[1];
tanahashi 0:5aef3912ae57 51 mission_time = *(int*)&data[2];
tanahashi 0:5aef3912ae57 52 flight_time = *(int*)&data[6];
tanahashi 0:5aef3912ae57 53 f_sd = data[10];
tanahashi 0:5aef3912ae57 54 f_gps = data[11];
tanahashi 0:5aef3912ae57 55 f_adxl = data[12];
tanahashi 0:5aef3912ae57 56 f_ina_in = data[13];
tanahashi 0:5aef3912ae57 57 f_ina_ex = data[14];
tanahashi 0:5aef3912ae57 58 f_lps = data[15];
tanahashi 0:5aef3912ae57 59 f_mpu = data[16];
tanahashi 0:5aef3912ae57 60 f_mpu_ak = data[17];
tanahashi 0:5aef3912ae57 61 phase = data[18];
tanahashi 0:5aef3912ae57 62 lat = *(float*)&data[19];
tanahashi 0:5aef3912ae57 63 lon = *(float*)&data[23];
tanahashi 0:5aef3912ae57 64 sat = *(int*)&data[27];
tanahashi 0:5aef3912ae57 65 fix = *(int*)&data[31];
tanahashi 0:5aef3912ae57 66 hdop = *(float*)&data[35];
tanahashi 0:5aef3912ae57 67 alt = *(float*)&data[39];
tanahashi 0:5aef3912ae57 68 geoid = *(float*)&data[43];
tanahashi 0:5aef3912ae57 69 high_accel[0] = *(float*)&data[47];
tanahashi 0:5aef3912ae57 70 high_accel[1] = *(float*)&data[51];
tanahashi 0:5aef3912ae57 71 high_accel[2] = *(float*)&data[55];
tanahashi 0:5aef3912ae57 72 voltage_in = *(float*)&data[59];
tanahashi 0:5aef3912ae57 73 current_in = *(float*)&data[63];
tanahashi 0:5aef3912ae57 74 voltage_ex = *(float*)&data[67];
tanahashi 0:5aef3912ae57 75 current_ex = *(float*)&data[71];
tanahashi 0:5aef3912ae57 76 press = *(float*)&data[75];
tanahashi 0:5aef3912ae57 77 temp = *(float*)&data[79];
tanahashi 0:5aef3912ae57 78 accel[0] = *(float*)&data[83];
tanahashi 0:5aef3912ae57 79 accel[1] = *(float*)&data[87];
tanahashi 0:5aef3912ae57 80 accel[2] = *(float*)&data[91];
tanahashi 0:5aef3912ae57 81 gyro[0] = *(float*)&data[95];
tanahashi 0:5aef3912ae57 82 gyro[1] = *(float*)&data[99];
tanahashi 0:5aef3912ae57 83 gyro[2] = *(float*)&data[103];
tanahashi 0:5aef3912ae57 84 mag[0] = *(float*)&data[107];
tanahashi 0:5aef3912ae57 85 mag[1] = *(float*)&data[111];
tanahashi 0:5aef3912ae57 86 mag[2] = *(float*)&data[115];
tanahashi 0:5aef3912ae57 87
tanahashi 0:5aef3912ae57 88 pc.printf("addr:%x", addr);
tanahashi 0:5aef3912ae57 89 pc.printf("mission_timer_reset: %d\r\n", mission_timer_reset);
tanahashi 0:5aef3912ae57 90 pc.printf("mission_time: %d\r\n", mission_time);
tanahashi 0:5aef3912ae57 91 pc.printf("flight_time: %d\r\n", flight_time);
tanahashi 0:5aef3912ae57 92 pc.printf("phase: %d\r\n", phase);
tanahashi 0:5aef3912ae57 93 pc.printf("f_sd: %d\r\n", f_sd);
tanahashi 0:5aef3912ae57 94 pc.printf("f_gps: %d\r\n", f_gps);
tanahashi 0:5aef3912ae57 95 pc.printf("f_adxl: %d\r\n", f_adxl);
tanahashi 0:5aef3912ae57 96 pc.printf("f_ina_in: %d\r\n", f_ina_in);
tanahashi 0:5aef3912ae57 97 pc.printf("f_ina_ex: %d\r\n", f_ina_ex);
tanahashi 0:5aef3912ae57 98 pc.printf("f_lps: %d\r\n", f_lps);
tanahashi 0:5aef3912ae57 99 pc.printf("f_mpu: %d\r\n", f_mpu);
tanahashi 0:5aef3912ae57 100 pc.printf("f_mpu_ak: %d\r\n", f_mpu_ak);
tanahashi 0:5aef3912ae57 101 pc.printf("lat: %f\r\n", lat);
tanahashi 0:5aef3912ae57 102 pc.printf("lon: %f\r\n", lon);
tanahashi 0:5aef3912ae57 103 pc.printf("sat: %d\r\n", sat);
tanahashi 0:5aef3912ae57 104 pc.printf("fix: %d\r\n", fix);
tanahashi 0:5aef3912ae57 105 pc.printf("hdop: %f\r\n", hdop);
tanahashi 0:5aef3912ae57 106 pc.printf("alt: %f\r\n", alt);
tanahashi 0:5aef3912ae57 107 pc.printf("geoid: %f\r\n", geoid);
tanahashi 0:5aef3912ae57 108 pc.printf("high_accel_x: %f\r\n", high_accel[0]);
tanahashi 0:5aef3912ae57 109 pc.printf("high_accel_y: %f\r\n", high_accel[1]);
tanahashi 0:5aef3912ae57 110 pc.printf("high_accel_z: %f\r\n", high_accel[2]);
tanahashi 0:5aef3912ae57 111 pc.printf("voltage_in: %f\r\n", voltage_in);
tanahashi 0:5aef3912ae57 112 pc.printf("current_in: %f\r\n", current_in);
tanahashi 0:5aef3912ae57 113 pc.printf("voltage_ex: %f\r\n", voltage_ex);
tanahashi 0:5aef3912ae57 114 pc.printf("current_ex: %f\r\n", current_ex);
tanahashi 0:5aef3912ae57 115 pc.printf("press: %f\r\n", press);
tanahashi 0:5aef3912ae57 116 pc.printf("temp: %f\r\n", temp);
tanahashi 0:5aef3912ae57 117 pc.printf("accel_x: %f\r\n", accel[0]);
tanahashi 0:5aef3912ae57 118 pc.printf("accel_y: %f\r\n", accel[1]);
tanahashi 0:5aef3912ae57 119 pc.printf("accel_z: %f\r\n", accel[2]);
tanahashi 0:5aef3912ae57 120 pc.printf("gyro_x: %f\r\n", gyro[0]);
tanahashi 0:5aef3912ae57 121 pc.printf("gyro_y: %f\r\n", gyro[1]);
tanahashi 0:5aef3912ae57 122 pc.printf("gyro_z: %f\r\n", gyro[2]);
tanahashi 0:5aef3912ae57 123 pc.printf("mag_x: %f\r\n", mag[0]);
tanahashi 0:5aef3912ae57 124 pc.printf("mag_y: %f\r\n", mag[1]);
tanahashi 0:5aef3912ae57 125 pc.printf("mag_z: %f\r\n", mag[2]);
tanahashi 0:5aef3912ae57 126 }
tanahashi 0:5aef3912ae57 127 }