/*==================================================================================================
* Project : RTD AUTOSAR 4.7
* Platform : CORTEXM
* Peripheral : S32K3XX
* Dependencies : none
*
* Autosar Version : 4.7.0
* Autosar Revision : ASR_REL_4_7_REV_0000
* Autosar Conf.Variant :
* SW Version : 5.0.0
* Build Version : S32K3_RTD_5_0_0_D2408_ASR_REL_4_7_REV_0000_20241002
*
* Copyright 2020 - 2024 NXP
*
* NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be 
*   used strictly in accordance with the applicable license terms.  By expressly 
*   accepting such terms or by downloading, installing, activating and/or otherwise 
*   using the software, you are agreeing that you have read, and that you agree to 
*   comply with and are bound by, such license terms.  If you do not agree to be 
*   bound by the applicable license terms, then you may not retain, install,
*   activate or otherwise use the software.
==================================================================================================*/

/**
*   @file main.c
*
*   @addtogroup main_module main module documentation
*   @{
*/

/* Including necessary configuration files. */
#include "Mcal.h"
#include "Clock_Ip.h"
#include "Siul2_Port_Ip.h"
#include "Lpi2c_Ip.h"
#include "IntCtrl_Ip.h"



uint8_t test_i2c[8];

volatile int exit_code = 0;
/* User includes */

/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
*/
int main(void)
{

     uint32_t delay = 0;


    /* Initialize Clock */
    Clock_Ip_StatusType Status_Init_Clock = CLOCK_IP_ERROR;

    Status_Init_Clock = Clock_Ip_Init(Clock_Ip_aClockConfig);


	/* Initialize all pins using the Port driver */
	Siul2_Port_Ip_PortStatusType Status_Init_Port = SIUL2_PORT_ERROR;
	Status_Init_Port = Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals);

	if(Status_Init_Port != SIUL2_PORT_SUCCESS)
	{
		while(1); /* Error during initialization. */
	}


    /* Install  ISR */
    IntCtrl_Ip_Init(&IntCtrlConfig_0);
    IP_LPI2C_0->MCR |= LPI2C_MCR_DBGEN_MASK;

	Lpi2c_Ip_MasterInit(0,&I2c_Lpi2cMasterChannel0);

	test_i2c[0]=0;
	test_i2c[1]=1;
	test_i2c[2]=2;
	test_i2c[3]=3;
	test_i2c[4]=4;
	test_i2c[5]=5;
	test_i2c[6]=6;
	test_i2c[7]=7;


    for(;;)
    {

    	for(delay = 0;delay < 10000; delay++);
    	Lpi2c_Ip_MasterSendData(0,&test_i2c[0],1,1);
    	for(delay = 0;delay < 10000; delay++);

        if(exit_code != 0)
        {
            break;
        }
    }
    return exit_code;
}

/** @} */
