/****************************************************************************************************/
/**
\file       DAC.h
\brief      
\author     Freescale Semiconductor
\author     Technical Information Center (TIC)
\version    1.0
\date		June 2010     
*/
/****************************************************************************************************/
/* Services performed by FREESCALE in this matter are performed AS IS and without any warranty.  	*/
/* CUSTOMER retains the final decision relative to the total design and functionality of the end 	*/
/* product.                                                                                      	*/
/* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the success of this project.*/
/*                                                                                                  */
/* FREESCALE disclaims all warranties, express, implied or statutory including, but not limited to, */
/* implied warranty of merchantability or fitness for a particular purpose on any hardware,         */
/* software ore advise supplied to the project by FREESCALE, and or any product resulting from      */
/* FREESCALE services.                                                                              */
/* In no event shall FREESCALE be liable for incidental or consequential damages arising out of     */
/* this agreement. CUSTOMER agrees to hold FREESCALE harmless against any and all claims demands or */
/* actions by anyone on account of any damage,or injury, whether commercial, contractual, or        */
/* tortuous, rising directly or indirectly as a result of the advise or assistance supplied CUSTOMER*/ 
/* in connectionwith product, services or goods supplied under this Agreement.                      */
/*                                                                                                  */
/****************************************************************************************************/

/*****************************************************************************************************
* Module definition against multiple inclusion
*****************************************************************************************************/
#ifndef __APP_DAC_H
#define __APP_DAC_H

/*****************************************************************************************************
* Include files
*****************************************************************************************************/
#include "derivative.h"
#include "FslTypes.h"

/*****************************************************************************************************
* Declaration of project wide TYPES
*****************************************************************************************************/

/*****************************************************************************************************
* Definition of project wide VARIABLES
*****************************************************************************************************/
extern UINT8 gu8DACConfig1;
extern UINT8 gu8DACConfig2;
extern UINT8 gu8DACStatus;
extern UINT8 u8HWTriggerFlag;
extern UINT16 au16WaveForm[16];

/*****************************************************************************************************
* Definition of project wide MACROS / #DEFINE-CONSTANTS 
*****************************************************************************************************/
#define DAC_NOT_BUFFERED      (0x00)
#define DAC_NORMAL_MODE       (DACC1_DACBFE_MASK)
#define DAC_SWING_MODE        (DACC1_DACBFE_MASK | DACC1_DACBFMD0_MASK)
#define DAC_ONE_SCAN_MODE     (DACC1_DACBFE_MASK | DACC1_DACBFMD1_MASK)

#define DAC_WATERMARK_1   (0x00)
#define DAC_WATERMARK_2   (DACC1_DACBFWM0_MASK)
#define DAC_WATERMARK_3   (DACC1_DACBFWM1_MASK)
#define DAC_WATERMARK_4   (DACC1_DACBFWM0_MASK | DACC1_DACBFWM0_MASK | DACC1_DACBFE_MASK)


#define DAC_BOTTOM_INTERRUPT       (DACC0_DACBIE_MASK)
#define DAC_TOP_INTERRUPT          (DACC0_DACTIE_MASK)
#define DAC_WATERMARK_INTERRUPT    (DACC0_DACWIE_MASK)

#define DAC_TRIGGER 				(DACC0_DACSTRG = 1)

#define DAC_INTERRUPT_OCCUR     (gu8DACStatus)


#define DAC_NEW_DATA			gu8DACStatus & (1<<DAC_NEW_DATA)
#define DAC_NEW_DATA_CLEAR		gu8DACStatus &= ~(1<<DAC_NEW_DATA)


/*****************************************************************************************************
* Declaration of project wide FUNCTIONS
*****************************************************************************************************/
void vfnDAC_Init (UINT8 u8DACC0Parameters, UINT8 u8DACC1Parameters);
void vfnDACSetPointer(UINT8 u8ReadPosition, UINT8 u8UpperPosition);
void vfnDACFillBuffer(UINT16* pu16NewData);
/*****************************************************************************************************
* Declaration of module wide FUNCTIONs - NOT for use in other modules
*****************************************************************************************************/

#endif /* __APP_DAC_H */
