aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/crc
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-12-17 22:09:14 +0100
committerDario Nieuwenhuis <[email protected]>2023-12-18 00:53:18 +0100
commit80c9d04bbd83367340a4f3a1e991df825a0b6029 (patch)
treed79b74b0ca17dd943dfcb3b809e895918f4ae629 /embassy-stm32/src/crc
parenta2d4bab2f8a4a9b994bc0289938a9f725950715f (diff)
stm32: add some docs.
Diffstat (limited to 'embassy-stm32/src/crc')
-rw-r--r--embassy-stm32/src/crc/v2v3.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs
index b36f6018c..0c4ae55ce 100644
--- a/embassy-stm32/src/crc/v2v3.rs
+++ b/embassy-stm32/src/crc/v2v3.rs
@@ -6,15 +6,19 @@ use crate::peripherals::CRC;
6use crate::rcc::sealed::RccPeripheral; 6use crate::rcc::sealed::RccPeripheral;
7use crate::Peripheral; 7use crate::Peripheral;
8 8
9/// CRC driver.
9pub struct Crc<'d> { 10pub struct Crc<'d> {
10 _peripheral: PeripheralRef<'d, CRC>, 11 _peripheral: PeripheralRef<'d, CRC>,
11 _config: Config, 12 _config: Config,
12} 13}
13 14
15/// CRC configuration errlr
14pub enum ConfigError { 16pub enum ConfigError {
17 /// The selected polynomial is invalid.
15 InvalidPolynomial, 18 InvalidPolynomial,
16} 19}
17 20
21/// CRC configuration
18pub struct Config { 22pub struct Config {
19 reverse_in: InputReverseConfig, 23 reverse_in: InputReverseConfig,
20 reverse_out: bool, 24 reverse_out: bool,
@@ -25,14 +29,20 @@ pub struct Config {
25 crc_poly: u32, 29 crc_poly: u32,
26} 30}
27 31
32/// Input reverse configuration.
28pub enum InputReverseConfig { 33pub enum InputReverseConfig {
34 /// Don't reverse anything
29 None, 35 None,
36 /// Reverse bytes
30 Byte, 37 Byte,
38 /// Reverse 16-bit halfwords.
31 Halfword, 39 Halfword,
40 /// Reverse 32-bit words.
32 Word, 41 Word,
33} 42}
34 43
35impl Config { 44impl Config {
45 /// Create a new CRC config.
36 pub fn new( 46 pub fn new(
37 reverse_in: InputReverseConfig, 47 reverse_in: InputReverseConfig,
38 reverse_out: bool, 48 reverse_out: bool,
@@ -57,7 +67,9 @@ impl Config {
57 } 67 }
58} 68}
59 69
70/// Polynomial size
60#[cfg(crc_v3)] 71#[cfg(crc_v3)]
72#[allow(missing_docs)]
61pub enum PolySize { 73pub enum PolySize {
62 Width7, 74 Width7,
63 Width8, 75 Width8,
@@ -81,6 +93,7 @@ impl<'d> Crc<'d> {
81 instance 93 instance
82 } 94 }
83 95
96 /// Reset the CRC engine.
84 pub fn reset(&mut self) { 97 pub fn reset(&mut self) {
85 PAC_CRC.cr().modify(|w| w.set_reset(true)); 98 PAC_CRC.cr().modify(|w| w.set_reset(true));
86 } 99 }