|
71 | 71 | //! rt = ["cortex-m-rt/device"] |
72 | 72 | //! ``` |
73 | 73 | //! |
74 | | -//! ## target != cortex-m |
| 74 | +//! ## target = msp430 |
75 | 75 | //! |
76 | | -//! When the target is msp430, riscv or none `svd2rust` will emit only the `lib.rs` file. Like in |
| 76 | +//! MSP430 does not natively use the SVD format. However, SVD files can be generated using the |
| 77 | +//! [`msp430_svd` application](https://github.com/pftbest/msp430_svd). Most header and DSLite |
| 78 | +//! files provided by TI are mirrored in the repository of `msp430_svd`. |
| 79 | +//! |
| 80 | +//! When targeting the MSP430 architecture `svd2rust` will _also_ generate three files in the |
| 81 | +//! current directory: |
| 82 | +//! |
| 83 | +//! - `build.rs`, build script that places `device.x` somewhere the linker can find. |
| 84 | +//! - `device.x`, linker script that weakly aliases all the interrupt handlers to the default |
| 85 | +//! exception handler (`DefaultHandler`). |
| 86 | +//! - `lib.rs`, the generated code. |
| 87 | +//! |
| 88 | +//! All these files must be included in the same device crate. The `lib.rs` file contains several |
| 89 | +//! inlined modules and its not formatted. It's recommend to split it out using the [`form`] tool |
| 90 | +//! and then format the output using `rustfmt` / `cargo fmt`: |
| 91 | +//! |
| 92 | +//! [`form`]: https://crates.io/crates/form |
| 93 | +//! |
| 94 | +//! ``` text |
| 95 | +//! $ msp430gen msp430g2553 > out.svd |
| 96 | +//! |
| 97 | +//! $ xmllint -format out.svd > msp430g2553.svd |
| 98 | +//! |
| 99 | +//! $ svd2rust --target=msp430 -i msp430g2553.svd |
| 100 | +//! |
| 101 | +//! $ rm -rf src |
| 102 | +//! |
| 103 | +//! $ form -i lib.rs -o src/ && rm lib.rs |
| 104 | +//! |
| 105 | +//! $ cargo fmt |
| 106 | +//! ``` |
| 107 | +//! |
| 108 | +//! The resulting crate must provide an opt-in "rt" feature and depend on these crates: |
| 109 | +//! `bare-metal` v0.2.x, `msp430` v0.2.x, `msp430-rt` v0.2.x and `vcell` v0.1.x. Furthermore |
| 110 | +//! the "device" feature of `msp430-rt` must be enabled when the "rt" feature is enabled. The |
| 111 | +//! `Cargo.toml` of the device crate will look like this: |
| 112 | +//! |
| 113 | +//! ``` toml |
| 114 | +//! [dependencies] |
| 115 | +//! bare-metal = "0.2.0" |
| 116 | +//! msp430 = "0.2.0" |
| 117 | +//! vcell = "0.1.0" |
| 118 | +//! |
| 119 | +//! [dependencies.msp430-rt] |
| 120 | +//! optional = true |
| 121 | +//! version = "0.2.0" |
| 122 | +//! |
| 123 | +//! [features] |
| 124 | +//! rt = ["msp430-rt/device"] |
| 125 | +//! ``` |
| 126 | +//! |
| 127 | +//! ## Other targets |
| 128 | +//! |
| 129 | +//! When the target is riscv or none `svd2rust` will emit only the `lib.rs` file. Like in |
77 | 130 | //! the cortex-m case we recommend you use `form` and `rustfmt` on the output. |
78 | 131 | //! |
79 | 132 | //! The resulting crate must provide an opt-in "rt" feature and depend on these crates: |
80 | 133 | //! |
81 | 134 | //! - [`bare-metal`](https://crates.io/crates/bare-metal) v0.2.x |
82 | 135 | //! - [`vcell`](https://crates.io/crates/vcell) v0.1.x |
83 | | -//! - [`msp430`](https://crates.io/crates/msp430) v0.1.x if target = msp430. |
84 | | -//! - [`msp430-rt`](https://crates.io/crates/msp430-rt) v0.1.x if target = msp430. |
85 | 136 | //! - [`riscv`](https://crates.io/crates/riscv) v0.4.x if target = riscv. |
86 | 137 | //! - [`riscv-rt`](https://crates.io/crates/riscv-rt) v0.4.x if target = riscv. |
87 | 138 | //! |
88 | 139 | //! The `*-rt` dependencies must be optional only enabled when the "rt" feature is enabled. The |
89 | | -//! `Cargo.toml` of the device crate will look like this for an msp430 target: |
| 140 | +//! `Cargo.toml` of the device crate will look like this for a riscv target: |
90 | 141 | //! |
91 | 142 | //! ``` toml |
92 | 143 | //! [dependencies] |
93 | | -//! bare-metal = "0.1.0" |
94 | | -//! msp430 = "0.1.0" |
| 144 | +//! bare-metal = "0.2.0" |
| 145 | +//! riscv = "0.4.0" |
95 | 146 | //! vcell = "0.1.0" |
96 | 147 | //! |
97 | | -//! [dependencies.msp430-rt] |
| 148 | +//! [dependencies.riscv-rt] |
98 | 149 | //! optional = true |
99 | | -//! version = "0.1.0" |
| 150 | +//! version = "0.4.0" |
100 | 151 | //! |
101 | 152 | //! [features] |
102 | | -//! rt = ["msp430-rt"] |
| 153 | +//! rt = ["riscv-rt"] |
103 | 154 | //! ``` |
104 | 155 | //! |
105 | 156 | //! # Peripheral API |
|
418 | 469 | //! |
419 | 470 | //! If the "rt" Cargo feature of the svd2rust generated crate is enabled the crate will populate the |
420 | 471 | //! part of the vector table that contains the interrupt vectors and provide an |
421 | | -//! [`interrupt!`](macro.interrupt.html) macro (non Cortex-M targets) or [`interrupt`] attribute |
422 | | -//! (Cortex-M) that can be used to register interrupt handlers. |
| 472 | +//! [`interrupt!`](macro.interrupt.html) macro (non Cortex-M/MSP430 targets) or [`interrupt`] attribute |
| 473 | +//! (Cortex-M or [MSP430](https://docs.rs/msp430-rt-macros/0.1/msp430_rt_macros/attr.interrupt.html)) |
| 474 | +//! that can be used to register interrupt handlers. |
423 | 475 | //! |
424 | 476 | //! [`interrupt`]: https://docs.rs/cortex-m-rt-macros/0.1/cortex_m_rt_macros/attr.interrupt.html |
425 | 477 | //! |
@@ -502,7 +554,7 @@ pub fn generate(xml: &str, target: Target, nightly: bool) -> Result<Generation> |
502 | 554 |
|
503 | 555 | /// Assigns a handler to an interrupt |
504 | 556 | /// |
505 | | -/// **NOTE** The `interrupt!` macro on Cortex-M device crates is closer in syntax to the |
| 557 | +/// **NOTE** The `interrupt!` macro on Cortex-M and MSP430 device crates is closer in syntax to the |
506 | 558 | /// [`exception!`] macro. This documentation doesn't apply to it. For the exact syntax of this macro |
507 | 559 | /// check the documentation of the device crate you are using. |
508 | 560 | /// |
|
0 commit comments