1
+ /* mbed Microcontroller Library
2
+ * Copyright (c) 2018 ARM Limited
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
#include "crc_api.h"
2
17
3
18
#include "drivers/fsl_crc.h"
@@ -10,19 +25,22 @@ static uint32_t final_xor;
10
25
11
26
bool hal_crc_is_supported (const crc_mbed_config_t * config )
12
27
{
13
- if (config == NULL )
28
+ if (config == NULL ) {
14
29
return false;
30
+ }
15
31
16
- if ((config -> width != 32 ) || (config -> width != 16 ))
32
+ if ((config -> width != 32 ) || (config -> width != 16 )) {
17
33
return false;
34
+ }
18
35
19
36
return true;
20
37
}
21
38
22
39
void hal_crc_compute_partial_start (const crc_mbed_config_t * config )
23
40
{
24
- if (config == NULL )
41
+ if (config == NULL ) {
25
42
return ;
43
+ }
26
44
27
45
width = ((config -> polynomial & 0xFFFF0000U ) != 0 ) ? kCrcBits32 : kCrcBits16 ;
28
46
final_xor = config -> final_xor ;
@@ -41,19 +59,20 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t* config)
41
59
42
60
void hal_crc_compute_partial (const uint8_t * data , const size_t size )
43
61
{
44
- if (data == NULL )
62
+ if (data == NULL ) {
45
63
return ;
64
+ }
46
65
47
- if (size == 0 )
66
+ if (size == 0 ) {
48
67
return ;
68
+ }
49
69
50
70
CRC_WriteData (CRC0 , data , size );
51
71
}
52
72
53
73
uint32_t hal_crc_get_result (void )
54
74
{
55
- if ((final_xor != 0x00000000U ) && (final_xor != 0xFFFFFFFFU ))
56
- {
75
+ if ((final_xor != 0x00000000U ) && (final_xor != 0xFFFFFFFFU )) {
57
76
CRC_WriteData (CRC0 , (uint8_t * )& final_xor , sizeof (final_xor ));
58
77
}
59
78
0 commit comments