Compare commits

...

194 Commits

Author SHA1 Message Date
Marc Poulhiès 34d2ee36e2 Implement FullDuplex for SPI and add check_errors method 2 years ago
Daniel Egger 2bb8bb9637
Merge pull request #126 from matoushybl/update-dependencies 2 years ago
Matous Hybl 5f656df6dc Update dependency versions. 2 years ago
Daniel Egger e679ab190f Bump version to 0.17.1 and release it 2 years ago
Daniel Egger 48d1b9a161
Merge pull request #120 from evils/complete_TscPin 2 years ago
Evils 0246e90e57 implement TscPin for remaining touch pins 2 years ago
Roman Valls Guimera 0bbb50f5fa
Move usb-remap internals for certain ICs to USB enable() (#119) 2 years ago
Daniel Egger 86ecf612f5 Enable USB features in CI 3 years ago
Daniel Egger 87a9955ce4
Merge pull request #117 from stm32-rs/release-0.17.0 3 years ago
Daniel Egger 77f4eedcd8 Bump version to 0.17.0 and prepare release 3 years ago
Daniel Egger ed4067b076 Fix inconsistent comment 3 years ago
Dimitri Polonski 16272ef716 fix typo 3 years ago
Torkel Danielsson bd8c2758ee fix warning 3 years ago
Torkel Danielsson 26d2148ee9 fix check errors 3 years ago
Torkel Danielsson db7428d398 Reduce the scope of some critical sections in the examples 3 years ago
Daniel Egger be4250e6ee
Merge pull request #114 from torkeldanielsson/stm32_rs_0_11 3 years ago
Daniel Egger b3a312ee5b
Create bors.toml 3 years ago
Daniel Egger b1c7ae0a92
Adjust branch configuration for CI 3 years ago
Daniel Egger 0951dad727
Adjust branch configuration for CI 3 years ago
Daniel Egger 8c7f38f16b
Adjust branch configuration for CI 3 years ago
Daniel Egger ad16336475
Merge pull request #115 from Pagten/dont-depend-on-cortex-m-rt 3 years ago
Pieter Agten c23640c84b Make cortex-m-rt a dev-dependency only 3 years ago
Torkel Danielsson 44607e3de0 Updated stm32f0 dependency to v0.11 3 years ago
Daniel Egger 6a576da322
Made I2C more resilient by handling more error conditions (#95) 3 years ago
Daniel Egger 8195927373 Only build PRs once 3 years ago
Daniel Egger 19452656e8
Add link to repository behind CI badge 3 years ago
Daniel Egger 2ba2f8c413
Use GH actions badge for CI 3 years ago
Daniel Egger 0d847798ce
We're now using GH actions for CI, travis be gone 3 years ago
Daniel Egger 8cee11620b
Merge pull request #110 from stm32-rs/GH-actions-CI 3 years ago
Daniel Egger a83c627d8e
Use GH actions for CI 3 years ago
Daniel Egger 91bb5d8418 Fix clippy lints 3 years ago
Daniel Egger f2986badc1 Ran rustfmt over all code 3 years ago
Daniel Egger 9e96a9e772 Add github actions to check formatting and clippy lints 3 years ago
Daniel Egger 52be08d441
Merge pull request #109 from richardeoin/readme-1 3 years ago
Richard Meadows caf90e4ca3
Update README.md 3 years ago
Daniel Egger a8d868e76f
Merge pull request #108 from stm32-rs/simplify-serial-read 3 years ago
Daniel Egger 879e4e3c77 Simplify serial `read()` error handling 3 years ago
Daniel Egger 14e945254f
Merge pull request #106 from stm32-rs/faster-spi 3 years ago
Daniel Egger 590bbbd73e Optimize 8-bit SPI transfers and add 16-bit SPI transfers 3 years ago
Daniel Egger 6ceb635c36
Merge pull request #105 from newAM/master 3 years ago
Alex M 798e467d83 Add thumbv6m-none-eabi target to docs. 3 years ago
Daniel Egger 976c9679cb
Merge pull request #103 from stm32-rs/stm32f0-0.10 3 years ago
Daniel Egger cb9581a4ed Bump stm32f0 to 0.10 3 years ago
Daniel Egger 0907de090d
Merge pull request #102 from stm32-rs/pac-instead-of-stm32 3 years ago
Daniel Egger c4ad05524e Soft-deprecate `stm32` for PAC access and use `pac` instead 3 years ago
Daniel Egger 7b1906848c
Merge pull request #101 from stm32-rs/infallible-instead-of-void 3 years ago
Daniel Egger ae29706781 Use core::convert::Infallible instead of void::Void for USARTs 3 years ago
Daniel Egger 0ff6b0c785
Merge pull request #100 from stm32-rs/stopwatch-example 3 years ago
Daniel Egger 2a561a279f Add a stopwatch example 3 years ago
Daniel Egger df7c6e7c8c Use core::mem::swap() in example to move things in/out of Mutex 3 years ago
Daniel Egger e6ae626855
Merge pull request #99 from Disasm/pac-accesses 3 years ago
Vadim Kaushan 154495b378
Replace volatile access with pac register read/write 3 years ago
Daniel Egger bf77bfc660
Merge pull request #98 from dbrgn/af-docs 3 years ago
Danilo Bargen 0e4998d2de Improve documentation for alternate function modes 3 years ago
Daniel Egger d299c1deec More parametrisation and added section sizes as requested 3 years ago
Daniel Egger 63778e9479 More refined and parametrized bloat capture scripts 3 years ago
Daniel Egger d27619fb47
Entry fir PLLSRC bits fix 3 years ago
Daniel Egger 55d8d39b48
Merge pull request #96 from Disasm/fix-clock-setup 3 years ago
Vadim Kaushan 407bd890c9
Fix pllsrc bits for HSE 3 years ago
Daniel Egger b6b18400c4 Release 0.16.0 3 years ago
Daniel Egger 9b646d9a5d
Merge pull request #93 from stm32-rs/MSRV 3 years ago
Daniel Egger e529a105a0 Mention MSRV of 1.39.0 and test it in CI 3 years ago
Daniel Egger 6c8a0a1179
Merge pull request #92 from stm32-rs/add-another-blinky 3 years ago
Daniel Egger 49dc85c295 Add a new timer and interrupt based blinky example 3 years ago
Daniel Egger 8e96202d05
Merge pull request #91 from stm32-rs/fix-timer 3 years ago
Daniel Egger 53e6f73106 Assume twice the timer frequency when HCLK != PCLK 3 years ago
Daniel Egger c39da7e3f3
Moved USB driver to unreleased release 3 years ago
James Munns b15fc1532f
Add I2C Read implementation (#88) 3 years ago
Daniel Egger 4c259b9ce1
Merge pull request #87 from pigrew/pllsrc 3 years ago
Nathan Conrad d59291f414 Correct logic used to determine default PLL pre-divider. 3 years ago
Nathan Conrad 258134c875 Disable stm32f030 CI test. 3 years ago
Daniel Egger 0d9f0b275f
Merge pull request #85 from pigrew/usbClkSrc 3 years ago
Nathan Conrad b3988e768e RCC: USB source switching code. 3 years ago
Daniel Egger 06c983c84b
Merge pull request #84 from pigrew/hsi488_cfg 3 years ago
Nathan Conrad 8bcf488582 RCC: Only provide HSI48 in API for devices which are documented to have it. 3 years ago
Daniel Egger 6c1420e0d1 Remove costly unwrap from example 3 years ago
Daniel Egger 865dc15f53 Run through rustfmt 3 years ago
Daniel Egger 33fe6da6dc Fix STM32F030/STM32F070 impl 3 years ago
Daniel Egger 67e29bfa8b Bump stm32f0 version to 0.9 and upgrade code accordingly 3 years ago
Daniel Egger 88a8d83179
Merge pull request #80 from pigrew/hse_bypass 3 years ago
Nathan Conrad 02278e5542 Add (breaking) API change to allow for HSE bypass to be selected. 3 years ago
Daniel Egger 8cefde6b03
Merge pull request #82 from pigrew/pll_en_fix 3 years ago
Nathan Conrad 3ba20dc0cb RCC: PLL: Modify CR instead of write, plus remove unnecessary unsafe tag. 3 years ago
Daniel Egger 22ad0dc0ed
Merge pull request #81 from pigrew/Systick_returns 3 years ago
Nathan Conrad 51d7c76ee8 systick returns, so should be marked as such. 3 years ago
Daniel Egger 31b63ed92d
Merge pull request #76 from Disasm/usb-feature 3 years ago
Vadim Kaushan 150063efa1
Mention the stm32-usbd feature 3 years ago
Daniel Egger 188d18a655
Merge pull request #75 from Disasm/usb-docs 3 years ago
Vadim Kaushan f6d087944e
Generate usb docs on docs.rs 3 years ago
Daniel Egger 0872ca4f14
Merge pull request #74 from Disasm/usb 3 years ago
Vadim Kaushan 74670ac848
Update CHANGELOG 3 years ago
Vadim Kaushan f9ef8c3479
Enable USB support for STM32F070x6/B 3 years ago
Vadim Kaushan 83a0e618f3
Add USB example 3 years ago
Vadim Kaushan 86c7f95c0e
Add USB driver 3 years ago
Daniel Egger 9cf30e9961
Merge pull request #73 from stm32-rs/gpios-in-one 3 years ago
Daniel Egger c943585403
Merge pull request #63 from stm32-rs/features/serial-clear-error 3 years ago
Daniel Egger 143f6b2bf8 Clear error flags before returning 3 years ago
Daniel Egger 9f933af6a2 Improve legibility by having a single macro structure for all pins 3 years ago
Daniel Egger d0c81220b2 Bumped version to 0.15.2 3 years ago
Daniel Egger 1310978435 Lift specificity of some dependencies and re-enabled LTO for all, yay! 3 years ago
Daniel Egger 1e649bbc0b Fix a number of clippy warnings 3 years ago
Mike Panetta 4c3504c8e1 Add dac (#70) 3 years ago
Daniel Egger c944a4e882 Changed a confusing comment in an example about the event clearing 3 years ago
Mattia Maldini 2a61f5092d Added an example for i2c (#69) 3 years ago
Daniel Egger 7e345c6b4c Changed implementation to implement digital v2 interface 3 years ago
Daniel Egger 2116717507 Fixed a number of deprecation warnings and lints 3 years ago
Daniel Egger ff1cea2829 Enable commented out GPIOE support which now works 4 years ago
Daniel Egger 9a1ba72ed1 Extract the GPIO RegisterBlock address only once per function call 4 years ago
Daniel Egger a34f6c84e6 Let capture_example_bloat script also capture dev mode sizes 4 years ago
Daniel Egger 35ba490c2a Release 0.15.1 4 years ago
Daniel Egger cf4de96aee Clear UART errors after we've detected and reported them 4 years ago
Daniel Egger 49283cff0e Forgot to push a new header to the CHANGELOG 4 years ago
Daniel Egger 4ba30c4edd Bumped version to 0.15.0 4 years ago
Daniel Egger aec4e470d9 Added #inline(always) attributes to gpio functions 4 years ago
Daniel Egger 3b124efe23 Improve example to not hold on to the criticial section 4 years ago
Daniel Egger d5568bef8c Add fancier SysTick exception example moving the data into the exception handler 4 years ago
Daniel Egger c13916c1ba
Merge pull request #67 from Maldus512/patch-1 4 years ago
Mattia Maldini 81d1565160
Added feature specification to the README 4 years ago
Daniel Egger 51f9a490bd
Merge pull request #64 from stm32-rs/0.14.1 4 years ago
Daniel Egger 221c570f24 Release 0.14.1 4 years ago
Daniel Egger 9c335156e2
Merge pull request #62 from stm32-rs/features/crs 4 years ago
Daniel Egger 89d2d6f07b Enable CRS support for USB 4 years ago
Daniel Egger 0699aef12c
Merge pull request #60 from matoushybl/fix/i2c-030 4 years ago
Matous Hybl 4714c70d18 Remove STM32F030 from devices that have I2C1 available on pins PA11 and PA12. 4 years ago
Daniel Egger 88b9c8fd44 Bumped version to 0.14.0 4 years ago
Daniel Egger 8fa4d3f527 Fixed warning by uppercasing static variable 4 years ago
Daniel Egger b10bbb76b0
Merge pull request #58 from jessebraham/update-stm32f0 4 years ago
Jesse Braham 208396d7b6 Update to stm32f0 v0.7.0 4 years ago
Daniel Egger 0420673374
Merge pull request #57 from cillian64/typo 4 years ago
David Turner be7084cbbe Fix typo in SPI example 4 years ago
Daniel Egger 5ef5130b37
Merge pull request #56 from stm32-rs/0.13.0 4 years ago
Daniel Egger 99c3a38c82 Release v0.13.0 4 years ago
Daniel Egger d30b844a60 Remove lto from Cargo.toml to fix nightly builds 4 years ago
Daniel Egger b4049b5323
Merge pull request #54 from stm32-rs/experimental-tsc 4 years ago
Daniel Egger 1e040f403b Implement TSC (touch sensitive controller) support 4 years ago
Daniel Egger cdac82c305
Merge pull request #55 from stm32-rs/fix-hsi14-init 4 years ago
Daniel Egger 2f0fb0b09e Use modify instead of write for HSI14 clock setup 4 years ago
Daniel Egger 77a6dad00a Improved serial write_str implementation to properly handle errors 4 years ago
Daniel Egger d0f4500481
Merge pull request #53 from HarkonenBade/adc-updates 4 years ago
HarkonenBade e081e82390 Update the ADC code to take advantage of the named variants in stm32-rs v0.6.0 4 years ago
Tom 1524cb1967 Update to stm32f0 - 0.6.0 (#52) 4 years ago
Daniel Egger cc5dbe03e5
Merge pull request #51 from jessebraham/peripheral-review 4 years ago
Jesse Braham 0dccc8956c Add self to authors 4 years ago
Jesse Braham 63bbfd3068 Review all device datasheets and fix inconsistencies 4 years ago
Daniel Egger 81f56fb4a2
Merge pull request #50 from jessebraham/stm32f0x8 4 years ago
Jesse Braham 1c7e2cd93b Update CHANGELOG and README 4 years ago
Jesse Braham e3d7111c08 Fix some long-standing errors and inconsistencies for USARTS 4 years ago
Jesse Braham 32b14bf976 Add support for stm32f098 4 years ago
Jesse Braham fca47168d2 Add support for stm32f078 4 years ago
Jesse Braham c79c69c0f3 Add support for stm32f058 4 years ago
Jesse Braham e225bc0f68 Add support for stm32f048 4 years ago
Jesse Braham 95aadbbe18 Add support for stm32f038 4 years ago
Tom 7e0b205292 Add myself to authors list (#48) 4 years ago
Daniel Egger 2dbe5cf753 Forgot to commit version change, DOH! Now 0.12.0 for real... 4 years ago
Daniel Egger f7a464f7ad Relesed 0.12.0 4 years ago
Daniel Egger 2b60666a31 Simplified examples a bit and fixed/added commentry 4 years ago
Daniel Egger 0ffbce722e
Merge pull request #34 from david-sawatzke/serial_mult 4 years ago
David Sawatzke c8dd9b1f81 Add documentation and update a few examples 4 years ago
David Sawatzke ec1fa416e2 Move `read`, `flush` & `write` in separate functions 4 years ago
David Sawatzke 2c62bd99eb Only enable usart tx/rx when needed 4 years ago
David Sawatzke ee11a821a0 Add changelog entry 4 years ago
David Sawatzke 8e0179d60c Add a tx only and a rx only serial instance 4 years ago
Daniel Egger ac4c91b95f
Merge pull request #43 from jessebraham/stm32f0x1 4 years ago
Jesse Braham ce2ef0d854 Fix build error, update CHANGELOG and README 4 years ago
Jesse Braham c4967c2645 Add support for stm32f071 4 years ago
Jesse Braham b016ffdfe9 Add support for stm32f051 4 years ago
Jesse Braham e6db427c09 Add support for stm32f031 4 years ago
Daniel Egger c6b96c397b
Merge pull request #41 from HarkonenBade/down-with-ub 4 years ago
HarkonenBade 7ea2af8a74 Enforce better safety guarentees 4 years ago
david-sawatzke f54423aa9c Optimize delay implementation (#42) 4 years ago
Tom 94eea3924b Tweaks to travis to run plain builds and faster cargo executions (#39) 4 years ago
david-sawatzke b2111b98b0 Fix overflow in delay (#40) 4 years ago
Tom 6b2ffaa650
Merge pull request #38 from HarkonenBade/RCC-fixes 4 years ago
Daniel Egger e10dae9663
Merge pull request #37 from david-sawatzke/spi_doc 4 years ago
HarkonenBade 626d8960e7 Add fixes to RCC code for plain builds 4 years ago
David Sawatzke 083323b110 Add more spi documentation 4 years ago
Daniel Egger aef15217c7
Merge pull request #36 from jessebraham/readme-updates 4 years ago
Jesse Braham be98d3ce8d Overhaul README, add Getting Started section 4 years ago
Ze'ev Klapow 23be76c14c RCC: Add ability to use HSE clock source (#25) 4 years ago
Jesse Braham 6f13445bfc Add support for the STM32f091 (#35) 4 years ago
Daniel Egger 35abc7a88f Released 0.11.1 4 years ago
Yatekii 7da190e507 Added definitions for the stm32f072xx chips (#31) 4 years ago
Daniel Egger e74eea773d
Merge pull request #33 from david-sawatzke/spi_example 4 years ago
David Sawatzke abe8d56db5 Add a basic spi example 4 years ago
Daniel Egger bc723e1437 More rubost error handling for I2C 4 years ago
Daniel Egger e3c8e6f1a5
Merge pull request #30 from HarkonenBade/readme-badges 4 years ago
HarkonenBade 187ea7d5b0 Add badges to README 4 years ago
Daniel Egger 2de56b0878 Bumped version to 0.11.0 for release 4 years ago
david-sawatzke f729f7e4df Allow multi delay instances for the systick timer (#23) 4 years ago
Daniel Egger f55163cd5c Ran rustfmt on the code 4 years ago
Daniel Egger 4c81088ce5 Added interupt enabling/disabling support to USART ports 4 years ago
Mike Panetta 1924bb15cc Stm32f04x additions for RCC (#17) 4 years ago
Daniel Egger 3691709340 Adressed a few clippy lints 4 years ago
Tom f6155f99a5 Initial test implementation of ADC helper functions (#22) 4 years ago
  1. 8
      .github/bors.toml
  2. 33
      .github/workflows/ci.yml
  3. 21
      .github/workflows/clippy.yml
  4. 23
      .github/workflows/rustfmt.yml
  5. 21
      .travis.yml
  6. 172
      CHANGELOG.md
  7. 81
      Cargo.toml
  8. 101
      README.md
  9. 89
      examples/adc_values.rs
  10. 24
      examples/blinky.rs
  11. 55
      examples/blinky_adc.rs
  12. 27
      examples/blinky_delay.rs
  13. 42
      examples/blinky_multiple.rs
  14. 31
      examples/blinky_timer.rs
  15. 98
      examples/blinky_timer_irq.rs
  16. 61
      examples/dac.rs
  17. 85
      examples/flash_systick.rs
  18. 96
      examples/flash_systick_fancier.rs
  19. 48
      examples/i2c_find_address.rs
  20. 92
      examples/led_hal_button_irq.rs
  21. 35
      examples/serial_echo.rs
  22. 70
      examples/serial_spi_bridge.rs
  23. 121
      examples/serial_stopwatch.rs
  24. 34
      examples/spi_hal_apa102c.rs
  25. 93
      examples/usb_serial.rs
  26. 38
      examples/watchdog.rs
  27. 438
      src/adc.rs
  28. 175
      src/dac.rs
  29. 76
      src/delay.rs
  30. 1004
      src/gpio.rs
  31. 296
      src/i2c.rs
  32. 75
      src/lib.rs
  33. 6
      src/prelude.rs
  34. 558
      src/rcc.rs
  35. 522
      src/serial.rs
  36. 486
      src/spi.rs
  37. 110
      src/timers.rs
  38. 430
      src/tsc.rs
  39. 58
      src/usb.rs
  40. 12
      src/watchdog.rs
  41. 24
      tools/capture_example_bloat.sh
  42. 31
      tools/capture_nightly_example_bloat.sh
  43. 47
      tools/check.py

8
.github/bors.toml

@ -0,0 +1,8 @@
required_approvals = 1
block_labels = ["wip"]
delete_merged_branches = true
status = [
"Rustfmt",
"ci (stable)",
"ci (1.39.0, stable)",
]

33
.github/workflows/ci.yml

@ -0,0 +1,33 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:
name: Continuous integration
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- 1.39.0 # MSRV
include:
- rust: nightly
experimental: true
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: thumbv6m-none-eabi
override: true
- name: Regular build
run: python tools/check.py
- name: Size check
run: python tools/check.py size_check

21
.github/workflows/clippy.yml

@ -0,0 +1,21 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:
name: Clippy check
jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: rustup component add clippy
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: thumbv6m-none-eabi
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --features=stm32f072 --target thumbv6m-none-eabi

23
.github/workflows/rustfmt.yml

@ -0,0 +1,23 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:
name: Code formatting check
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

21
.travis.yml

@ -1,21 +0,0 @@
language: rust
rust:
- stable
- nightly
cache: cargo
env:
- MCU=stm32f042
- MCU=stm32f030
- MCU=stm32f030x6
- MCU=stm32f030x8
- MCU=stm32f030xc
- MCU=stm32f070
- MCU=stm32f070x6
- MCU=stm32f070xb
matrix:
allow_failures:
- rust: nightly
fast_finish: true
script:
- rustup target add thumbv6m-none-eabi
- cargo build --features=$MCU --examples --release

172
CHANGELOG.md

@ -7,6 +7,162 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [v0.17.1] - 2020-08-30
### Changed
- Simplify USB PA11/12 remapping for STM32F042x via `usb_bus.usb_remap()` function.
### Added
- Complete the `TscPin` trait implementation for all touch pins in the f0 family
## [v0.17.0] - 2020-06-27
### Changed
- Remove duplicate error bits clearing in serial `read()` implementation
- Optimize SPI implementation
- Use `pac` instead of `stm32` for PAC access and soft-deprecate the former
- Updated stm32f0 dependency to v0.11 (breaking change)
### Added
- Add 16bit SPI transfers
- Another example resembling a stop watch controlled via serial interface
### Fixed
- Incorrect PLLSRC bits when using HSE
## [v0.16.0] - 2020-02-02
### Added
- Another blinky example using a timer interrupt
### Changed
- Added "bypass" parameter to Rcc HSE configuration (breaking change)
- Add "usbsrc" function to Rcc configuration, used for selecting USB clock source
- For STM32F030, require use more specific feature flag, e.g. "stm32f030xc"
- Add `embedded-hal` `blocking::i2c::Read` implementation for I2C
- Added USB driver
### Fixed
- Timer: Fix use of wrong frequency when HCLK != PCLK
- RCC: Correct code to enable PLL
- RCC: Correct calculation of PLL multiplier
## [v0.15.2] - 2019-11-04
### Changed
- Re-enabled LTO
- Changed digital pin functionality to implement v2 versions
- Fixed a few deprecation warning and lints
- Enabled commented out and now available GPIOE support for 07x and 09x families
- Extract register block address only once
- Add DAC driver
## [v0.15.1] - 2019-08-11
### Fixed
- Clear UART errors in hardware after handling them
## [v0.15.0] - 2019-08-09
### Changed
- Updated stm32f0 dependency to v0.8.0 (breaking change)
- Made blinky example more universal by reducing CS
### Added
- Added fancier example moving a resource into an exception handler
## [v0.14.1] - 2019-06-06
### Added
- Support for CRS for devices with USB and HSI48
### Changed
- Clear error flags in serial read() before returning
- Revised feature flags for HSI48 clock support
## [v0.14.0] - 2019-04-25
### Changed
- Updated stm32f0 dependency to v0.7.0 (breaking change) - @jessebraham
- Bumped cortex-m dependency to ">=0.5.8,<0.7.0" to let user decide version
- Bumped cortex-m-rt dependency to v0.6.8
## [v0.13.0] - 2019-02-06
### Added
- Support for stm32f0x8 line - @jessebraham
- Support for capacitive touch sensing (TSC)
### Changed
- Updated to stm32-rs v0.6.0 - @HarkonenBade
- Updated the ADC code to use variants added in stm32-rs v0.6.0 - @HarkonenBade
- Improved serial `write_str` implementation
### Fixed
- Fixed ADC use trampling over the HSI48 clock settings
## [v0.12.0] - 2019-01-13
### Added
- Support for stm32f0x1 line - @jessebraham
- Support for HSE as a system clocksource (#25 - breaking change) - @zklapow
- Add ability to use a Tx/Rx only serial instance - @david-sawatzke
### Changed
- Optimize delay implemenation (#42) - @david-sawatzke
- Enforced more rigorous safety guarentees (#41 - Very breaking change) - @HarkonenBade
### Fixed
- Fixed panic in delay overflow handling for debug builds - @david-sawatzke
## [v0.11.1] - 2019-01-05
### Added
- Added peripheral definitions for the stm32f072xx line - @Yatekii
### Changed
- Fixed broken PC GPIO definitions with feature = "stm32f030" and feature = "stm32f070"
- More robust error handling for I2C
## [v0.11.0] - 2019-01-04
### Added
- Added ADC helper functions to read more intuitive values (#22) - @HarkonenBade
- Added interrupt enabling/disabling support to USART ports
- Added the option to have multiple Delay instances by cloning it - @david-sawatzke
### Changed
- Fixed a few clippy lints
### Removed
- Removed the free() method on the Delay provider (breaking change)
## [v0.10.1] - 2018-12-25
### Added
@ -25,7 +181,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Reworked GPIOs and added fully erased pins
- Timer support
- Support for STM32F070
- Support for STM32F070 - @jessebraham
- Additional peripheral support for STM32F030
- Watchdog support
@ -58,7 +214,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Updated stm32f0 dependency to v0.5.0.
- Interrupt handler to new #[interrupt] attribute
[Unreleased]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.10.1...HEAD
[Unreleased]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.17.1...HEAD
[v0.17.1]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.17.0...v0.17.1
[v0.17.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.16.0...v0.17.0
[v0.16.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.15.2...v0.16.0
[v0.15.2]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.15.1...v0.15.2
[v0.15.1]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.15.0...v0.15.1
[v0.15.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.14.1...v0.15.0
[v0.14.1]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.14.0...v0.14.1
[v0.14.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.13.0...v0.14.0
[v0.13.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.12.0...v0.13.0
[v0.12.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.11.1...v0.12.0
[v0.11.1]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.11.0...v0.11.1
[v0.11.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.10.1...v0.11.0
[v0.10.1]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.10.0...v0.10.1
[v0.10.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.9.0...v0.10.0
[v0.9.0]: https://github.com/stm32-rs/stm32f0xx-hal/compare/v0.8.0...v0.9.0

81
Cargo.toml

@ -1,6 +1,10 @@
[package]
edition = "2018"
authors = ["Daniel Egger <daniel@eggers-club.de>"]
authors = [
"Daniel Egger <daniel@eggers-club.de>",
"Thomas Bytheway <github@harkonen.net>",
"Jesse Braham <jesse@beta7.io>",
]
categories = [
"embedded",
"hardware-support",
@ -19,51 +23,76 @@ license = "0BSD"
name = "stm32f0xx-hal"
readme = "README.md"
repository = "https://github.com/stm32-rs/stm32f0xx-hal"
version = "0.10.1"
version = "0.17.1"
[package.metadata.docs.rs]
features = ["stm32f042", "rt"]
features = ["stm32f042", "rt", "stm32-usbd"]
targets = ["thumbv6m-none-eabi"]
[dependencies]
bare-metal = { version = "0.2.4", features = ["const-fn"] }
cortex-m = "0.5.8"
cortex-m-rt = "0.6.7"
nb = "0.1.1"
void = { version = "1.0.2", default-features = false }
stm32f0 = "0.5.0"
[dependencies.cast]
default-features = false
version = "0.2.2"
[dependencies.embedded-hal]
features = ["unproven"]
version = "0.2.2"
bare-metal = { version = "1.0.0" }
cast = { version = "0.2", default-features = false }
cortex-m = "0.6"
embedded-hal = { version = "0.2", features = ["unproven"] }
stm32f0 = "0.12.1"
nb = "1.0"
void = { version = "1.0", default-features = false }
stm32-usbd = { version = "0.5.1", features = ["ram_access_2x16"], optional = true }
[dev-dependencies]
panic-halt = "0.2.0"
cortex-m-rt = "0.6"
panic-halt = "0.2"
usb-device = "0.2.7"
usbd-serial = "0.1.1"
[features]
device-selected = []
rt = ["stm32f0/rt"]
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
stm32f030 = ["stm32f0/stm32f0x0", "device-selected"]
stm32f030x4 = ["stm32f030x6", "device-selected"]
stm32f030x6 = ["stm32f030", "device-selected"]
stm32f030x8 = ["stm32f030", "device-selected"]
stm32f030xc = ["stm32f030", "device-selected"]
stm32f030x4 = ["stm32f030"]
stm32f030x6 = ["stm32f030"]
stm32f030x8 = ["stm32f030"]
stm32f030xc = ["stm32f030"]
stm32f031 = ["stm32f0/stm32f0x1", "device-selected"]
stm32f038 = ["stm32f0/stm32f0x8", "device-selected"]
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
stm32f048 = ["stm32f0/stm32f0x8", "device-selected"]
stm32f051 = ["stm32f0/stm32f0x1", "device-selected"]
stm32f058 = ["stm32f0/stm32f0x8", "device-selected"]
stm32f070 = ["stm32f0/stm32f0x0", "device-selected"]
stm32f070x6 = ["stm32f070", "device-selected"]
stm32f070xb = ["stm32f070", "device-selected"]
stm32f070x6 = ["stm32f070"]
stm32f070xb = ["stm32f070"]
stm32f071 = ["stm32f0/stm32f0x1", "device-selected"]
stm32f072 = ["stm32f0/stm32f0x2", "device-selected"]
stm32f078 = ["stm32f0/stm32f0x8", "device-selected"]
stm32f091 = ["stm32f0/stm32f0x1", "device-selected"]
stm32f098 = ["stm32f0/stm32f0x8", "device-selected"]
[profile.dev]
debug = true
lto = true
[profile.release]
debug = true
lto = true
debug = true
opt-level = "s"
[[example]]
name = "blinky_timer_irq"
required-features = ["stm32f072", "rt"]
[[example]]
name = "serial_stopwatch"
required-features = ["stm32f072", "rt"]
[[example]]
name = "dac"
required-features = ["stm32f072"]
[[example]]
name = "led_hal_button_irq"
required-features = ["stm32f042", "rt"]
[[example]]
name = "usb_serial"
required-features = ["rt", "stm32f042", "stm32-usbd"]

101
README.md

@ -1,41 +1,74 @@
stm32f0xx-hal
=============
_stm32f0xx-hal_ contains a hardware abstraction on top of the peripheral access
API for the STMicro STM32F0xx family of microcontrollers. It replaces the
[stm32f042-hal][] by a more ubiqitous version suitable for additional families.
Currently supported configuration are:
* stm32f030
* stm32f030x4
* stm32f030x6
* stm32f030x8
* stm32f030xc
* stm32f042
* stm32f070
* stm32f070x6
* stm32f070xb
The idea behind this crate is to gloss over the slight differences in the
various peripherals available on those MCUs so a HAL can be written for all
chips in that same family without having to cut and paste crates for every
single model.
Collaboration on this crate is highly welcome as are pull requests!
This crate relies on Adam Greigs fantastic [stm32f0][] crate to provide
appropriate register definitions and implements a partial set of the
[embedded-hal][] traits.
Some of the implementation was shamelessly adapted from the [stm32f103xx-hal][]
crate by Jorge Aparicio.
[stm32f0]: https://crates.io/crates/stm32f0
[stm32f042-hal]: https://github.com/therealprof/stm32f042-hal
[stm32f103xx-hal]: https://github.com/japaric/stm32f103xx-hal
[embedded-hal]: https://github.com/japaric/embedded-hal.git
[![Continuous integration](https://github.com/stm32-rs/stm32f0xx-hal/workflows/Continuous%20integration/badge.svg)](https://github.com/stm32-rs/stm32f0xx-hal)
[![Crates.io](https://img.shields.io/crates/v/stm32f0xx-hal.svg)](https://crates.io/crates/stm32f0xx-hal)
[![docs.rs](https://docs.rs/stm32f0xx-hal/badge.svg)](https://docs.rs/stm32f0xx-hal/)
[_stm32f0xx-hal_](https://github.com/stm32-rs/stm32f0xx-hal) contains a hardware abstraction on top of the peripheral access API for the STMicro STM32F0xx family of microcontrollers.
This crate replaces the [stm32f042-hal](https://github.com/therealprof/stm32f042-hal) by a more ubiquitous version suitable for additional families. The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model.
This crate relies on Adam Greig's fantastic [stm32f0](https://crates.io/crates/stm32f0) crate to provide appropriate register definitions, and implements a partial set of the [embedded-hal](https://github.com/rust-embedded/embedded-hal) traits. Some of the implementation was shamelessly adapted from the [stm32f103xx-hal](https://github.com/japaric/stm32f103xx-hal) crate by Jorge Aparicio.
Collaboration on this crate is highly welcome, as are pull requests!
Supported Configurations
------------------------
* __stm32f030__ (stm32f030x4, stm32f030x6, stm32f030x8, stm32f030xc)
* __stm32f031__
* __stm32f038__
* __stm32f042__
* __stm32f048__
* __stm32f051__
* __stm32f058__
* __stm32f070__ (stm32f070x6, stm32f070xb)
* __stm32f071__
* __stm32f072__
* __stm32f078__
* __stm32f091__
* __stm32f098__
Getting Started
---------------
The `examples` folder contains several example programs. To compile them, one must specify the target device as cargo feature:
```
$ cargo build --features=stm32f030
```
To use stm32f0xx-hal as a dependency in a standalone project the target device feature must be specified in the `Cargo.toml` file:
```
[dependencies]
cortex-m = "0.6.0"
cortex-m-rt = "0.6.8"
stm32f0xx-hal = {version = "0.16", features = ["stm32f030"]}
```
If you are unfamiliar with embedded development using Rust, there are a number of fantastic resources available to help.
- [Embedded Rust Documentation](https://docs.rust-embedded.org/)
- [The Embedded Rust Book](https://docs.rust-embedded.org/book/)
- [Rust Embedded FAQ](https://docs.rust-embedded.org/faq.html)
- [rust-embedded/awesome-embedded-rust](https://github.com/rust-embedded/awesome-embedded-rust)
Minimum supported Rust version
------------------------------
The minimum supported Rust version at the moment is **1.39.0**. Older versions
**may** compile, especially when some features are not used in your
application.
Changelog
---------
See [CHANGELOG.md](CHANGELOG.md).
License
-------
[0-clause BSD license](LICENSE-0BSD.txt).
0-Clause BSD License, see [LICENSE-0BSD.txt](LICENSE-0BSD.txt) for more details.

89
examples/adc_values.rs

@ -0,0 +1,89 @@
#![no_main]
#![no_std]
use panic_halt as _;
use stm32f0xx_hal as hal;
use crate::hal::{pac, prelude::*};
use cortex_m::{interrupt::Mutex, peripheral::syst::SystClkSource::Core};
use cortex_m_rt::{entry, exception};
use core::{cell::RefCell, fmt::Write};
struct Shared {
adc: hal::adc::Adc,
tx: hal::serial::Tx<pac::USART1>,
}
static SHARED: Mutex<RefCell<Option<Shared>>> = Mutex::new(RefCell::new(None));
#[entry]
fn main() -> ! {
if let (Some(p), Some(cp)) = (
hal::pac::Peripherals::take(),
cortex_m::peripheral::Peripherals::take(),
) {
cortex_m::interrupt::free(move |cs| {
let mut flash = p.FLASH;
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut flash);
let gpioa = p.GPIOA.split(&mut rcc);
let mut syst = cp.SYST;
// Set source for SysTick counter, here full operating frequency (== 8MHz)
syst.set_clock_source(Core);
// Set reload value, i.e. timer delay 8 MHz/counts
syst.set_reload(8_000_000 - 1);
// Start SysTick counter
syst.enable_counter();
// Start SysTick interrupt generation
syst.enable_interrupt();
// USART1 at PA9 (TX) and PA10(RX)
let tx = gpioa.pa9.into_alternate_af1(cs);
let rx = gpioa.pa10.into_alternate_af1(cs);
// Initialiase UART
let (mut tx, _) =
hal::serial::Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc).split();
// Initialise ADC
let adc = hal::adc::Adc::new(p.ADC, &mut rcc);
// Output a friendly greeting
tx.write_str("\n\rThis ADC example will read various values using the ADC and print them out to the serial terminal\r\n").ok();
// Move all components under Mutex supervision
*SHARED.borrow(cs).borrow_mut() = Some(Shared { adc, tx });
});
}
loop {
continue;
}
}
#[exception]
fn SysTick() {
use core::ops::DerefMut;
// Enter critical section
cortex_m::interrupt::free(|cs| {
// Get access to the Mutex protected shared data
if let Some(ref mut shared) = SHARED.borrow(cs).borrow_mut().deref_mut() {
// Read temperature data from internal sensor using ADC
let t = hal::adc::VTemp::read(&mut shared.adc, None);
writeln!(shared.tx, "Temperature {}.{}C\r", t / 100, t % 100).ok();
// Read volatage reference data from internal sensor using ADC
let t = hal::adc::VRef::read_vdda(&mut shared.adc);
writeln!(shared.tx, "Vdda {}mV\r", t).ok();
}
});
}

24
examples/blinky.rs

@ -1,32 +1,32 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
use crate::hal::prelude::*;
use crate::hal::stm32;
use crate::hal::{pac, prelude::*};
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
if let Some(p) = stm32::Peripherals::take() {
let gpioa = p.GPIOA.split();
if let Some(mut p) = pac::Peripherals::take() {
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
/* (Re-)configure PA1 as output */
let mut led = gpioa.pa1.into_push_pull_output();
let gpioa = p.GPIOA.split(&mut rcc);
// (Re-)configure PA1 as output
let mut led = cortex_m::interrupt::free(|cs| gpioa.pa1.into_push_pull_output(cs));
loop {
/* Turn PA1 on a million times in a row */
// Turn PA1 on a million times in a row
for _ in 0..1_000_000 {
led.set_high();
led.set_high().ok();
}
/* Then turn PA1 off a million times in a row */
// Then turn PA1 off a million times in a row
for _ in 0..1_000_000 {
led.set_low();
led.set_low().ok();
}
}
}

55
examples/blinky_adc.rs

@ -1,50 +1,47 @@
#![no_main]
#![no_std]
#[allow(unused_imports)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
use crate::hal::delay::Delay;
use crate::hal::prelude::*;
use crate::hal::stm32;
use crate::hal::adc::Adc;
use crate::hal::{adc::Adc, delay::Delay, pac, prelude::*};
use cortex_m::peripheral::Peripherals;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
if let (Some(p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
let gpioa = p.GPIOA.split();
/* (Re-)configure PA1 as output */
let mut led = gpioa.pa1.into_push_pull_output();
/* (Re-)configure PA0 as analog in */
let mut an_in = gpioa.pa0.into_analog();
if let (Some(mut p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
/* Constrain clocking registers */
let rcc = p.RCC.constrain();
let gpioa = p.GPIOA.split(&mut rcc);
/* Configure clock to 8 MHz (i.e. the default) and freeze it */
let clocks = rcc.cfgr.sysclk(8.mhz()).freeze();
let (mut led, mut an_in) = cortex_m::interrupt::free(move |cs| {
(
// (Re-)configure PA1 as output
gpioa.pa1.into_push_pull_output(cs),
// (Re-)configure PA0 as analog input
gpioa.pa0.into_analog(cs),
)
});
/* Get delay provider */
let mut delay = Delay::new(cp.SYST, clocks);
// Get delay provider
let mut delay = Delay::new(cp.SYST, &rcc);
let mut adc = Adc::new(p.ADC);
// Get access to the ADC
let mut adc = Adc::new(p.ADC, &mut rcc);
loop {
led.toggle();
let val: u16 = adc.read(&mut an_in).unwrap();
/* shift the value right by 3, same as divide by 8, reduces
the 0-4095 range into something approximating 1-512 */
let time: u16 = (val >> 3) + 1;
led.toggle().ok();
let time: u16 = if let Ok(val) = adc.read(&mut an_in) as Result<u16, _> {
/* shift the value right by 3, same as divide by 8, reduces
the 0-4095 range into something approximating 1-512 */
(val >> 3) + 1
} else {
1000
};
delay.delay_ms(time);
}

27
examples/blinky_delay.rs

@ -1,37 +1,30 @@
#![no_main]
#![no_std]
#[allow(unused)]
use panic_halt;
use panic_halt as _;
use stm32f0xx_hal as hal;
use crate::hal::delay::Delay;
use crate::hal::prelude::*;
use crate::hal::stm32;
use crate::hal::{delay::Delay, pac, prelude::*};
use cortex_m::peripheral::Peripherals;
use cortex_m_rt::entry;
#[entry]</