diff --git a/Common/Inc/CommonDataTypes.hpp b/Common/Inc/CommonDataTypes.hpp index 020c655..c6c82a7 100644 --- a/Common/Inc/CommonDataTypes.hpp +++ b/Common/Inc/CommonDataTypes.hpp @@ -1,21 +1,35 @@ -// -// Created by Gordon Fountain 2022-11-30. -// +/** CommonDataTypes.hpp + * Contains a bunch of common datatypes! + * + * Created by: Gordon Fountain 2022-11-30 + * Updated by: Anthony Luo + * Last update: 2024-04-18 +*/ #ifndef ZPSW3_COMMON_DATATYPES_HPP #define ZPSW3_COMMON_DATATYPES_HPP #include +/************************************************ + * Sensor/Error structs (can be either or. tbd ig) + ************************************************/ +typedef enum SensorErrorCode { + SENSOR_SUCCESS = 0, + SENSOR_FAIL = -1, + SENSOR_BUSY = 1, +} SensorErrorCode; + +/************************************************ + * Control limits & inter-manager datatypes + ************************************************/ namespace AM { - struct AttitudeManagerInput { float roll; float pitch; float yaw; float throttle; }; - } // Namespace AM typedef enum { diff --git a/Drivers/imu/inc/imu.hpp b/Drivers/imu/inc/imu.hpp new file mode 100644 index 0000000..3355a3a --- /dev/null +++ b/Drivers/imu/inc/imu.hpp @@ -0,0 +1,52 @@ +/** + * IMU class definition / stub + * Designed to be extended by IMU devices + * Created by: Anthony Luo on 2024-04-18 + * Maintained by: + * Last updated: +*/ + +#ifndef IMU_HPP +#define IMU_HPP + +#include "CommonDataTypes.hpp" + +/************************************************ + * Definitions + ************************************************/ + +struct IMUData_t { + float gyrx, gyry, gyrz; + float accx, accy, accz; + float magx, magy, magz; + + bool is_data_new; + SensorErrorCode sensor_status; // TODO: determine if we need this? +}; + +/************************************************ + * Prototypes + ************************************************/ +class IMU{ + public: + // Leaving the constructor to be elsewhere.... don't know how to handle passing SPI/I2C handles + + /** + * Re-calibrates sensor. Useful if we need to hard re-set an IMU in-flight or something. + */ + virtual SensorErrorCode calibrate() = 0; + /** + * Begins IMU data sampling. TODO: determine how this is determined + * Data should be stored in a buffer and accessible at any time. + * + */ + virtual void beginMeasuring() = 0; + + /** + * Retrieves newest data stored by IMU. + * TODO: determine if we want to return error codes or if we want to set the struct + */ + virtual SensorErrorCode getResult(IMUData_t &data) = 0; + private: + IMUData_t latest_data; +}; \ No newline at end of file