/**
 ******************************************************************************
 *
 * @file        MG32_APX_SDT_Init.h
 *
 * @brief       This file is to configure APB SDT output setting.
 *              Device : MG32F02N128
 * @par         Project
 *              MG32 
 * @version     V1.01
 * @date        2026/01/27
 * @author      MG32CoGen: 2.0.0.32 , 2026/2/9 上午 10:15 
 * @copyright   Copyright (c) 2022 MegaWin Technology Co., Ltd.
 *              All rights reserved.
 *
 ******************************************************************************
 * @par     Disclaimer 
 *    The Demo software is provided "AS IS"  without any warranty, either 
 *    expressed or implied, including, but not limited to, the implied warranties 
 *    of merchantability and fitness for a particular purpose.  The author will 
 *    not be liable for any special, incidental, consequential or indirect 
 *    damages due to loss of data or any other reason. 
 *    These statements agree with the world wide and local dictated laws about 
 *    authorship and violence against these laws. 
 *******************************************************************************
 *******************************************************************************
 */

#ifndef _MG32_APX_SDT_INIT_H
/*!< _MG32_APX_SDT_INIT_H */ 
#define _MG32_APX_SDT_INIT_H

#include "MG32_APX_DRV.h"

// <<< Use Configuration Wizard in Context Menu >>>
//<e0.0> Configure SDT Module
    #define CONF_SDT_MODE                      0x00000000
//  <h> SDT (SDT P4 - Pattern)
//      <o0.10..11> SDT4 detect input line initial state-0 setting value.
//          <0=> [SDT_I0, SDT_I1] = [0,0]
//          <1=> [SDT_I0, SDT_I1] = [0,1]
//          <2=> [SDT_I0, SDT_I1] = [1,0]
//          <3=> [SDT_I0, SDT_I1] = [1,1]
        #define CONF_APX_SDT1_SDT_P4I                 0x00000000
//      <o0.0..9> SDT4 detect input line state setting value. <0x00-0x3F>
//          <i> The adjacent two state settings must be different.
//          <i> [0,1] : state-1 value of input line-0,1
//          <i> [2,3] : state-2 value of input line-0,1
//          <i> [4,5] : state-3 value of input line-0,1
//          <i> [6,7] : state-4 value of input line-0,1
//          <i> [8,9] : state-5 value of input line-0,1
        #define CONF_APX_SDT1_SDT_P4S                 0x00000000
//      <o0.12..14> SDT4 detect end state index.
//          <0=> Index-1
//          <1=> Index-2
//          <2=> Index-3
//          <3=> Index-4
//          <4=> Index-5
        #define CONF_APX_SDT1_SDT_P4E                 0x00000000
//  </h>   

//  <h> SDT (SDT P5 - Pattern)
//      <o0.26..27> SDT5 detect input line initial state-0 setting value.
//          <0=> [SDT_I0, SDT_I1] = [0,0]
//          <1=> [SDT_I0, SDT_I1] = [0,1]
//          <2=> [SDT_I0, SDT_I1] = [1,0]
//          <3=> [SDT_I0, SDT_I1] = [1,1]
        #define CONF_APX_SDT1_SDT_P5I                 0x00000000
//      <o0.16..25> SDT5 detect input line state setting value. <0x00-0x3F>
//          <i> The adjacent two state settings must be different.
//          <i> [0,1] : state-1 value of input line-0,1
//          <i> [2,3] : state-2 value of input line-0,1
//          <i> [4,5] : state-3 value of input line-0,1
//          <i> [6,7] : state-4 value of input line-0,1
//          <i> [8,9] : state-5 value of input line-0,1
        #define CONF_APX_SDT1_SDT_P5S                 0x00000000
//      <o0.28..30> SDT5 detect end state index.
//          <0=> Index-1
//          <1=> Index-2
//          <2=> Index-3
//          <3=> Index-4
//          <4=> Index-5
        #define CONF_APX_SDT1_SDT_P5E                 0x00000000
//  </h>   

//  <h> SDT_P0 setting
//      <O0.7> SDT_P0 output mode select.
//          <0=> Normal : signal directly output
//          <1=> Toggle : output toggle by detect event
        #define CONF_APX_SDT0_SDT_PMDS                0x00000000
//      <O0.8..11> SDT_P0 output mode select.
//          <4=> PROC4 : state procedure-4 detect event
//          <5=> PROC5 : state procedure-5 detect event
        #define CONF_APX_SDT0_SDT_PSEL                0x00000400
//      <O0.30..31> SDT_P0 output initial state.
//          <2=> 0 (Output 0)
//          <3=> 1 (Output 1)
        #define CONF_APX_SDT0_SDT_PSTA                0x80000000
//  </h>   

//  <O0.23> SDT input signals SDT_I0, SDT_I1 deglitch function enable bit.
//      <0=> Disable
//      <1=> Enable
        #define CONF_APX_SDT0_SDT_DEG                 0x00000000

//  <O0.4..5> SDT internal clock input divider.
//      <0x0=> DIV1 : divided by 1
//      <0x1=> DIV2 : divided by 2
//      <0x2=> DIV4 : divided by 4
//      <0x3=> DIV8 : divided by 8
    #define CONF_APX_SDT0_SDT_DIV                 0x00000000

//  <h> APX_SDT interrupt enable 
//    <q0.12> SDT state procedure-4 detect interrupt enable.
      #define CONF_APX_INT_SDT_IE4                0x00000000
//    <q0.13> SDT state procedure-5 detect interrupt enable.
      #define CONF_APX_INT_SDT_IE5                0x00000000
//  </h>


//</e>
// <<< end of Configuration section >>>

// Combined with APX_CRO register bit function
// --------------------------------------------------------------------
// APX SDT Module
// --------------------------------------------------------------------

// ----------------------------------------------
#define CONF_APX_SDT0       CONF_APX_SDT0_SDT_PMDS  |\
                            CONF_APX_SDT0_SDT_PSEL  |\
                            CONF_APX_SDT0_SDT_PSTA  |\
                            CONF_APX_SDT0_SDT_DEG   |\
                            CONF_APX_SDT0_SDT_DIV   

#define CONF_APX_SDT1       CONF_APX_SDT1_SDT_P4I   |\
                            CONF_APX_SDT1_SDT_P4S   |\
                            CONF_APX_SDT1_SDT_P4E   |\
                            CONF_APX_SDT1_SDT_P5I   |\
                            CONF_APX_SDT1_SDT_P5S   |\
                            CONF_APX_SDT1_SDT_P5E

#if (CONF_APX_INT_SDT_IE4 != 0) || (CONF_APX_INT_SDT_IE5 != 0)                     
    #define CONF_APX_SDT_INT    (CONF_APX_INT_SDT_IE4   |\
                                 CONF_APX_INT_SDT_IE5   |\
                                 APX_INT_IEA_enable_w)
#else
    #define CONF_APX_SDT_INT    (0)
#endif
    
/**
 * @name  Function announce
 *      
 */
///@{ 
void APX_SDT_Init(void);

///@}
#endif  // _MG32_APX_SDT_INIT_H

