aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-07-28 15:16:51 -0400
committerGitHub <[email protected]>2021-07-28 15:16:51 -0400
commit6e4f4b63a8b09644e536543c56c440f2adda076d (patch)
treee2c1847643ecf130add00bb0e02179a52f90dc02
parent126407f8c8d3c3373993e57f4cc31afb58db498a (diff)
parentd8c6ffe3a28aa41e46e880e475b0e7aedc9ece71 (diff)
Merge pull request #317 from bobmcwhirter/peri_irq
Peri irq
-rw-r--r--.github/workflows/rust.yml56
-rw-r--r--README.md1
-rw-r--r--embassy-stm32/src/dma/bdma.rs4
-rw-r--r--embassy-stm32/src/dma/dma.rs4
m---------stm32-data0
-rw-r--r--stm32-metapac-gen/src/lib.rs34
6 files changed, 34 insertions, 65 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 69cd9ff14..118143daa 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -95,24 +95,21 @@ jobs:
95 - uses: actions/checkout@v2 95 - uses: actions/checkout@v2
96 with: 96 with:
97 submodules: true 97 submodules: true
98 - uses: actions/cache@v2 98 - uses: actions-rs/toolchain@v1
99 with: 99 with:
100 path: | 100 toolchain: stable
101 ~/.cargo/bin/ 101 - name: cache
102 ~/.cargo/registry/index/ 102 id: cache-target
103 ~/.cargo/registry/cache/ 103 uses: actions/cache@v2
104 ~/.cargo/git/db/ 104 with:
105 target/ 105 path: target
106 key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }} 106 key: ${{ runner.os }}-${{ matrix.target }}
107 restore-keys: |
108 ${{ runner.os }}-cargo-${{ matrix.target }}-
109 107
110 # We have to append the "-D warnings" flag to .cargo/config rather than 108 # We have to append the "-D warnings" flag to .cargo/config rather than
111 # using the RUSTFLAGS environment variable because if we set RUSTFLAGS 109 # using the RUSTFLAGS environment variable because if we set RUSTFLAGS
112 # cargo will ignore the rustflags config in .cargo/config. 110 # cargo will ignore the rustflags config in .cargo/config.
113 - name: Check 111 - name: Check
114 run: | 112 run: |
115 export CARGO_TARGET_DIR=$PWD/target
116 mkdir -p .cargo 113 mkdir -p .cargo
117 echo -e '[target."cfg(all())"]\nrustflags = ["-D", "warnings"]' >> .cargo/config 114 echo -e '[target."cfg(all())"]\nrustflags = ["-D", "warnings"]' >> .cargo/config
118 cd ${{ matrix.package }} && RUSTFLAGS=-Dwarnings cargo check --features=${{ matrix.features }} --target=${{ matrix.target }} 115 cd ${{ matrix.package }} && RUSTFLAGS=-Dwarnings cargo check --features=${{ matrix.features }} --target=${{ matrix.target }}
@@ -121,6 +118,9 @@ jobs:
121 runs-on: ubuntu-latest 118 runs-on: ubuntu-latest
122 steps: 119 steps:
123 - uses: actions/checkout@v2 120 - uses: actions/checkout@v2
121 - uses: actions-rs/toolchain@v1
122 with:
123 toolchain: stable
124 - name: Check fmt 124 - name: Check fmt
125 run: for i in embassy-*; do (cd $i; cargo fmt -- --check); done 125 run: for i in embassy-*; do (cd $i; cargo fmt -- --check); done
126 126
@@ -128,22 +128,11 @@ jobs:
128 runs-on: ubuntu-latest 128 runs-on: ubuntu-latest
129 steps: 129 steps:
130 - uses: actions/checkout@v2 130 - uses: actions/checkout@v2
131 - uses: actions/cache@v2 131 - uses: actions-rs/toolchain@v1
132 with: 132 with:
133 path: | 133 toolchain: stable
134 ~/.cargo/bin/
135 ~/.cargo/registry/index/
136 ~/.cargo/registry/cache/
137 ~/.cargo/git/db/
138 target/
139 key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
140 restore-keys: |
141 ${{ runner.os }}-cargo-
142 - name: Test 134 - name: Test
143 run: | 135 run: cd embassy && cargo test
144 export CARGO_TARGET_DIR=$PWD/target
145 cd embassy
146 cargo test
147 136
148 metapac_gen: 137 metapac_gen:
149 runs-on: ubuntu-latest 138 runs-on: ubuntu-latest
@@ -151,19 +140,8 @@ jobs:
151 - uses: actions/checkout@v2 140 - uses: actions/checkout@v2
152 with: 141 with:
153 submodules: true 142 submodules: true
154 - uses: actions/cache@v2 143 - uses: actions-rs/toolchain@v1
155 with: 144 with:
156 path: | 145 toolchain: stable
157 ~/.cargo/bin/
158 ~/.cargo/registry/index/
159 ~/.cargo/registry/cache/
160 ~/.cargo/git/db/
161 target/
162 key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
163 restore-keys: |
164 ${{ runner.os }}-cargo-
165 - name: Generate pregenerated metapac 146 - name: Generate pregenerated metapac
166 run: | 147 run: cd stm32-metapac-gen; cargo run --release
167 export CARGO_TARGET_DIR=$PWD/target
168 cd stm32-metapac-gen
169 cargo run --release
diff --git a/README.md b/README.md
index 8d5fddd0d..13bcf6e5b 100644
--- a/README.md
+++ b/README.md
@@ -87,3 +87,4 @@ This work is licensed under either of
87- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 87- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
88 88
89at your option. 89at your option.
90
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs
index c52188c36..2aa00ebee 100644
--- a/embassy-stm32/src/dma/bdma.rs
+++ b/embassy-stm32/src/dma/bdma.rs
@@ -143,7 +143,7 @@ unsafe fn on_irq() {
143/// safety: must be called only once 143/// safety: must be called only once
144pub(crate) unsafe fn init() { 144pub(crate) unsafe fn init() {
145 pac::interrupts! { 145 pac::interrupts! {
146 (BDMA, $irq:ident) => { 146 ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => {
147 crate::interrupt::$irq::steal().enable(); 147 crate::interrupt::$irq::steal().enable();
148 }; 148 };
149 } 149 }
@@ -242,7 +242,7 @@ pac::dma_channels! {
242} 242}
243 243
244pac::interrupts! { 244pac::interrupts! {
245 (BDMA, $irq:ident) => { 245 ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => {
246 #[crate::interrupt] 246 #[crate::interrupt]
247 unsafe fn $irq () { 247 unsafe fn $irq () {
248 on_irq() 248 on_irq()
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs
index 606c9d3d7..47120c39d 100644
--- a/embassy-stm32/src/dma/dma.rs
+++ b/embassy-stm32/src/dma/dma.rs
@@ -149,7 +149,7 @@ unsafe fn on_irq() {
149/// safety: must be called only once 149/// safety: must be called only once
150pub(crate) unsafe fn init() { 150pub(crate) unsafe fn init() {
151 pac::interrupts! { 151 pac::interrupts! {
152 (DMA, $irq:ident) => { 152 ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => {
153 interrupt::$irq::steal().enable(); 153 interrupt::$irq::steal().enable();
154 }; 154 };
155 } 155 }
@@ -248,7 +248,7 @@ pac::dma_channels! {
248} 248}
249 249
250pac::interrupts! { 250pac::interrupts! {
251 (DMA, $irq:ident) => { 251 ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => {
252 #[crate::interrupt] 252 #[crate::interrupt]
253 unsafe fn $irq () { 253 unsafe fn $irq () {
254 on_irq() 254 on_irq()
diff --git a/stm32-data b/stm32-data
Subproject 5412725bf5401c6d49c4932487d80463fdb0228 Subproject 07eae071915f8ffbf311bd5dfc6391dcca92ee1
diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs
index 203d943de..ce720c677 100644
--- a/stm32-metapac-gen/src/lib.rs
+++ b/stm32-metapac-gen/src/lib.rs
@@ -50,6 +50,8 @@ pub struct Peripheral {
50 pub pins: Vec<Pin>, 50 pub pins: Vec<Pin>,
51 #[serde(default)] 51 #[serde(default)]
52 pub dma_channels: HashMap<String, Vec<PeripheralDmaChannel>>, 52 pub dma_channels: HashMap<String, Vec<PeripheralDmaChannel>>,
53 #[serde(default)]
54 pub interrupts: HashMap<String, String>
53} 55}
54 56
55#[derive(Debug, Eq, PartialEq, Clone, Deserialize)] 57#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
@@ -306,9 +308,6 @@ pub fn gen(options: Options) {
306 } 308 }
307 } 309 }
308 310
309 let mut has_bdma = false;
310 let mut has_dma = false;
311
312 for (name, p) in &core.peripherals { 311 for (name, p) in &core.peripherals {
313 let captures = number_suffix_re.captures(&name).unwrap(); 312 let captures = number_suffix_re.captures(&name).unwrap();
314 let root_peri_name = captures.get(1).unwrap().as_str().to_string(); 313 let root_peri_name = captures.get(1).unwrap().as_str().to_string();
@@ -328,12 +327,6 @@ pub fn gen(options: Options) {
328 if let Some(block) = &p.block { 327 if let Some(block) = &p.block {
329 let bi = BlockInfo::parse(block); 328 let bi = BlockInfo::parse(block);
330 329
331 if bi.module == "bdma" {
332 has_bdma = true
333 } else if bi.module == "dma" {
334 has_dma = true
335 }
336
337 peripheral_counts.insert( 330 peripheral_counts.insert(
338 bi.module.clone(), 331 bi.module.clone(),
339 peripheral_counts.get(&bi.module).map_or(1, |v| v + 1), 332 peripheral_counts.get(&bi.module).map_or(1, |v| v + 1),
@@ -352,6 +345,16 @@ pub fn gen(options: Options) {
352 peripheral_pins_table.push(row); 345 peripheral_pins_table.push(row);
353 } 346 }
354 347
348 for (signal, irq_name) in &p.interrupts {
349 let mut row = Vec::new();
350 row.push(name.clone());
351 row.push(bi.module.clone());
352 row.push(bi.block.clone());
353 row.push( signal.clone() );
354 row.push( irq_name.to_ascii_uppercase() );
355 interrupt_table.push(row)
356 }
357
355 for (request, dma_channels) in &p.dma_channels { 358 for (request, dma_channels) in &p.dma_channels {
356 for channel in dma_channels.iter() { 359 for channel in dma_channels.iter() {
357 let mut row = Vec::new(); 360 let mut row = Vec::new();
@@ -553,19 +556,6 @@ pub fn gen(options: Options) {
553 556
554 interrupt_table.push(vec![name.clone()]); 557 interrupt_table.push(vec![name.clone()]);
555 558
556 if name.starts_with("DMA1_") || name.starts_with("DMA2_") || name.contains("_DMA") {
557 if has_dma {
558 interrupt_table.push(vec!["DMA".to_string(), name.clone()]);
559 } else if has_bdma {
560 interrupt_table.push(vec!["BDMA".to_string(), name.clone()]);
561 }
562 }
563
564 if name.starts_with("BDMA_") || name.starts_with("BDMA1_") || name.starts_with("BDMA2_")
565 {
566 interrupt_table.push(vec!["BDMA".to_string(), name.clone()]);
567 }
568
569 if name.contains("EXTI") { 559 if name.contains("EXTI") {
570 interrupt_table.push(vec!["EXTI".to_string(), name.clone()]); 560 interrupt_table.push(vec!["EXTI".to_string(), name.clone()]);
571 } 561 }