Date: March 20, 2011 This library is created from "LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library (GNU, Keil, IAR) (Jan 28, 2011)", available from NXP's website, under "All microcontrollers support documents" [[http://ics.nxp.com/support/documents/microcontrollers/?type=software]] You will need to follow [[/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h]] while using this library Examples provided here [[/users/frank26080115/programs/LPC1700CMSIS_Examples/]] The beautiful thing is that NXP does not place copyright protection on any of the files in here Only a few modifications are made to make it compile with the mbed online compiler, I fixed some warnings as well. This is untested as of March 20, 2011 Forum post about this library: [[/forum/mbed/topic/2030/]]

Committer:
frank26080115
Date:
Sun Mar 20 18:45:15 2011 +0000
Revision:
0:84d7747641aa

        

Who changed what in which revision?

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