{"action":"created","comment":{"url":"https://api.github.com/repos/tessel/t2-firmware/pulls/comments/33166225","id":33166225,"diff_hunk":"@@ -112,3 +121,146 @@ make\n # T2 Hardware API\n \n When you `require('tessel')` within a script which is executed on Tessel 2, this loads a library which interfaces with the Tessel 2 hardware, including pins, ports, and LEDs, just like Tessel 1 ([Tessel 1 hardware documentation](https://tessel.io/docs/hardwareAPI)). The code for Tessel 2's hardware object can be found [here](https://github.com/tessel/t2-firmware/blob/master/node/tessel.js).\n+\n+## Ports and pins\n+\n+Tessel has two ports, A and B. They are referred to as `tessel.port.B`. `tessel.port['B']` is also an acceptable reference style.\n+\n+Tessel's ports can be used as module ports as in Tessel 1 (e.g. `accelerometer.use(tessel.port.B)`), or used as flexible GPIO pins (e.g. `myPin = tessel.port.A.pins[0]`).\n+\n+### Modules\n+\n+Tessel 2's module ports can be used with [Tessel modules](//tessel.io/modules) much as in [Tessel 1](http://start.tessel.io/modules).\n+\n+Here is an example of using the Tessel Climate module on Tessel's port B:\n+\n+```js\n+var tessel = require('tessel');\n+var climatelib = require('climate-si7020').use(tessel.port.B);\n+```\n+\n+### Pin mapping\n+\n+The module ports are not just for modules! They can also be used as flexible, simply addressable GPIO pins.\n+\n+The pin layout for ports A and B is as follows:\n+\n+| Port | Pin | Digital I/O | SCL | SDA | SCK | MISO | MOSI | TX | RX | Analog In | Analog Out |\n+|------|-----|-------------|-----|-----|-----|------|------|----|----|-----------|------------|\n+|A     | 0   | ✓           | ✓   |     |     |      |      |    |    |           |            |\n+|A     | 1   | ✓           |     | ✓   |     |      |      |    |    |           |            |\n+|A     | 2   | ✓           |     |     | ✓   |      |      |    |    |           |            |\n+|A     | 3   | ✓           |     |     |     | ✓    |      |    |    |           |            |\n+|A     | 4   | ✓           |     |     |     |      | ✓    |    |    | ✓         |            |\n+|A     | 5   | ✓           |     |     |     |      |      | ✓  |    |           |            |\n+|A     | 6   | ✓           |     |     |     |      |      |    | ✓  |           |            |\n+|A     | 7   | ✓           |     |     |     |      |      |    |    | ✓         |            |\n+|B     | 0   | ✓           | ✓   |     |     |      |      |    |    | ✓         |            |\n+|B     | 1   | ✓           |     | ✓   |     |      |      |    |    | ✓         |            |\n+|B     | 2   | ✓           |     |     | ✓   |      |      |    |    | ✓         |            |\n+|B     | 3   | ✓           |     |     |     | ✓    |      |    |    | ✓         |            |\n+|B     | 4   | ✓           |     |     |     |      | ✓    |    |    | ✓         |            |\n+|B     | 5   | ✓           |     |     |     |      |      | ✓  |    | ✓         |            |\n+|B     | 6   | ✓           |     |     |     |      |      |    | ✓  | ✓         |            |\n+|B     | 7   | ✓           |     |     |     |      |      |    |    | ✓         | ✓          |\n+\n+All pins (0-7) can be used as digital pins. All pins on port B and pin 7 on port A can be used as analog pins.\n+\n+If you're newer to hardware and these functions look like alphabet soup to you, take a look at our [communication protocols documentation](https://tessel.io/docs/communicationProtocols) to get an idea of how these pins should be used.\n+\n+### Digital pins\n+\n+A digital pin (any pin other than 3.3V and GND on Tessel 2) is either high (on/3.3V) or low (off/0V). On both of ports A and B, pins 0 and 1 are pulled high to 3.3V by default.\n+\n+Here is an example usage of a digital pin on Tessel:\n+\n+```js\n+var tessel = require('tessel'); // import tessel\n+var myPin = tessel.port.A.pin[2]; // select pin 2 on port A\n+myPin.output(1);  // turn pin high (on)\n+console.log(myPin.read()); // print the pin value to the console\n+myPin.output(0);  // turn pin low (off)\n+```\n+\n+### Analog pins\n+\n+An analog pin is a pin whose value can vary in the range between 0V and 3.3V. Pins 4 and 7 on port A and all pins on port B can read analog values (though pins 0 and 1 are pulled to 3.3V by default and are thus not recommended for this purpose). Pin 7 on port B can write an analog value.\n+\n+Here is an example usage of an analog pin on Tessel:\n+\n+```js\n+var tessel = require('tessel'); // import tessel\n+var myPin = tessel.port.B.pin[7]; // select pin 2 on port A","path":"README.md","position":98,"original_position":98,"commit_id":"c8d02f6601f6cd945fdbe46d9cc6181e66d64147","original_commit_id":"c8d02f6601f6cd945fdbe46d9cc6181e66d64147","user":{"login":"Frijol","id":454690,"avatar_url":"https://avatars.githubusercontent.com/u/454690?v=3","gravatar_id":"","url":"https://api.github.com/users/Frijol","html_url":"https://github.com/Frijol","followers_url":"https://api.github.com/users/Frijol/followers","following_url":"https://api.github.com/users/Frijol/following{/other_user}","gists_url":"https://api.github.com/users/Frijol/gists{/gist_id}","starred_url":"https://api.github.com/users/Frijol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Frijol/subscriptions","organizations_url":"https://api.github.com/users/Frijol/orgs","repos_url":"https://api.github.com/users/Frijol/repos","events_url":"https://api.github.com/users/Frijol/events{/privacy}","received_events_url":"https://api.github.com/users/Frijol/received_events","type":"User","site_admin":false},"body":"oof good catch","created_at":"2015-06-24T16:23:08Z","updated_at":"2015-06-24T16:23:08Z","html_url":"https://github.com/tessel/t2-firmware/pull/47#discussion_r33166225","pull_request_url":"https://api.github.com/repos/tessel/t2-firmware/pulls/47","_links":{"self":{"href":"https://api.github.com/repos/tessel/t2-firmware/pulls/comments/33166225"},"html":{"href":"https://github.com/tessel/t2-firmware/pull/47#discussion_r33166225"},"pull_request":{"href":"https://api.github.com/repos/tessel/t2-firmware/pulls/47"}}},"pull_request":{"url":"https://api.github.com/repos/tessel/t2-firmware/pulls/47","id":37976994,"html_url":"https://github.com/tessel/t2-firmware/pull/47","diff_url":"https://github.com/tessel/t2-firmware/pull/47.diff","patch_url":"https://github.com/tessel/t2-firmware/pull/47.patch","issue_url":"https://api.github.com/repos/tessel/t2-firmware/issues/47","number":47,"state":"open","locked":false,"title":"more complete hardware API docs","user":{"login":"Frijol","id":454690,"avatar_url":"https://avatars.githubusercontent.com/u/454690?v=3","gravatar_id":"","url":"https://api.github.com/users/Frijol","html_url":"https://github.com/Frijol","followers_url":"https://api.github.com/users/Frijol/followers","following_url":"https://api.github.com/users/Frijol/following{/other_user}","gists_url":"https://api.github.com/users/Frijol/gists{/gist_id}","starred_url":"https://api.github.com/users/Frijol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Frijol/subscriptions","organizations_url":"https://api.github.com/users/Frijol/orgs","repos_url":"https://api.github.com/users/Frijol/repos","events_url":"https://api.github.com/users/Frijol/events{/privacy}","received_events_url":"https://api.github.com/users/Frijol/received_events","type":"User","site_admin":false},"body":"@ekolker can you give this a fairly thorough looking over? I suspect I'm missing information re what the pins can do.\r\n\r\nAlso not certain what is/isn't all the way implemented; @kevinmehall can you note if I've documented anything that doesn't exist/work that way yet?","created_at":"2015-06-18T07:05:56Z","updated_at":"2015-06-24T16:23:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fde5690fea1d17fff4050cf86da9d50e400cf987","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tessel/t2-firmware/pulls/47/commits","review_comments_url":"https://api.github.com/repos/tessel/t2-firmware/pulls/47/comments","review_comment_url":"https://api.github.com/repos/tessel/t2-firmware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tessel/t2-firmware/issues/47/comments","statuses_url":"https://api.github.com/repos/tessel/t2-firmware/statuses/c8d02f6601f6cd945fdbe46d9cc6181e66d64147","head":{"label":"tessel:kb-docs","ref":"kb-docs","sha":"c8d02f6601f6cd945fdbe46d9cc6181e66d64147","user":{"login":"tessel","id":5573563,"avatar_url":"https://avatars.githubusercontent.com/u/5573563?v=3","gravatar_id":"","url":"https://api.github.com/users/tessel","html_url":"https://github.com/tessel","followers_url":"https://api.github.com/users/tessel/followers","following_url":"https://api.github.com/users/tessel/following{/other_user}","gists_url":"https://api.github.com/users/tessel/gists{/gist_id}","starred_url":"https://api.github.com/users/tessel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tessel/subscriptions","organizations_url":"https://api.github.com/users/tessel/orgs","repos_url":"https://api.github.com/users/tessel/repos","events_url":"https://api.github.com/users/tessel/events{/privacy}","received_events_url":"https://api.github.com/users/tessel/received_events","type":"Organization","site_admin":false},"repo":{"id":29262099,"name":"t2-firmware","full_name":"tessel/t2-firmware","owner":{"login":"tessel","id":5573563,"avatar_url":"https://avatars.githubusercontent.com/u/5573563?v=3","gravatar_id":"","url":"https://api.github.com/users/tessel","html_url":"https://github.com/tessel","followers_url":"https://api.github.com/users/tessel/followers","following_url":"https://api.github.com/users/tessel/following{/other_user}","gists_url":"https://api.github.com/users/tessel/gists{/gist_id}","starred_url":"https://api.github.com/users/tessel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tessel/subscriptions","organizations_url":"https://api.github.com/users/tessel/orgs","repos_url":"https://api.github.com/users/tessel/repos","events_url":"https://api.github.com/users/tessel/events{/privacy}","received_events_url":"https://api.github.com/users/tessel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tessel/t2-firmware","description":"Firmware for Tessel 2's SAMD21 coprocessor and related SoC code","fork":false,"url":"https://api.github.com/repos/tessel/t2-firmware","forks_url":"https://api.github.com/repos/tessel/t2-firmware/forks","keys_url":"https://api.github.com/repos/tessel/t2-firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tessel/t2-firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tessel/t2-firmware/teams","hooks_url":"https://api.github.com/repos/tessel/t2-firmware/hooks","issue_events_url":"https://api.github.com/repos/tessel/t2-firmware/issues/events{/number}","events_url":"https://api.github.com/repos/tessel/t2-firmware/events","assignees_url":"https://api.github.com/repos/tessel/t2-firmware/assignees{/user}","branches_url":"https://api.github.com/repos/tessel/t2-firmware/branches{/branch}","tags_url":"https://api.github.com/repos/tessel/t2-firmware/tags","blobs_url":"https://api.github.com/repos/tessel/t2-firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tessel/t2-firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tessel/t2-firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/tessel/t2-firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tessel/t2-firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/tessel/t2-firmware/languages","stargazers_url":"https://api.github.com/repos/tessel/t2-firmware/stargazers","contributors_url":"https://api.github.com/repos/tessel/t2-firmware/contributors","subscribers_url":"https://api.github.com/repos/tessel/t2-firmware/subscribers","subscription_url":"https://api.github.com/repos/tessel/t2-firmware/subscription","commits_url":"https://api.github.com/repos/tessel/t2-firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/tessel/t2-firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/tessel/t2-firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/tessel/t2-firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/tessel/t2-firmware/contents/{+path}","compare_url":"https://api.github.com/repos/tessel/t2-firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tessel/t2-firmware/merges","archive_url":"https://api.github.com/repos/tessel/t2-firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tessel/t2-firmware/downloads","issues_url":"https://api.github.com/repos/tessel/t2-firmware/issues{/number}","pulls_url":"https://api.github.com/repos/tessel/t2-firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/tessel/t2-firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/tessel/t2-firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tessel/t2-firmware/labels{/name}","releases_url":"https://api.github.com/repos/tessel/t2-firmware/releases{/id}","created_at":"2015-01-14T19:38:00Z","updated_at":"2015-06-23T09:39:42Z","pushed_at":"2015-06-24T06:16:30Z","git_url":"git://github.com/tessel/t2-firmware.git","ssh_url":"git@github.com:tessel/t2-firmware.git","clone_url":"https://github.com/tessel/t2-firmware.git","svn_url":"https://github.com/tessel/t2-firmware","homepage":"","size":1103,"stargazers_count":9,"watchers_count":9,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":16,"forks":2,"open_issues":16,"watchers":9,"default_branch":"master"}},"base":{"label":"tessel:master","ref":"master","sha":"d4001f9679c5843706a11d93919b00060c7670e2","user":{"login":"tessel","id":5573563,"avatar_url":"https://avatars.githubusercontent.com/u/5573563?v=3","gravatar_id":"","url":"https://api.github.com/users/tessel","html_url":"https://github.com/tessel","followers_url":"https://api.github.com/users/tessel/followers","following_url":"https://api.github.com/users/tessel/following{/other_user}","gists_url":"https://api.github.com/users/tessel/gists{/gist_id}","starred_url":"https://api.github.com/users/tessel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tessel/subscriptions","organizations_url":"https://api.github.com/users/tessel/orgs","repos_url":"https://api.github.com/users/tessel/repos","events_url":"https://api.github.com/users/tessel/events{/privacy}","received_events_url":"https://api.github.com/users/tessel/received_events","type":"Organization","site_admin":false},"repo":{"id":29262099,"name":"t2-firmware","full_name":"tessel/t2-firmware","owner":{"login":"tessel","id":5573563,"avatar_url":"https://avatars.githubusercontent.com/u/5573563?v=3","gravatar_id":"","url":"https://api.github.com/users/tessel","html_url":"https://github.com/tessel","followers_url":"https://api.github.com/users/tessel/followers","following_url":"https://api.github.com/users/tessel/following{/other_user}","gists_url":"https://api.github.com/users/tessel/gists{/gist_id}","starred_url":"https://api.github.com/users/tessel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tessel/subscriptions","organizations_url":"https://api.github.com/users/tessel/orgs","repos_url":"https://api.github.com/users/tessel/repos","events_url":"https://api.github.com/users/tessel/events{/privacy}","received_events_url":"https://api.github.com/users/tessel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tessel/t2-firmware","description":"Firmware for Tessel 2's SAMD21 coprocessor and related SoC code","fork":false,"url":"https://api.github.com/repos/tessel/t2-firmware","forks_url":"https://api.github.com/repos/tessel/t2-firmware/forks","keys_url":"https://api.github.com/repos/tessel/t2-firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tessel/t2-firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tessel/t2-firmware/teams","hooks_url":"https://api.github.com/repos/tessel/t2-firmware/hooks","issue_events_url":"https://api.github.com/repos/tessel/t2-firmware/issues/events{/number}","events_url":"https://api.github.com/repos/tessel/t2-firmware/events","assignees_url":"https://api.github.com/repos/tessel/t2-firmware/assignees{/user}","branches_url":"https://api.github.com/repos/tessel/t2-firmware/branches{/branch}","tags_url":"https://api.github.com/repos/tessel/t2-firmware/tags","blobs_url":"https://api.github.com/repos/tessel/t2-firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tessel/t2-firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tessel/t2-firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/tessel/t2-firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tessel/t2-firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/tessel/t2-firmware/languages","stargazers_url":"https://api.github.com/repos/tessel/t2-firmware/stargazers","contributors_url":"https://api.github.com/repos/tessel/t2-firmware/contributors","subscribers_url":"https://api.github.com/repos/tessel/t2-firmware/subscribers","subscription_url":"https://api.github.com/repos/tessel/t2-firmware/subscription","commits_url":"https://api.github.com/repos/tessel/t2-firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/tessel/t2-firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/tessel/t2-firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/tessel/t2-firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/tessel/t2-firmware/contents/{+path}","compare_url":"https://api.github.com/repos/tessel/t2-firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tessel/t2-firmware/merges","archive_url":"https://api.github.com/repos/tessel/t2-firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tessel/t2-firmware/downloads","issues_url":"https://api.github.com/repos/tessel/t2-firmware/issues{/number}","pulls_url":"https://api.github.com/repos/tessel/t2-firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/tessel/t2-firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/tessel/t2-firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tessel/t2-firmware/labels{/name}","releases_url":"https://api.github.com/repos/tessel/t2-firmware/releases{/id}","created_at":"2015-01-14T19:38:00Z","updated_at":"2015-06-23T09:39:42Z","pushed_at":"2015-06-24T06:16:30Z","git_url":"git://github.com/tessel/t2-firmware.git","ssh_url":"git@github.com:tessel/t2-firmware.git","clone_url":"https://github.com/tessel/t2-firmware.git","svn_url":"https://github.com/tessel/t2-firmware","homepage":"","size":1103,"stargazers_count":9,"watchers_count":9,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":16,"forks":2,"open_issues":16,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tessel/t2-firmware/pulls/47"},"html":{"href":"https://github.com/tessel/t2-firmware/pull/47"},"issue":{"href":"https://api.github.com/repos/tessel/t2-firmware/issues/47"},"comments":{"href":"https://api.github.com/repos/tessel/t2-firmware/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/tessel/t2-firmware/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/tessel/t2-firmware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tessel/t2-firmware/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/tessel/t2-firmware/statuses/c8d02f6601f6cd945fdbe46d9cc6181e66d64147"}}}}