lib.rs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //! # HAL for the STM32F1 family of microcontrollers
  2. //!
  3. //! This is an implementation of the [`embedded-hal`] traits for the STM32F1 family of
  4. //! microcontrollers.
  5. //!
  6. //! [`embedded-hal`]: https://crates.io/crates/embedded-hal
  7. //!
  8. //! # Usage
  9. //!
  10. //! ## Building an application (binary crate)
  11. //!
  12. //! A detailed usage guide can be found in the [README]
  13. //!
  14. //! supported microcontrollers are:
  15. //!
  16. //! - stm32f103
  17. //! - stm32f101
  18. //! - stm32f100
  19. //!
  20. //! ## Usage
  21. //!
  22. //! This crate supports multiple microcontrollers in the
  23. //! stm32f1 family. Which specific microcontroller you want to build for has to be
  24. //! specified with a feature, for example `stm32f103`.
  25. //!
  26. //! If no microcontroller is specified, the crate will not compile.
  27. //!
  28. //! The currently supported variants are
  29. //!
  30. //! - `stm32f100`
  31. //! - `stm32f101`
  32. //! - `stm32f103`
  33. //!
  34. //! You may also need to specify the density of the device with `medium`, `high` or `xl`
  35. //! to enable certain peripherals. Generally the density can be determined by the 2nd character
  36. //! after the number in the device name (i.e. For STM32F103C6U, the 6 indicates a low-density
  37. //! device) but check the datasheet or CubeMX to be sure.
  38. //! * 4, 6 => low density, no feature required
  39. //! * 8, B => `medium` feature
  40. //! * C, D, E => `high` feature
  41. //! * F, G => `xl` feature
  42. //!
  43. //!
  44. //!
  45. //! [cortex-m-quickstart]: https://docs.rs/cortex-m-quickstart/0.3.1
  46. //!
  47. //! ## Usage examples
  48. //!
  49. //! See the [examples] folder.
  50. //!
  51. //! Most of the examples require the following additional dependencies
  52. //! ```toml
  53. //! [dependencies]
  54. //! embedded-hal = "0.2.3"
  55. //! nb = "0.1.2"
  56. //! cortex-m = "0.6.2"
  57. //! cortex-m-rt = "0.6.11"
  58. //! # Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
  59. //! panic-halt = "0.2.0"
  60. //! ```
  61. //!
  62. //! [examples]: https://github.com/stm32-rs/stm32f1xx-hal/tree/v0.5.3/examples
  63. //! [README]: https://github.com/stm32-rs/stm32f1xx-hal/tree/v0.5.3
  64. #![no_std]
  65. #![deny(intra_doc_link_resolution_failure)]
  66. // If no target specified, print error message.
  67. #[cfg(not(any(feature = "stm32f100", feature = "stm32f101", feature = "stm32f103")))]
  68. compile_error!("Target not found. A `--features <target-name>` is required.");
  69. // If any two or more targets are specified, print error message.
  70. #[cfg(any(
  71. all(feature = "stm32f100", feature = "stm32f101"),
  72. all(feature = "stm32f100", feature = "stm32f103"),
  73. all(feature = "stm32f101", feature = "stm32f103"),
  74. ))]
  75. compile_error!(
  76. "Multiple targets specified. Only a single `--features <target-name>` can be specified."
  77. );
  78. #[cfg(feature = "device-selected")]
  79. use embedded_hal as hal;
  80. #[cfg(feature = "stm32f100")]
  81. pub use stm32f1::stm32f100 as pac;
  82. #[cfg(feature = "stm32f101")]
  83. pub use stm32f1::stm32f101 as pac;
  84. #[cfg(feature = "stm32f103")]
  85. pub use stm32f1::stm32f103 as pac;
  86. #[cfg(feature = "device-selected")]
  87. #[deprecated(since = "0.6.0", note = "please use `pac` instead")]
  88. pub use crate::pac as device;
  89. #[cfg(feature = "device-selected")]
  90. #[deprecated(since = "0.6.0", note = "please use `pac` instead")]
  91. pub use crate::pac as stm32;
  92. #[cfg(feature = "device-selected")]
  93. pub mod adc;
  94. #[cfg(feature = "device-selected")]
  95. pub mod afio;
  96. #[cfg(feature = "device-selected")]
  97. pub mod backup_domain;
  98. #[cfg(feature = "device-selected")]
  99. pub mod bb;
  100. #[cfg(feature = "device-selected")]
  101. pub mod delay;
  102. #[cfg(feature = "device-selected")]
  103. pub mod dma;
  104. #[cfg(feature = "device-selected")]
  105. pub mod flash;
  106. #[cfg(feature = "device-selected")]
  107. pub mod gpio;
  108. #[cfg(feature = "device-selected")]
  109. pub mod i2c;
  110. #[cfg(feature = "device-selected")]
  111. pub mod prelude;
  112. #[cfg(feature = "device-selected")]
  113. pub mod pwm;
  114. #[cfg(feature = "device-selected")]
  115. pub mod pwm_input;
  116. #[cfg(feature = "device-selected")]
  117. pub mod qei;
  118. #[cfg(feature = "device-selected")]
  119. pub mod rcc;
  120. #[cfg(feature = "device-selected")]
  121. pub mod rtc;
  122. #[cfg(feature = "device-selected")]
  123. pub mod serial;
  124. #[cfg(feature = "device-selected")]
  125. pub mod spi;
  126. #[cfg(feature = "device-selected")]
  127. pub mod time;
  128. #[cfg(feature = "device-selected")]
  129. pub mod timer;
  130. #[cfg(all(
  131. feature = "stm32-usbd",
  132. any(feature = "stm32f102", feature = "stm32f103")
  133. ))]
  134. pub mod usb;
  135. #[cfg(feature = "device-selected")]
  136. pub mod watchdog;