/**
 * @file ft_sender.h
 *
 * @brief This file contains function prototypes of CRC calculation
 *
 * @copyright Copyright 2023 Antaris, Inc.
 *
 * 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.
*/

#ifndef CRC_CAL_H_
#define CRC_CAL_H_

#include "exo_common.h"

/******************************************************************************/
/*               Declaration of global function prototypes                    */
/******************************************************************************/

/**
 * @brief This function used to perform integrity check and return the status
 *
 * @param[in]  start_address : address of the data buffer to caluclate CRC CRC from this memory
 * @param[in]  length : length of memory to calculate CRC
 * @param[in]  crc_append_address : address of already calculated CRC
 *
 * @return status of integrity
 * @retval 1 indicates integrity pass
 */
uint8_t crc32_checking(uint32_t start_address, uint32_t length, uint32_t crc_append_address );

/**
 * @brief This function used to calculate CRCand append at the end of data buffer
 *
 * @param[in]  start_address : address of the data buffer to calculate CRC CRC from this memory
 * @param[in]  length : length of memory to calculate CRC
 */
void crc32_calculate_crc_and_append(uint32_t start_address, uint16_t length );

/**
 * @brief This function used to calculate integrity and return the calculated CRC
 *
 * @param[in]  data_buf : pointer to data buffer to caluclate CRC CRC from this memory
 * @param[in]  length : length of memory to calculate CRC
 *
 * @return calculated CRC value
 * @retval CRC value
 */
uint32_t calc_checksum_memory(uint8_t *data_buf,uint32_t length);

#endif /* CRC_CAL_H_ */
