/** @file notification.c 
*   @brief User Notification Definition File
*   @date 20.May.2014
*   @version 04.00.00
*
*   This file  defines  empty  notification  routines to avoid
*   linker errors, Driver expects user to define the notification. 
*   The user needs to either remove this file and use their custom 
*   notification function or place their code sequence in this file 
*   between the provided USER CODE BEGIN and USER CODE END.
*
*/

/* Include Files */

#include "esm.h"
#include "sys_selftest.h"
#include "gio.h"
#include "rti.h"

/* USER CODE BEGIN (0) */
#include "reg_het.h"
/* USER CODE END */
#pragma WEAK(esmGroup1Notification)
void esmGroup1Notification(uint32 channel)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (1) */
	/* USER CODE END */
}

/* USER CODE BEGIN (2) */
/* USER CODE END */
#pragma WEAK(esmGroup2Notification)
void esmGroup2Notification(uint32 channel)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (3) */
	/* USER CODE END */
}

/* USER CODE BEGIN (4) */
/* USER CODE END */
#pragma WEAK(memoryPort0TestFailNotification)
void memoryPort0TestFailNotification(uint32 groupSelect, uint32 dataSelect, uint32 address, uint32 data)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (5) */
	/* USER CODE END */
}

/* USER CODE BEGIN (6) */
/* USER CODE END */
#pragma WEAK(memoryPort1TestFailNotification)
void memoryPort1TestFailNotification(uint32 groupSelect, uint32 dataSelect, uint32 address, uint32 data)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (7) */
	/* USER CODE END */
}

/* USER CODE BEGIN (8) */
/* USER CODE END */
#pragma WEAK(rtiNotification)
void rtiNotification(uint32 notification)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (9) */
	switch(notification)
	{
	case rtiNOTIFICATION_COMPARE0:
	{
		uint32 u32Period  = rtiGetPeriod(rtiCOMPARE0);
		uint32 u32CurrCmp = rtiREG1->CMP[rtiCOMPARE0].COMPx;

		gioSetBit(gioPORTA, 2ull, 1ull); /* Switch on LED D12 */

		/* Wait for half the period proir to switch off the LED */
		while(rtiREG1->CNT[0].FRCx < (u32CurrCmp - (u32Period >> 1)));

		gioSetBit(gioPORTA, 2ull, 0ull); /* Switch off LED D12 */
	}
	break;
	case rtiNOTIFICATION_COMPARE1:
	{
		uint32 u32Period  = rtiGetPeriod(rtiCOMPARE1);
		uint32 u32CurrCmp = rtiREG1->CMP[rtiCOMPARE1].COMPx;

		gioSetBit(hetPORT1, 8ull, 1ull); /* Switch on LED D11 */

		/* Wait for half the period proir to switch off the LED */
		while(rtiREG1->CNT[0].FRCx < (u32CurrCmp - (u32Period >> 1)));

		gioSetBit(hetPORT1, 8ull, 0ull); /* Switch off LED D11 */
	}
	break;
	default:
		break;
	}
	/* USER CODE END */
}

/* USER CODE BEGIN (10) */
/* USER CODE END */
#pragma WEAK(gioNotification)
void gioNotification(gioPORT_t *port, uint32 bit)
{
/*  enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (19) */
	/* USER CODE END */
}

/* USER CODE BEGIN (20) */
/* USER CODE END */




/* USER CODE BEGIN (43) */
/* USER CODE END */


/* USER CODE BEGIN (47) */
/* USER CODE END */


/* USER CODE BEGIN (50) */
/* USER CODE END */


/* USER CODE BEGIN (53) */
/* USER CODE END */


/* USER CODE BEGIN (56) */
/* USER CODE END */

/* USER CODE BEGIN (58) */
/* USER CODE END */

/* USER CODE BEGIN (60) */
/* USER CODE END */
