Skip to content

Commit f593555

Browse files
author
deepikabhavnani
committed
Guard hardware related implementation into DEVICE_CRC
1 parent 531a83e commit f593555

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/MbedCRC.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ namespace mbed {
9595
template <uint32_t polynomial = POLY_32BIT_ANSI, uint8_t width = 32>
9696
class MbedCRC {
9797
public:
98-
enum CrcMode { HARDWARE = 0, TABLE, BITWISE };
98+
enum CrcMode
99+
{
100+
#ifdef DEVICE_CRC
101+
HARDWARE = 0,
102+
#endif
103+
TABLE = 1,
104+
BITWISE
105+
};
99106

100107
public:
101108
typedef uint64_t crc_data_size_t;
@@ -170,12 +177,12 @@ class MbedCRC {
170177
int32_t compute_partial(void *buffer, crc_data_size_t size, uint32_t *crc)
171178
{
172179
switch (_mode) {
173-
case HARDWARE:
174180
#ifdef DEVICE_CRC
181+
case HARDWARE:
175182
hal_crc_compute_partial((uint8_t *)buffer, size);
176-
#endif // DEVICE_CRC
177183
*crc = 0;
178184
return 0;
185+
#endif
179186
case TABLE:
180187
return table_compute_partial(buffer, size, crc);
181188
case BITWISE:
@@ -229,15 +236,12 @@ class MbedCRC {
229236
{
230237
MBED_ASSERT(crc != NULL);
231238

232-
if (_mode == HARDWARE) {
233239
#ifdef DEVICE_CRC
240+
if (_mode == HARDWARE) {
234241
*crc = hal_crc_get_result();
235242
return 0;
236-
#else
237-
return -1;
238-
#endif
239243
}
240-
244+
#endif
241245
uint32_t p_crc = *crc;
242246
if ((width < 8) && (NULL == _crc_table)) {
243247
p_crc = (uint32_t)(p_crc << (8 - width));

0 commit comments

Comments
 (0)