Skip to content

Commit 6229322

Browse files
authored
Merge pull request #10846 from bulislaw/crc_doxy
MbedCRC doxygen fixes
2 parents fa2e021 + 13f1217 commit 6229322

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

drivers/MbedCRC.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "platform/SingletonPtr.h"
2424
#include "platform/PlatformMutex.h"
2525

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
2727
if ((width < 8) && (NULL == _crc_table)) {
2828
p_crc = (uint32_t)(p_crc << (8 - width));
2929
}
@@ -43,11 +43,21 @@ namespace mbed {
4343
/** \addtogroup drivers */
4444
/** @{*/
4545

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.
4754
*
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.
5161
* @note Synchronization level: Thread safe
5262
*
5363
* @tparam polynomial CRC polynomial value in hex
@@ -93,9 +103,6 @@ namespace mbed {
93103
* @endcode
94104
* @ingroup drivers
95105
*/
96-
97-
extern SingletonPtr<PlatformMutex> mbed_crc_mutex;
98-
99106
template <uint32_t polynomial = POLY_32BIT_ANSI, uint8_t width = 32>
100107
class MbedCRC {
101108

hal/crc_api.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
* Different polynomial values supported
2929
*/
3030
typedef enum crc_polynomial {
31-
POLY_OTHER = 0,
32-
POLY_8BIT_CCITT = 0x07, // x8+x2+x+1
33-
POLY_7BIT_SD = 0x9, // x7+x3+1;
34-
POLY_16BIT_CCITT = 0x1021, // x16+x12+x5+1
35-
POLY_16BIT_IBM = 0x8005, // x16+x15+x2+1
36-
POLY_32BIT_ANSI = 0x04C11DB7, // x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
37-
POLY_32BIT_REV_ANSI = 0xEDB88320
31+
POLY_OTHER = 0, ///< Custom polynomial
32+
POLY_8BIT_CCITT = 0x07, ///< x8+x2+x+1
33+
POLY_7BIT_SD = 0x9, ///< x7+x3+1
34+
POLY_16BIT_CCITT = 0x1021, ///< x16+x12+x5+1
35+
POLY_16BIT_IBM = 0x8005, ///< x16+x15+x2+1
36+
POLY_32BIT_ANSI = 0x04C11DB7, ///< x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
37+
POLY_32BIT_REV_ANSI = 0xEDB88320 ///< x31+x30+x29+x27+x26+x24+x23+x21+x20+x19+x15+x9+x8+x5
3838
} crc_polynomial_t;
3939

4040
typedef struct crc_mbed_config {

0 commit comments

Comments
 (0)