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 #include "mxc_device.h"
22 #include "mxc_errors.h"
23 #include "mxc_assert.h"
24 #include "mxc_sys.h"
25 
26 #include "crc.h"
27 #include "crc_reva.h"
28 
29 /* ************************************************************************* */
30 /* Global Control/Configuration functions                                    */
31 /* ************************************************************************* */
32 
MXC_CRC_Init(void)33 int MXC_CRC_Init(void)
34 {
35 #ifndef MSDK_NO_GPIO_CLK_INIT
36     MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CRC);
37 #endif
38 
39     MXC_CRC_RevA_Init((mxc_crc_reva_regs_t *)MXC_CRC);
40 
41     return E_NO_ERROR;
42 }
43 
MXC_CRC_Shutdown(void)44 int MXC_CRC_Shutdown(void)
45 {
46     int error = MXC_CRC_RevA_Shutdown((mxc_crc_reva_regs_t *)MXC_CRC);
47 
48     MXC_SYS_ClockDisable(MXC_SYS_PERIPH_CLOCK_CRC);
49 
50     return error;
51 }
52 
MXC_CRC_Handler(int ch,int error)53 void MXC_CRC_Handler(int ch, int error)
54 {
55     MXC_CRC_RevA_Handler(ch, error);
56 }
57 
MXC_CRC_SetDirection(mxc_crc_bitorder_t bitOrder)58 void MXC_CRC_SetDirection(mxc_crc_bitorder_t bitOrder)
59 {
60     MXC_CRC_RevA_SetDirection((mxc_crc_reva_regs_t *)MXC_CRC, (mxc_crc_reva_bitorder_t)bitOrder);
61 }
62 
MXC_CRC_GetDirection(void)63 mxc_crc_bitorder_t MXC_CRC_GetDirection(void)
64 {
65     return MXC_CRC_RevA_GetDirection((mxc_crc_reva_regs_t *)MXC_CRC);
66 }
67 
MXC_CRC_SwapDataIn(mxc_crc_bitorder_t bitOrder)68 void MXC_CRC_SwapDataIn(mxc_crc_bitorder_t bitOrder)
69 {
70     MXC_CRC_RevA_SwapDataIn((mxc_crc_reva_regs_t *)MXC_CRC, (mxc_crc_reva_bitorder_t)bitOrder);
71 }
72 
MXC_CRC_SwapDataOut(mxc_crc_bitorder_t bitOrder)73 void MXC_CRC_SwapDataOut(mxc_crc_bitorder_t bitOrder)
74 {
75     MXC_CRC_RevA_SwapDataOut((mxc_crc_reva_regs_t *)MXC_CRC, (mxc_crc_reva_bitorder_t)bitOrder);
76 }
77 
MXC_CRC_SetPoly(uint32_t poly)78 void MXC_CRC_SetPoly(uint32_t poly)
79 {
80     MXC_CRC_RevA_SetPoly((mxc_crc_reva_regs_t *)MXC_CRC, poly);
81 }
82 
MXC_CRC_GetPoly(void)83 uint32_t MXC_CRC_GetPoly(void)
84 {
85     return MXC_CRC_RevA_GetPoly((mxc_crc_reva_regs_t *)MXC_CRC);
86 }
87 
MXC_CRC_GetResult(void)88 uint32_t MXC_CRC_GetResult(void)
89 {
90     return MXC_CRC_RevA_GetResult((mxc_crc_reva_regs_t *)MXC_CRC);
91 }
92 
MXC_CRC_Compute(mxc_crc_req_t * req)93 int MXC_CRC_Compute(mxc_crc_req_t *req)
94 {
95     return MXC_CRC_RevA_Compute((mxc_crc_reva_regs_t *)MXC_CRC, (mxc_crc_reva_req_t *)req);
96 }
97 
MXC_CRC_ComputeAsync(mxc_crc_req_t * req)98 int MXC_CRC_ComputeAsync(mxc_crc_req_t *req)
99 {
100     return MXC_CRC_RevA_ComputeAsync((mxc_crc_reva_regs_t *)MXC_CRC, (mxc_crc_reva_req_t *)req);
101 }
102