![](/media/cache/group/icon1_qbDJ87a.png.50x50_q85.png)
EEPROM読み取り用
main.cpp
- Committer:
- tanahashi
- Date:
- 2021-03-08
- Revision:
- 0:3fb5ae3480ae
- Child:
- 1:daa7e093ac88
File content as of revision 0:3fb5ae3480ae:
#include "mbed.h" #include "PQ_EEPROM.h" Serial pc(USBTX, USBRX, 115200); I2C i2c(p28, p27); EEPROM eeprom(i2c); char data[128]; char *phase_names[] = {"SAFETY", "READY", "FLIGHT", "SEP", "EMERGENCY", "RECOVERY"}; int mission_time; float flight_time; char phase; char f_launched; char f_burning; char f_apogee; char f_mission; char f_relay; char f_flight_pin; char f_sep; char f_buzzer; char f_sd; char f_gps; char f_adxl; char f_ina_in; char f_ina_ex; char f_lps; char f_mpu; char f_mpu_ak; float lat; float lon; int sat; int fix; float hdop; float alt; float geoid; float high_accel[3]; float voltage_in; float current_in; float voltage_ex; float current_ex; float press; float temp; float accel[3]; float gyro[3]; float mag[3]; int mission_hour, mission_min, mission_sec; int main() { for(int addr = 0x000000; addr < 0x07FFFF; addr += 0x80) { eeprom.read(addr, data, 128); mission_time = *(int*)&data[0]; flight_time = *(float*)&data[4]; phase = *(float*)&data[8]; f_launched = *(float*)&data[9]; f_burning = *(float*)&data[10]; f_apogee = *(float*)&data[11]; f_mission = *(float*)&data[12]; f_relay = *(float*)&data[13]; f_flight_pin = *(float*)&data[14]; f_sep = *(float*)&data[15]; f_buzzer = *(float*)&data[16]; f_sd = *(float*)&data[17]; f_gps = *(float*)&data[18]; f_adxl = *(float*)&data[19]; f_ina_in = *(float*)&data[20]; f_ina_ex = *(float*)&data[21]; f_lps = *(float*)&data[22]; f_mpu = *(float*)&data[23]; f_mpu_ak = *(float*)&data[24]; lat = *(float*)&data[25]; lon = *(float*)&data[29]; sat = *(float*)&data[33]; fix = *(float*)&data[37]; hdop = *(float*)&data[41]; alt = *(float*)&data[45]; geoid = *(float*)&data[49]; high_accel[0] = *(float*)&data[53]; high_accel[1] = *(float*)&data[57]; high_accel[2] = *(float*)&data[61]; voltage_in = *(float*)&data[65]; current_in = *(float*)&data[69]; voltage_ex = *(float*)&data[73]; current_ex = *(float*)&data[77]; press = *(float*)&data[81]; temp = *(float*)&data[85]; accel[0] = *(float*)&data[89]; accel[1] = *(float*)&data[93]; accel[2] = *(float*)&data[97]; gyro[0] = *(float*)&data[101]; gyro[1] = *(float*)&data[105]; gyro[2] = *(float*)&data[109]; mag[0] = *(float*)&data[113]; mag[1] = *(float*)&data[117]; mag[2] = *(float*)&data[121]; mission_hour = mission_time / 3600; mission_time %= 3600; mission_min = mission_time / 60; mission_time %= 60; mission_sec = mission_time; pc.printf(" mission time:\t%02d:%02d:%02d\r\n", mission_hour, mission_min, mission_sec); pc.printf(" flight time:\t%.3f[s]\r\n", flight_time); pc.printf(" phase:\t%s\r\n", phase_names[phase]); pc.printf(" flags:\tLAUNCH\tBURNING\tAPOGEE\tMISSION\tRELAY\tFLIGHT\tSEP\tBUZZER\r\n"); pc.printf(" \t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n", f_launched, f_burning, f_apogee, f_mission, f_relay, f_flight_pin, f_sep, f_buzzer); pc.printf(" flags:\tSD\tGPS\tADXL\tINA_in\tINA_ex\tLPS\tMPU\tMPU_AK\r\n"); pc.printf(" \t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n", f_sd, f_gps, f_adxl, f_ina_in, f_ina_ex, f_lps, f_mpu, f_mpu_ak); pc.printf("\r\n"); pc.printf(" lat:\t\t%.6f\r\n", lat); pc.printf(" lon:\t\t%.6f\r\n", lon); pc.printf(" alt:\t\t%.1f[m]\r\n", alt); pc.printf("\r\n"); pc.printf(" internal:\tvoltage\t\tcurrent\r\n"); pc.printf(" \t%.2f[V]\t\t%.0f[mA]\r\n", voltage_in / 1000.0f, current_in); pc.printf(" external:\tvoltage\t\tcurrent\r\n"); pc.printf(" \t%.2f[V]\t\t%.0f[mA]\r\n", voltage_ex / 1000.0f, current_ex); pc.printf("\r\n"); pc.printf(" press:\t\t%.2f[hPa]\r\n", press); pc.printf(" temp:\t\t%.2f[C]\r\n", temp); pc.printf("\r\n"); pc.printf(" high_accel:\tx\t\ty\t\tz\r\n"); pc.printf(" \t\t%.2f\t\t%.2f\t\t%.2f\t[G]\r\n", high_accel[0], high_accel[1], high_accel[2]); pc.printf(" accel:\t\tx\t\ty\t\tz\r\n"); pc.printf(" \t\t%.2f\t\t%.2f\t\t%.2f\t[G]\r\n", accel[0], accel[1], accel[2]); pc.printf(" gyro:\t\tx\t\ty\t\tz\r\n"); pc.printf(" \t\t%.2f\t\t%.2f\t\t%.2f\t[rad/s]\r\n", gyro[0], gyro[1], gyro[2]); } }