/**
 ******************************************************************************
 * @file    IAP_Option_EW.h
 * @author  SOC AE Team
 * @version V1.0.0
 * @date    2026-04-22
 * @brief   Header file of IAP module.
 *          -This document is for the SinOne 92 and 95 series microcontrollers:
 *           SC95: SC95F8x1xB, SC95F7x1xB, SC95F8x6x, SC95F7x6x, SC95R50x, SC95F873x, SC95F8x7x,
 *           	   SC95F7x7x, SC95R702, SC95R61x, SC95R602, SC95R605, SC95R751.
 *           SC92: SC92F6x1x, SC92R43x, SC92Fx41xB, SC92R445, SC92L840x, SC92R422A, SC92R429B,
 *           	   SC92R448M, SC92R449, SC92R450, YX2501, SC92F652x, SC92R343, SC92R519, SC92F531x, SC92R515,
 *           	   SC92R348, SC92F5x5x, SC92F637x, SC92R51x_R52x, SC92F552x, SC92R349, SC92F663x, SC92R350,
 *           	   SC92R523, SC92R351, SC92F563x, SC92R352, SC92R524, SC92R454.
 ******************************************************************************
 * @attention
 *
 *1.This software is supplied by Shenzhen SaiYuan Microelectronics Co.,Ltd. and is only
 *intended for use with SaiYuan products. No other uses are authorized. This
 *software is owned by Shenzhen SaiYuan Microelectronics Co.,Ltd. and is protected under
 *all applicable laws, including copyright laws.
 *2.The software which is for guidance only aims at providing customers with
 *coding information regarding their products in order for them to save time.
 *As a result, SaiYuan shall not be held liable for any direct, indirect or
 *consequential damages with respect to any claims arising from the content of
 *such software and/or the use made by customers of the coding information
 *contained herein in connection with their products.
 *
 *  COPYRIGHT 2026 Shenzhen SaiYuan Microelectronics
 */

#ifndef _IAP_OPTION_EW_H_
#define	_IAP_OPTION_EW_H_


/*============================ SC95 Series ============================*/
#ifdef SC95F8x1xB
  #include "SC95F8x1xB_C.H"
#endif

#ifdef SC95F7x1xB
  #include "SC95F7x1xB_C.H"
#endif

#ifdef SC95F8x6x
  #include "SC95F8x6x_C.H"
#endif

#ifdef SC95F7x6x
  #include "SC95F7x6x_C.H"
#endif

#ifdef SC95R503
  #include "SC95R503_C.H"
#endif

#ifdef SC95F8x3x
  #include "SC95F8x3x_C.H"
#endif

#ifdef SC95F8x7x
  #include "SC95F8x7x_C.H"
#endif

#ifdef SC95F7x7x
  #include "SC95F7x7x_C.H"
#endif

#ifdef SC95R702
  #include "SC95R702_C.H"
#endif

#ifdef SC95R61x
  #include "SC95R61x_C.H"
#endif

#ifdef SC95R602
  #include "SC95R602_C.H"
#endif

#ifdef SC95R605
  #include "SC95R605_C.H"
#endif

#ifdef SC95R751
  #include "SC95R751_C.H"
#endif
/*============================ SC92 Series ============================*/
#ifdef SC92F6x1x
  #include "SC92F641x_C.H"
#endif

#ifdef SC92R436
  #include "SC92R436_C.H"
#endif

#ifdef SC92R438
  #include "SC92R438_C.H"
#endif

#ifdef SC92R439
  #include "SC92R439_C.H"
#endif

#ifdef SC92Fx41xB
  #include "SC92Fx41xB_C.H"
#endif

#ifdef SC92R445
  #include "SC92R445_C.H"
#endif

#ifdef SC92L840x
  #include "SC92L840x_C.H"
#endif

#ifdef SC92R422A
  #include "SC92R422A_C.H"
#endif

#ifdef SC92R429B
  #include "SC92R429B_C.H"
#endif

#ifdef SC92R448M
  #include "SC92R448M_C.H"
#endif

#ifdef SC92R449
  #include "SC92R449_C.H"
#endif

#ifdef SC92R450
  #include "SC92R450_C.H"
#endif

#ifdef YX2501
  #include "YX2501_C.H"
#endif

#ifdef SC92F652x
  #include "SC92F652x_C.H"
#endif

#ifdef SC92R343
  #include "SC92R343_C.H"
