{"action":"created","issue":{"url":"https://api.github.com/repos/japaric/cortex-m-rtfm/issues/34","repository_url":"https://api.github.com/repos/japaric/cortex-m-rtfm","labels_url":"https://api.github.com/repos/japaric/cortex-m-rtfm/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/japaric/cortex-m-rtfm/issues/34/comments","events_url":"https://api.github.com/repos/japaric/cortex-m-rtfm/issues/34/events","html_url":"https://github.com/japaric/cortex-m-rtfm/pull/34","id":240464505,"number":34,"title":"[WIP] rtfm! macro take 2","user":{"login":"japaric","id":5018213,"avatar_url":"https://avatars0.githubusercontent.com/u/5018213?v=3","gravatar_id":"","url":"https://api.github.com/users/japaric","html_url":"https://github.com/japaric","followers_url":"https://api.github.com/users/japaric/followers","following_url":"https://api.github.com/users/japaric/following{/other_user}","gists_url":"https://api.github.com/users/japaric/gists{/gist_id}","starred_url":"https://api.github.com/users/japaric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/japaric/subscriptions","organizations_url":"https://api.github.com/users/japaric/orgs","repos_url":"https://api.github.com/users/japaric/repos","events_url":"https://api.github.com/users/japaric/events{/privacy}","received_events_url":"https://api.github.com/users/japaric/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-07-04T16:32:39Z","updated_at":"2017-07-11T22:18:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/japaric/cortex-m-rtfm/pulls/34","html_url":"https://github.com/japaric/cortex-m-rtfm/pull/34","diff_url":"https://github.com/japaric/cortex-m-rtfm/pull/34.diff","patch_url":"https://github.com/japaric/cortex-m-rtfm/pull/34.patch"},"body":"### Update\r\n\r\nMore ports from RTFM v1 to this macro:\r\n\r\n- [Two wheeled robot](https://github.com/japaric/2wd/pull/4)\r\n- [WS2812B LED driver](https://github.com/japaric/ws2812b/pull/1)\r\n- [Several examples from the blue-pill crate](https://github.com/japaric/blue-pill/pull/19)\r\n\r\n---\r\n\r\n[Full example](https://gist.github.com/japaric/e825cabe5a95d8e75e08917a4bf4d195)\r\n\r\n^ This is semantically the same example presented in #31, but with this new\r\nmacro 33% less code is required.\r\n\r\nNext iteration of the rtfm! macro presented in #31. The most notable change wrt\r\nthe previous version is that the macro has become a compiler plugin.\r\n\r\n# Pros\r\n\r\n- Automatic ceiling derivation. The ceiling will be computed from the\r\n  information about which tasks use which resources.\r\n\r\n- Simpler task and resource specification. There's no split between interrupts\r\n  used as tasks and exceptions used as tasks; there's only tasks now. Likewise\r\n  there's no distinction between peripherals used as resources and data\r\n  resources; there's only resources now.\r\n\r\n- More flexible syntax. The fields can be shuffled around without breaking the\r\n  parser.\r\n\r\n- Simpler signatures as there's no `Peripherals` / `Resources` split.\r\n\r\n- Adaptive signatures. The signature of idle will be `fn() -> !` if it makes no\r\n  uses of resources and has no local data, but it will change to\r\n  `fn(idle::Local)` if local data is used, etc.\r\n\r\n- Less claims. Full access to resources is given to tasks whose priority matches\r\n  the resource ceiling.\r\n\r\n- More control over error messages related to the parsing and expansion of\r\n  `rtfm!`.\r\n\r\n# Cons\r\n\r\n`rtfm!` is now a compiler plugin. This makes the chance of it breaking across\r\nnightly updates greater than zero. However, I've implemented the compiler plugin\r\non top of token streams so we should be safe from compiler changes related to\r\nthe language syntax and parser. Once function style macros becomes available via\r\nthe more stable proc-macros feature it should be straightforward to move to it.\r\nAnd yes, I tried [proc-macro-hack] which allows function style proc macros on\r\ntop of custom derive proc macros but it doesn't work for no-std / cross\r\ncompilation because the hack requires a proc-macro crate compiled for the target\r\n(which is not possible for thumb because proc-macro contains `String`s).\r\n\r\n[proc-macro-hack]: https://github.com/dtolnay/proc-macro-hack\r\n\r\n# Other changes\r\n\r\n- I realized that the change to scope based safety fixes #13 so I've added a\r\n  `borrow` / `borrow_mut` method to resources to get direct access to them\r\n  within a global critical section.\r\n\r\n- Given that we pretty much generate the implementation of the claim methods in\r\n  the application crate I have changed things such that (NVIC) PRIORITY_BITS is\r\n  no longer in the cortex-m-rtfm, but rather it's expected to be provided by the\r\n  device crate. This way we don't need a bunch of P{2,3,..} Cargo features in\r\n  the cortex-m-rtfm crate. OTOH, device generated crates now must provide a\r\n  `NVIC_PRIO_BITS` constant that provides this information. SVD files contain\r\n  this information in the form of the optional [`<nvicPrioBits>`] field.\r\n  svd2rust will be taught to generate the `NVIC_PRIO_BITS` constant.\r\n\r\n[`<nvicPrioBits>`]: https://www.keil.com/pack/doc/CMSIS/SVD/html/elem_cpu.html\r\n\r\n- The declaration of task local data and the task function path has been moved\r\n  into a `task!` macro. This macro doesn't have to be in the root of the crate.\r\n\r\ncc @whitequark\r\n"},"comment":{"url":"https://api.github.com/repos/japaric/cortex-m-rtfm/issues/comments/314588424","html_url":"https://github.com/japaric/cortex-m-rtfm/pull/34#issuecomment-314588424","issue_url":"https://api.github.com/repos/japaric/cortex-m-rtfm/issues/34","id":314588424,"user":{"login":"japaric","id":5018213,"avatar_url":"https://avatars0.githubusercontent.com/u/5018213?v=3","gravatar_id":"","url":"https://api.github.com/users/japaric","html_url":"https://github.com/japaric","followers_url":"https://api.github.com/users/japaric/followers","following_url":"https://api.github.com/users/japaric/following{/other_user}","gists_url":"https://api.github.com/users/japaric/gists{/gist_id}","starred_url":"https://api.github.com/users/japaric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/japaric/subscriptions","organizations_url":"https://api.github.com/users/japaric/orgs","repos_url":"https://api.github.com/users/japaric/repos","events_url":"https://api.github.com/users/japaric/events{/privacy}","received_events_url":"https://api.github.com/users/japaric/received_events","type":"User","site_admin":false},"created_at":"2017-07-11T22:18:37Z","updated_at":"2017-07-11T22:18:37Z","body":"@whitequark I thought that functionlike! proc macros weren't implemented given the existence of proc-macro-hack and the lack of documentation about macros 2.0 so I was using a compiler plugin. But I figured out how to use `#![proc_macro]` so I'll switch to that."}}
{"actor":{"display_login":"japaric"}}