{"action":"closed","number":51,"pull_request":{"url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/51","id":264290798,"node_id":"MDExOlB1bGxSZXF1ZXN0MjY0MjkwNzk4","html_url":"https://github.com/stm32-rs/stm32f1xx-hal/pull/51","diff_url":"https://github.com/stm32-rs/stm32f1xx-hal/pull/51.diff","patch_url":"https://github.com/stm32-rs/stm32f1xx-hal/pull/51.patch","issue_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues/51","number":51,"state":"closed","locked":false,"title":"RFC: add support for ADC","user":{"login":"geomatsi","id":619979,"node_id":"MDQ6VXNlcjYxOTk3OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/619979?v=4","gravatar_id":"","url":"https://api.github.com/users/geomatsi","html_url":"https://github.com/geomatsi","followers_url":"https://api.github.com/users/geomatsi/followers","following_url":"https://api.github.com/users/geomatsi/following{/other_user}","gists_url":"https://api.github.com/users/geomatsi/gists{/gist_id}","starred_url":"https://api.github.com/users/geomatsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geomatsi/subscriptions","organizations_url":"https://api.github.com/users/geomatsi/orgs","repos_url":"https://api.github.com/users/geomatsi/repos","events_url":"https://api.github.com/users/geomatsi/events{/privacy}","received_events_url":"https://api.github.com/users/geomatsi/received_events","type":"User","site_admin":false},"body":"Summary\r\n-------------\r\n\r\nThis PR adds the following bits:\r\n- implement ADC clock configuration in rcc module\r\n- implement ADC support, including multiple ADC blocks\r\n- add ADC example\r\n\r\nThis PR is based on #19 by @TheZoq2 . As per request from @therealprof , it has been reworked following stm32f0x ADC implementation. Besides, some implementation details follow stm32f4x ADC implementation.\r\n\r\nLimitations\r\n-------------\r\n1. Basic one-shot support only: similar to what we have in stm32f0x, but not in stm32f4xx\r\n2. No dual ADC mode support when 2 ADC blocks are available\r\n3. No fool proof against using the same channel in two ADC blocks.\r\n\r\nImplementation notes\r\n-------------\r\n1. Split of ADC implementation to simplify review\r\nTo simplify review, ADC implementation is split into the following two parts: \r\n   - 2nd commit: implement one-shot support for ADC1 only\r\n   - 3rd commit: use rust macros to support multiple ADC blocks (including gpio channel assignment) w/o functional changes to ADC handling code\r\n2. Hardware support\r\nCurrent implementation enables the following ADC blocks:\r\n   - the only available ADC1 for both stm32f100 and stm32f101\r\n   - both ADC1 and ADC2 available on medium-density stm32f103 chips\r\n3. Support for a more capable stm32f10x chips\r\nNote that XL-density stm32f103 chips support ADC3 as well. Besides, gpio-to-channel mapping is different on those chips. Meanwhile it can be also embraced by suggested implementation. For instance, something like the following should work: \r\n```\r\n#[cfg(feature = \"stm32f103XL\")]\r\nadc_pins!(ADC1,\r\n    gpioa::PA0<Analog> => 0_u8,\r\n    gpioa::PA1<Analog> => 1_u8,\r\n    gpioa::PA2<Analog> => 2_u8,\r\n    gpioa::PA3<Analog> => 3_u8,\r\n    gpioa::PA4<Analog> => 4_u8,\r\n    gpioa::PA5<Analog> => 5_u8,\r\n    gpioa::PA6<Analog> => 6_u8,\r\n    gpioa::PA7<Analog> => 7_u8,\r\n    gpiob::PB0<Analog> => 8_u8,\r\n    gpiob::PB1<Analog> => 9_u8,\r\n    gpioc::PC0<Analog> => 10_u8,\r\n    gpioc::PC1<Analog> => 11_u8,\r\n    gpioc::PC2<Analog> => 12_u8,\r\n    gpioc::PC3<Analog> => 13_u8,\r\n    gpioc::PC4<Analog> => 14_u8,\r\n    gpioc::PC5<Analog> => 15_u8,\r\n);\r\n\r\n#[cfg(feature = \"stm32f103XL\")]\r\nadc_pins!(ADC3,\r\n    gpioa::PA0<Analog> => 0_u8,\r\n    gpioa::PA1<Analog> => 1_u8,\r\n    gpioa::PA2<Analog> => 2_u8,\r\n    gpioa::PA3<Analog> => 3_u8,\r\n    gpioa::PA4<Analog> => 4_u8,\r\n    gpioa::PA5<Analog> => 5_u8,\r\n    gpioa::PA6<Analog> => 6_u8,\r\n    gpioa::PA7<Analog> => 7_u8,\r\n    gpiob::PB0<Analog> => 8_u8,\r\n    gpiob::PB1<Analog> => 9_u8,\r\n    gpioc::PC0<Analog> => 10_u8,\r\n    gpioc::PC1<Analog> => 11_u8,\r\n    gpioc::PC2<Analog> => 12_u8,\r\n    gpioc::PC3<Analog> => 13_u8,\r\n    gpioc::PC4<Analog> => 14_u8,\r\n    gpioc::PC5<Analog> => 15_u8,\r\n);\r\n\r\n#[cfg(feature = \"stm32f103XL\")]\r\nadc_pins!(ADC3,\r\n    gpioa::PA0<Analog> => 0_u8,\r\n    gpioa::PA1<Analog> => 1_u8,\r\n    gpioa::PA2<Analog> => 2_u8,\r\n    gpioa::PA3<Analog> => 3_u8,\r\n    gpiof::PF6<Analog> => 4_u8,\r\n    gpiof::PF7<Analog> => 5_u8,\r\n    gpiof::PF8<Analog> => 6_u8,\r\n    gpiof::PF9<Analog> => 7_u8,\r\n    gpiof::PF10<Analog> => 8_u8,\r\n    gpioc::PC0<Analog> => 10_u8,\r\n    gpioc::PC1<Analog> => 11_u8,\r\n    gpioc::PC2<Analog> => 12_u8,\r\n    gpioc::PC3<Analog> => 13_u8,\r\n);\r\n\r\n#[cfg(feature = \"stm32f103XL\")]\r\nadc_hal! {\r\n    ADC1: (\r\n        adc1,\r\n        adc1en,\r\n        adc1rst\r\n    ),\r\n    ADC2: (\r\n        adc2,\r\n        adc2en,\r\n        adc2rst\r\n    ),\r\n    ADC3: (\r\n        adc3,\r\n        adc3en,\r\n        adc3rst\r\n    ),\r\n}\r\n```","created_at":"2019-03-25T21:14:44Z","updated_at":"2019-03-28T19:23:58Z","closed_at":"2019-03-28T19:23:57Z","merged_at":"2019-03-28T19:23:57Z","merge_commit_sha":"3b78e6b2996a55f74db4ef834a73f4381e9b08c2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/51/commits","review_comments_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/51/comments","review_comment_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues/51/comments","statuses_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/statuses/642abbfb684fc289c57c86c5dcd80ba51cbb16fb","head":{"label":"geomatsi:adc-wip","ref":"adc-wip","sha":"642abbfb684fc289c57c86c5dcd80ba51cbb16fb","user":{"login":"geomatsi","id":619979,"node_id":"MDQ6VXNlcjYxOTk3OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/619979?v=4","gravatar_id":"","url":"https://api.github.com/users/geomatsi","html_url":"https://github.com/geomatsi","followers_url":"https://api.github.com/users/geomatsi/followers","following_url":"https://api.github.com/users/geomatsi/following{/other_user}","gists_url":"https://api.github.com/users/geomatsi/gists{/gist_id}","starred_url":"https://api.github.com/users/geomatsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geomatsi/subscriptions","organizations_url":"https://api.github.com/users/geomatsi/orgs","repos_url":"https://api.github.com/users/geomatsi/repos","events_url":"https://api.github.com/users/geomatsi/events{/privacy}","received_events_url":"https://api.github.com/users/geomatsi/received_events","type":"User","site_admin":false},"repo":{"id":176150179,"node_id":"MDEwOlJlcG9zaXRvcnkxNzYxNTAxNzk=","name":"stm32f1xx-hal","full_name":"geomatsi/stm32f1xx-hal","private":false,"owner":{"login":"geomatsi","id":619979,"node_id":"MDQ6VXNlcjYxOTk3OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/619979?v=4","gravatar_id":"","url":"https://api.github.com/users/geomatsi","html_url":"https://github.com/geomatsi","followers_url":"https://api.github.com/users/geomatsi/followers","following_url":"https://api.github.com/users/geomatsi/following{/other_user}","gists_url":"https://api.github.com/users/geomatsi/gists{/gist_id}","starred_url":"https://api.github.com/users/geomatsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geomatsi/subscriptions","organizations_url":"https://api.github.com/users/geomatsi/orgs","repos_url":"https://api.github.com/users/geomatsi/repos","events_url":"https://api.github.com/users/geomatsi/events{/privacy}","received_events_url":"https://api.github.com/users/geomatsi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/geomatsi/stm32f1xx-hal","description":"[WIP] A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal","fork":true,"url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal","forks_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/forks","keys_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/teams","hooks_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/hooks","issue_events_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/issues/events{/number}","events_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/events","assignees_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/assignees{/user}","branches_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/branches{/branch}","tags_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/tags","blobs_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/git/refs{/sha}","trees_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/statuses/{sha}","languages_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/languages","stargazers_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/stargazers","contributors_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/contributors","subscribers_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/subscribers","subscription_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/subscription","commits_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/commits{/sha}","git_commits_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/git/commits{/sha}","comments_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/comments{/number}","issue_comment_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/issues/comments{/number}","contents_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/contents/{+path}","compare_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/merges","archive_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/downloads","issues_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/issues{/number}","pulls_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/pulls{/number}","milestones_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/milestones{/number}","notifications_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/labels{/name}","releases_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/releases{/id}","deployments_url":"https://api.github.com/repos/geomatsi/stm32f1xx-hal/deployments","created_at":"2019-03-17T19:31:58Z","updated_at":"2019-03-22T19:45:12Z","pushed_at":"2019-03-26T20:22:50Z","git_url":"git://github.com/geomatsi/stm32f1xx-hal.git","ssh_url":"git@github.com:geomatsi/stm32f1xx-hal.git","clone_url":"https://github.com/geomatsi/stm32f1xx-hal.git","svn_url":"https://github.com/geomatsi/stm32f1xx-hal","homepage":"","size":120,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"stm32-rs:master","ref":"master","sha":"c7a575082481a5724e81d925580bea96241577bc","user":{"login":"stm32-rs","id":44086113,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDg2MTEz","avatar_url":"https://avatars3.githubusercontent.com/u/44086113?v=4","gravatar_id":"","url":"https://api.github.com/users/stm32-rs","html_url":"https://github.com/stm32-rs","followers_url":"https://api.github.com/users/stm32-rs/followers","following_url":"https://api.github.com/users/stm32-rs/following{/other_user}","gists_url":"https://api.github.com/users/stm32-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/stm32-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stm32-rs/subscriptions","organizations_url":"https://api.github.com/users/stm32-rs/orgs","repos_url":"https://api.github.com/users/stm32-rs/repos","events_url":"https://api.github.com/users/stm32-rs/events{/privacy}","received_events_url":"https://api.github.com/users/stm32-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":161557523,"node_id":"MDEwOlJlcG9zaXRvcnkxNjE1NTc1MjM=","name":"stm32f1xx-hal","full_name":"stm32-rs/stm32f1xx-hal","private":false,"owner":{"login":"stm32-rs","id":44086113,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ0MDg2MTEz","avatar_url":"https://avatars3.githubusercontent.com/u/44086113?v=4","gravatar_id":"","url":"https://api.github.com/users/stm32-rs","html_url":"https://github.com/stm32-rs","followers_url":"https://api.github.com/users/stm32-rs/followers","following_url":"https://api.github.com/users/stm32-rs/following{/other_user}","gists_url":"https://api.github.com/users/stm32-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/stm32-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stm32-rs/subscriptions","organizations_url":"https://api.github.com/users/stm32-rs/orgs","repos_url":"https://api.github.com/users/stm32-rs/repos","events_url":"https://api.github.com/users/stm32-rs/events{/privacy}","received_events_url":"https://api.github.com/users/stm32-rs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stm32-rs/stm32f1xx-hal","description":"[WIP] A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal","fork":false,"url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal","forks_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/forks","keys_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/teams","hooks_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/hooks","issue_events_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues/events{/number}","events_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/events","assignees_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/assignees{/user}","branches_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/branches{/branch}","tags_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/tags","blobs_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/git/refs{/sha}","trees_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/statuses/{sha}","languages_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/languages","stargazers_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/stargazers","contributors_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/contributors","subscribers_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/subscribers","subscription_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/subscription","commits_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/commits{/sha}","git_commits_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/git/commits{/sha}","comments_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/comments{/number}","issue_comment_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues/comments{/number}","contents_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/contents/{+path}","compare_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/merges","archive_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/downloads","issues_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues{/number}","pulls_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls{/number}","milestones_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/milestones{/number}","notifications_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/labels{/name}","releases_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/releases{/id}","deployments_url":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/deployments","created_at":"2018-12-12T23:24:52Z","updated_at":"2019-03-22T20:14:00Z","pushed_at":"2019-03-28T19:23:57Z","git_url":"git://github.com/stm32-rs/stm32f1xx-hal.git","ssh_url":"git@github.com:stm32-rs/stm32f1xx-hal.git","clone_url":"https://github.com/stm32-rs/stm32f1xx-hal.git","svn_url":"https://github.com/stm32-rs/stm32f1xx-hal","homepage":"","size":107,"stargazers_count":34,"watchers_count":34,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":20,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":15,"open_issues":20,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/51"},"html":{"href":"https://github.com/stm32-rs/stm32f1xx-hal/pull/51"},"issue":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues/51"},"comments":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/stm32-rs/stm32f1xx-hal/statuses/642abbfb684fc289c57c86c5dcd80ba51cbb16fb"}},"author_association":"CONTRIBUTOR","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"TheZoq2","id":5312813,"node_id":"MDQ6VXNlcjUzMTI4MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/5312813?v=4","gravatar_id":"","url":"https://api.github.com/users/TheZoq2","html_url":"https://github.com/TheZoq2","followers_url":"https://api.github.com/users/TheZoq2/followers","following_url":"https://api.github.com/users/TheZoq2/following{/other_user}","gists_url":"https://api.github.com/users/TheZoq2/gists{/gist_id}","starred_url":"https://api.github.com/users/TheZoq2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheZoq2/subscriptions","organizations_url":"https://api.github.com/users/TheZoq2/orgs","repos_url":"https://api.github.com/users/TheZoq2/repos","events_url":"https://api.github.com/users/TheZoq2/events{/privacy}","received_events_url":"https://api.github.com/users/TheZoq2/received_events","type":"User","site_admin":false},"comments":5,"review_comments":16,"maintainer_can_modify":false,"commits":4,"additions":518,"deletions":2,"changed_files":6}}
{"actor":{"display_login":"TheZoq2"}}