#endif

#ifdef SC92R519
  #include "SC92R519_C.H"
#endif

#ifdef SC92F531x
  #include "SC92F531x_C.H"
#endif

#ifdef SC92R515
  #include "SC92R515_C.H"
#endif

#ifdef SC92R348
  #include "SC92R348_C.H"
#endif

#ifdef SC92F5x5x
  #include "SC92F5x5x_C.H"
#endif

#ifdef SC92F637x
  #include "SC92F637x_C.H"
#endif

#ifdef SC92R51x_R52x
  #include "SC92R51x_R52x_C.H"
#endif

#ifdef SC92F552x
  #include "SC92F552x_C.H"
#endif

#ifdef SC92R349
  #include "SC92R349_C.H"
#endif

#ifdef SC92F663x
  #include "SC92F663x_C.H"
#endif

#ifdef SC92R350
  #include "SC92R350_C.H"
#endif

#ifdef SC92R523
  #include "SC92R523_C.H"
#endif

#ifdef SC92R351
  #include "SC92R351_C.H"
#endif

#ifdef SC92F563x
  #include "SC92F563x_C.H"
#endif

#ifdef SC92R352
  #include "SC92R352_C.H"
#endif

#ifdef SC92R524
  #include "SC92R524_C.H"
#endif

#ifdef SC92R454
  #include "SC92R454_C.H"
#endif
/** @addtogroup IAP_Driver
 * @{
 */

/** @defgroup IAP_Exported_Types IAP Exported Types
 * @{
 */

/**
 * @brief IAP Write Enable & Protection Key Definition
 */
typedef enum{
	IAP_ENABLE     = 0x69,    /*!< IAP operation enable command */
	IAP_SOFTKEY1   = 0x09,    /*!< IAP protection soft key 1 */
	IAP_SOFTKEY2   = 0x60,    /*!< IAP protection soft key 2 */
	IAP_DISABLE    = 0x00     /*!< IAP operation disable */
}IAPOPTION_FLAG;

/**
 * @}
 */

/** @defgroup IAP_Exported_Variables IAP Exported Variables
 * @{
 */

/**
 * @brief IAP global write enable flag
 * @note  Set 0x69 to enable IAP write/erase operation
 */
extern unsigned char IapWriteFlag;

/**
 * @}
 */

/** @defgroup IAP_Exported_Constants IAP Exported Constants
 * @{
 */

/** @brief CPU Hold Time Duration Configuration
 * @{
 */
#if defined(SC92Fx41xB)||defined(SC92R445)||defined(SC92R429B)||defined(SC92R448)||defined(SC92R449)||defined(SC92R450)||defined(SC92R343)||defined(SC92R348)\
	||defined(SC92R454)
/**
 * @brief  CPU Hold Time Selection for Normal Series
 */
typedef enum
{
  CPU_Hold_4ms    = (unsigned char)(0x00U << 2),  /*!< CPU Hold 4ms during IAP */
  CPU_Hold_2ms    = (unsigned char)(0x01U << 2),  /*!< CPU Hold 2ms during IAP */
  CPU_Hold_1ms    = (unsigned char)(0x02U << 2),  /*!< CPU Hold 1ms during IAP */
} CPU_HoldTime_TypeDef;

#elif defined(SC92L840x)
/**
 * @brief  CPU Hold Time Selection for SC92L840x Series
 */
typedef enum
{
  CPU_Hold_6ms    = (unsigned char)(0x00U << 2),  /*!< CPU Hold 6ms during IAP */
  CPU_Hold_3ms    = (unsigned char)(0x01U << 2),  /*!< CPU Hold 3ms during IAP */
  CPU_Hold_1_5ms  = (unsigned char)(0x02U << 2),  /*!< CPU Hold 1.5ms during IAP */
} CPU_HoldTime_TypeDef;
#endif
/**
 * @}
 */

/** @brief EEPROM Write Time Configuration
 * @{
 */
#if defined(SC92F531x)||defined(SC92F5x5x)||defined(SC92F637x)||defined(SC92R349)||defined(SC92R350)||defined(SC92R351)||defined(SC92R352)
typedef enum
{
  EEPROM_WriteTime_4ms = (unsigned char)(0x00U << 2),  /*!< EEPROM write time 4ms */
  EEPROM_WriteTime_2ms = (unsigned char)(0x01U << 2),  /*!< EEPROM write time 2ms */
  EEPROM_WriteTime_1ms = (unsigned char)(0x02U << 2),  /*!< EEPROM write time 1ms */
} EEPROM_WriteTime_TypeDef;
#endif
/**
 * @}
 */


