/*
 * Copyright 2021 MindMotion Microelectronics Co., Ltd.
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <stdint.h>
#include <stdio.h>

#include "board_init.h"

/*
 * Definitions.
 */

/*
 * Variables.
 */

/* the CLU 4 input source for one CLU output as source, max length if 4. default logic 0. */
uint32_t conn_in[4] = {CONN_IN_0, CONN_IN_1, CONN_IN_2, CONN_IN_3};

/*
 * Declerations.
 */
void app_mds_init(void);

/*
 * Functions.
 */

int main(void)
{
    BOARD_Init();

    printf("\r\nmds_conn_clu example.\r\n");
    printf("press any key to start.\r\n");

    while (1)
    {
        /* type any key into the terminal to trigger the conversion. */
        getchar();
        app_mds_init();
        printf("mds_conn_clu example done.\r\n");
    }
}
/* setup the mds module, and prepare peripheral control signal interaction. */
void app_mds_init(void)
{
	
    /* configure, when using clu output as the source */
    MDS_CluConf_Type conf;

    for(uint32_t i =0; i<4; i++)
    {
        conf.CluInSource[i] = conn_in[i];
    }
    conf.CluInSourceInvertMask = CLU_IN_INVERT_MASK;
    conf.CluLogic = MDS_CluLogic_OR_OR; /* the clu operation logic is OR-OR. */

    MDS_EnableConnClu(BOARD_MDS_PORT, CONN_OUT, CONN_CLU_IN, &conf);
}

/* EOF. */
