


/**
 ******************************************************************************
 *
 * @file        MG32_APX_ASB_Init.c
 * @brief       MG32 ASB of APX configure C Code. 
 *
 * @par         Project
 *              MG32
 * @version     V1.00
 * @date        2025/07/04
 * @author      Megawin Software Center
 * @copyright   Copyright (c) 2017 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.
 *******************************************************************************
 *******************************************************************************
 */

/* Includes ------------------------------------------------------------------*/
#include "MG32_APX_ASB_Init.h"

/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/


#if defined(ModuleExist_ASB) && CONF_APX_ASB_INIT_EN == 1
/**
 *******************************************************************************
 * @brief	   ASB initial function
 * @details                                           
 * @return     
 * @exception   
 * @note        
 *******************************************************************************
 */
void APX_ASB_Init(void)
{
    /*ASB signal configure*/
    APX->CR0.W = ((APX->CR0.W & (~CONF_APX_ASB_MASK)) | ( CONF_APX_ASB_CR0 & CONF_APX_ASB_MASK));
    
    /*ASB clock related configure*/
    APX->CR1.W = CONF_APX_ASB_CR1;
    
    /*ASB Channel 0 initial and clear FIFO*/
    #if defined(CONF_ASB0_EN) && CONF_ASB0_EN == 1
        APX->ASB00.W = (CONF_APX_ASB00 | APX_ASB00_ASB0_FCLR_mask_w);
        APX->ASB01.W = CONF_APX_ASB01;
    #endif
    /*ASB Channel 1 initial and clear FIFO*/
    #if defined(CONF_ASB1_EN) && CONF_ASB1_EN == 1
        APX->ASB10.W = (CONF_APX_ASB10 | APX_ASB10_ASB1_FCLR_mask_w);
        APX->ASB11.W = CONF_APX_ASB11;
    #endif
    /*ASB Channel 2 initial and clear FIFO*/
    #if defined(CONF_ASB2_EN) && CONF_ASB2_EN == 1
        APX->ASB20.W = (CONF_APX_ASB20 | APX_ASB20_ASB2_FCLR_mask_w);
        APX->ASB21.W = CONF_APX_ASB21;
    #endif
    /*ASB Channel 3 initial and clear FIFO*/
    #if defined(CONF_ASB3_EN) && CONF_ASB3_EN == 1
        APX->ASB30.W = (CONF_APX_ASB30 | APX_ASB30_ASB3_FCLR_mask_w);
        APX->ASB31.W = CONF_APX_ASB31;
    #endif
    /*Clear ASB flag*/
    APX->STA.W = CONF_APX_ASB_STA_MASK;
    
    /*ASB interrupt configure*/ 
    APX->INT.W = ((APX->INT.W & (~CONF_APX_ASB_INT_MASK)) | CONF_APX_ASB_INT);
    
    APX_ASB_InitCallback();
}


/**
 *******************************************************************************
 * @brief     ASB initial complete callback function   
 * @details                                                    
 * @return     
 * @exception   
 * @note        
 *******************************************************************************
 */

__WEAK void APX_ASB_InitCallback(void)
{
    //=========================================================
    //Note : This function should not be modified, when the function
    //       is needed, the function can be implemented in the user file.
}
#endif


