Skip to content

Commit d79c186

Browse files
committed
update pin alternate function mapping
1 parent 061f583 commit d79c186

File tree

9 files changed

+56
-32
lines changed

9 files changed

+56
-32
lines changed

.vscode/settings.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
2-
"rust-analyzer.checkOnSave.allTargets": false,
3-
"rust-analyzer.checkOnSave.extraArgs": [
4-
"--target",
5-
"thumbv6m-none-eabi"
6-
],
2+
"rust-analyzer.check.allTargets": false,
3+
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
74
"rust-analyzer.cargo.features": [
85
"rt",
96
"stm32c031"

LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT LICENSE
22

3-
Copyright (c) 2022 Vitaly Domnikov <[email protected]>
3+
Copyright (c) 2022-2023 Vitaly Domnikov <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

examples/blinky.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() -> ! {
1515
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
1616
let mut rcc = dp.RCC.constrain();
1717
let port_a = dp.GPIOA.split(&mut rcc);
18-
let mut led = port_a.pa0.into_push_pull_output();
18+
let mut led = port_a.pa5.into_push_pull_output();
1919
loop {
2020
led.toggle().unwrap();
2121
for _ in 0..1_000_000 {

examples/button.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ fn main() -> ! {
1515
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
1616
let mut rcc = dp.RCC.constrain();
1717
let port_a = dp.GPIOA.split(&mut rcc);
18+
let port_c = dp.GPIOC.split(&mut rcc);
1819

19-
let button = port_a.pa1.into_pull_up_input();
20-
let mut led = port_a.pa0.into_push_pull_output();
20+
let button = port_c.pc13.into_pull_up_input();
21+
let mut led = port_a.pa5.into_push_pull_output();
2122

2223
loop {
2324
if button.is_high().unwrap() {

src/analog/adc.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,11 @@ macro_rules! int_adc {
432432
}
433433

434434
int_adc! {
435-
VTemp: (12, tsen),
436-
VRef: (13, vrefen),
435+
//TODO; check channel ids
436+
VTemp: (9, tsen),
437+
VRef: (10, vrefen),
438+
// Vdda: (15, --),
439+
// Vssa: (16, --),
437440
}
438441

439442
macro_rules! adc_pin {
@@ -457,13 +460,18 @@ adc_pin! {
457460
Channel5: (PA5<Analog>, 5u8),
458461
Channel6: (PA6<Analog>, 6u8),
459462
Channel7: (PA7<Analog>, 7u8),
460-
Channel8: (PB0<Analog>, 8u8),
461-
Channel9: (PB1<Analog>, 9u8),
462-
Channel10: (PB2<Analog>, 10u8),
463-
Channel11: (PB10<Analog>, 11u8),
464-
Channel11: (PB7<Analog>, 11u8),
465-
Channel15: (PB11<Analog>, 15u8),
466-
Channel16: (PB12<Analog>, 16u8),
467-
Channel17: (PC4<Analog>, 17u8),
468-
Channel18: (PC5<Analog>, 18u8),
463+
Channel8: (PA8<Analog>, 8u8),
464+
// Channel9: (<Analog>, 9u8),
465+
// Channel10: (<Analog>, 10u8),
466+
Channel11: (PA11<Analog>, 11u8),
467+
Channel12: (PA12<Analog>, 12u8),
468+
Channel13: (PA13<Analog>, 13u8),
469+
Channel14: (PA14<Analog>, 14u8),
470+
//TODO check sequecer
471+
Channel17: (PB0<Analog>, 17u8),
472+
Channel18: (PB1<Analog>, 18u8),
473+
Channel19: (PB2<Analog>, 19u8),
474+
Channel20: (PB10<Analog>, 20u8),
475+
Channel21: (PB11<Analog>, 21u8),
476+
Channel22: (PB12<Analog>, 22u8),
469477
}

src/gpio.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ pub(crate) enum AltFunction {
180180
AF5 = 5,
181181
AF6 = 6,
182182
AF7 = 7,
183+
AF8 = 8,
184+
AF9 = 9,
185+
AF10 = 10,
186+
AF11 = 11,
187+
AF12 = 12,
188+
AF13 = 13,
189+
AF14 = 14,
190+
AF15 = 15,
183191
}
184192

185193
macro_rules! gpio {

src/serial/usart.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ macro_rules! uart_shared {
298298
}
299299

300300
// impl Tx<$USARTX> {
301-
302301
// /// Starts listening for an interrupt event
303302
// pub fn listen(&mut self) {
304303
// let usart = unsafe { &(*$USARTX::ptr()) };
@@ -316,7 +315,6 @@ macro_rules! uart_shared {
316315
// let usart = unsafe { &(*$USARTX::ptr()) };
317316
// usart.isr.read().txe().bit_is_set()
318317
// }
319-
320318
// }
321319

322320
// impl hal::serial::Write<u8> for Tx<$USARTX> {
@@ -354,7 +352,6 @@ macro_rules! uart_shared {
354352
// }
355353
// }
356354

357-
358355
impl Serial<$USARTX> {
359356

360357
/// Separates the serial struct into separate channel objects for sending (Tx) and
@@ -533,35 +530,45 @@ macro_rules! uart {
533530

534531
uart_shared!(USART1, USART1_RX, USART1_TX,
535532
tx: [
533+
(PA0, AltFunction::AF4),
536534
(PA9, AltFunction::AF1),
537535
(PB6, AltFunction::AF0),
538-
(PC4, AltFunction::AF1),
536+
(PC14, AltFunction::AF0),
539537
],
540538
rx: [
539+
(PA1, AltFunction::AF4),
540+
(PA8, AltFunction::AF14),
541541
(PA10, AltFunction::AF1),
542+
(PB2, AltFunction::AF0),
542543
(PB7, AltFunction::AF0),
543-
(PC5, AltFunction::AF1),
544544
],
545545
de: [
546546
(PA12, AltFunction::AF1),
547+
(PA14, AltFunction::AF12),
548+
(PA15, AltFunction::AF4),
547549
(PB3, AltFunction::AF4),
550+
(PB6, AltFunction::AF4),
548551
]
549552
);
550553

551554
uart_shared!(USART2, USART2_RX, USART2_TX,
552555
tx: [
553556
(PA2, AltFunction::AF1),
557+
(PA4, AltFunction::AF1),
558+
(PA8, AltFunction::AF1),
554559
(PA14, AltFunction::AF1),
555-
(PD5, AltFunction::AF0),
556560
],
557561
rx: [
558562
(PA3, AltFunction::AF1),
559-
(PA15, AltFunction::AF1),
560-
(PD6, AltFunction::AF0),
563+
(PA5, AltFunction::AF1),
564+
(PA13, AltFunction::AF4),
565+
(PA14, AltFunction::AF9),
566+
(PA15, AltFunction::AF1),
561567
],
562568
de: [
563569
(PA1, AltFunction::AF1),
564-
(PD4, AltFunction::AF0),
570+
(PB9, AltFunction::AF1),
571+
(PC14, AltFunction::AF9),
565572
]
566573
);
567574

src/spi.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,26 +277,27 @@ macro_rules! spi {
277277
}
278278
}
279279

280+
280281
spi!(
281282
SPI,
282283
spi1,
283284
sck: [
284285
(PA1<DefaultMode>, AltFunction::AF0),
285286
(PA5<DefaultMode>, AltFunction::AF0),
286287
(PB3<DefaultMode>, AltFunction::AF0),
287-
(PD8<DefaultMode>, AltFunction::AF1),
288+
(PB6<DefaultMode>, AltFunction::AF10),
288289
],
289290
miso: [
290291
(PA6<DefaultMode>, AltFunction::AF0),
291292
(PA11<DefaultMode>, AltFunction::AF0),
292293
(PB4<DefaultMode>, AltFunction::AF0),
293-
(PD5<DefaultMode>, AltFunction::AF1),
294+
(PB6<DefaultMode>, AltFunction::AF9),
294295
],
295296
mosi: [
296297
(PA2<DefaultMode>, AltFunction::AF0),
297298
(PA7<DefaultMode>, AltFunction::AF0),
298299
(PA12<DefaultMode>, AltFunction::AF0),
299300
(PB5<DefaultMode>, AltFunction::AF0),
300-
(PD6<DefaultMode>, AltFunction::AF1),
301+
(PB6<DefaultMode>, AltFunction::AF8),
301302
],
302303
);

src/watchdog.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ impl IndependedWatchdog {
1414
}
1515

1616
pub fn start(&mut self, period: MicroSecond) {
17+
//TODO: check IndependedWatchdog clocks
1718
let mut cycles = crate::time::cycles(period, 16_384.Hz());
1819
let mut psc = 0;
1920
let mut reload = 0;
@@ -147,6 +148,7 @@ pub trait WWDGExt {
147148
impl WWDGExt for WWDG {
148149
fn constrain(self, rcc: &mut Rcc) -> WindowWatchdog {
149150
WWDG::enable(rcc);
151+
//TODO: check WWDG clock prescaler
150152
let clk = rcc.clocks.apb_clk.raw() / 4096;
151153
WindowWatchdog {
152154
wwdg: self,

0 commit comments

Comments
 (0)