Skip to content

Commit e94fc7b

Browse files
bors[bot]kiffie
andauthored
Merge #493
493: Mips target r=burrbull a=kiffie r? @therealprof Hi all, Willing to add some basic support for MIPS cores? This patch enables the Peripheral Singleton. I use svd2rust to create PACs for PIC32MX microcontroller. Best regards, Stephan Co-authored-by: Stephan <kiffie@users.noreply.github.com>
2 parents 6bfc843 + f18d69d commit e94fc7b

File tree

9 files changed

+45
-3
lines changed

9 files changed

+45
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
rust: [stable]
1515

1616
# All vendor files we want to test on stable
17-
VENDOR: [rustfmt, Atmel, Freescale, Fujitsu, Holtek, Nordic, Nuvoton, NXP, RISC-V, SiliconLabs, Spansion, STMicro, Toshiba]
17+
VENDOR: [rustfmt, Atmel, Freescale, Fujitsu, Holtek, Microchip, Nordic, Nuvoton, NXP, RISC-V, SiliconLabs, Spansion, STMicro, Toshiba]
1818

1919
# The default target we're compiling on and for
2020
TARGET: [x86_64-unknown-linux-gnu]

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616

1717
- Generated peripherals now implement `core::fmt::Debug`.
1818

19+
- Support for MIPS MCU cores, in particular for PIC32MX microcontrollers
20+
1921
### Fixed
2022

2123
- Keyword sanitizing (`async`)

ci/script.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,17 @@ main() {
417417
test_svd ht32f275x
418418
;;
419419

420+
Microchip)
421+
echo '[dependencies.bare-metal]' >> $td/Cargo.toml
422+
echo 'version = "0.2.0"' >> $td/Cargo.toml
423+
424+
echo '[dependencies.mips-mcu]' >> $td/Cargo.toml
425+
echo 'version = "0.1.0"' >> $td/Cargo.toml
426+
427+
test_svd_for_target mips https://raw.githubusercontent.com/kiffie/pic32-pac/master/pic32mx1xxfxxxb/PIC32MX170F256B.svd.patched
428+
test_svd_for_target mips https://raw.githubusercontent.com/kiffie/pic32-pac/master/pic32mx2xxfxxxb/PIC32MX270F256B.svd.patched
429+
;;
430+
420431
Nordic)
421432
# BAD-SVD two enumeratedValues have the same value
422433
# test_svd nrf52

ci/svd2rust-regress/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct Opt {
4646
mfgr: Option<String>,
4747

4848
/// Filter by architecture, case sensitive, may be combined with other filters
49-
/// Options are: "CortexM", "RiscV", and "Msp430"
49+
/// Options are: "CortexM", "RiscV", Mips, and "Msp430"
5050
#[structopt(
5151
short = "a",
5252
long = "architecture",

ci/svd2rust-regress/src/svd_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const CRATES_MSP430: &[&str] = &["msp430 = \"0.2.2\""];
1010
const CRATES_CORTEX_M: &[&str] = &["cortex-m = \"0.7.0\"", "cortex-m-rt = \"0.6.13\""];
1111
const CRATES_RISCV: &[&str] = &["riscv = \"0.5.0\"", "riscv-rt = \"0.6.0\""];
1212
const CRATES_XTENSALX6: &[&str] = &["xtensa-lx6-rt = \"0.2.0\"", "xtensa-lx6 = \"0.1.0\""];
13+
const CRATES_MIPS: &[&str] = &["mips-mcu = \"0.1.0\""];
1314
const PROFILE_ALL: &[&str] = &["[profile.dev]", "incremental = false"];
1415
const FEATURES_ALL: &[&str] = &["[features]"];
1516

@@ -129,6 +130,7 @@ pub fn test(
129130
.chain(match &t.arch {
130131
CortexM => CRATES_CORTEX_M.iter(),
131132
RiscV => CRATES_RISCV.iter(),
133+
Mips => CRATES_MIPS.iter(),
132134
Msp430 => CRATES_MSP430.iter(),
133135
XtensaLX => CRATES_XTENSALX6.iter(),
134136
})
@@ -158,6 +160,7 @@ pub fn test(
158160
let target = match t.arch {
159161
CortexM => "cortex-m",
160162
Msp430 => "msp430",
163+
Mips => "mips",
161164
RiscV => "riscv",
162165
XtensaLX => "xtensa-lx",
163166
};
@@ -183,7 +186,7 @@ pub fn test(
183186
process_stderr_paths.push(svd2rust_err_file);
184187

185188
match t.arch {
186-
CortexM | Msp430 | XtensaLX => {
189+
CortexM | Mips | Msp430 | XtensaLX => {
187190
// TODO: Give error the path to stderr
188191
fs::rename(path_helper_base(&chip_dir, &["lib.rs"]), &lib_rs_file)
189192
.chain_err(|| "While moving lib.rs file")?

ci/svd2rust-regress/src/tests.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub enum Architecture {
55
// TODO: Coming soon!
66
// Avr,
77
CortexM,
8+
Mips,
89
Msp430,
910
RiscV,
1011
XtensaLX,
@@ -16,6 +17,7 @@ pub enum Manufacturer {
1617
Freescale,
1718
Fujitsu,
1819
Holtek,
20+
Microchip,
1921
Nordic,
2022
Nuvoton,
2123
NXP,
@@ -4238,4 +4240,24 @@ pub const TESTS: &[&TestCase] = &[
42384240
should_pass: true,
42394241
run_when: Always,
42404242
},
4243+
&TestCase {
4244+
arch: Mips,
4245+
mfgr: Microchip,
4246+
chip: "pic32mx170f256b",
4247+
svd_url: Some(
4248+
"https://raw.githubusercontent.com/kiffie/pic32-pac/master/pic32mx1xxfxxxb/PIC32MX170F256B.svd.patched",
4249+
),
4250+
should_pass: true,
4251+
run_when: Always,
4252+
},
4253+
&TestCase {
4254+
arch: Mips,
4255+
mfgr: Microchip,
4256+
chip: "pic32mx270f256b",
4257+
svd_url: Some(
4258+
"https://raw.githubusercontent.com/kiffie/pic32-pac/master/pic32mx2xxfxxxb/PIC32MX270F256B.svd.patched",
4259+
),
4260+
should_pass: true,
4261+
run_when: Always,
4262+
},
42414263
];

src/generate/device.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub fn render(
199199
Target::Msp430 => Some(Ident::new("msp430", span)),
200200
Target::RISCV => Some(Ident::new("riscv", span)),
201201
Target::XtensaLX => Some(Ident::new("xtensa_lx", span)),
202+
Target::Mips => Some(Ident::new("mips_mcu", span)),
202203
Target::None => None,
203204
}
204205
.map(|krate| {

src/generate/interrupt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub fn render(
150150
];
151151
});
152152
}
153+
Target::Mips => {}
153154
Target::None => {}
154155
}
155156

src/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum Target {
1919
Msp430,
2020
RISCV,
2121
XtensaLX,
22+
Mips,
2223
None,
2324
}
2425

@@ -29,6 +30,7 @@ impl Target {
2930
"msp430" => Target::Msp430,
3031
"riscv" => Target::RISCV,
3132
"xtensa-lx" => Target::XtensaLX,
33+
"mips" => Target::Mips,
3234
"none" => Target::None,
3335
_ => bail!("unknown target {}", s),
3436
})

0 commit comments

Comments
 (0)