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