1 /******************************************************************************* 2 * File Name: cyhal_crc.c 3 * 4 * Description: 5 * Provides a high level interface for interacting with the Infineon CRC. This is 6 * a wrapper around the lower level PDL API. 7 * 8 ******************************************************************************** 9 * \copyright 10 * Copyright 2018-2022 Cypress Semiconductor Corporation (an Infineon company) or 11 * an affiliate of Cypress Semiconductor Corporation 12 * 13 * SPDX-License-Identifier: Apache-2.0 14 * 15 * Licensed under the Apache License, Version 2.0 (the "License"); 16 * you may not use this file except in compliance with the License. 17 * You may obtain a copy of the License at 18 * 19 * http://www.apache.org/licenses/LICENSE-2.0 20 * 21 * Unless required by applicable law or agreed to in writing, software 22 * distributed under the License is distributed on an "AS IS" BASIS, 23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 * See the License for the specific language governing permissions and 25 * limitations under the License. 26 *******************************************************************************/ 27 28 #include "cyhal_crypto_common.h" 29 #include "cyhal_crc_impl.h" 30 #include "cyhal_hwmgr.h" 31 32 #if (CYHAL_DRIVER_AVAILABLE_CRC) 33 34 #if defined(__cplusplus) 35 extern "C" 36 { 37 #endif 38 39 #if defined(CY_IP_M0S8CRYPTO) 40 cy_stc_crypto_crc_context_t _cyhal_crc_context[CY_IP_M0S8CRYPTO_INSTANCES]; 41 #endif 42 43 /******************************************************************************* 44 * Functions 45 *******************************************************************************/ cyhal_crc_init(cyhal_crc_t * obj)46cy_rslt_t cyhal_crc_init(cyhal_crc_t *obj) 47 { 48 CY_ASSERT(NULL != obj); 49 // Note: this takes care of enabling the Crypto block 50 return cyhal_crypto_reserve(&(obj->base), &(obj->resource), CYHAL_CRYPTO_CRC); 51 } 52 cyhal_crc_free(cyhal_crc_t * obj)53void cyhal_crc_free(cyhal_crc_t *obj) 54 { 55 CY_ASSERT(NULL != obj || obj->resource.type != CYHAL_RSC_CRYPTO); 56 _cyhal_crc_calc_free(obj->base); 57 if (obj->resource.type != CYHAL_RSC_INVALID) 58 { 59 cyhal_crypto_free(obj->base, &(obj->resource), CYHAL_CRYPTO_CRC); 60 } 61 } 62 63 #if defined(__cplusplus) 64 } 65 #endif 66 67 #endif /* CYHAL_DRIVER_AVAILABLE_CRC */ 68