diff --git a/.cargo/config b/.cargo/config index e4946d4ddfa7c4c71ae0d85e5f65d90337e11d0f..3b7dfa1063a560f3c3750a3afa169f72e2d3debf 100644 --- a/.cargo/config +++ b/.cargo/config @@ -34,8 +34,8 @@ rustflags = [ # Pick ONE of these compilation targets # target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+ # target = "thumbv7m-none-eabi" # Cortex-M3 -target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU) -# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) +# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU) +target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) # target = "thumbv8m.base-none-eabi" # Cortex-M23 # target = "thumbv8m.main-none-eabi" # Cortex-M33 (no FPU) # target = "thumbv8m.main-none-eabihf" # Cortex-M33 (with FPU) diff --git a/Cargo.toml b/Cargo.toml index e9e9cc8aa7afc31ed89b859c624aa7bc9ab20101..c250d53b167bf3711da10e6ccd58242df4e3509f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ features = ["stm32f411", "rt"] [dependencies.stm32f4xx-hal] version = "0.8.3" features = ["rt", "stm32f411", "usb_fs"] +git = "https://github.com/stm32-rs/stm32f4xx-hal" # this lets you use `cargo fix`! [[bin]] diff --git a/README.md b/README.md index 884c8e68852cff04998f742b762fd6e1b27681d4..e35bb5b3e449a3b05a0ecce496fe131c5f283b70 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,31 @@ ## Resources -- [UM1724 - stm32 Nucleo-64](https://www.st.com/resource/en/user_manual/dm00105823-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf) +- Nucleo 64 + - [UM1724 - stm32 Nucleo-64](https://www.st.com/resource/en/user_manual/dm00105823-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf). + - [Nucleo 64 Schematics](https://www.st.com/resource/en/schematic_pack/nucleo_64pins_sch.zip) (The file MB1136.pdf is the schematics in pdf.) + - [stm32f4xx_hal](https://docs.rs/stm32f4xx-hal/0.8.3/stm32f4xx_hal/) documentation of the HAL API, and [git repository](https://github.com/stm32-rs/stm32f4xx-hal). -- [RM0383 - F411 Reference Manual](https://www.st.com/resource/zh/reference_manual/dm00119316-stm32f411xce-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) and [RM0368 - F401 Reference Manual](https://www.st.com/resource/en/reference_manual/dm00096844-stm32f401xbc-and-stm32f401xde-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -- [Nucleo 64 Schematics](https://www.st.com/resource/en/schematic_pack/nucleo_64pins_sch.zip) (The file MB1136.pdf is the schematics in pdf.) +- STM32F01/FO11 + - [RM0383 - F411 Reference Manual](https://www.st.com/resource/zh/reference_manual/dm00119316-stm32f411xce-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + - [RM0368 - F401 Reference Manual](https://www.st.com/resource/en/reference_manual/dm00096844-stm32f401xbc-and-stm32f401xde-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + - [PM0214 - M4 Programming manual](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjOtd645OTtAhXEHXcKHdwYCoQQFjAAegQIBhAC&url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fprogramming_manual%2Fdm00046982-stm32-cortex-m4-mcus-and-mpus-programming-manual-stmicroelectronics.pdf&usg=AOvVaw0n3XXybtMMDbifhDZse1Pl) -- [PM0214 - M4 Programming manual](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjOtd645OTtAhXEHXcKHdwYCoQQFjAAegQIBhAC&url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fprogramming_manual%2Fdm00046982-stm32-cortex-m4-mcus-and-mpus-programming-manual-stmicroelectronics.pdf&usg=AOvVaw0n3XXybtMMDbifhDZse1Pl) +- PixArt PMW33xx Optical Navigation Chip + - [PMW3389DM-T3QU](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwicx5OA9eTtAhWC-yoKHVfKAJ0QFjAAegQIBhAC&url=https%3A%2F%2Fwww.pixart.com%2F_getfs.php%3Ftb%3Dproduct%26id%3D4%26fs%3Dck2_fs_cn&usg=AOvVaw1A1rR533Pt-7EgnVSS-_ch), optical navigation chip + - [Jack Enterprise Breakout Board](https://www.tindie.com/products/jkicklighter/pmw3389-motion-sensor/), an example design with software linked. -- [PMW3389DM-T3QU](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwicx5OA9eTtAhWC-yoKHVfKAJ0QFjAAegQIBhAC&url=https%3A%2F%2Fwww.pixart.com%2F_getfs.php%3Ftb%3Dproduct%26id%3D4%26fs%3Dck2_fs_cn&usg=AOvVaw1A1rR533Pt-7EgnVSS-_ch), optical navigation chip +- General Embedded + - [Introduction to SPI](https://www.analog.com/en/analog-dialogue/articles/introduction-to-spi-interface.html#), a short introduction to the SPI interface. -- [Jack Enterprise Breakout Board](https://www.tindie.com/products/jkicklighter/pmw3389-motion-sensor/), an example design with software linked. -- [Introduction to SPI](https://www.analog.com/en/analog-dialogue/articles/introduction-to-spi-interface.html#), a short introduction to the SPI interface. - + + +--- + +## Connections + - [USB Cable] | Signl | Color | Pin | diff --git a/examples/rtic_blinky.rs b/examples/rtic_blinky.rs index 9bf9bb2945c580cafd74bb905c80b1251fbfb683..6828905fca45542e24bfe0afb8c522a4bee1b25b 100644 --- a/examples/rtic_blinky.rs +++ b/examples/rtic_blinky.rs @@ -5,7 +5,7 @@ use cortex_m::peripheral::DWT; use cortex_m_semihosting::hprintln; -use panic_halt as _; +use panic_rtt_target as _; use rtic::cyccnt::{Instant, U32Ext as _}; use stm32f4xx_hal::stm32; diff --git a/examples/rtt-pwm.rs b/examples/rtt-pwm.rs new file mode 100644 index 0000000000000000000000000000000000000000..b43031579ef74f5fb0964eace2b82b17f96924e2 --- /dev/null +++ b/examples/rtt-pwm.rs @@ -0,0 +1,53 @@ +//! examples/rtt_timing.rs +//! cargo run --examples rtt-pwm + +#![deny(unsafe_code)] +// #![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m::{asm, peripheral::DWT}; +use panic_halt as _; +use rtt_target::{rprintln, rtt_init_print}; +use stm32f4xx_hal::{dma, gpio::Speed, prelude::*, pwm, stm32}; + +#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true)] +const APP: () = { + #[init] + fn init(mut cx: init::Context) { + rtt_init_print!(); + rprintln!("init"); + let dp = cx.device; + + // Initialize (enable) the monotonic timer (CYCCNT) + cx.core.DCB.enable_trace(); + cx.core.DWT.enable_cycle_counter(); + + // Set up the system clock. 16 MHz? + let rcc = dp.RCC.constrain(); + let clocks = rcc.cfgr.freeze(); + + let gpioa = dp.GPIOA.split(); + let channels = ( + gpioa.pa8.into_alternate_af1().set_speed(Speed::Low), + gpioa.pa9.into_alternate_af1(), + ); + + let pwm = pwm::tim1(dp.TIM1, channels, clocks, 1u32.khz()); + let (mut ch1, mut ch2) = pwm; + let max_duty = ch1.get_max_duty(); + rprintln!("max_duty {}", max_duty); + ch1.set_duty(max_duty / 2); + ch1.enable(); + ch2.set_duty((max_duty * 1) / 2); + ch2.enable(); + } + + #[idle] + fn idle(_cx: idle::Context) -> ! { + rprintln!("idle"); + loop { + continue; + } + } +}; diff --git a/examples/rtt-timing.rs b/examples/rtt-timing.rs index 2f601f7a7fc4c594c9572765a539d7e72d1b0db4..720e79982a954295b6e7d3501f4385444feb1065 100644 --- a/examples/rtt-timing.rs +++ b/examples/rtt-timing.rs @@ -1,4 +1,5 @@ //! examples/rtt_timing.rs +//! cargo run --examples rtt-timing #![deny(unsafe_code)] #![deny(warnings)] diff --git a/openocd.cfg b/openocd.cfg index 1c082fe51c8ec2d4641dd92be4071ac6a4c2bcaa..577828f1224ae32378f9ee9ba8f6869af3d07a29 100644 --- a/openocd.cfg +++ b/openocd.cfg @@ -1,4 +1,4 @@ -# Sample OpenOCD configuration for the STM32F3DISCOVERY development board +# Sample OpenOCD configuration for the STM Nucleo-F401RE/F411RE development board # Depending on the hardware revision you got you'll have to pick ONE of these # interfaces. At any time only one interface should be commented out. diff --git a/openocd.gdb b/openocd.gdb index 918dff9a0af41e51057d4a16a4958c9459ab4ee0..1623a86cd3930d71776af1709ded3b30298c7e32 100644 --- a/openocd.gdb +++ b/openocd.gdb @@ -32,7 +32,7 @@ monitor tpiu config internal itm.txt uart off 16000000 # monitor tpiu config external uart off 8000000 2000000 # # enable ITM port 0 -# monitor itm port 0 on +monitor itm port 0 on load