{"action":"created","comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/31419258","id":31419258,"diff_hunk":"@@ -151,109 +61,103 @@ typedef enum {\n } gpio_flank_t;\n \n /**\n- * @brief Signature for function called from interrupt context after an external event\n- *\n- * @param[in] arg       optional context for the callback\n- */\n-typedef void (*gpio_cb_t)(void *arg);\n-\n-/**\n- * @brief Initialize GPIO pin as output pin\n+ * @brief   Initialize the given pin as general purpose input or output\n  *\n- * @param[in] dev       the GPIO pin to set as output\n- * @param[in] pullup    define if pull resistors should be used\n+ * @param[in] pin       pin to initialize\n+ * @param[in] dir       direction for the pin, input or output\n+ * @param[in] pullup    define what pull resistors should be used\n  *\n  * @return              0 on success\n- * @return              -1 on pull-up mode unavailable\n+ * @return              -1 on error\n  */\n-int gpio_init_out(gpio_t dev, gpio_pp_t pullup);\n+int gpio_init(gpio_t pin, gpio_dir_t dir, gpio_pp_t pullup);\n \n /**\n- * @brief Initialize a GPIO pin in input mode\n+ * @brief   Initialize a GPIO pin for external interrupt usage\n  *\n- * @param[in] dev       the GPIO pin to use as input\n- * @param[in] pullup    define if pull resistors should be used\n+ * The registered callback function will be called in interrupt context every\n+ * time the defined flank(s) are detected.\n+ *\n+ * The interrupt is activated automatically after the initialization.\n+ *\n+ * @param[in] pin       pin to initialize\n+ * @param[in] pullup    define what pull resistors should be enabled\n+ * @param[in] flank     define the active flank(s)\n+ * @param[in] cb        callback that is called from interrupt context\n+ * @param[in] arg       optional argument passed to the callback\n  *\n  * @return              0 on success\n- * @return              -1 on pull-up mode unavailable\n+ * @return              -1 on error\n  */\n-int gpio_init_in(gpio_t dev, gpio_pp_t pullup);\n+int gpio_init_exti(gpio_t pin, gpio_pp_t pullup, gpio_flank_t flank,","path":"drivers/include/periph/gpio.h","position":197,"original_position":197,"commit_id":"92903add60ea3fb6c9725ee052b316d020878810","original_commit_id":"81db1229cd5aaefa80f3fd06622d10e885f4822b","user":{"login":"PeterKietzmann","id":7765855,"avatar_url":"https://avatars.githubusercontent.com/u/7765855?v=3","gravatar_id":"","url":"https://api.github.com/users/PeterKietzmann","html_url":"https://github.com/PeterKietzmann","followers_url":"https://api.github.com/users/PeterKietzmann/followers","following_url":"https://api.github.com/users/PeterKietzmann/following{/other_user}","gists_url":"https://api.github.com/users/PeterKietzmann/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterKietzmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterKietzmann/subscriptions","organizations_url":"https://api.github.com/users/PeterKietzmann/orgs","repos_url":"https://api.github.com/users/PeterKietzmann/repos","events_url":"https://api.github.com/users/PeterKietzmann/events{/privacy}","received_events_url":"https://api.github.com/users/PeterKietzmann/received_events","type":"User","site_admin":false},"body":"When starting to touch so many things I'd also argue pro `gpio_init_exti`. I think this semantic is used more often and prevents to be misread.","created_at":"2015-06-01T12:06:05Z","updated_at":"2015-06-01T12:06:05Z","html_url":"https://github.com/RIOT-OS/RIOT/pull/3095#discussion_r31419258","pull_request_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095","_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/31419258"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/3095#discussion_r31419258"},"pull_request":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095"}}},"pull_request":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095","id":36328469,"html_url":"https://github.com/RIOT-OS/RIOT/pull/3095","diff_url":"https://github.com/RIOT-OS/RIOT/pull/3095.diff","patch_url":"https://github.com/RIOT-OS/RIOT/pull/3095.patch","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3095","number":3095,"state":"open","locked":false,"title":"drivers/gpio: changed periph driver interface","user":{"login":"haukepetersen","id":620834,"avatar_url":"https://avatars.githubusercontent.com/u/620834?v=3","gravatar_id":"","url":"https://api.github.com/users/haukepetersen","html_url":"https://github.com/haukepetersen","followers_url":"https://api.github.com/users/haukepetersen/followers","following_url":"https://api.github.com/users/haukepetersen/following{/other_user}","gists_url":"https://api.github.com/users/haukepetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/haukepetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haukepetersen/subscriptions","organizations_url":"https://api.github.com/users/haukepetersen/orgs","repos_url":"https://api.github.com/users/haukepetersen/repos","events_url":"https://api.github.com/users/haukepetersen/events{/privacy}","received_events_url":"https://api.github.com/users/haukepetersen/received_events","type":"User","site_admin":false},"body":"After talking a lot with @kaspar030, we decided to give the peripheral driver a little overhaul to make them more efficient and portable. In this effort, the GPIO driver is the first I touched.\r\n\r\nThe main motivation behind this is to allow for more efficient implementation through more control on a platform to platform level. The most important difference is, that CPUs have now to define the peripheral device types (i.e. `gpio_t`, `spi_t`, etc.). This allows platforms for example to use base register addresses as peripheral identifiers directly, making these very ugly (and huge) swith-case structures superfluous in many times.\r\n\r\nAnother important change for the GPIO driver: Now are all pins accessible and it is not needed anymore to define them in the `periph_conf.h`. \r\n\r\nSummarized the changes tot he GPIO peripheral driver interface:\r\n\r\n- all CPU pins are accessible\r\n- `gpio_t` type must be defined by the CPU\r\n- `gpio_init_out()` and `gpio_init_in()` are merged into a single function\r\n- `gpio_init_int()` is renamed to `gpio_init_exti()` (I regularly read `in` instead of `int` -> this won't happy with this change...)\r\n- a new function for configuration the internal pin multiplexing, `gpio_init_mux()` for internal use only was added. This will make other peripheral drivers easier to implement/make their code easier to read\r\n\r\nTo make the migration to this change interface easier, I added a compatibility header, that still allows for the known `gpio_t` type. To make all existing code work with the new interface, these steps have to be done:\r\n\r\n- rename `gpio_init_int()` to `gpio_init_exti()`\r\n- join `gpio_init_out` and `gpio_init_int()`\r\n- add a file called `periph_cpu.h` to `CPU/include/` and add `#include \"periph/compat.h\" to this file\r\n\r\n\r\nThe plan is to agree on the interface and make all CPUs work with the new interface through the compatiblity layer as first step. As second step we would need to improve all GPIO implementations, but this can then be done step-by-step.\r\n\r\nContents of this PR so far:\r\n\r\n- the changed gpio interface (`drivers/include/periph/gpio.h`)\r\n- the compatiblity header (`drivers/include/periph/compat.h`)\r\n- new improved, slimmer and better GPIO implementations for the `samd21`, `nrf51822`, and the `stm32f4`\r\n- the `iot-lab_M3` (`stm32f1`) works already through the compat header\r\n- all device drivers are adjusted\r\n- a new GPIO test application\r\n\r\nAs you can see, the code is much much much more easy to read and way smaller (~1kB on the `stm32f4`) by offering more functionality...\r\n\r\nI will adapt all effected CPUs once the new Interface is ACKed (and help with this is very welcome...).","created_at":"2015-05-27T17:32:46Z","updated_at":"2015-06-01T12:06:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84225f26be56ce1aa0c1cc2aca53c1ada0faf5aa","assignee":{"login":"gebart","id":317506,"avatar_url":"https://avatars.githubusercontent.com/u/317506?v=3","gravatar_id":"","url":"https://api.github.com/users/gebart","html_url":"https://github.com/gebart","followers_url":"https://api.github.com/users/gebart/followers","following_url":"https://api.github.com/users/gebart/following{/other_user}","gists_url":"https://api.github.com/users/gebart/gists{/gist_id}","starred_url":"https://api.github.com/users/gebart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gebart/subscriptions","organizations_url":"https://api.github.com/users/gebart/orgs","repos_url":"https://api.github.com/users/gebart/repos","events_url":"https://api.github.com/users/gebart/events{/privacy}","received_events_url":"https://api.github.com/users/gebart/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/12","html_url":"https://github.com/RIOT-OS/RIOT/milestones/Release%202015.06","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/12/labels","id":1088995,"number":12,"title":"Release 2015.06","description":"This release aims mainly to include the brand new network stack.","creator":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"open_issues":66,"closed_issues":117,"state":"open","created_at":"2015-04-29T10:11:27Z","updated_at":"2015-06-01T08:55:30Z","due_on":"2015-06-02T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095/commits","review_comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095/comments","review_comment_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3095/comments","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/92903add60ea3fb6c9725ee052b316d020878810","head":{"label":"haukepetersen:opt_gpio","ref":"opt_gpio","sha":"92903add60ea3fb6c9725ee052b316d020878810","user":{"login":"haukepetersen","id":620834,"avatar_url":"https://avatars.githubusercontent.com/u/620834?v=3","gravatar_id":"","url":"https://api.github.com/users/haukepetersen","html_url":"https://github.com/haukepetersen","followers_url":"https://api.github.com/users/haukepetersen/followers","following_url":"https://api.github.com/users/haukepetersen/following{/other_user}","gists_url":"https://api.github.com/users/haukepetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/haukepetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haukepetersen/subscriptions","organizations_url":"https://api.github.com/users/haukepetersen/orgs","repos_url":"https://api.github.com/users/haukepetersen/repos","events_url":"https://api.github.com/users/haukepetersen/events{/privacy}","received_events_url":"https://api.github.com/users/haukepetersen/received_events","type":"User","site_admin":false},"repo":{"id":13741766,"name":"RIOT","full_name":"haukepetersen/RIOT","owner":{"login":"haukepetersen","id":620834,"avatar_url":"https://avatars.githubusercontent.com/u/620834?v=3","gravatar_id":"","url":"https://api.github.com/users/haukepetersen","html_url":"https://github.com/haukepetersen","followers_url":"https://api.github.com/users/haukepetersen/followers","following_url":"https://api.github.com/users/haukepetersen/following{/other_user}","gists_url":"https://api.github.com/users/haukepetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/haukepetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haukepetersen/subscriptions","organizations_url":"https://api.github.com/users/haukepetersen/orgs","repos_url":"https://api.github.com/users/haukepetersen/repos","events_url":"https://api.github.com/users/haukepetersen/events{/privacy}","received_events_url":"https://api.github.com/users/haukepetersen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/haukepetersen/RIOT","description":"RIOT OS -  The revolutionary IoT OS","fork":true,"url":"https://api.github.com/repos/haukepetersen/RIOT","forks_url":"https://api.github.com/repos/haukepetersen/RIOT/forks","keys_url":"https://api.github.com/repos/haukepetersen/RIOT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haukepetersen/RIOT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haukepetersen/RIOT/teams","hooks_url":"https://api.github.com/repos/haukepetersen/RIOT/hooks","issue_events_url":"https://api.github.com/repos/haukepetersen/RIOT/issues/events{/number}","events_url":"https://api.github.com/repos/haukepetersen/RIOT/events","assignees_url":"https://api.github.com/repos/haukepetersen/RIOT/assignees{/user}","branches_url":"https://api.github.com/repos/haukepetersen/RIOT/branches{/branch}","tags_url":"https://api.github.com/repos/haukepetersen/RIOT/tags","blobs_url":"https://api.github.com/repos/haukepetersen/RIOT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haukepetersen/RIOT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haukepetersen/RIOT/git/refs{/sha}","trees_url":"https://api.github.com/repos/haukepetersen/RIOT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haukepetersen/RIOT/statuses/{sha}","languages_url":"https://api.github.com/repos/haukepetersen/RIOT/languages","stargazers_url":"https://api.github.com/repos/haukepetersen/RIOT/stargazers","contributors_url":"https://api.github.com/repos/haukepetersen/RIOT/contributors","subscribers_url":"https://api.github.com/repos/haukepetersen/RIOT/subscribers","subscription_url":"https://api.github.com/repos/haukepetersen/RIOT/subscription","commits_url":"https://api.github.com/repos/haukepetersen/RIOT/commits{/sha}","git_commits_url":"https://api.github.com/repos/haukepetersen/RIOT/git/commits{/sha}","comments_url":"https://api.github.com/repos/haukepetersen/RIOT/comments{/number}","issue_comment_url":"https://api.github.com/repos/haukepetersen/RIOT/issues/comments{/number}","contents_url":"https://api.github.com/repos/haukepetersen/RIOT/contents/{+path}","compare_url":"https://api.github.com/repos/haukepetersen/RIOT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haukepetersen/RIOT/merges","archive_url":"https://api.github.com/repos/haukepetersen/RIOT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haukepetersen/RIOT/downloads","issues_url":"https://api.github.com/repos/haukepetersen/RIOT/issues{/number}","pulls_url":"https://api.github.com/repos/haukepetersen/RIOT/pulls{/number}","milestones_url":"https://api.github.com/repos/haukepetersen/RIOT/milestones{/number}","notifications_url":"https://api.github.com/repos/haukepetersen/RIOT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haukepetersen/RIOT/labels{/name}","releases_url":"https://api.github.com/repos/haukepetersen/RIOT/releases{/id}","created_at":"2013-10-21T12:31:38Z","updated_at":"2015-03-02T09:15:38Z","pushed_at":"2015-06-01T11:36:34Z","git_url":"git://github.com/haukepetersen/RIOT.git","ssh_url":"git@github.com:haukepetersen/RIOT.git","clone_url":"https://github.com/haukepetersen/RIOT.git","svn_url":"https://github.com/haukepetersen/RIOT","homepage":"https://github.com/RIOT-OS/RIOT/wiki","size":20892,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"RIOT-OS:master","ref":"master","sha":"ae3d88fcae7ea70b15fd035c04a7eca428c2fdf4","user":{"login":"RIOT-OS","id":3079480,"avatar_url":"https://avatars.githubusercontent.com/u/3079480?v=3","gravatar_id":"","url":"https://api.github.com/users/RIOT-OS","html_url":"https://github.com/RIOT-OS","followers_url":"https://api.github.com/users/RIOT-OS/followers","following_url":"https://api.github.com/users/RIOT-OS/following{/other_user}","gists_url":"https://api.github.com/users/RIOT-OS/gists{/gist_id}","starred_url":"https://api.github.com/users/RIOT-OS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIOT-OS/subscriptions","organizations_url":"https://api.github.com/users/RIOT-OS/orgs","repos_url":"https://api.github.com/users/RIOT-OS/repos","events_url":"https://api.github.com/users/RIOT-OS/events{/privacy}","received_events_url":"https://api.github.com/users/RIOT-OS/received_events","type":"Organization","site_admin":false},"repo":{"id":7370241,"name":"RIOT","full_name":"RIOT-OS/RIOT","owner":{"login":"RIOT-OS","id":3079480,"avatar_url":"https://avatars.githubusercontent.com/u/3079480?v=3","gravatar_id":"","url":"https://api.github.com/users/RIOT-OS","html_url":"https://github.com/RIOT-OS","followers_url":"https://api.github.com/users/RIOT-OS/followers","following_url":"https://api.github.com/users/RIOT-OS/following{/other_user}","gists_url":"https://api.github.com/users/RIOT-OS/gists{/gist_id}","starred_url":"https://api.github.com/users/RIOT-OS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIOT-OS/subscriptions","organizations_url":"https://api.github.com/users/RIOT-OS/orgs","repos_url":"https://api.github.com/users/RIOT-OS/repos","events_url":"https://api.github.com/users/RIOT-OS/events{/privacy}","received_events_url":"https://api.github.com/users/RIOT-OS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RIOT-OS/RIOT","description":"RIOT -  The friendly OS for IoT","fork":false,"url":"https://api.github.com/repos/RIOT-OS/RIOT","forks_url":"https://api.github.com/repos/RIOT-OS/RIOT/forks","keys_url":"https://api.github.com/repos/RIOT-OS/RIOT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RIOT-OS/RIOT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RIOT-OS/RIOT/teams","hooks_url":"https://api.github.com/repos/RIOT-OS/RIOT/hooks","issue_events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/events{/number}","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/events","assignees_url":"https://api.github.com/repos/RIOT-OS/RIOT/assignees{/user}","branches_url":"https://api.github.com/repos/RIOT-OS/RIOT/branches{/branch}","tags_url":"https://api.github.com/repos/RIOT-OS/RIOT/tags","blobs_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/refs{/sha}","trees_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/{sha}","languages_url":"https://api.github.com/repos/RIOT-OS/RIOT/languages","stargazers_url":"https://api.github.com/repos/RIOT-OS/RIOT/stargazers","contributors_url":"https://api.github.com/repos/RIOT-OS/RIOT/contributors","subscribers_url":"https://api.github.com/repos/RIOT-OS/RIOT/subscribers","subscription_url":"https://api.github.com/repos/RIOT-OS/RIOT/subscription","commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/commits{/sha}","git_commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/commits{/sha}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/comments{/number}","issue_comment_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments{/number}","contents_url":"https://api.github.com/repos/RIOT-OS/RIOT/contents/{+path}","compare_url":"https://api.github.com/repos/RIOT-OS/RIOT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RIOT-OS/RIOT/merges","archive_url":"https://api.github.com/repos/RIOT-OS/RIOT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RIOT-OS/RIOT/downloads","issues_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues{/number}","pulls_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls{/number}","milestones_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones{/number}","notifications_url":"https://api.github.com/repos/RIOT-OS/RIOT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/labels{/name}","releases_url":"https://api.github.com/repos/RIOT-OS/RIOT/releases{/id}","created_at":"2012-12-29T20:38:40Z","updated_at":"2015-05-30T16:29:04Z","pushed_at":"2015-06-01T10:57:41Z","git_url":"git://github.com/RIOT-OS/RIOT.git","ssh_url":"git@github.com:RIOT-OS/RIOT.git","clone_url":"https://github.com/RIOT-OS/RIOT.git","svn_url":"https://github.com/RIOT-OS/RIOT","homepage":"https://github.com/RIOT-OS/RIOT/wiki","size":125804,"stargazers_count":402,"watchers_count":402,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":306,"mirror_url":null,"open_issues_count":325,"forks":306,"open_issues":325,"watchers":402,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/3095"},"issue":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3095"},"comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3095/comments"},"review_comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095/comments"},"review_comment":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3095/commits"},"statuses":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/92903add60ea3fb6c9725ee052b316d020878810"}}}}