2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /******************************************************************************
19 * @brief Header File for CRC Driver
22 ******************************************************************************/
31 #include <drv_errno.h>
32 #include <drv_common.h>
35 /****** CRC specific error codes *****/
36 #define CRC_ERROR_MODE (EDRV_SPECIFIC + 1) ///< Specified Mode not supported
38 /// definition for crc handle.
39 typedef void *crc_handle_t;
41 /*----- CRC Control Codes: Mode -----*/
43 CRC_MODE_CRC8 = 0, ///< Mode CRC8
44 CRC_MODE_CRC16 , ///< Mode CRC16
45 CRC_MODE_CRC32 ///< Mode CRC32
48 /*----- CRC Control Codes: Mode Parameters: Key length -----*/
50 CRC_STANDARD_CRC_ROHC = 0, ///< Standard CRC RHOC
51 CRC_STANDARD_CRC_MAXIM , ///< Standard CRC MAXIAM
52 CRC_STANDARD_CRC_X25 , ///< Standard CRC X25
53 CRC_STANDARD_CRC_CCITT , ///< Standard CRC CCITT
54 CRC_STANDARD_CRC_USB , ///< Standard CRC USB
55 CRC_STANDARD_CRC_IBM , ///< Standard CRC IBM
56 CRC_STANDARD_CRC_MODBUS ///< Standard CRC MODBUS
63 uint32_t busy : 1; ///< busy flag
66 /****** CRC Event *****/
68 CRC_EVENT_CALCULATE_COMPLETE = 0, ///< Calculate completed
71 typedef void (*crc_event_cb_t)(crc_event_e event); ///< Pointer to \ref crc_event_cb_t : CRC Event call back.
74 \brief CRC Device Driver Capabilities.
77 uint32_t ROHC : 1; ///< supports ROHC mode
78 uint32_t MAXIM : 1; ///< supports MAXIM mode
79 uint32_t X25 : 1; ///< supports X25 mode
80 uint32_t CCITT : 1; ///< supports CCITT mode
81 uint32_t USB : 1; ///< supports USB mode
82 uint32_t IBM : 1; ///< supports IBM mode
83 uint32_t MODBUS : 1; ///< supports MODBUS mode
86 // Function documentation
89 \brief get crc handle count.
90 \return crc handle count
92 int32_t csi_crc_get_instance_count(void);
95 \brief Initialize CRC Interface. 1. Initializes the resources needed for the CRC interface 2.registers event callback function
96 \param[in] idx must not exceed return value of csi_crc_get_handle_count()
97 \param[in] cb_event Pointer to \ref crc_event_cb_t
98 \return return crc handle if success
100 crc_handle_t csi_crc_initialize(int32_t idx, crc_event_cb_t cb_event);
103 \brief De-initialize CRC Interface. stops operation and releases the software resources used by the interface
104 \param[in] handle crc handle to operate.
107 int32_t csi_crc_uninitialize(crc_handle_t handle);
110 \brief Get driver capabilities.
111 \param[in] handle crc handle to operate.
112 \return \ref crc_capabilities_t
114 crc_capabilities_t csi_crc_get_capabilities(crc_handle_t handle);
117 \brief config crc mode.
118 \param[in] handle crc handle to operate.
119 \param[in] mode \ref crc_mode_e
120 \param[in] standard \ref crc_standard_crc_e
123 int32_t csi_crc_config(crc_handle_t handle,
125 crc_standard_crc_e standard
129 \brief calculate crc.
130 \param[in] handle crc handle to operate.
131 \param[in] in Pointer to the input data
132 \param[out] out Pointer to the result.
133 \param[in] len intpu data len.
136 int32_t csi_crc_calculate(crc_handle_t handle, const void *in, void *out, uint32_t len);
139 \brief Get CRC status.
140 \param[in] handle crc handle to operate.
141 \return CRC status \ref crc_status_t
143 crc_status_t csi_crc_get_status(crc_handle_t handle);
150 #endif /* _CSI_CRC_H_ */