File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,14 @@ namespace mbed {
95
95
template <uint32_t polynomial = POLY_32BIT_ANSI, uint8_t width = 32 >
96
96
class MbedCRC {
97
97
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
+ };
99
106
100
107
public:
101
108
typedef uint64_t crc_data_size_t ;
@@ -170,12 +177,12 @@ class MbedCRC {
170
177
int32_t compute_partial (void *buffer, crc_data_size_t size, uint32_t *crc)
171
178
{
172
179
switch (_mode) {
173
- case HARDWARE:
174
180
#ifdef DEVICE_CRC
181
+ case HARDWARE:
175
182
hal_crc_compute_partial ((uint8_t *)buffer, size);
176
- #endif // DEVICE_CRC
177
183
*crc = 0 ;
178
184
return 0 ;
185
+ #endif
179
186
case TABLE:
180
187
return table_compute_partial (buffer, size, crc);
181
188
case BITWISE:
@@ -229,15 +236,12 @@ class MbedCRC {
229
236
{
230
237
MBED_ASSERT (crc != NULL );
231
238
232
- if (_mode == HARDWARE) {
233
239
#ifdef DEVICE_CRC
240
+ if (_mode == HARDWARE) {
234
241
*crc = hal_crc_get_result ();
235
242
return 0 ;
236
- #else
237
- return -1 ;
238
- #endif
239
243
}
240
-
244
+ # endif
241
245
uint32_t p_crc = *crc;
242
246
if ((width < 8 ) && (NULL == _crc_table)) {
243
247
p_crc = (uint32_t )(p_crc << (8 - width));
You can’t perform that action at this time.
0 commit comments