1 /******************************************************************************
2  *
3  * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
4  * Analog Devices, Inc.),
5  * Copyright (C) 2023-2024 Analog Devices, Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************************/
20 
21 #ifndef LIBRARIES_PERIPHDRIVERS_SOURCE_CRC_CRC_REVA_H_
22 #define LIBRARIES_PERIPHDRIVERS_SOURCE_CRC_CRC_REVA_H_
23 
24 #include "crc.h"
25 #include "crc_reva_regs.h"
26 
27 /***** CRC Definitions *****/
28 /**
29   * @brief  Structure used to set up CRC request
30   *
31   */
32 typedef struct _mxc_crc_reva_req_t {
33     uint32_t *dataBuffer; ///< Pointer to the data
34     uint32_t dataLen; ///< Length of the data
35     uint32_t resultCRC; ///< Calculated CRC value
36 } mxc_crc_reva_req_t;
37 
38 /**
39  * @brief CRC data bit order
40  *
41  */
42 typedef enum { CRC_REVA_LSB_FIRST, CRC_REVA_MSB_FIRST } mxc_crc_reva_bitorder_t;
43 
44 int MXC_CRC_RevA_Init(mxc_crc_reva_regs_t *crc);
45 int MXC_CRC_RevA_Shutdown(mxc_crc_reva_regs_t *crc);
46 int MXC_CRC_RevA_Handler(int ch, int error);
47 void MXC_CRC_RevA_SetDirection(mxc_crc_reva_regs_t *crc, mxc_crc_reva_bitorder_t bitOrder);
48 mxc_crc_bitorder_t MXC_CRC_RevA_GetDirection(mxc_crc_reva_regs_t *crc);
49 void MXC_CRC_RevA_SwapDataIn(mxc_crc_reva_regs_t *crc, mxc_crc_reva_bitorder_t bitOrder);
50 void MXC_CRC_RevA_SwapDataOut(mxc_crc_reva_regs_t *crc, mxc_crc_reva_bitorder_t bitOrder);
51 void MXC_CRC_RevA_SetPoly(mxc_crc_reva_regs_t *crc, uint32_t poly);
52 uint32_t MXC_CRC_RevA_GetPoly(mxc_crc_reva_regs_t *crc);
53 uint32_t MXC_CRC_RevA_GetResult(mxc_crc_reva_regs_t *crc);
54 int MXC_CRC_RevA_Compute(mxc_crc_reva_regs_t *crc, mxc_crc_reva_req_t *req);
55 int MXC_CRC_RevA_ComputeAsync(mxc_crc_reva_regs_t *crc, mxc_crc_reva_req_t *req);
56 
57 #endif // LIBRARIES_PERIPHDRIVERS_SOURCE_CRC_CRC_REVA_H_
58