{"action":"created","comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/38646540","id":38646540,"diff_hunk":"@@ -0,0 +1,228 @@\n+/*\n+ * Copyright (C) 2015 Freie Universität Berlin\n+ *\n+ * This file is subject to the terms and conditions of the GNU Lesser\n+ * General Public License v2.1. See the file LICENSE in the top level\n+ * directory for more details.\n+ */\n+\n+/**\n+ * @ingroup     cpu_msp430fxyz\n+ * @{\n+ *\n+ * @file\n+ * @brief       Low-level GPIO driver implementation\n+ *\n+ * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>\n+ *\n+ * @}\n+ */\n+\n+#include \"cpu.h\"\n+#include \"bitarithm.h\"\n+#include \"periph/gpio.h\"\n+\n+/**\n+ * @brief   Number of possible interrupt lines: 2 ports * 8 pins\n+ */\n+#define ISR_NUMOF           (16U)\n+\n+/**\n+ * @brief   Number of pins on each port\n+ */\n+#define PINS_PER_PORT       (8U)\n+\n+/**\n+ * @brief   Datatype to use for saving the interrupt contexts\n+ */\n+typedef struct {\n+    gpio_cb_t cb;       /**< callback to call on GPIO interrupt */\n+    void *arg;          /**< argument passed to the callback */\n+} isr_ctx_t;\n+\n+/**\n+ * @brief   Interrupt context for each interrupt line\n+ */\n+static isr_ctx_t isr_ctx[ISR_NUMOF];\n+\n+\n+static msp_port_t *_port(gpio_t pin)\n+{\n+    switch (pin >> 8) {\n+        case 1:\n+            return PORT_1;\n+        case 2:\n+            return PORT_2;\n+        case 3:\n+            return PORT_3;\n+        case 4:\n+            return PORT_4;\n+        case 5:\n+            return PORT_5;\n+        case 6:\n+            return PORT_6;\n+        default:\n+            return NULL;\n+    }\n+}\n+\n+static inline msp_port_isr_t *_isr_port(gpio_t pin)\n+{\n+    msp_port_t *p = _port(pin);\n+    if ((p == PORT_1) || (p == PORT_2)) {\n+        return (msp_port_isr_t *)p;\n+    }\n+    return NULL;\n+}\n+\n+static inline uint8_t _pin(gpio_t pin)\n+{\n+    return (uint8_t)(pin & 0xff);\n+}\n+\n+static int _ctx(gpio_t pin)\n+{\n+    int i = bitarithm_lsb(_pin(pin));\n+    return (_port(pin) == PORT_1) ? i : (i + 8);\n+}\n+\n+int gpio_init(gpio_t pin, gpio_dir_t dir, gpio_pp_t pullup)\n+{\n+    msp_port_t *port = _port(pin);\n+    /* check if port is valid and pull resistor are valid */\n+    if ((port == NULL) || (pullup != GPIO_NOPULL)) {\n+        return -1;\n+    }\n+    /* set pin direction */\n+    port->DIR &= ~(_pin(pin));\n+    port->DIR |= (dir & _pin(pin));\n+    /* reset output value */\n+    port->OD &= ~(_pin(pin));\n+    return 0;\n+}\n+\n+int gpio_init_int(gpio_t pin, gpio_pp_t pullup, gpio_flank_t flank,\n+                    gpio_cb_t cb, void *arg)\n+{\n+    msp_port_isr_t *port = _isr_port(pin);\n+\n+    /* check if port, pull resistor and flank configuration are valid */\n+    if ((port == NULL) || (pullup != GPIO_NOPULL) || (fank == GPIO_BOTH)) {","path":"cpu/msp430fxyz/periph/gpio.c","position":110,"original_position":110,"commit_id":"b19e5a42d3307eb1144948193d534a704812edec","original_commit_id":"b19e5a42d3307eb1144948193d534a704812edec","user":{"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},"body":"typo: `s/fank/flank`","created_at":"2015-09-03T13:44:57Z","updated_at":"2015-09-03T13:44:57Z","html_url":"https://github.com/RIOT-OS/RIOT/pull/3760#discussion_r38646540","pull_request_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760","_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/38646540"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/3760#discussion_r38646540"},"pull_request":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760"}}},"pull_request":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760","id":43973047,"html_url":"https://github.com/RIOT-OS/RIOT/pull/3760","diff_url":"https://github.com/RIOT-OS/RIOT/pull/3760.diff","patch_url":"https://github.com/RIOT-OS/RIOT/pull/3760.patch","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3760","number":3760,"state":"open","locked":false,"title":"cpu/msp430: added periph GPIO driver implementation","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":"EDIT\r\n~~Based on #3724~~\r\n\r\nAnd here is also the GPIO driver.\r\n\r\nEDIT\r\n~~Known issue: When configuring a pin as external interrupt source, the system crashes after 2-3 interrupt events. The behavior is pretty similar to the crashing on UART RX (-> see #3742). My first guess is that there is something wrong with the context switching on the MSP430, but not sure yet... Will keep looking into this.~~","created_at":"2015-09-02T09:53:57Z","updated_at":"2015-09-03T13:44:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10de19eac895b1d1604e75f4a1935b9bc9ab3bcb","assignee":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/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.09","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/12/labels","id":1088995,"number":12,"title":"Release 2015.09","description":"This release aims mainly to include the gnrc network stack as the new default IPv6/6LoWPAN 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":54,"closed_issues":396,"state":"open","created_at":"2015-04-29T10:11:27Z","updated_at":"2015-09-03T13:35:29Z","due_on":"2015-09-17T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760/commits","review_comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760/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/3760/comments","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/b19e5a42d3307eb1144948193d534a704812edec","head":{"label":"haukepetersen:add_msp430_periph_gpio","ref":"add_msp430_periph_gpio","sha":"b19e5a42d3307eb1144948193d534a704812edec","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-09-03T13:36:19Z","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":24519,"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":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RIOT-OS:master","ref":"master","sha":"076e9db374b3e5c5475ee789c38383830ccd754e","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-09-02T07:46:36Z","pushed_at":"2015-09-03T13:36:20Z","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":127494,"stargazers_count":486,"watchers_count":486,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":368,"mirror_url":null,"open_issues_count":356,"forks":368,"open_issues":356,"watchers":486,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/3760"},"issue":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3760"},"comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/3760/comments"},"review_comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/3760/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/3760/commits"},"statuses":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/b19e5a42d3307eb1144948193d534a704812edec"}}}}