Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MatrixMath LPS25HB_I2C LSM9DS1 Matrix2 PIDcontroller LoopTicker SBUS_without_mainfile UsaPack solaESKF_wind Vector3 CalibrateMagneto FastPWM
datatransfer.cpp
- Committer:
- NaotoMorita
- Date:
- 2021-09-01
- Revision:
- 75:7fa924da9d32
- Parent:
- 73:be7a8b8188de
- Child:
- 80:31e0ffc82931
File content as of revision 75:7fa924da9d32:
#include "global.hpp"
void send2center()
{
valuePack& vp = posValues;
vp.day = updateValues.day;
vp.ms = updateValues.ms;
ekf.getGyroBias(vp.gyroBias, vp.gyroBiasCov);
//ekf.getAccBias(vp.accBias, vp.accBiasCov);
vp.acc[0] = acc.x;
vp.acc[1] = acc.y;
vp.acc[2] = acc.z;
vp.gyro[0] = gyro.x;
vp.gyro[1] = gyro.y;
vp.gyro[2] = gyro.z;
vp.mag[0] = mag.x;
vp.mag[1] = mag.y;
vp.mag[2] = mag.z;
vp.rpy[0] = rpy.x;
vp.rpy[1] = rpy.y;
vp.rpy[2] = rpy.z;
vp.de = de;
vp.deobj = deobj;
for(int i = 0 ; i<5 ; i++){
vp.rc[i] = rc[i];
}
tail.Send(tail_address[pos_tail], &(posValues));
ekf.updateCenteredGyroBiasCorrection(updateValues.gyroBias);
//ekf.updateCenteredAccBiasCorrection(updateValues.accBias);
//pc.printf("%f %f\n\r",rpy.x*180.0f/M_PI,updateValues.gyroBias[0]);
}
// eeprom書き込み・読み込みに必要な関数
void writeEEPROM(int address, unsigned int eeaddress, char *data, int size)
{
char i2cBuffer[size + 2];
i2cBuffer[0] = (unsigned char)(eeaddress >> 8); // MSB
i2cBuffer[1] = (unsigned char)(eeaddress & 0xFF); // LSB
for (int i = 0; i < size; i++) {
i2cBuffer[i + 2] = data[i];
}
int result = i2c.write(address, i2cBuffer, size + 2, false);
//sleep_ms(500);
}
// this function has no read limit
void readEEPROM(int address, unsigned int eeaddress, char *data, int size)
{
char i2cBuffer[2];
i2cBuffer[0] = (unsigned char)(eeaddress >> 8); // MSB
i2cBuffer[1] = (unsigned char)(eeaddress & 0xFF); // LSB
// Reset eeprom pointer address
int result = i2c.write(address, i2cBuffer, 2, false);
//sleep_ms(500);
// Read eeprom
i2c.read(address, data, size);
//sleep_ms(500);
}