{"action":"created","comment":{"url":"https://api.github.com/repos/PX4/Firmware/pulls/comments/193560215","pull_request_review_id":126556646,"id":193560215,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzU2MDIxNQ==","diff_hunk":"@@ -532,44 +584,87 @@ int MPU9250::reset_mpu()\n int\n MPU9250::probe()\n {\n+\tint ret = -EIO;\n \t/* look for device ID */\n-\t_whoami = read_reg(MPUREG_WHOAMI);\n-\n-\t// verify product revision\n-\tswitch (_whoami) {\n-\tcase MPU_WHOAMI_9250:\n-\tcase MPU_WHOAMI_6500:\n-\t\tmemset(_checked_values, 0, sizeof(_checked_values));\n-\t\tmemset(_checked_bad, 0, sizeof(_checked_bad));\n-\t\t_checked_values[0] = _whoami;\n-\t\t_checked_bad[0] = _whoami;\n-\t\treturn OK;\n+\tswitch(_device_type) {\n+\n+\tcase MPU_DEVICE_TYPE_MPU9250:\n+\t\t_whoami = read_reg(MPUREG_WHOAMI);\n+\n+\t\t// verify product revision\n+\t\tswitch (_whoami) {\n+\t\tcase MPU_WHOAMI_9250:\n+\t\tcase MPU_WHOAMI_6500:\n+\t\t\t_num_checked_registers = MPU9250_NUM_CHECKED_REGISTERS;\n+\t\t\t_checked_registers = _mpu9250_checked_registers;\n+\t\t\tmemset(_checked_values, 0, sizeof(_mpu9250_checked_registers));","path":"src/drivers/imu/mpu9250/mpu9250.cpp","position":219,"original_position":219,"commit_id":"bebd7f886109e5f5d1dc830efd28917c4e826a50","original_commit_id":"bebd7f886109e5f5d1dc830efd28917c4e826a50","user":{"login":"DanielePettenuzzo","id":35664507,"node_id":"MDQ6VXNlcjM1NjY0NTA3","avatar_url":"https://avatars2.githubusercontent.com/u/35664507?v=4","gravatar_id":"","url":"https://api.github.com/users/DanielePettenuzzo","html_url":"https://github.com/DanielePettenuzzo","followers_url":"https://api.github.com/users/DanielePettenuzzo/followers","following_url":"https://api.github.com/users/DanielePettenuzzo/following{/other_user}","gists_url":"https://api.github.com/users/DanielePettenuzzo/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielePettenuzzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielePettenuzzo/subscriptions","organizations_url":"https://api.github.com/users/DanielePettenuzzo/orgs","repos_url":"https://api.github.com/users/DanielePettenuzzo/repos","events_url":"https://api.github.com/users/DanielePettenuzzo/events{/privacy}","received_events_url":"https://api.github.com/users/DanielePettenuzzo/received_events","type":"User","site_admin":false},"body":"eg.\r\nmemset(_checked_values, 0, sizeof(_checked_values));","created_at":"2018-06-06T21:09:48Z","updated_at":"2018-06-06T21:09:49Z","html_url":"https://github.com/PX4/Firmware/pull/9362#discussion_r193560215","pull_request_url":"https://api.github.com/repos/PX4/Firmware/pulls/9362","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/PX4/Firmware/pulls/comments/193560215"},"html":{"href":"https://github.com/PX4/Firmware/pull/9362#discussion_r193560215"},"pull_request":{"href":"https://api.github.com/repos/PX4/Firmware/pulls/9362"}},"in_reply_to_id":193556424},"pull_request":{"url":"https://api.github.com/repos/PX4/Firmware/pulls/9362","id":183574583,"node_id":"MDExOlB1bGxSZXF1ZXN0MTgzNTc0NTgz","html_url":"https://github.com/PX4/Firmware/pull/9362","diff_url":"https://github.com/PX4/Firmware/pull/9362.diff","patch_url":"https://github.com/PX4/Firmware/pull/9362.patch","issue_url":"https://api.github.com/repos/PX4/Firmware/issues/9362","number":9362,"state":"open","locked":false,"title":"Sketch for ICM20948 integration into MPU9250 driver.","user":{"login":"flochir","id":38494856,"node_id":"MDQ6VXNlcjM4NDk0ODU2","avatar_url":"https://avatars2.githubusercontent.com/u/38494856?v=4","gravatar_id":"","url":"https://api.github.com/users/flochir","html_url":"https://github.com/flochir","followers_url":"https://api.github.com/users/flochir/followers","following_url":"https://api.github.com/users/flochir/following{/other_user}","gists_url":"https://api.github.com/users/flochir/gists{/gist_id}","starred_url":"https://api.github.com/users/flochir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flochir/subscriptions","organizations_url":"https://api.github.com/users/flochir/orgs","repos_url":"https://api.github.com/users/flochir/repos","events_url":"https://api.github.com/users/flochir/events{/privacy}","received_events_url":"https://api.github.com/users/flochir/received_events","type":"User","site_admin":false},"body":"Hello again!\nI sketched out an approach to adding support for ICM20948 to the MPU9250 driver as suggested (#9345, #8624). Here it is (far from functional, mind you).\nIf you agree that this is a good path to follow, I will continue with this.\nThe changes with the biggest impact on the original MPU9250 driver parts should be done. It builds and the driver seems to be running OK with MPU9250 on my Pixhawk 2.1.\n\nOutline of the changes/thoughts:\nThe ICM20948 not only uses different register addresses, but spreads them over 4 banks of registers. So to access a particular register, one has to first select the containing bank by writing to the BANK_SEL register.\nThis would actually not be needed to only support the magnetometer (writes to default bank 0 suffice), but adding the gyro and accel and generally supporting the device needs this. I could just hack in magnetometer support, but I guess full support would be nice. Or is this superfluous?\n\nSo I started to add multiple device support analogous to MPU6000.\n\nThe additional information about the register banks I have added by expanding the register definitions for ICM20948 to 16 bit and using the lower two bits of the MSB. All the write/read functions take 16 bit register addresses anyway and use bit 0x8000 to encode bus speed.\nI added a bit of code to the read and write functions which should make this work transparently for the rest of the code (just using 8/16 bit addresses).\nI had also played with a lookup table for register/bank pairs but this keeps the definitions more in one place and is probably a bit more memory efficient.\n\nBest, Flochir","created_at":"2018-04-23T22:29:05Z","updated_at":"2018-06-06T21:09:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2302d4a4bb8ce2caa8182382fc7ab7b0deb2d267","assignee":{"login":"bkueng","id":281593,"node_id":"MDQ6VXNlcjI4MTU5Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/281593?v=4","gravatar_id":"","url":"https://api.github.com/users/bkueng","html_url":"https://github.com/bkueng","followers_url":"https://api.github.com/users/bkueng/followers","following_url":"https://api.github.com/users/bkueng/following{/other_user}","gists_url":"https://api.github.com/users/bkueng/gists{/gist_id}","starred_url":"https://api.github.com/users/bkueng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkueng/subscriptions","organizations_url":"https://api.github.com/users/bkueng/orgs","repos_url":"https://api.github.com/users/bkueng/repos","events_url":"https://api.github.com/users/bkueng/events{/privacy}","received_events_url":"https://api.github.com/users/bkueng/received_events","type":"User","site_admin":false},"assignees":[{"login":"bkueng","id":281593,"node_id":"MDQ6VXNlcjI4MTU5Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/281593?v=4","gravatar_id":"","url":"https://api.github.com/users/bkueng","html_url":"https://github.com/bkueng","followers_url":"https://api.github.com/users/bkueng/followers","following_url":"https://api.github.com/users/bkueng/following{/other_user}","gists_url":"https://api.github.com/users/bkueng/gists{/gist_id}","starred_url":"https://api.github.com/users/bkueng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkueng/subscriptions","organizations_url":"https://api.github.com/users/bkueng/orgs","repos_url":"https://api.github.com/users/bkueng/repos","events_url":"https://api.github.com/users/bkueng/events{/privacy}","received_events_url":"https://api.github.com/users/bkueng/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/PX4/Firmware/pulls/9362/commits","review_comments_url":"https://api.github.com/repos/PX4/Firmware/pulls/9362/comments","review_comment_url":"https://api.github.com/repos/PX4/Firmware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PX4/Firmware/issues/9362/comments","statuses_url":"https://api.github.com/repos/PX4/Firmware/statuses/bebd7f886109e5f5d1dc830efd28917c4e826a50","head":{"label":"flochir:icm20948_discussion2","ref":"icm20948_discussion2","sha":"bebd7f886109e5f5d1dc830efd28917c4e826a50","user":{"login":"flochir","id":38494856,"node_id":"MDQ6VXNlcjM4NDk0ODU2","avatar_url":"https://avatars2.githubusercontent.com/u/38494856?v=4","gravatar_id":"","url":"https://api.github.com/users/flochir","html_url":"https://github.com/flochir","followers_url":"https://api.github.com/users/flochir/followers","following_url":"https://api.github.com/users/flochir/following{/other_user}","gists_url":"https://api.github.com/users/flochir/gists{/gist_id}","starred_url":"https://api.github.com/users/flochir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flochir/subscriptions","organizations_url":"https://api.github.com/users/flochir/orgs","repos_url":"https://api.github.com/users/flochir/repos","events_url":"https://api.github.com/users/flochir/events{/privacy}","received_events_url":"https://api.github.com/users/flochir/received_events","type":"User","site_admin":false},"repo":{"id":130268778,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAyNjg3Nzg=","name":"Firmware","full_name":"flochir/Firmware","owner":{"login":"flochir","id":38494856,"node_id":"MDQ6VXNlcjM4NDk0ODU2","avatar_url":"https://avatars2.githubusercontent.com/u/38494856?v=4","gravatar_id":"","url":"https://api.github.com/users/flochir","html_url":"https://github.com/flochir","followers_url":"https://api.github.com/users/flochir/followers","following_url":"https://api.github.com/users/flochir/following{/other_user}","gists_url":"https://api.github.com/users/flochir/gists{/gist_id}","starred_url":"https://api.github.com/users/flochir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flochir/subscriptions","organizations_url":"https://api.github.com/users/flochir/orgs","repos_url":"https://api.github.com/users/flochir/repos","events_url":"https://api.github.com/users/flochir/events{/privacy}","received_events_url":"https://api.github.com/users/flochir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/flochir/Firmware","description":"PX4 Pro Autopilot Software","fork":true,"url":"https://api.github.com/repos/flochir/Firmware","forks_url":"https://api.github.com/repos/flochir/Firmware/forks","keys_url":"https://api.github.com/repos/flochir/Firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flochir/Firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flochir/Firmware/teams","hooks_url":"https://api.github.com/repos/flochir/Firmware/hooks","issue_events_url":"https://api.github.com/repos/flochir/Firmware/issues/events{/number}","events_url":"https://api.github.com/repos/flochir/Firmware/events","assignees_url":"https://api.github.com/repos/flochir/Firmware/assignees{/user}","branches_url":"https://api.github.com/repos/flochir/Firmware/branches{/branch}","tags_url":"https://api.github.com/repos/flochir/Firmware/tags","blobs_url":"https://api.github.com/repos/flochir/Firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flochir/Firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flochir/Firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/flochir/Firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flochir/Firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/flochir/Firmware/languages","stargazers_url":"https://api.github.com/repos/flochir/Firmware/stargazers","contributors_url":"https://api.github.com/repos/flochir/Firmware/contributors","subscribers_url":"https://api.github.com/repos/flochir/Firmware/subscribers","subscription_url":"https://api.github.com/repos/flochir/Firmware/subscription","commits_url":"https://api.github.com/repos/flochir/Firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/flochir/Firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/flochir/Firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/flochir/Firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/flochir/Firmware/contents/{+path}","compare_url":"https://api.github.com/repos/flochir/Firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flochir/Firmware/merges","archive_url":"https://api.github.com/repos/flochir/Firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flochir/Firmware/downloads","issues_url":"https://api.github.com/repos/flochir/Firmware/issues{/number}","pulls_url":"https://api.github.com/repos/flochir/Firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/flochir/Firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/flochir/Firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flochir/Firmware/labels{/name}","releases_url":"https://api.github.com/repos/flochir/Firmware/releases{/id}","deployments_url":"https://api.github.com/repos/flochir/Firmware/deployments","created_at":"2018-04-19T20:24:44Z","updated_at":"2018-04-20T08:24:34Z","pushed_at":"2018-06-05T12:35:00Z","git_url":"git://github.com/flochir/Firmware.git","ssh_url":"git@github.com:flochir/Firmware.git","clone_url":"https://github.com/flochir/Firmware.git","svn_url":"https://github.com/flochir/Firmware","homepage":"http://px4.io","size":98681,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"PX4:master","ref":"master","sha":"ca5e22583f9dd81852856a9169523d8135b81db6","user":{"login":"PX4","id":2096014,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTYwMTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2096014?v=4","gravatar_id":"","url":"https://api.github.com/users/PX4","html_url":"https://github.com/PX4","followers_url":"https://api.github.com/users/PX4/followers","following_url":"https://api.github.com/users/PX4/following{/other_user}","gists_url":"https://api.github.com/users/PX4/gists{/gist_id}","starred_url":"https://api.github.com/users/PX4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PX4/subscriptions","organizations_url":"https://api.github.com/users/PX4/orgs","repos_url":"https://api.github.com/users/PX4/repos","events_url":"https://api.github.com/users/PX4/events{/privacy}","received_events_url":"https://api.github.com/users/PX4/received_events","type":"Organization","site_admin":false},"repo":{"id":5298790,"node_id":"MDEwOlJlcG9zaXRvcnk1Mjk4Nzkw","name":"Firmware","full_name":"PX4/Firmware","owner":{"login":"PX4","id":2096014,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTYwMTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2096014?v=4","gravatar_id":"","url":"https://api.github.com/users/PX4","html_url":"https://github.com/PX4","followers_url":"https://api.github.com/users/PX4/followers","following_url":"https://api.github.com/users/PX4/following{/other_user}","gists_url":"https://api.github.com/users/PX4/gists{/gist_id}","starred_url":"https://api.github.com/users/PX4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PX4/subscriptions","organizations_url":"https://api.github.com/users/PX4/orgs","repos_url":"https://api.github.com/users/PX4/repos","events_url":"https://api.github.com/users/PX4/events{/privacy}","received_events_url":"https://api.github.com/users/PX4/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PX4/Firmware","description":"PX4 Pro Autopilot Software","fork":false,"url":"https://api.github.com/repos/PX4/Firmware","forks_url":"https://api.github.com/repos/PX4/Firmware/forks","keys_url":"https://api.github.com/repos/PX4/Firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PX4/Firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PX4/Firmware/teams","hooks_url":"https://api.github.com/repos/PX4/Firmware/hooks","issue_events_url":"https://api.github.com/repos/PX4/Firmware/issues/events{/number}","events_url":"https://api.github.com/repos/PX4/Firmware/events","assignees_url":"https://api.github.com/repos/PX4/Firmware/assignees{/user}","branches_url":"https://api.github.com/repos/PX4/Firmware/branches{/branch}","tags_url":"https://api.github.com/repos/PX4/Firmware/tags","blobs_url":"https://api.github.com/repos/PX4/Firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PX4/Firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PX4/Firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/PX4/Firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PX4/Firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/PX4/Firmware/languages","stargazers_url":"https://api.github.com/repos/PX4/Firmware/stargazers","contributors_url":"https://api.github.com/repos/PX4/Firmware/contributors","subscribers_url":"https://api.github.com/repos/PX4/Firmware/subscribers","subscription_url":"https://api.github.com/repos/PX4/Firmware/subscription","commits_url":"https://api.github.com/repos/PX4/Firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/PX4/Firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/PX4/Firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/PX4/Firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/PX4/Firmware/contents/{+path}","compare_url":"https://api.github.com/repos/PX4/Firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PX4/Firmware/merges","archive_url":"https://api.github.com/repos/PX4/Firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PX4/Firmware/downloads","issues_url":"https://api.github.com/repos/PX4/Firmware/issues{/number}","pulls_url":"https://api.github.com/repos/PX4/Firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/PX4/Firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/PX4/Firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PX4/Firmware/labels{/name}","releases_url":"https://api.github.com/repos/PX4/Firmware/releases{/id}","deployments_url":"https://api.github.com/repos/PX4/Firmware/deployments","created_at":"2012-08-04T21:19:36Z","updated_at":"2018-06-06T21:03:56Z","pushed_at":"2018-06-06T21:03:35Z","git_url":"git://github.com/PX4/Firmware.git","ssh_url":"git@github.com:PX4/Firmware.git","clone_url":"https://github.com/PX4/Firmware.git","svn_url":"https://github.com/PX4/Firmware","homepage":"http://px4.io","size":99826,"stargazers_count":1751,"watchers_count":1751,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5129,"mirror_url":null,"archived":false,"open_issues_count":445,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":5129,"open_issues":445,"watchers":1751,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PX4/Firmware/pulls/9362"},"html":{"href":"https://github.com/PX4/Firmware/pull/9362"},"issue":{"href":"https://api.github.com/repos/PX4/Firmware/issues/9362"},"comments":{"href":"https://api.github.com/repos/PX4/Firmware/issues/9362/comments"},"review_comments":{"href":"https://api.github.com/repos/PX4/Firmware/pulls/9362/comments"},"review_comment":{"href":"https://api.github.com/repos/PX4/Firmware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PX4/Firmware/pulls/9362/commits"},"statuses":{"href":"https://api.github.com/repos/PX4/Firmware/statuses/bebd7f886109e5f5d1dc830efd28917c4e826a50"}},"author_association":"NONE"}}
{"actor":{"display_login":"DanielePettenuzzo"}}