{"action":"created","comment":{"url":"https://api.github.com/repos/libopencm3/libopencm3/pulls/comments/34638201","id":34638201,"diff_hunk":"@@ -0,0 +1,313 @@\n+/*\n+ * This file is part of the libopencm3 project.\n+ *\n+ * Copyright (C) 2015 Owen Kirby <osk@exegin.com>\n+ *\n+ * This library is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU Lesser General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This library is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public License\n+ * along with this library.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+#include <libopencm3/cm3/common.h>\n+#include <libopencm3/cm3/nvic.h>\n+#include <libopencm3/sam/pmc.h>\n+#include <libopencm3/sam/usb.h>\n+#include <libopencm3/sam/periph.h>\n+#include <libopencm3/usb/usbd.h>\n+#include \"usb_private.h\"\n+\n+static usbd_device *udp_init(void);\n+static void udp_set_address(usbd_device *usbd_dev, uint8_t addr);\n+static void udp_ep_setup(usbd_device *usbd_dev, uint8_t addr,\n+\t\t\t\t\tuint8_t type, uint16_t max_size,\n+\t\t\t\t\tvoid (*callback) (usbd_device *usbd_dev, uint8_t ep));\n+static void udp_endpoints_reset(usbd_device *usbd_dev);\n+static void udp_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall);\n+static uint8_t udp_ep_stall_get(usbd_device *usbd_dev, uint8_t addr);\n+static void udp_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak);\n+static uint16_t udp_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,\n+\t\t\t\t\t  const void *buf, uint16_t len);\n+static uint16_t udp_ep_read_packet(usbd_device *usbd_dev, uint8_t addr,\n+\t\t\t\t\t void *buf, uint16_t len);\n+static void udp_poll(usbd_device *usbd_dev);\n+\n+static struct _usbd_device udp_dev;\n+\n+const struct _usbd_driver sam_udp_usb_driver = {\n+\t.init = udp_init,\n+\t.set_address = udp_set_address,\n+\t.ep_setup = udp_ep_setup,\n+\t.ep_reset = udp_endpoints_reset,\n+\t.ep_stall_set = udp_ep_stall_set,\n+\t.ep_stall_get = udp_ep_stall_get,\n+\t.ep_nak_set = udp_ep_nak_set,\n+\t.ep_write_packet = udp_ep_write_packet,\n+\t.ep_read_packet = udp_ep_read_packet,\n+\t.poll = udp_poll,\n+};\n+\n+static void\n+udp_csr_set(uint8_t ep, uint32_t bits)\n+{\n+\tuint32_t csr = UDP_CSR(ep);\n+\tUDP_CSR(ep) = csr | UDP_CSR_WRITE_NOP | bits;\n+\twhile ((UDP_CSR(ep) & bits) != bits);\n+} /* udp_csr_set */","path":"lib/usb/usb_sam_udp.c","position":64,"original_position":64,"commit_id":"cecc77eddb72d95f21ad24bf3a9bd775c1117330","original_commit_id":"cecc77eddb72d95f21ad24bf3a9bd775c1117330","user":{"login":"karlp","id":127907,"avatar_url":"https://avatars.githubusercontent.com/u/127907?v=3","gravatar_id":"","url":"https://api.github.com/users/karlp","html_url":"https://github.com/karlp","followers_url":"https://api.github.com/users/karlp/followers","following_url":"https://api.github.com/users/karlp/following{/other_user}","gists_url":"https://api.github.com/users/karlp/gists{/gist_id}","starred_url":"https://api.github.com/users/karlp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlp/subscriptions","organizations_url":"https://api.github.com/users/karlp/orgs","repos_url":"https://api.github.com/users/karlp/repos","events_url":"https://api.github.com/users/karlp/events{/privacy}","received_events_url":"https://api.github.com/users/karlp/received_events","type":"User","site_admin":false},"body":"drop these trailing comments please.","created_at":"2015-07-15T01:17:12Z","updated_at":"2015-07-15T01:17:12Z","html_url":"https://github.com/libopencm3/libopencm3/pull/436#discussion_r34638201","pull_request_url":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436","_links":{"self":{"href":"https://api.github.com/repos/libopencm3/libopencm3/pulls/comments/34638201"},"html":{"href":"https://github.com/libopencm3/libopencm3/pull/436#discussion_r34638201"},"pull_request":{"href":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436"}}},"pull_request":{"url":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436","id":35382114,"html_url":"https://github.com/libopencm3/libopencm3/pull/436","diff_url":"https://github.com/libopencm3/libopencm3/pull/436.diff","patch_url":"https://github.com/libopencm3/libopencm3/pull/436.patch","issue_url":"https://api.github.com/repos/libopencm3/libopencm3/issues/436","number":436,"state":"open","locked":false,"title":"sam: add USB (full speed) driver for SAM3S family","user":{"login":"oskirby","id":7256630,"avatar_url":"https://avatars.githubusercontent.com/u/7256630?v=3","gravatar_id":"","url":"https://api.github.com/users/oskirby","html_url":"https://github.com/oskirby","followers_url":"https://api.github.com/users/oskirby/followers","following_url":"https://api.github.com/users/oskirby/following{/other_user}","gists_url":"https://api.github.com/users/oskirby/gists{/gist_id}","starred_url":"https://api.github.com/users/oskirby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oskirby/subscriptions","organizations_url":"https://api.github.com/users/oskirby/orgs","repos_url":"https://api.github.com/users/oskirby/repos","events_url":"https://api.github.com/users/oskirby/events{/privacy}","received_events_url":"https://api.github.com/users/oskirby/received_events","type":"User","site_admin":false},"body":"This adds a full-speed USB driver for the SAM3S family. In the Atmel datasheets this is referred to as the UDP peripheral, and is common to the SAM3S, SAM4S and SAM4E chips.","created_at":"2015-05-13T23:43:20Z","updated_at":"2015-07-15T01:17:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"262580a81e802af939771c87708178ca88e9ea66","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436/commits","review_comments_url":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436/comments","review_comment_url":"https://api.github.com/repos/libopencm3/libopencm3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libopencm3/libopencm3/issues/436/comments","statuses_url":"https://api.github.com/repos/libopencm3/libopencm3/statuses/cecc77eddb72d95f21ad24bf3a9bd775c1117330","head":{"label":"oskirby:sam-usb","ref":"sam-usb","sha":"cecc77eddb72d95f21ad24bf3a9bd775c1117330","user":{"login":"oskirby","id":7256630,"avatar_url":"https://avatars.githubusercontent.com/u/7256630?v=3","gravatar_id":"","url":"https://api.github.com/users/oskirby","html_url":"https://github.com/oskirby","followers_url":"https://api.github.com/users/oskirby/followers","following_url":"https://api.github.com/users/oskirby/following{/other_user}","gists_url":"https://api.github.com/users/oskirby/gists{/gist_id}","starred_url":"https://api.github.com/users/oskirby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oskirby/subscriptions","organizations_url":"https://api.github.com/users/oskirby/orgs","repos_url":"https://api.github.com/users/oskirby/repos","events_url":"https://api.github.com/users/oskirby/events{/privacy}","received_events_url":"https://api.github.com/users/oskirby/received_events","type":"User","site_admin":false},"repo":{"id":28459798,"name":"libopencm3","full_name":"oskirby/libopencm3","owner":{"login":"oskirby","id":7256630,"avatar_url":"https://avatars.githubusercontent.com/u/7256630?v=3","gravatar_id":"","url":"https://api.github.com/users/oskirby","html_url":"https://github.com/oskirby","followers_url":"https://api.github.com/users/oskirby/followers","following_url":"https://api.github.com/users/oskirby/following{/other_user}","gists_url":"https://api.github.com/users/oskirby/gists{/gist_id}","starred_url":"https://api.github.com/users/oskirby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oskirby/subscriptions","organizations_url":"https://api.github.com/users/oskirby/orgs","repos_url":"https://api.github.com/users/oskirby/repos","events_url":"https://api.github.com/users/oskirby/events{/privacy}","received_events_url":"https://api.github.com/users/oskirby/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oskirby/libopencm3","description":"Open Source ARM cortex m microcontroller library","fork":true,"url":"https://api.github.com/repos/oskirby/libopencm3","forks_url":"https://api.github.com/repos/oskirby/libopencm3/forks","keys_url":"https://api.github.com/repos/oskirby/libopencm3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oskirby/libopencm3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oskirby/libopencm3/teams","hooks_url":"https://api.github.com/repos/oskirby/libopencm3/hooks","issue_events_url":"https://api.github.com/repos/oskirby/libopencm3/issues/events{/number}","events_url":"https://api.github.com/repos/oskirby/libopencm3/events","assignees_url":"https://api.github.com/repos/oskirby/libopencm3/assignees{/user}","branches_url":"https://api.github.com/repos/oskirby/libopencm3/branches{/branch}","tags_url":"https://api.github.com/repos/oskirby/libopencm3/tags","blobs_url":"https://api.github.com/repos/oskirby/libopencm3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oskirby/libopencm3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oskirby/libopencm3/git/refs{/sha}","trees_url":"https://api.github.com/repos/oskirby/libopencm3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oskirby/libopencm3/statuses/{sha}","languages_url":"https://api.github.com/repos/oskirby/libopencm3/languages","stargazers_url":"https://api.github.com/repos/oskirby/libopencm3/stargazers","contributors_url":"https://api.github.com/repos/oskirby/libopencm3/contributors","subscribers_url":"https://api.github.com/repos/oskirby/libopencm3/subscribers","subscription_url":"https://api.github.com/repos/oskirby/libopencm3/subscription","commits_url":"https://api.github.com/repos/oskirby/libopencm3/commits{/sha}","git_commits_url":"https://api.github.com/repos/oskirby/libopencm3/git/commits{/sha}","comments_url":"https://api.github.com/repos/oskirby/libopencm3/comments{/number}","issue_comment_url":"https://api.github.com/repos/oskirby/libopencm3/issues/comments{/number}","contents_url":"https://api.github.com/repos/oskirby/libopencm3/contents/{+path}","compare_url":"https://api.github.com/repos/oskirby/libopencm3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oskirby/libopencm3/merges","archive_url":"https://api.github.com/repos/oskirby/libopencm3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oskirby/libopencm3/downloads","issues_url":"https://api.github.com/repos/oskirby/libopencm3/issues{/number}","pulls_url":"https://api.github.com/repos/oskirby/libopencm3/pulls{/number}","milestones_url":"https://api.github.com/repos/oskirby/libopencm3/milestones{/number}","notifications_url":"https://api.github.com/repos/oskirby/libopencm3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oskirby/libopencm3/labels{/name}","releases_url":"https://api.github.com/repos/oskirby/libopencm3/releases{/id}","created_at":"2014-12-24T19:19:43Z","updated_at":"2015-05-07T21:55:48Z","pushed_at":"2015-05-13T23:41:21Z","git_url":"git://github.com/oskirby/libopencm3.git","ssh_url":"git@github.com:oskirby/libopencm3.git","clone_url":"https://github.com/oskirby/libopencm3.git","svn_url":"https://github.com/oskirby/libopencm3","homepage":"http://libopencm3.org/","size":5683,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"libopencm3:master","ref":"master","sha":"6d658c20b8c2aecc6a0734846c778d1f7532e67c","user":{"login":"libopencm3","id":1656279,"avatar_url":"https://avatars.githubusercontent.com/u/1656279?v=3","gravatar_id":"","url":"https://api.github.com/users/libopencm3","html_url":"https://github.com/libopencm3","followers_url":"https://api.github.com/users/libopencm3/followers","following_url":"https://api.github.com/users/libopencm3/following{/other_user}","gists_url":"https://api.github.com/users/libopencm3/gists{/gist_id}","starred_url":"https://api.github.com/users/libopencm3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libopencm3/subscriptions","organizations_url":"https://api.github.com/users/libopencm3/orgs","repos_url":"https://api.github.com/users/libopencm3/repos","events_url":"https://api.github.com/users/libopencm3/events{/privacy}","received_events_url":"https://api.github.com/users/libopencm3/received_events","type":"Organization","site_admin":false},"repo":{"id":4065980,"name":"libopencm3","full_name":"libopencm3/libopencm3","owner":{"login":"libopencm3","id":1656279,"avatar_url":"https://avatars.githubusercontent.com/u/1656279?v=3","gravatar_id":"","url":"https://api.github.com/users/libopencm3","html_url":"https://github.com/libopencm3","followers_url":"https://api.github.com/users/libopencm3/followers","following_url":"https://api.github.com/users/libopencm3/following{/other_user}","gists_url":"https://api.github.com/users/libopencm3/gists{/gist_id}","starred_url":"https://api.github.com/users/libopencm3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libopencm3/subscriptions","organizations_url":"https://api.github.com/users/libopencm3/orgs","repos_url":"https://api.github.com/users/libopencm3/repos","events_url":"https://api.github.com/users/libopencm3/events{/privacy}","received_events_url":"https://api.github.com/users/libopencm3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libopencm3/libopencm3","description":"Open Source ARM cortex m microcontroller library","fork":false,"url":"https://api.github.com/repos/libopencm3/libopencm3","forks_url":"https://api.github.com/repos/libopencm3/libopencm3/forks","keys_url":"https://api.github.com/repos/libopencm3/libopencm3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libopencm3/libopencm3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libopencm3/libopencm3/teams","hooks_url":"https://api.github.com/repos/libopencm3/libopencm3/hooks","issue_events_url":"https://api.github.com/repos/libopencm3/libopencm3/issues/events{/number}","events_url":"https://api.github.com/repos/libopencm3/libopencm3/events","assignees_url":"https://api.github.com/repos/libopencm3/libopencm3/assignees{/user}","branches_url":"https://api.github.com/repos/libopencm3/libopencm3/branches{/branch}","tags_url":"https://api.github.com/repos/libopencm3/libopencm3/tags","blobs_url":"https://api.github.com/repos/libopencm3/libopencm3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libopencm3/libopencm3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libopencm3/libopencm3/git/refs{/sha}","trees_url":"https://api.github.com/repos/libopencm3/libopencm3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libopencm3/libopencm3/statuses/{sha}","languages_url":"https://api.github.com/repos/libopencm3/libopencm3/languages","stargazers_url":"https://api.github.com/repos/libopencm3/libopencm3/stargazers","contributors_url":"https://api.github.com/repos/libopencm3/libopencm3/contributors","subscribers_url":"https://api.github.com/repos/libopencm3/libopencm3/subscribers","subscription_url":"https://api.github.com/repos/libopencm3/libopencm3/subscription","commits_url":"https://api.github.com/repos/libopencm3/libopencm3/commits{/sha}","git_commits_url":"https://api.github.com/repos/libopencm3/libopencm3/git/commits{/sha}","comments_url":"https://api.github.com/repos/libopencm3/libopencm3/comments{/number}","issue_comment_url":"https://api.github.com/repos/libopencm3/libopencm3/issues/comments{/number}","contents_url":"https://api.github.com/repos/libopencm3/libopencm3/contents/{+path}","compare_url":"https://api.github.com/repos/libopencm3/libopencm3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libopencm3/libopencm3/merges","archive_url":"https://api.github.com/repos/libopencm3/libopencm3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libopencm3/libopencm3/downloads","issues_url":"https://api.github.com/repos/libopencm3/libopencm3/issues{/number}","pulls_url":"https://api.github.com/repos/libopencm3/libopencm3/pulls{/number}","milestones_url":"https://api.github.com/repos/libopencm3/libopencm3/milestones{/number}","notifications_url":"https://api.github.com/repos/libopencm3/libopencm3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libopencm3/libopencm3/labels{/name}","releases_url":"https://api.github.com/repos/libopencm3/libopencm3/releases{/id}","created_at":"2012-04-18T16:51:38Z","updated_at":"2015-07-14T23:04:12Z","pushed_at":"2015-07-15T00:41:48Z","git_url":"git://github.com/libopencm3/libopencm3.git","ssh_url":"git@github.com:libopencm3/libopencm3.git","clone_url":"https://github.com/libopencm3/libopencm3.git","svn_url":"https://github.com/libopencm3/libopencm3","homepage":"http://libopencm3.org/","size":9821,"stargazers_count":300,"watchers_count":300,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":213,"mirror_url":null,"open_issues_count":110,"forks":213,"open_issues":110,"watchers":300,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436"},"html":{"href":"https://github.com/libopencm3/libopencm3/pull/436"},"issue":{"href":"https://api.github.com/repos/libopencm3/libopencm3/issues/436"},"comments":{"href":"https://api.github.com/repos/libopencm3/libopencm3/issues/436/comments"},"review_comments":{"href":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436/comments"},"review_comment":{"href":"https://api.github.com/repos/libopencm3/libopencm3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libopencm3/libopencm3/pulls/436/commits"},"statuses":{"href":"https://api.github.com/repos/libopencm3/libopencm3/statuses/cecc77eddb72d95f21ad24bf3a9bd775c1117330"}}}}