lpc-field

Template project for programming NXP's LPC1768 MCUs
git clone git://git.mdnr.space/lpc-field
Log | Files | Refs | README | LICENSE

lpc17xx_dac.h (5045B)


      1 /**********************************************************************
      2 * $Id$		lpc17xx_dac.h				2010-05-21
      3 *//**
      4 * @file		lpc17xx_dac.h
      5 * @brief	Contains all macro definitions and function prototypes
      6 * 			support for Clock and Power Control firmware library on LPC17xx
      7 * @version	2.0
      8 * @date		21. May. 2010
      9 * @author	NXP MCU SW Application Team
     10 *
     11 * Copyright(C) 2010, NXP Semiconductor
     12 * All rights reserved.
     13 *
     14 ***********************************************************************
     15 * Software that is described herein is for illustrative purposes only
     16 * which provides customers with programming information regarding the
     17 * products. This software is supplied "AS IS" without any warranties.
     18 * NXP Semiconductors assumes no responsibility or liability for the
     19 * use of the software, conveys no license or title under any patent,
     20 * copyright, or mask work right to the product. NXP Semiconductors
     21 * reserves the right to make changes in the software without
     22 * notification. NXP Semiconductors also make no representation or
     23 * warranty that such application will be suitable for the specified
     24 * use without further testing or modification.
     25 * Permission to use, copy, modify, and distribute this software and its
     26 * documentation is hereby granted, under NXP Semiconductors'
     27 * relevant copyright in the software, without fee, provided that it
     28 * is used in conjunction with NXP Semiconductors microcontrollers.  This
     29 * copyright, permission, and disclaimer notice must appear in all copies of
     30 * this code.
     31 **********************************************************************/
     32 
     33 /* Peripheral group ----------------------------------------------------------- */
     34 /** @defgroup DAC DAC (Digital-to-Analog Controller)
     35  * @ingroup LPC1700CMSIS_FwLib_Drivers
     36  * @{
     37  */
     38 
     39 #ifndef LPC17XX_DAC_H_
     40 #define LPC17XX_DAC_H_
     41 
     42 /* Includes ------------------------------------------------------------------- */
     43 #include "LPC17xx.h"
     44 #include "lpc_types.h"
     45 
     46 
     47 #ifdef __cplusplus
     48 extern "C"
     49 {
     50 #endif
     51 
     52 /* Public Macros -------------------------------------------------------------- */
     53 /** @defgroup DAC_Private_Macros DAC Private Macros
     54  * @{
     55  */
     56 
     57 /** After the selected settling time after this field is written with a
     58 new VALUE, the voltage on the AOUT pin (with respect to VSSA)
     59 is VALUE/1024 × VREF */
     60 #define DAC_VALUE(n) 		((uint32_t)((n&0x3FF)<<6))
     61 /** If this bit = 0: The settling time of the DAC is 1 microsecond max,
     62  * and the maximum current is 700 microAmpere
     63  * If this bit = 1: The settling time of the DAC is 2.5 microsecond
     64  * and the maximum current is 350 microAmpere */
     65 #define DAC_BIAS_EN			((uint32_t)(1<<16))
     66 /** Value to reload interrupt DMA counter */
     67 #define DAC_CCNT_VALUE(n)  ((uint32_t)(n&0xffff))
     68 
     69 /** DCAR double buffering */
     70 #define DAC_DBLBUF_ENA		((uint32_t)(1<<1))
     71 /** DCAR Time out count enable */
     72 #define DAC_CNT_ENA			((uint32_t)(1<<2))
     73 /** DCAR DMA access */
     74 #define DAC_DMA_ENA			((uint32_t)(1<<3))
     75 /** DCAR DACCTRL mask bit */
     76 #define DAC_DACCTRL_MASK	((uint32_t)(0x0F))
     77 
     78 /** Macro to determine if it is valid DAC peripheral */
     79 #define PARAM_DACx(n)	(((uint32_t *)n)==((uint32_t *)LPC_DAC))
     80 
     81 /** Macro to check DAC current optional parameter */
     82 #define	PARAM_DAC_CURRENT_OPT(OPTION) ((OPTION == DAC_MAX_CURRENT_700uA)\
     83 ||(OPTION == DAC_MAX_CURRENT_350uA))
     84 /**
     85  * @}
     86  */
     87 /* Public Types --------------------------------------------------------------- */
     88 /** @defgroup DAC_Public_Types DAC Public Types
     89  * @{
     90  */
     91 
     92 /**
     93  * @brief Current option in DAC configuration option */
     94 typedef enum
     95 {
     96 	DAC_MAX_CURRENT_700uA = 0, 	/*!< The settling time of the DAC is 1 us max,
     97 								and the maximum	current is 700 uA */
     98 	DAC_MAX_CURRENT_350uA		/*!< The settling time of the DAC is 2.5 us
     99 								and the maximum current is 350 uA */
    100 } DAC_CURRENT_OPT;
    101 
    102 /**
    103  * @brief Configuration for DAC converter control register */
    104 typedef struct
    105 {
    106 
    107 	uint8_t  DBLBUF_ENA; 	/**<
    108 	                         -0: Disable DACR double buffering
    109 	                         -1: when bit CNT_ENA, enable DACR double buffering feature
    110 							 */
    111 	uint8_t  CNT_ENA;		/*!<
    112 	                         -0: Time out counter is disable
    113 	                         -1: Time out conter is enable
    114 							 */
    115 	uint8_t  DMA_ENA;		/*!<
    116 		                         -0: DMA access is disable
    117 		                         -1: DMA burst request
    118 							*/
    119 	uint8_t RESERVED;
    120 
    121 } DAC_CONVERTER_CFG_Type;
    122 
    123 /**
    124  * @}
    125  */
    126 
    127 /* Public Functions ----------------------------------------------------------- */
    128 /** @defgroup DAC_Public_Functions DAC Public Functions
    129  * @{
    130  */
    131 
    132 void 	DAC_Init(LPC_DAC_TypeDef *DACx);
    133 void    DAC_UpdateValue (LPC_DAC_TypeDef *DACx, uint32_t dac_value);
    134 void    DAC_SetBias (LPC_DAC_TypeDef *DACx,uint32_t bias);
    135 void    DAC_ConfigDAConverterControl (LPC_DAC_TypeDef *DACx,DAC_CONVERTER_CFG_Type *DAC_ConverterConfigStruct);
    136 void 	DAC_SetDMATimeOut(LPC_DAC_TypeDef *DACx,uint32_t time_out);
    137 
    138 /**
    139  * @}
    140  */
    141 
    142 #ifdef __cplusplus
    143 }
    144 #endif
    145 
    146 
    147 #endif /* LPC17XX_DAC_H_ */
    148 
    149 /**
    150  * @}
    151  */
    152 
    153 /* --------------------------------- End Of File ------------------------------ */
    154