Skip to content

Commit 1da75e5

Browse files
author
Steven Cartmell
committed
HAL CRC: Fix code to match coding conventions
1 parent f006002 commit 1da75e5

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

hal/crc_api.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ typedef enum crc_polynomial {
3636
} crc_polynomial_t;
3737

3838
typedef struct crc_mbed_config {
39-
/// CRC Polynomial. Example polynomial: 0x21 = 0010_0011 = x^5+x+1
39+
/** CRC Polynomial. Example polynomial: 0x21 = 0010_0011 = x^5+x+1 */
4040
uint32_t polynomial;
41-
/// CRC Bit Width
41+
/** CRC Bit Width */
4242
uint32_t width;
43-
/// Initial seed value for the computation.
43+
/** Initial seed value for the computation. */
4444
uint32_t initial_xor;
45-
/// Final xor value for the computation.
45+
/** Final xor value for the computation. */
4646
uint32_t final_xor;
47-
/// Reflect bits on input.
47+
/** Reflect bits on input. */
4848
bool reflect_in;
49-
/// Reflect bits in final result before returning.
49+
/** Reflect bits in final result before returning. */
5050
bool reflect_out;
5151
} crc_mbed_config_t;
5252

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
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+
*/
116
#include "crc_api.h"
217

318
#include "drivers/fsl_crc.h"
@@ -10,19 +25,22 @@ static uint32_t final_xor;
1025

1126
bool hal_crc_is_supported(const crc_mbed_config_t* config)
1227
{
13-
if (config == NULL)
28+
if (config == NULL) {
1429
return false;
30+
}
1531

16-
if ((config->width != 32) || (config->width != 16))
32+
if ((config->width != 32) || (config->width != 16)) {
1733
return false;
34+
}
1835

1936
return true;
2037
}
2138

2239
void hal_crc_compute_partial_start(const crc_mbed_config_t* config)
2340
{
24-
if (config == NULL)
41+
if (config == NULL) {
2542
return;
43+
}
2644

2745
width = ((config->polynomial & 0xFFFF0000U) != 0) ? kCrcBits32 : kCrcBits16;
2846
final_xor = config->final_xor;
@@ -41,19 +59,20 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t* config)
4159

4260
void hal_crc_compute_partial(const uint8_t *data, const size_t size)
4361
{
44-
if (data == NULL)
62+
if (data == NULL) {
4563
return;
64+
}
4665

47-
if (size == 0)
66+
if (size == 0) {
4867
return;
68+
}
4969

5070
CRC_WriteData(CRC0, data, size);
5171
}
5272

5373
uint32_t hal_crc_get_result(void)
5474
{
55-
if ((final_xor != 0x00000000U) && (final_xor != 0xFFFFFFFFU))
56-
{
75+
if ((final_xor != 0x00000000U) && (final_xor != 0xFFFFFFFFU)) {
5776
CRC_WriteData(CRC0, (uint8_t*)&final_xor, sizeof(final_xor));
5877
}
5978

0 commit comments

Comments
 (0)