/*
 * Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
 * All rights reserved.
 *
 * Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
 * exclusively with CVA's microcontroller products. This file can be freely
 * distributed within development tools that are supporting such microcontroller
 * products.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 * CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
 * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 */

#ifndef _UDS_SERVICE36_H_
#define _UDS_SERVICE36_H_

/*! \brief Contains public interface to various functions related
 *         to the user-defined UDS service 36
 */

/*******************************************************************************
 * the includes
 ******************************************************************************/

#include <stdbool.h>
#include <stdint.h>
#include "../stack/uds.h"

#ifdef __cplusplus
extern "C" {
#endif

/*******************************************************************************
 * the defines
 ******************************************************************************/

/*******************************************************************************
 * the typedefs
 ******************************************************************************/

/*! \brief The Uds IO control type
 */
typedef enum _UdsTransDirType_
{
    UDS_TRANSFER_DIR_NONE     = 0x00,
    UDS_TRANSFER_DIR_DOWNLOAD = 0x01,
    UDS_TRANSFER_DIR_UPLOAD   = 0x02,
} UdsTransDirType;

/*******************************************************************************
 * the globals
 ******************************************************************************/

/*******************************************************************************
 * the function prototypes
 ******************************************************************************/
extern void Uds_InitDownload(void);

/*! \brief set memery start address
 */
extern void Uds_SetMemAddr(uint32_t addr);

/*! \brief get memery start address
 */
extern uint32_t Uds_GetMemAddr(void);

/*! \brief set memery size
 */
extern void Uds_SetMemSize(uint32_t size);

/*! \brief get memery size
 */
extern uint32_t Uds_GetMemSize(void);

/*! \brief set data transfer direct
 */
extern void Uds_SetDataTransferDirect(UdsTransDirType dirType);

/*! \brief get data transfer direct
 */
extern UdsTransDirType Uds_GetDataTransferDirect(void);

/*! \brief get receive data total len
 */
extern uint32_t Uds_GetRcvDataTotalLen(void);

/*! \brief Uds Service 10 processing
 */
extern void UdsService36_TransferData(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen);

#ifdef __cplusplus
}
#endif /* extern "C" */

#endif /* _UDS_SERVICE36_H_ */
