/****************************************************************************************************/
/**
\file       DAC.h
\brief      
\author     Freescale Semiconductor
\author     Technical Information Center (TIC)
\version    1.0
\date		Jun 9, 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 __DAC_H__H
#define __DAC_H__H

/*****************************************************************************************************
* Include files
*****************************************************************************************************/
#include "derivative.h"
#include "FslTypes.h"
/*****************************************************************************************************
* Declaration of project wide TYPES
*****************************************************************************************************/
typedef enum
{
    DACV1_BOTTOM_FLAG = 0,
    DACV1_TOP_FLAG,
    DACV1_WATERMARK_FLAG,
    DAC_NEW_DATA
    
}eDACV1InterruptFlags;

extern UINT8 gu8DACStatus;
/*****************************************************************************************************
* Definition of project wide MACROS / #DEFINE-CONSTANTS 
*****************************************************************************************************/
#define DACV1_NOT_BUFFERED      (0x00)
#define DACV1_NORMAL_MODE       (DACC1_DACBFE_MASK)
#define DACV1_SWING_MODE        (DACC1_DACBFE_MASK | DACC1_DACBFMD0_MASK)
#define DACV1_ONE_SCAN_MODE     (DACC1_DACBFE_MASK | DACC1_DACBFMD1_MASK)

#define DACV1_WATERMARK_1   (0x00)
#define DACV1_WATERMARK_2   (DACC1_DACBFWM0_MASK)
#define DACV1_WATERMARK_3   (DACC1_DACBFWM1_MASK)
#define DACV1_WATERMARK_4   (DACC1_DACBFWM0_MASK | DACC1_DACBFWM0_MASK | DACC1_DACBFE_MASK)


#define DACV1_BOTTOM_INTERRUPT       (DACC0_DACBIE_MASK)
#define DACV1_TOP_INTERRUPT          (DACC0_DACTIE_MASK)
#define DACV1_WATERMARK_INTERRUPT    (DACC0_DACWIE_MASK)

#define DACV1_TRIGGER 				(DACC0_DACSTRG = 1)

#define DACV1_INTERRUPT_OCCUR     (gu8DACStatus)


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

/*****************************************************************************************************
* Definition of project wide VARIABLES
*****************************************************************************************************/
/** Sine wave buffer values */
const static UINT16 au16WaveForm[16] =
{
    2436,
    2388,
    2316,
    2232,
    2148,
    2076,
    2028,
    2010,
    2028,
    2076,
    2148,
    2232,
    2316,
    2388,
    2436,
    2454
};

/*const static UINT16 au16WaveForm[16] =
{

    0x000,
    0x1FF,
    0x3FF,
    0x5FF,
    0x7FF,
    0x9FF,
    0xBFF,
    0xDFF,
    0xFFF,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
};*/
extern UINT8 gu8DACConfig1;
extern UINT8 gu8DACConfig2;
extern UINT8 u8HWTriggerFlag;

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

#endif /* __DAC_H__H */
