{"action":"created","comment":{"url":"https://api.github.com/repos/tock/tock/pulls/comments/197177528","pull_request_review_id":130870412,"id":197177528,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzE3NzUyOA==","diff_hunk":"@@ -0,0 +1,194 @@\n+//! Segger RTT implementation.\n+//!\n+//! RTT is a protocol for sending debugging messages to a connected host. The\n+//! embedded platform configures a portion of memory in a special way, and then\n+//! the host uses a JTAG connection to read the messages out of the chip's\n+//! memory.\n+//!\n+//!\tReceiving RTT Messages\n+//!\t----------------------\n+//!\n+//!\tWith the jlink tools, reciving RTT messages is a two step process. First,\n+//!\topen a JTAG connection with a command like:\n+//!\n+//!\t    $ JLinkExe -device nrf52 -if swd -speed 1000 -autoconnect 1\n+//!\n+//!\tThen, use the `JLinkRTTClient` tool in a different terminal to print the\n+//!\tmessages:\n+//!\n+//!\t    $ JLinkRTTClient\n+//!\n+//! Notes\n+//! -----\n+//!\n+//! This capsule requires a timer, but the timer is only there to defer the\n+//! `transmit_complete` callback until the next scheduler loop. In the future,\n+//! if there is support for software interrupts or deferred calls in capsules,\n+//! this timer should be removed.\n+//!\n+//! Usage\n+//! -----\n+//!\n+//! ```\n+//! let virtual_alarm_rtt = static_init!(\n+//!     capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf5x::rtc::Rtc>,\n+//!     capsules::virtual_alarm::VirtualMuxAlarm::new(mux_alarm)\n+//! );\n+//!\n+//! let rtt_memory = static_init!(\n+//!     capsules::segger_rtt::SeggerRttMemory,\n+//!     capsules::segger_rtt::SeggerRttMemory::new(b\"Terminal\\0\",\n+//!         &mut capsules::segger_rtt::UP_BUFFER,\n+//!         b\"Terminal\\0\",\n+//!         &mut capsules::segger_rtt::DOWN_BUFFER)\n+//! );\n+//!\n+//! let rtt = static_init!(\n+//!     capsules::segger_rtt::SeggerRtt<VirtualMuxAlarm<'static, nrf5x::rtc::Rtc>>,\n+//!     capsules::segger_rtt::SeggerRtt::new(virtual_alarm_rtt, rtt_memory,\n+//!         &mut capsules::segger_rtt::UP_BUFFER,\n+//!         &mut capsules::segger_rtt::DOWN_BUFFER)\n+//! );\n+//! virtual_alarm_rtt.set_client(rtt);\n+//! ```\n+\n+use kernel::common::cells::{OptionalCell, TakeCell};\n+use kernel::hil;\n+use kernel::hil::time::Frequency;\n+\n+/// Buffer for transmitting to the host.\n+pub static mut UP_BUFFER: [u8; 1024] = [0; 1024];\n+\n+/// Buffer for receiving messages from the host.\n+pub static mut DOWN_BUFFER: [u8; 32] = [0; 32];\n+\n+/// This structure is defined by the segger RTT protocol.\n+#[repr(C)]\n+pub struct SeggerRttMemory {\n+    id: [u8; 16],\n+    number_up_buffers: u32,\n+    number_down_buffers: u32,\n+    up_buffer: SeggerRttBuffer,\n+    down_buffer: SeggerRttBuffer,\n+}\n+\n+#[repr(C)]\n+pub struct SeggerRttBuffer {\n+    name: *const u8, // Pointer to the name of this channel. Must be a 4 byte thin pointer.\n+    buffer: *const u8, // Pointer to the buffer for this channel.\n+    length: u32,\n+    write_position: u32,\n+    read_position: u32,\n+    flags: u32,\n+}\n+\n+impl SeggerRttMemory {\n+    pub fn new(\n+        up_buffer_name: &'static [u8],\n+        up_buffer: &'static [u8],\n+        down_buffer_name: &'static [u8],\n+        down_buffer: &'static [u8],\n+    ) -> SeggerRttMemory {\n+        SeggerRttMemory {\n+            // Must be \"SEGGER RTT\".\n+            id: [\n+                0x53, 0x45, 0x47, 0x47, 0x45, 0x52, 0x20, 0x52, 0x54, 0x54, 0, 0, 0, 0, 0, 0,\n+            ],\n+            number_up_buffers: 1,\n+            number_down_buffers: 1,\n+            up_buffer: SeggerRttBuffer {\n+                name: up_buffer_name.as_ptr(),\n+                buffer: up_buffer.as_ptr(),\n+                length: 1024,\n+                write_position: 0,\n+                read_position: 0,\n+                flags: 0,\n+            },\n+            down_buffer: SeggerRttBuffer {\n+                name: down_buffer_name.as_ptr(),\n+                buffer: down_buffer.as_ptr(),\n+                length: 32,\n+                write_position: 0,\n+                read_position: 0,\n+                flags: 0,\n+            },\n+        }\n+    }\n+}\n+\n+pub struct SeggerRtt<'a, A: hil::time::Alarm + 'a> {","path":"capsules/src/segger_rtt.rs","position":124,"original_position":119,"commit_id":"eac5dc37419f27e2550ee3fb1ff2fb28d26cd4d0","original_commit_id":"9ef9dbd285be45a548f1950c23b714aaa507046c","user":{"login":"bradjc","id":1467890,"node_id":"MDQ6VXNlcjE0Njc4OTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1467890?v=4","gravatar_id":"","url":"https://api.github.com/users/bradjc","html_url":"https://github.com/bradjc","followers_url":"https://api.github.com/users/bradjc/followers","following_url":"https://api.github.com/users/bradjc/following{/other_user}","gists_url":"https://api.github.com/users/bradjc/gists{/gist_id}","starred_url":"https://api.github.com/users/bradjc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradjc/subscriptions","organizations_url":"https://api.github.com/users/bradjc/orgs","repos_url":"https://api.github.com/users/bradjc/repos","events_url":"https://api.github.com/users/bradjc/events{/privacy}","received_events_url":"https://api.github.com/users/bradjc/received_events","type":"User","site_admin":false},"body":"What docs are you looking for? I don't see any docs on the main capsule struct in other capsules.","created_at":"2018-06-21T15:27:48Z","updated_at":"2018-06-21T15:28:49Z","html_url":"https://github.com/tock/tock/pull/1013#discussion_r197177528","pull_request_url":"https://api.github.com/repos/tock/tock/pulls/1013","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/tock/tock/pulls/comments/197177528"},"html":{"href":"https://github.com/tock/tock/pull/1013#discussion_r197177528"},"pull_request":{"href":"https://api.github.com/repos/tock/tock/pulls/1013"}},"in_reply_to_id":197051771},"pull_request":{"url":"https://api.github.com/repos/tock/tock/pulls/1013","id":196291417,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MjkxNDE3","html_url":"https://github.com/tock/tock/pull/1013","diff_url":"https://github.com/tock/tock/pull/1013.diff","patch_url":"https://github.com/tock/tock/pull/1013.patch","issue_url":"https://api.github.com/repos/tock/tock/issues/1013","number":1013,"state":"open","locked":false,"title":"capsules: add Segger RTT capsule","user":{"login":"bradjc","id":1467890,"node_id":"MDQ6VXNlcjE0Njc4OTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1467890?v=4","gravatar_id":"","url":"https://api.github.com/users/bradjc","html_url":"https://github.com/bradjc","followers_url":"https://api.github.com/users/bradjc/followers","following_url":"https://api.github.com/users/bradjc/following{/other_user}","gists_url":"https://api.github.com/users/bradjc/gists{/gist_id}","starred_url":"https://api.github.com/users/bradjc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradjc/subscriptions","organizations_url":"https://api.github.com/users/bradjc/orgs","repos_url":"https://api.github.com/users/bradjc/repos","events_url":"https://api.github.com/users/bradjc/events{/privacy}","received_events_url":"https://api.github.com/users/bradjc/received_events","type":"User","site_admin":false},"body":"This provides a \"UART\" interface that transmits messages using Segger's\r\nRTT protocol.\r\n\r\n\r\n\r\n\r\n### Testing Strategy\r\n\r\nThis pull request was tested by using it successfully on the ADC52832.\r\n\r\n\r\n### TODO or Help Wanted\r\n\r\nn/a\r\n\r\n\r\n### Documentation Updated\r\n\r\n- [x] Updated the relevant files in `/docs`, or no updates are required.\r\n\r\n### Formatting\r\n\r\n- [x] Ran `make formatall`.\r\n","created_at":"2018-06-20T22:38:57Z","updated_at":"2018-06-21T15:28:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f2e26cea81058b8244adad36baf1dd176d9232e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tock/tock/pulls/1013/commits","review_comments_url":"https://api.github.com/repos/tock/tock/pulls/1013/comments","review_comment_url":"https://api.github.com/repos/tock/tock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tock/tock/issues/1013/comments","statuses_url":"https://api.github.com/repos/tock/tock/statuses/eac5dc37419f27e2550ee3fb1ff2fb28d26cd4d0","head":{"label":"tock:rtt","ref":"rtt","sha":"eac5dc37419f27e2550ee3fb1ff2fb28d26cd4d0","user":{"login":"tock","id":34076064,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MDc2MDY0","avatar_url":"https://avatars1.githubusercontent.com/u/34076064?v=4","gravatar_id":"","url":"https://api.github.com/users/tock","html_url":"https://github.com/tock","followers_url":"https://api.github.com/users/tock/followers","following_url":"https://api.github.com/users/tock/following{/other_user}","gists_url":"https://api.github.com/users/tock/gists{/gist_id}","starred_url":"https://api.github.com/users/tock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tock/subscriptions","organizations_url":"https://api.github.com/users/tock/orgs","repos_url":"https://api.github.com/users/tock/repos","events_url":"https://api.github.com/users/tock/events{/privacy}","received_events_url":"https://api.github.com/users/tock/received_events","type":"Organization","site_admin":false},"repo":{"id":36428094,"node_id":"MDEwOlJlcG9zaXRvcnkzNjQyODA5NA==","name":"tock","full_name":"tock/tock","owner":{"login":"tock","id":34076064,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MDc2MDY0","avatar_url":"https://avatars1.githubusercontent.com/u/34076064?v=4","gravatar_id":"","url":"https://api.github.com/users/tock","html_url":"https://github.com/tock","followers_url":"https://api.github.com/users/tock/followers","following_url":"https://api.github.com/users/tock/following{/other_user}","gists_url":"https://api.github.com/users/tock/gists{/gist_id}","starred_url":"https://api.github.com/users/tock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tock/subscriptions","organizations_url":"https://api.github.com/users/tock/orgs","repos_url":"https://api.github.com/users/tock/repos","events_url":"https://api.github.com/users/tock/events{/privacy}","received_events_url":"https://api.github.com/users/tock/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tock/tock","description":"A secure embedded operating system for Cortex-M based microcontrollers","fork":false,"url":"https://api.github.com/repos/tock/tock","forks_url":"https://api.github.com/repos/tock/tock/forks","keys_url":"https://api.github.com/repos/tock/tock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tock/tock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tock/tock/teams","hooks_url":"https://api.github.com/repos/tock/tock/hooks","issue_events_url":"https://api.github.com/repos/tock/tock/issues/events{/number}","events_url":"https://api.github.com/repos/tock/tock/events","assignees_url":"https://api.github.com/repos/tock/tock/assignees{/user}","branches_url":"https://api.github.com/repos/tock/tock/branches{/branch}","tags_url":"https://api.github.com/repos/tock/tock/tags","blobs_url":"https://api.github.com/repos/tock/tock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tock/tock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tock/tock/git/refs{/sha}","trees_url":"https://api.github.com/repos/tock/tock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tock/tock/statuses/{sha}","languages_url":"https://api.github.com/repos/tock/tock/languages","stargazers_url":"https://api.github.com/repos/tock/tock/stargazers","contributors_url":"https://api.github.com/repos/tock/tock/contributors","subscribers_url":"https://api.github.com/repos/tock/tock/subscribers","subscription_url":"https://api.github.com/repos/tock/tock/subscription","commits_url":"https://api.github.com/repos/tock/tock/commits{/sha}","git_commits_url":"https://api.github.com/repos/tock/tock/git/commits{/sha}","comments_url":"https://api.github.com/repos/tock/tock/comments{/number}","issue_comment_url":"https://api.github.com/repos/tock/tock/issues/comments{/number}","contents_url":"https://api.github.com/repos/tock/tock/contents/{+path}","compare_url":"https://api.github.com/repos/tock/tock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tock/tock/merges","archive_url":"https://api.github.com/repos/tock/tock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tock/tock/downloads","issues_url":"https://api.github.com/repos/tock/tock/issues{/number}","pulls_url":"https://api.github.com/repos/tock/tock/pulls{/number}","milestones_url":"https://api.github.com/repos/tock/tock/milestones{/number}","notifications_url":"https://api.github.com/repos/tock/tock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tock/tock/labels{/name}","releases_url":"https://api.github.com/repos/tock/tock/releases{/id}","deployments_url":"https://api.github.com/repos/tock/tock/deployments","created_at":"2015-05-28T09:26:47Z","updated_at":"2018-06-21T14:47:12Z","pushed_at":"2018-06-21T15:26:29Z","git_url":"git://github.com/tock/tock.git","ssh_url":"git@github.com:tock/tock.git","clone_url":"https://github.com/tock/tock.git","svn_url":"https://github.com/tock/tock","homepage":"https://www.tockos.org","size":135051,"stargazers_count":900,"watchers_count":900,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":114,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":114,"open_issues":45,"watchers":900,"default_branch":"master"}},"base":{"label":"tock:master","ref":"master","sha":"ae2157a1cbaaded3a1c48fb8e631cc2ac58d66af","user":{"login":"tock","id":34076064,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MDc2MDY0","avatar_url":"https://avatars1.githubusercontent.com/u/34076064?v=4","gravatar_id":"","url":"https://api.github.com/users/tock","html_url":"https://github.com/tock","followers_url":"https://api.github.com/users/tock/followers","following_url":"https://api.github.com/users/tock/following{/other_user}","gists_url":"https://api.github.com/users/tock/gists{/gist_id}","starred_url":"https://api.github.com/users/tock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tock/subscriptions","organizations_url":"https://api.github.com/users/tock/orgs","repos_url":"https://api.github.com/users/tock/repos","events_url":"https://api.github.com/users/tock/events{/privacy}","received_events_url":"https://api.github.com/users/tock/received_events","type":"Organization","site_admin":false},"repo":{"id":36428094,"node_id":"MDEwOlJlcG9zaXRvcnkzNjQyODA5NA==","name":"tock","full_name":"tock/tock","owner":{"login":"tock","id":34076064,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MDc2MDY0","avatar_url":"https://avatars1.githubusercontent.com/u/34076064?v=4","gravatar_id":"","url":"https://api.github.com/users/tock","html_url":"https://github.com/tock","followers_url":"https://api.github.com/users/tock/followers","following_url":"https://api.github.com/users/tock/following{/other_user}","gists_url":"https://api.github.com/users/tock/gists{/gist_id}","starred_url":"https://api.github.com/users/tock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tock/subscriptions","organizations_url":"https://api.github.com/users/tock/orgs","repos_url":"https://api.github.com/users/tock/repos","events_url":"https://api.github.com/users/tock/events{/privacy}","received_events_url":"https://api.github.com/users/tock/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tock/tock","description":"A secure embedded operating system for Cortex-M based microcontrollers","fork":false,"url":"https://api.github.com/repos/tock/tock","forks_url":"https://api.github.com/repos/tock/tock/forks","keys_url":"https://api.github.com/repos/tock/tock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tock/tock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tock/tock/teams","hooks_url":"https://api.github.com/repos/tock/tock/hooks","issue_events_url":"https://api.github.com/repos/tock/tock/issues/events{/number}","events_url":"https://api.github.com/repos/tock/tock/events","assignees_url":"https://api.github.com/repos/tock/tock/assignees{/user}","branches_url":"https://api.github.com/repos/tock/tock/branches{/branch}","tags_url":"https://api.github.com/repos/tock/tock/tags","blobs_url":"https://api.github.com/repos/tock/tock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tock/tock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tock/tock/git/refs{/sha}","trees_url":"https://api.github.com/repos/tock/tock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tock/tock/statuses/{sha}","languages_url":"https://api.github.com/repos/tock/tock/languages","stargazers_url":"https://api.github.com/repos/tock/tock/stargazers","contributors_url":"https://api.github.com/repos/tock/tock/contributors","subscribers_url":"https://api.github.com/repos/tock/tock/subscribers","subscription_url":"https://api.github.com/repos/tock/tock/subscription","commits_url":"https://api.github.com/repos/tock/tock/commits{/sha}","git_commits_url":"https://api.github.com/repos/tock/tock/git/commits{/sha}","comments_url":"https://api.github.com/repos/tock/tock/comments{/number}","issue_comment_url":"https://api.github.com/repos/tock/tock/issues/comments{/number}","contents_url":"https://api.github.com/repos/tock/tock/contents/{+path}","compare_url":"https://api.github.com/repos/tock/tock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tock/tock/merges","archive_url":"https://api.github.com/repos/tock/tock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tock/tock/downloads","issues_url":"https://api.github.com/repos/tock/tock/issues{/number}","pulls_url":"https://api.github.com/repos/tock/tock/pulls{/number}","milestones_url":"https://api.github.com/repos/tock/tock/milestones{/number}","notifications_url":"https://api.github.com/repos/tock/tock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tock/tock/labels{/name}","releases_url":"https://api.github.com/repos/tock/tock/releases{/id}","deployments_url":"https://api.github.com/repos/tock/tock/deployments","created_at":"2015-05-28T09:26:47Z","updated_at":"2018-06-21T14:47:12Z","pushed_at":"2018-06-21T15:26:29Z","git_url":"git://github.com/tock/tock.git","ssh_url":"git@github.com:tock/tock.git","clone_url":"https://github.com/tock/tock.git","svn_url":"https://github.com/tock/tock","homepage":"https://www.tockos.org","size":135051,"stargazers_count":900,"watchers_count":900,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":114,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":114,"open_issues":45,"watchers":900,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tock/tock/pulls/1013"},"html":{"href":"https://github.com/tock/tock/pull/1013"},"issue":{"href":"https://api.github.com/repos/tock/tock/issues/1013"},"comments":{"href":"https://api.github.com/repos/tock/tock/issues/1013/comments"},"review_comments":{"href":"https://api.github.com/repos/tock/tock/pulls/1013/comments"},"review_comment":{"href":"https://api.github.com/repos/tock/tock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tock/tock/pulls/1013/commits"},"statuses":{"href":"https://api.github.com/repos/tock/tock/statuses/eac5dc37419f27e2550ee3fb1ff2fb28d26cd4d0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bradjc"}}