{"action":"created","comment":{"url":"https://api.github.com/repos/google/periph/pulls/comments/171099038","pull_request_review_id":99893206,"id":171099038,"diff_hunk":"@@ -0,0 +1,752 @@\n+// Copyright 2018 The Periph Authors. All rights reserved.\n+// Use of this source code is governed under the Apache License, Version 2.0\n+// that can be found in the LICENSE file.\n+\n+// Package mfrc522 controls a Mifare RFID card reader.\n+//\n+// The code is largely ported from Python library : https://github.com/mxgxw/MFRC522-python\n+//\n+// The datasheet is available at : https://www.nxp.com/docs/en/data-sheet/MFRC522.pdf\n+package mfrc522\n+\n+import (\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"periph.io/x/periph/conn/gpio\"\n+\t\"periph.io/x/periph/conn/gpio/gpioreg\"\n+\t\"periph.io/x/periph/conn/spi\"\n+\t\"periph.io/x/periph/experimental/devices/mfrc522/commands\"\n+\t\"time\"\n+)\n+\n+// Dev is an handle to an MFRC522 RFID reader.\n+type Dev struct {\n+\tresetPin      gpio.PinOut\n+\tirqPin        gpio.PinIn\n+\tAuthenticated bool\n+\tmaxSpeedHz    int64\n+\tspiDev        spi.Conn\n+}\n+\n+// DefaultKey provides the default bytes for card authentication for method B.\n+var DefaultKey = []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}\n+\n+const maxSpeed = int64(1000000)\n+\n+/*\n+NewSPI creates and initializes the RFID card reader attached to SPI.\n+\tspiPort - the SPI device to use.\n+\tresetPin - reset GPIO pin.\n+\tirqPin - irq GPIO pin.\n+*/\n+func NewSPI(spiPort spi.Port, resetPin, irqPin string) (*Dev, error) {\n+\n+\tspiDev, err := spiPort.Connect(maxSpeed, spi.Mode0, 8)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tdev := &Dev{\n+\t\tspiDev:     spiDev,\n+\t\tmaxSpeedHz: maxSpeed,\n+\t}\n+\n+\tpin := gpioreg.ByName(resetPin)\n+\tdev.resetPin = pin\n+\tdev.resetPin.Out(gpio.High)\n+\n+\tpin = gpioreg.ByName(irqPin)\n+\tdev.irqPin = pin\n+\tdev.irqPin.In(gpio.PullUp, gpio.FallingEdge)\n+\n+\terr = dev.Init()\n+\n+\treturn dev, nil\n+}\n+\n+var initCommands = [][]byte{\n+\t{commands.TModeReg, 0x8D},\n+\t{commands.TPrescalerReg, 0x3E},\n+\t{commands.TReloadRegL, 30},\n+\t{commands.TReloadRegH, 0},\n+\t{commands.TxAutoReg, 0x40},\n+\t{commands.ModeReg, 0x3D},\n+}\n+\n+// Init initializes the RFID chip.\n+func (r *Dev) Init() error {\n+\terr := r.Reset()","path":"experimental/devices/mfrc522/mfrc522.go","position":82,"original_position":82,"commit_id":"dd9dd09746e8a0869374948ae5e588816d3c61d3","original_commit_id":"62191f1ac12d474bc548f6ad9212a24405958da0","user":{"login":"jdevelop","id":141402,"avatar_url":"https://avatars0.githubusercontent.com/u/141402?v=4","gravatar_id":"","url":"https://api.github.com/users/jdevelop","html_url":"https://github.com/jdevelop","followers_url":"https://api.github.com/users/jdevelop/followers","following_url":"https://api.github.com/users/jdevelop/following{/other_user}","gists_url":"https://api.github.com/users/jdevelop/gists{/gist_id}","starred_url":"https://api.github.com/users/jdevelop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdevelop/subscriptions","organizations_url":"https://api.github.com/users/jdevelop/orgs","repos_url":"https://api.github.com/users/jdevelop/repos","events_url":"https://api.github.com/users/jdevelop/events{/privacy}","received_events_url":"https://api.github.com/users/jdevelop/received_events","type":"User","site_admin":false},"body":"Why do you think that it is memory-mapped? ","created_at":"2018-02-27T23:15:36Z","updated_at":"2018-02-27T23:15:36Z","html_url":"https://github.com/google/periph/pull/220#discussion_r171099038","pull_request_url":"https://api.github.com/repos/google/periph/pulls/220","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/google/periph/pulls/comments/171099038"},"html":{"href":"https://github.com/google/periph/pull/220#discussion_r171099038"},"pull_request":{"href":"https://api.github.com/repos/google/periph/pulls/220"}},"in_reply_to_id":171085324},"pull_request":{"url":"https://api.github.com/repos/google/periph/pulls/220","id":171755735,"html_url":"https://github.com/google/periph/pull/220","diff_url":"https://github.com/google/periph/pull/220.diff","patch_url":"https://github.com/google/periph/pull/220.patch","issue_url":"https://api.github.com/repos/google/periph/issues/220","number":220,"state":"open","locked":false,"title":"Initial support for the Mifare MFRC522 RFID Reader","user":{"login":"jdevelop","id":141402,"avatar_url":"https://avatars0.githubusercontent.com/u/141402?v=4","gravatar_id":"","url":"https://api.github.com/users/jdevelop","html_url":"https://github.com/jdevelop","followers_url":"https://api.github.com/users/jdevelop/followers","following_url":"https://api.github.com/users/jdevelop/following{/other_user}","gists_url":"https://api.github.com/users/jdevelop/gists{/gist_id}","starred_url":"https://api.github.com/users/jdevelop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdevelop/subscriptions","organizations_url":"https://api.github.com/users/jdevelop/orgs","repos_url":"https://api.github.com/users/jdevelop/repos","events_url":"https://api.github.com/users/jdevelop/events{/privacy}","received_events_url":"https://api.github.com/users/jdevelop/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-27T19:07:03Z","updated_at":"2018-02-27T23:15:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"234e20e6e7b74af72c54147e0935f7e3f3e86641","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/periph/pulls/220/commits","review_comments_url":"https://api.github.com/repos/google/periph/pulls/220/comments","review_comment_url":"https://api.github.com/repos/google/periph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/periph/issues/220/comments","statuses_url":"https://api.github.com/repos/google/periph/statuses/dd9dd09746e8a0869374948ae5e588816d3c61d3","head":{"label":"jdevelop:feature/mifare-rfid","ref":"feature/mifare-rfid","sha":"dd9dd09746e8a0869374948ae5e588816d3c61d3","user":{"login":"jdevelop","id":141402,"avatar_url":"https://avatars0.githubusercontent.com/u/141402?v=4","gravatar_id":"","url":"https://api.github.com/users/jdevelop","html_url":"https://github.com/jdevelop","followers_url":"https://api.github.com/users/jdevelop/followers","following_url":"https://api.github.com/users/jdevelop/following{/other_user}","gists_url":"https://api.github.com/users/jdevelop/gists{/gist_id}","starred_url":"https://api.github.com/users/jdevelop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdevelop/subscriptions","organizations_url":"https://api.github.com/users/jdevelop/orgs","repos_url":"https://api.github.com/users/jdevelop/repos","events_url":"https://api.github.com/users/jdevelop/events{/privacy}","received_events_url":"https://api.github.com/users/jdevelop/received_events","type":"User","site_admin":false},"repo":{"id":122910640,"name":"periph","full_name":"jdevelop/periph","owner":{"login":"jdevelop","id":141402,"avatar_url":"https://avatars0.githubusercontent.com/u/141402?v=4","gravatar_id":"","url":"https://api.github.com/users/jdevelop","html_url":"https://github.com/jdevelop","followers_url":"https://api.github.com/users/jdevelop/followers","following_url":"https://api.github.com/users/jdevelop/following{/other_user}","gists_url":"https://api.github.com/users/jdevelop/gists{/gist_id}","starred_url":"https://api.github.com/users/jdevelop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdevelop/subscriptions","organizations_url":"https://api.github.com/users/jdevelop/orgs","repos_url":"https://api.github.com/users/jdevelop/repos","events_url":"https://api.github.com/users/jdevelop/events{/privacy}","received_events_url":"https://api.github.com/users/jdevelop/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jdevelop/periph","description":"Go·Hardware·Lean","fork":true,"url":"https://api.github.com/repos/jdevelop/periph","forks_url":"https://api.github.com/repos/jdevelop/periph/forks","keys_url":"https://api.github.com/repos/jdevelop/periph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jdevelop/periph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jdevelop/periph/teams","hooks_url":"https://api.github.com/repos/jdevelop/periph/hooks","issue_events_url":"https://api.github.com/repos/jdevelop/periph/issues/events{/number}","events_url":"https://api.github.com/repos/jdevelop/periph/events","assignees_url":"https://api.github.com/repos/jdevelop/periph/assignees{/user}","branches_url":"https://api.github.com/repos/jdevelop/periph/branches{/branch}","tags_url":"https://api.github.com/repos/jdevelop/periph/tags","blobs_url":"https://api.github.com/repos/jdevelop/periph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jdevelop/periph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jdevelop/periph/git/refs{/sha}","trees_url":"https://api.github.com/repos/jdevelop/periph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jdevelop/periph/statuses/{sha}","languages_url":"https://api.github.com/repos/jdevelop/periph/languages","stargazers_url":"https://api.github.com/repos/jdevelop/periph/stargazers","contributors_url":"https://api.github.com/repos/jdevelop/periph/contributors","subscribers_url":"https://api.github.com/repos/jdevelop/periph/subscribers","subscription_url":"https://api.github.com/repos/jdevelop/periph/subscription","commits_url":"https://api.github.com/repos/jdevelop/periph/commits{/sha}","git_commits_url":"https://api.github.com/repos/jdevelop/periph/git/commits{/sha}","comments_url":"https://api.github.com/repos/jdevelop/periph/comments{/number}","issue_comment_url":"https://api.github.com/repos/jdevelop/periph/issues/comments{/number}","contents_url":"https://api.github.com/repos/jdevelop/periph/contents/{+path}","compare_url":"https://api.github.com/repos/jdevelop/periph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jdevelop/periph/merges","archive_url":"https://api.github.com/repos/jdevelop/periph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jdevelop/periph/downloads","issues_url":"https://api.github.com/repos/jdevelop/periph/issues{/number}","pulls_url":"https://api.github.com/repos/jdevelop/periph/pulls{/number}","milestones_url":"https://api.github.com/repos/jdevelop/periph/milestones{/number}","notifications_url":"https://api.github.com/repos/jdevelop/periph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jdevelop/periph/labels{/name}","releases_url":"https://api.github.com/repos/jdevelop/periph/releases{/id}","deployments_url":"https://api.github.com/repos/jdevelop/periph/deployments","created_at":"2018-02-26T03:59:31Z","updated_at":"2018-02-26T03:59:33Z","pushed_at":"2018-02-27T22:15:00Z","git_url":"git://github.com/jdevelop/periph.git","ssh_url":"git@github.com:jdevelop/periph.git","clone_url":"https://github.com/jdevelop/periph.git","svn_url":"https://github.com/jdevelop/periph","homepage":"https://periph.io","size":1170,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"495220b17db3c9ff55d6bb42850f9feff7879990","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":70828109,"name":"periph","full_name":"google/periph","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/periph","description":"Go·Hardware·Lean","fork":false,"url":"https://api.github.com/repos/google/periph","forks_url":"https://api.github.com/repos/google/periph/forks","keys_url":"https://api.github.com/repos/google/periph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/periph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/periph/teams","hooks_url":"https://api.github.com/repos/google/periph/hooks","issue_events_url":"https://api.github.com/repos/google/periph/issues/events{/number}","events_url":"https://api.github.com/repos/google/periph/events","assignees_url":"https://api.github.com/repos/google/periph/assignees{/user}","branches_url":"https://api.github.com/repos/google/periph/branches{/branch}","tags_url":"https://api.github.com/repos/google/periph/tags","blobs_url":"https://api.github.com/repos/google/periph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/periph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/periph/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/periph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/periph/statuses/{sha}","languages_url":"https://api.github.com/repos/google/periph/languages","stargazers_url":"https://api.github.com/repos/google/periph/stargazers","contributors_url":"https://api.github.com/repos/google/periph/contributors","subscribers_url":"https://api.github.com/repos/google/periph/subscribers","subscription_url":"https://api.github.com/repos/google/periph/subscription","commits_url":"https://api.github.com/repos/google/periph/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/periph/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/periph/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/periph/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/periph/contents/{+path}","compare_url":"https://api.github.com/repos/google/periph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/periph/merges","archive_url":"https://api.github.com/repos/google/periph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/periph/downloads","issues_url":"https://api.github.com/repos/google/periph/issues{/number}","pulls_url":"https://api.github.com/repos/google/periph/pulls{/number}","milestones_url":"https://api.github.com/repos/google/periph/milestones{/number}","notifications_url":"https://api.github.com/repos/google/periph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/periph/labels{/name}","releases_url":"https://api.github.com/repos/google/periph/releases{/id}","deployments_url":"https://api.github.com/repos/google/periph/deployments","created_at":"2016-10-13T16:53:51Z","updated_at":"2018-02-26T21:14:15Z","pushed_at":"2018-02-27T22:15:02Z","git_url":"git://github.com/google/periph.git","ssh_url":"git@github.com:google/periph.git","clone_url":"https://github.com/google/periph.git","svn_url":"https://github.com/google/periph","homepage":"https://periph.io","size":1154,"stargazers_count":896,"watchers_count":896,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":57,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":57,"open_issues":32,"watchers":896,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/periph/pulls/220"},"html":{"href":"https://github.com/google/periph/pull/220"},"issue":{"href":"https://api.github.com/repos/google/periph/issues/220"},"comments":{"href":"https://api.github.com/repos/google/periph/issues/220/comments"},"review_comments":{"href":"https://api.github.com/repos/google/periph/pulls/220/comments"},"review_comment":{"href":"https://api.github.com/repos/google/periph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/periph/pulls/220/commits"},"statuses":{"href":"https://api.github.com/repos/google/periph/statuses/dd9dd09746e8a0869374948ae5e588816d3c61d3"}},"author_association":"NONE"}}
{"actor":{"display_login":"jdevelop"}}