Skip to content

Commit 2ad1dae

Browse files
committed
add pin combinations
1 parent dd31504 commit 2ad1dae

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ rt = ["stm32f4/rt"]
7171
# so it's intended for e.g. stm32f405/415 to both enable stm32f4/stm32f405.
7272
stm32f401 = ["stm32f4/stm32f401", "device-selected"]
7373
stm32f405 = ["stm32f4/stm32f405", "device-selected", "has-can"]
74-
stm32f407 = ["stm32f4/stm32f407", "device-selected"]
74+
stm32f407 = ["stm32f4/stm32f407", "device-selected", "has-can"]
7575
stm32f410 = ["stm32f4/stm32f410", "device-selected"]
7676
stm32f411 = ["stm32f4/stm32f411", "device-selected"]
7777
stm32f412 = ["stm32f4/stm32f412", "device-selected"]

src/can.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
//! # Controller Area Network (CAN) Interface
22
//!
3-
//!
4-
//! TX: Alternate Push-Pull Output
5-
//! RX: Input Floating Input
6-
//!
7-
//! ### CAN1
8-
//!
9-
//! | Function | Pins |
10-
//! |----------|-------|
11-
//! | TX | PB9 |
12-
//! | RX | PB8 |
13-
//!
14-
//! ### CAN2
15-
//!
16-
//! | Function | Pins |
17-
//! |----------|-------|
18-
//! | TX | PB13 |
19-
//! | RX | PB12 |
203
214
use crate::bb;
225
use crate::gpio::{
236
gpioa::{PA11, PA12},
247
gpiob::{PB12, PB13, PB5, PB6, PB8, PB9},
8+
gpiod::{PD0, PD1},
9+
gpioh::PH13,
10+
gpioi::PI9,
2511
Alternate, AF9,
2612
};
2713
use crate::pac::{CAN1, CAN2};
@@ -44,7 +30,6 @@ pub trait Pins: sealed::Sealed {
4430
/*
4531
order: tx, rx similar to serial
4632
*/
47-
4833
macro_rules! pins {
4934
($($PER:ident => ($tx:ident, $rx:ident),)+) => {
5035
$(
@@ -56,9 +41,17 @@ macro_rules! pins {
5641
}
5742
}
5843

44+
/*
45+
See DS8626 Rev 9 Table 9.
46+
47+
Applies to stm32f405, stm32f407, stm32f446.
48+
To add MCUs, add has-can and check the pins.
49+
*/
5950
pins! {
6051
CAN1 => (PA12, PA11),
6152
CAN1 => (PB9, PB8),
53+
CAN1 => (PD1, PD0),
54+
CAN1 => (PH13, PI9),
6255
CAN2 => (PB13, PB12),
6356
CAN2 => (PB6, PB5),
6457
}
@@ -108,6 +101,14 @@ where
108101
Instance::enable(apb);
109102
Can { _peripheral: can }
110103
}
104+
105+
pub fn new_unchecked<P>(can: Instance, apb: &mut APB1) -> Can<Instance>
106+
where
107+
P: Pins<Instance = Instance>,
108+
{
109+
Instance::enable(apb);
110+
Can { _peripheral: can }
111+
}
111112
}
112113

113114
unsafe impl bxcan::Instance for Can<CAN1> {

0 commit comments

Comments
 (0)