Jacky Tseng
/
imu_driver
handle master side communication of openIMU300ZI module
Diff: imu_driver.hpp
- Revision:
- 10:d8223969c541
- Parent:
- 9:9591afda2394
- Child:
- 11:866dd73e4ab3
diff -r 9591afda2394 -r d8223969c541 imu_driver.hpp --- a/imu_driver.hpp Sun Nov 17 09:42:48 2019 +0000 +++ b/imu_driver.hpp Mon Nov 18 08:05:02 2019 +0000 @@ -1,5 +1,7 @@ /** * @file imu_driver.hpp + * @brief ImuDriver class and other data storage struct definition. The C language version + * can be found at <A HREF="https://github.com/osjacky430/imu_driver">this github website</A> */ #ifndef IMU_DRIVER_HPP_ @@ -8,11 +10,6 @@ #include <mbed.h> #include <cstdint> -typedef enum ImuDriverStatus { - ImuDriverStatusOK, - ImuDriverStatusDataNotReady -} ImuDriverStatus; - typedef enum ImuDriverRegister { ReadAhrsBurstDataRegister = 0x3D, ReadBurstDataRegister = 0x3E, @@ -25,6 +22,11 @@ std::int16_t temperature; } AhrsRawData; +/** + * @brief AhrsProcessedData is data storage class, which consists of + * + * - attitude: pitch, roll, yaw in deg, range from -180 ~ +180 deg + */ typedef struct AhrsProcessedData { float attitude[3]; } AhrsProcessedData; @@ -36,6 +38,14 @@ std::int16_t temperature; } ImuRawData; +/** + * @brief ImuProcessedData is data storage class, which consists of: + * + * - status: if status = 0x0010 (over range error), status = 0 (no error) + * - gyroscope: deg/s, range from -300 deg/s ~ 300 deg/s + * - accelerometer: g, range from -4.5g ~ 4.5g + * - temperature: Celcius + */ typedef struct ImuProcessedData { std::uint16_t status; @@ -55,7 +65,7 @@ * - Frequency: 1.40625 MHz (Baudrate prescaler 32 for NUCLEO-F446RE under 180MHz) * - Endian: MSB first (Mbed only support MSB AFAIK) * - * According to <A HREF="https://openimu.readthedocs.io/en/latest/software/SPImessaging.html">openIMU300ZI SPI framework</A> + * According to <A HREF="https://openimu.readthedocs.io/en/latest/software/SPImessaging.html">openIMU300ZI SPI framework</A>: * * - Data transferred in 16-bit word-length and MSB-first * - fCLK ≤ 2.0 MHz @@ -97,10 +107,6 @@ class ImuDriver { private: - typedef ImuDriver<Spi, rst, drdy, ss> ImuDriverType; - typedef ImuDriverStatus (ImuDriver<Spi, rst, drdy, ss>::*DrdyCallback)(); - - SPI& m_spi; DigitalOut m_rst, m_ss; DigitalIn m_drdy; @@ -163,10 +169,29 @@ receiveAhrsMsg(); } public: + typedef enum ImuDriverStatus { + ImuDriverStatusOK, + ImuDriverStatusDataNotReady + } ImuDriverStatus; +public: + /** + * imuRawData contains raw data received from @ref receiveBurstMsg(bool t_extended) + */ ImuRawData imuRawData; + + /** + * imuProcessedData contains processed data, which is merely scaling operation + */ ImuProcessedData imuProcessedData; + /** + * ahrsRawaData contains raw data received from @ref receiveAhrsMsg() + */ AhrsRawData ahrsRawData; + + /** + * ahrsProcessedData contains processed data, which is merely scaling operation + */ AhrsProcessedData ahrsProcessedData; static const int DEFAULT_IMU_ACCEL_SCALER = 4000; @@ -188,7 +213,7 @@ /** * @brief This function handles the receiving of burst message function, burst message - * contains accelerometer, gyroscope, status and temperature data + * contains accelerometer (g), gyroscope (deg/s), status and temperature data (Celcius) * * @param t_extended bool to indicate the message type is extended or not, default false * @@ -251,7 +276,7 @@ /** * @brief This function handles the receiving of AHRS burst message function, AHRS - * burst message contains the attitude in euler angle. + * burst message contains the attitude in euler angle (deg). * * @return ImuDriverStatus to indicate the result of the receive operation *