lib.rs 4.7 KB

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