#include "ape_drv.h"

#include "stc_timer.h"
#include "ape_cnt.h"
#include "ape_csu.h"
#include "ape_mtimer.h"
#include "phy_para.h"
#include "ctc_intr.h"
#include "ucp_utility.h"
#include "ucp_printf.h"

void ape_drv_init(void)
{
    int32_t apeId = get_core_id();
#ifdef PALLADIUM_TEST
    int32_t flag = 1;
    debug_write((DBG_DDR_IDX_DRV_BASE+(apeId<<2)), flag);	// 0x100
#endif

    ape_cnt_init();
    UCP_PRINT_EMPTY("ape cnt init.\r\n");
#ifdef PALLADIUM_TEST
    flag++;
    debug_write((DBG_DDR_IDX_DRV_BASE+(apeId<<2)), flag);
#endif

    ape_csu_init();
    UCP_PRINT_EMPTY("ape csu init.\r\n");
#ifdef PALLADIUM_TEST
    flag++;
    debug_write((DBG_DDR_IDX_DRV_BASE+(apeId<<2)), flag);
#endif

    sfn_para_init();
    UCP_PRINT_EMPTY("sfn para init.\r\n");
#ifdef PALLADIUM_TEST
    flag++;
    debug_write((DBG_DDR_IDX_DRV_BASE+(apeId<<2)), flag);
#endif
}

void ape_drv_int_init()
{
#ifdef PALLADIUM_TEST
    int32_t apeId = get_core_id();
    int32_t flag = 1;
    debug_write((DBG_DDR_IDX_DRV_BASE+3+(apeId<<2)), flag);  // 0x10C
#endif
    //stc_timer_todint_init();
    //ape_mtimer_int_init();    // slot int
#ifdef PALLADIUM_TEST
    flag++;
    debug_write((DBG_DDR_IDX_DRV_BASE+3+(apeId<<2)), flag);
#endif

    stc_timer_ctwint_init();    // stc timer ctw int
#ifdef PALLADIUM_TEST
    flag++;
    debug_write((DBG_DDR_IDX_DRV_BASE+3+(apeId<<2)), flag);
#endif

    ctc_cal_intr_init();		// ctc int
#ifdef PALLADIUM_TEST
    flag++;
    debug_write((DBG_DDR_IDX_DRV_BASE+3+(apeId<<2)), flag);
#endif
}

void tod_int_init(void)
{
    int apeId = get_core_id();
    if (0 == apeId)
    {
        stc_timer_todint_init();
        UCP_PRINT_EMPTY("stc tod int init. \r\n");
    }

    return;
}



