/*
 * otsu_ftm.h
 *
 *  Created on: 29-Dec-2023
 *      Author: Invcuser52
 */

#ifndef _INC_OTSU_FTM_H_
#define _INC_OTSU_FTM_H_

#include "otsu.h"


#define MEM_CPY_RUN_SAME_THREAD  		 (uint8_t)1


typedef enum
{
	FTM_GET_SCT_STATUS_OTSU          = 1,
	FTM_GET_SCT_STATUS_ADCS          = 2,
	FTM_GET_SCT_STATUS_COMMS         = 3,
	FTM_GET_SCT_STATUS_EPS_FILE_ONE  = 4,
	FTM_GET_SCT_STATUS_EPS_FILE_TWO  = 5
}ftm_sct_module_id;


/**
 * @brief memcpy handler info
 */
typedef struct memcpy_info_save_def
{
	uint32_t src_addrs;				///< source memory address to start copy from
	uint32_t des_addrs;				///< Destination memory address to copied
	uint32_t size;					///< Size of memory to copy
	uint32_t checksum;				///< Checksum of source memory
}memcpy_info_save_otsu;

void send_ftm_dwld_msg(void);

void otsu_ftm_register(void);

/**
 * @brief This is the callback function which will be invoked by memory copy module
 * once it completed the copy operation for firmware copy from SDRAM to NOR flash
 * after the file download
 *
 * @param[in]  sts  : status of memory copy completion status
 *
 * @return none
 * @retval void : none
 */
 void sdram_fmc_flash_copy_clbk(uint8_t sts);



 /* Read FTM savecontext data has available in ext flash
  * */

uint8_t ftm_get_savecontext_status(ftm_sct_module_id module_id);

/**
 * @brief This function used to perform integrity check before
 * the context info are to be read
 *
 * @param[in]  flash_address  : start address of header section to be verified
 *
 * @return status of integrity check
 * @retval R_OK1 - integrity pass
 */
uint8_t ftmSaveConext_nvm_crc_verify(ftm_sct_module_id module_id);


#endif /* _INC_OTSU_FTM_H_ */
