-
Notifications
You must be signed in to change notification settings - Fork 65
Support Sparkfun ICM20948 Breakout board (SPI only, I2C TBD) #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3895d95
e896acf
527d8b1
8bd66ff
1ded436
c258480
42736b0
176314e
9fa51c6
af6d8bf
b04db65
860abb5
86d07e9
21d4588
726d540
c6ed36a
0088470
7b99f7e
af09253
fa4f032
73232a7
bec9795
f77ef9a
1a3495d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include "ahr.h" | ||
|
|
||
| class AhrGizmoImu : public AhrGizmo { | ||
| private: | ||
| AhrConfig *config; | ||
| AhrState *state; | ||
|
|
||
| //NED reference frame | ||
| //gyro in rad/sec | ||
| //acc in g | ||
| //mag any unit of measurement | ||
|
|
||
| // quaternion of sensor frame relative to auxiliary frame | ||
| float q0 = 1.0f; //Initialize quaternion | ||
| float q1 = 0.0f; | ||
| float q2 = 0.0f; | ||
| float q3 = 0.0f; | ||
|
|
||
| public: | ||
| AhrGizmoImu(Ahr *ahr) { | ||
| this->config = &(ahr->config); | ||
| this->state = (AhrState*)ahr; | ||
| } | ||
|
|
||
| void setInitalOrientation(float *qnew) { | ||
| q0 = qnew[0]; | ||
| q1 = qnew[1]; | ||
| q2 = qnew[2]; | ||
| q3 = qnew[3]; | ||
| } | ||
|
|
||
| bool update() { | ||
| // just copy the quaternions from the IMU | ||
| state->q[0] = config->pimu->q[0]; | ||
| state->q[1] = config->pimu->q[1]; | ||
| state->q[2] = config->pimu->q[2]; | ||
| state->q[3] = config->pimu->q[3]; | ||
| return true; | ||
| } | ||
| }; |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put this in a new PR - I think this will need some additional considerations... Some (random) thoughts: Rather add a new imu_gizmo mf_ICM20948_6DOF than a new parameter. (I try to keep number of parameters as low as possible) If adding a parameter: New config params should be added at the end of the array - this allows users to upgrade without eeprom corruption. I would use value 0 or 1 (not <=0 or 1) Default value 1 makes more sense to me - use mag if we have it. Rather name the param and related vars imu_use_mag, and reserve the "has" properties for driver capabilities. Not consistent with current 9dof drivers...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, not consistent with existing drivers - made it use_mag and moved to bottom. Only really used by ICM20948 for now, could be used by MPU9250 if it supports 6DOF. But left others alone to have minimal code changes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the meantime, my quadcopter crashed and burned badly - need to debug it, it stopped listening to IBUS and didn't automatically disarm itself when it lost contact!
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ouch!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I seemed to have lost some code when I split Icm20948 and ibus code so putting it back - related to calibration and quaternions |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #ifndef _AK09916_ENUMERATIONS_H_ | ||
| #define _AK09916_ENUMERATIONS_H_ | ||
|
|
||
| typedef enum | ||
| { | ||
| AK09916_mode_power_down = 0x00, | ||
| AK09916_mode_single = (0x01 << 0), | ||
| AK09916_mode_cont_10hz = (0x01 << 1), | ||
| AK09916_mode_cont_20hz = (0x02 << 1), | ||
| AK09916_mode_cont_50hz = (0x03 << 1), | ||
| AK09916_mode_cont_100hz = (0x04 << 1), | ||
| AK09916_mode_self_test = (0x01 << 4), | ||
| } AK09916_mode_e; | ||
|
|
||
| #endif // _AK09916_ENUMERATIONS_H_ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #ifndef _AK09916_REGISTERS_H_ | ||
| #define _AK09916_REGISTERS_H_ | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| typedef enum | ||
| { | ||
| AK09916_REG_WIA1 = 0x00, | ||
| AK09916_REG_WIA2, | ||
| AK09916_REG_RSV1, | ||
| AK09916_REG_RSV2, // Reserved register. We start reading here when using the DMP. Secret sauce... | ||
| // discontinuity - containing another nine reserved registers? Secret sauce... | ||
| AK09916_REG_ST1 = 0x10, | ||
| AK09916_REG_HXL, | ||
| AK09916_REG_HXH, | ||
| AK09916_REG_HYL, | ||
| AK09916_REG_HYH, | ||
| AK09916_REG_HZL, | ||
| AK09916_REG_HZH, | ||
| // discontinuity | ||
| AK09916_REG_ST2 = 0x18, | ||
| // discontinuity | ||
| AK09916_REG_CNTL2 = 0x31, | ||
| AK09916_REG_CNTL3, | ||
| } AK09916_Reg_Addr_e; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint8_t WIA1; | ||
| } AK09916_WIA1_Reg_t; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint8_t WIA2; | ||
| } AK09916_WIA2_Reg_t; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint8_t DRDY : 1; | ||
| uint8_t DOR : 1; | ||
| uint8_t reserved_0 : 6; | ||
| } AK09916_ST1_Reg_t; | ||
|
|
||
| // typedef struct{ | ||
|
|
||
| // }AK09916_HXL_Reg_t; | ||
|
|
||
| // typedef struct{ | ||
|
|
||
| // }AK09916_HXH_Reg_t; | ||
| // typedef struct{ | ||
|
|
||
| // }AK09916_HYL_Reg_t; | ||
| // typedef struct{ | ||
|
|
||
| // }AK09916_HYH_Reg_t; | ||
| // typedef struct{ | ||
|
|
||
| // }AK09916_HZL_Reg_t; | ||
| // typedef struct{ | ||
|
|
||
| // }AK09916_HZH_Reg_t; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint8_t reserved_0 : 3; | ||
| uint8_t HOFL : 1; | ||
| uint8_t reserved_1 : 4; | ||
| } AK09916_ST2_Reg_t; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint8_t MODE : 5; | ||
| uint8_t reserved_0 : 3; | ||
| } AK09916_CNTL2_Reg_t; | ||
|
|
||
| typedef struct | ||
| { | ||
| uint8_t SRST : 1; | ||
| uint8_t reserved_0 : 7; | ||
| } AK09916_CNTL3_Reg_t; | ||
|
|
||
| #endif // _AK09916_REGISTERS_H_ |
Uh oh!
There was an error while loading. Please reload this page.