From 1da75e5e85dc788019afa4ba1b6639071cf4680f Mon Sep 17 00:00:00 2001 From: Steven Cartmell Date: Fri, 4 May 2018 16:23:47 +0100 Subject: [PATCH] HAL CRC: Fix code to match coding conventions --- hal/crc_api.h | 12 +++---- .../TARGET_MCU_K64F/mbed_crc_api.c | 33 +++++++++++++++---- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/hal/crc_api.h b/hal/crc_api.h index 2806df4c38..954b61dbd0 100644 --- a/hal/crc_api.h +++ b/hal/crc_api.h @@ -36,17 +36,17 @@ typedef enum crc_polynomial { } crc_polynomial_t; typedef struct crc_mbed_config { - /// CRC Polynomial. Example polynomial: 0x21 = 0010_0011 = x^5+x+1 + /** CRC Polynomial. Example polynomial: 0x21 = 0010_0011 = x^5+x+1 */ uint32_t polynomial; - /// CRC Bit Width + /** CRC Bit Width */ uint32_t width; - /// Initial seed value for the computation. + /** Initial seed value for the computation. */ uint32_t initial_xor; - /// Final xor value for the computation. + /** Final xor value for the computation. */ uint32_t final_xor; - /// Reflect bits on input. + /** Reflect bits on input. */ bool reflect_in; - /// Reflect bits in final result before returning. + /** Reflect bits in final result before returning. */ bool reflect_out; } crc_mbed_config_t; diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c index bb445fe648..8f300193fe 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c @@ -1,3 +1,18 @@ +/* mbed Microcontroller Library + * Copyright (c) 2018 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "crc_api.h" #include "drivers/fsl_crc.h" @@ -10,19 +25,22 @@ static uint32_t final_xor; bool hal_crc_is_supported(const crc_mbed_config_t* config) { - if (config == NULL) + if (config == NULL) { return false; + } - if ((config->width != 32) || (config->width != 16)) + if ((config->width != 32) || (config->width != 16)) { return false; + } return true; } void hal_crc_compute_partial_start(const crc_mbed_config_t* config) { - if (config == NULL) + if (config == NULL) { return; + } width = ((config->polynomial & 0xFFFF0000U) != 0) ? kCrcBits32 : kCrcBits16; final_xor = config->final_xor; @@ -41,19 +59,20 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t* config) void hal_crc_compute_partial(const uint8_t *data, const size_t size) { - if (data == NULL) + if (data == NULL) { return; + } - if (size == 0) + if (size == 0) { return; + } CRC_WriteData(CRC0, data, size); } uint32_t hal_crc_get_result(void) { - if ((final_xor != 0x00000000U) && (final_xor != 0xFFFFFFFFU)) - { + if ((final_xor != 0x00000000U) && (final_xor != 0xFFFFFFFFU)) { CRC_WriteData(CRC0, (uint8_t*)&final_xor, sizeof(final_xor)); }