23
23
#include " platform/SingletonPtr.h"
24
24
#include " platform/PlatformMutex.h"
25
25
26
- /* This is invalid warning from the compiler for below section of code
26
+ /* This is an invalid warning from the compiler for the below section of code
27
27
if ((width < 8) && (NULL == _crc_table)) {
28
28
p_crc = (uint32_t)(p_crc << (8 - width));
29
29
}
@@ -43,11 +43,21 @@ namespace mbed {
43
43
/* * \addtogroup drivers */
44
44
/* * @{*/
45
45
46
- /* * CRC object provides CRC generation through hardware/software
46
+ extern SingletonPtr<PlatformMutex> mbed_crc_mutex;
47
+
48
+ /* * CRC object provides CRC generation through hardware or software
49
+ *
50
+ * CRC sums can be generated using three different methods: hardware, software ROM tables
51
+ * and bitwise computation. The mode used is selected automatically based on required
52
+ * polynomial and hardware capabilities. Any polynomial in standard form (`x^3 + x + 1`)
53
+ * can be used for computation, but custom ones can affect the performance.
47
54
*
48
- * ROM polynomial tables for supported polynomials (:: crc_polynomial_t) will be used for
49
- * software CRC computation, if ROM tables are not available then CRC is computed runtime
50
- * bit by bit for all data input.
55
+ * First choice is the hardware mode. The supported polynomials are hardware specific, and
56
+ * you need to consult your MCU manual to discover them. Next, ROM polynomial tables
57
+ * are tried (you can find list of supported polynomials here ::crc_polynomial). If the selected
58
+ * configuration is supported, it will accelerate the software computations. If ROM tables
59
+ * are not available for the selected polynomial, then CRC is computed at run time bit by bit
60
+ * for all data input.
51
61
* @note Synchronization level: Thread safe
52
62
*
53
63
* @tparam polynomial CRC polynomial value in hex
@@ -93,9 +103,6 @@ namespace mbed {
93
103
* @endcode
94
104
* @ingroup drivers
95
105
*/
96
-
97
- extern SingletonPtr<PlatformMutex> mbed_crc_mutex;
98
-
99
106
template <uint32_t polynomial = POLY_32BIT_ANSI, uint8_t width = 32 >
100
107
class MbedCRC {
101
108
0 commit comments