/**
 * @file comms_uhf_csp.h
 *
 * @brief This file contains function prototypes and types that is used
 *        for sending and receiving data through can interface
 *
 * @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 COMMS_UHF_CSP_H_
#define COMMS_UHF_CSP_H_

#include <stdint.h>
#include <errno.h>
#include <csp_types.h>

/** UHF module SRC/DST addresses*/
#define UHF_UART_TX_ADDRESS 15
#define UHF_CMD_TX_ADDRESS 14

#define UHF_TM_STOR_TIMER		2*1000
/** UHF module port numbers */
#define UHF_CSP_TX_DATA_PORT 35
#define UHF_CSP_RX_DATA_PORT 25

#define UHF_UART_MTU 245

#define UHF_DEFAULT_TIMEOUT 1000

void comms_uhf_upd_port_addr(uint8_t *csp_tx_port,uint8_t *csp_tx_addr);
void comms_uhf_sim_upd_port_addr(uint8_t *csp_tx_port,uint8_t *csp_tx_addr);

/**
* @brief This function is used for sending the CSP data via UHF module
* This function is used for testing
*/
void uhf_csp_tx_data(void);

/**
* @brief  This function is used for sending the CSP ping packets
* 
* @param tc_cmd
*/
void uhf_csp_ping(uint8_t *tc_cmd);

/**
* @brief This function is used for packing the UART data to send via UHF module
*/
void uhf_pack_uart_csp_frame(csp_packet_t *packet, uint8_t *frame_buff);

/**
* @brief This function is used for unpacking the UART data to send via UHF module
*/
void uhf_unpack_uart_csp_frame(csp_packet_t *packet, uint8_t *frame_buff);

/**
* @brief This function is used for packing the UART data to send via UHF module
*/
void uhf_pack_uart_frame(csp_packet_t *packet, uint8_t *frame_buff);

/**
* @brief This function is used for unpacking the UART data to send via UHF module
*/
void uhf_unpack_uart_frame(csp_packet_t *packet, uint8_t *frame_buff);

/**
* @brief This function updates the command.
*/
void uhf_upd_send_uart_cmd(uint8_t cmd_id);

int32_t uhf_csp_uart_cmd_tx(uint8_t* data, uint16_t len);

uint8_t uhf_proc_uart_cmd_rsp(uint8_t *pld);

void uhf_send_rx_uart_cmd(uint8_t *frame,uint8_t uhf_packet_length);

uint8_t uhf_fw_update_seq(uint8_t *pld);

int8_t is_page_empty(void);

#endif /* COMMS_UHF_CSP_H_ */