/** @defgroup IAP_Exported_Functions IAP Exported Functions
 * @{
 */

#if !(defined(SC92L840x)||defined(SC92F531x)||defined(SC92R348)||defined(SC92F5x5x)||defined(SC92F637x)||defined(SC92R349)||defined(SC92R350)||defined(SC92R351)||defined(SC92R352))
void IAP_CodeProgramByteOption(unsigned long Add,unsigned char Data);
#endif


#if defined(SC95F8x1xB)||defined(SC95F7x1xB)||defined(SC95F8x6x)||defined(SC95F7x6x)||defined(SC95R503)||defined(SC95F8x3x)\
	||defined(SC95F8x7x)||defined(SC95F7x7x)||defined(SC95R702)||defined(SC95R61x)||defined(SC95R602)||defined(SC95R605)||defined(SC95R751)\
	||defined(SC92F6x1x)||defined(SC92R436)||defined(SC92R438)||defined(SC92R439)||defined(SC92R422A)||defined(YX2501)\
	||defined(SC92F652x)||defined(SC92R519)||defined(SC92R515)||defined(SC92R51x_R52x)||defined(SC92F552x)||defined(SC92F663x)\
    ||defined(SC92R523)||defined(SC92F563x)||defined(SC92R524)
void IAP_CodeSectorEraseOption(unsigned long Add);
#endif


#if defined(SC95F8x1xB)||defined(SC95F7x1xB)||defined(SC95F8x6x)||defined(SC95F7x6x)||defined(SC95R503)||defined(SC95F8x3x)\
	||defined(SC95F8x7x)||defined(SC95F7x7x)||defined(SC95R702)||defined(SC95R61x)||defined(SC95R602)||defined(SC95R605)||defined(SC95R751)\
	||defined(SC92Fx41xB)||defined(SC92R445)||defined(SC92L840x)||defined(SC92R429B)||defined(SC92R448M)\
    ||defined(SC92R449)||defined(SC92R450)||defined(YX2501)||defined(SC92F652x)||defined(SC92R343)\
    ||defined(SC92R519)||defined(SC92F531x)||defined(SC92R515)||defined(SC92R348)||defined(SC92F5x5x)\
    ||defined(SC92F637x)||defined(SC92R51x_R52x)||defined(SC92F552x)||defined(SC92R349)||defined(SC92F663x)\
    ||defined(SC92R350)||defined(SC92R523)||defined(SC92R351)||defined(SC92F563x)||defined(SC92R352)\
	||defined(SC92R524)||defined(SC92R454)
void IAP_EEPROMProgramByteOption(unsigned int Add, unsigned char Data);
#endif


#if defined(SC95F8x1xB)||defined(SC95F7x1xB)||defined(SC95F8x6x)||defined(SC95F7x6x)||defined(SC95R503)||defined(SC95F8x3x)\
	||defined(SC95F8x7x)||defined(SC95F7x7x)||defined(SC95R702)||defined(SC95R61x)||defined(SC95R602)||defined(SC95R605)||defined(SC95R751)\
	||defined(YX2501)||defined(SC92F652x)||defined(SC92R519)||defined(SC92R515)||defined(SC92R51x_R52x)||defined(SC92F552x)\
    ||defined(SC92F663x)||defined(SC92R523)||defined(SC92F563x)||defined(SC92R524)
void IAP_EEPROMSectorEraseOption(unsigned int Add);
#endif


#if defined(SC92Fx41xB)||defined(SC92R445)||defined(SC92L840x)||defined(SC92R429B)||defined(SC92R448)||defined(SC92R449)||defined(SC92R450)||defined(SC92R343)||defined(SC92R348)\
	||defined(SC92R454)
void CPU_HoldTime_Config(CPU_HoldTime_TypeDef CPU_HoldTime);
#endif


#if defined(SC92F531x)||defined(SC92F5x5x)||defined(SC92F637x)||defined(SC92R349)||defined(SC92R350)||defined(SC92R351)||defined(SC92R352)
void EEPROM_WriteTime_Config(EEPROM_WriteTime_TypeDef EEPROM_WriteTime);
#endif


#endif
