1 /** mbed Microcontroller Library
2  ******************************************************************************
3  * @file    analogout_api.h
4  * @author
5  * @version V1.0.0
6  * @brief   This file provides following mbed Analog_out API
7  ******************************************************************************
8  * @attention
9  *
10  * Copyright (c) 2006-2013 ARM Limited
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 #ifndef MBED_ANALOGOUT_API_H
25 #define MBED_ANALOGOUT_API_H
26 
27 #include "device.h"
28 
29 
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /** @addtogroup analog_out ANALOG_OUT
36  *  @ingroup    hal
37  *  @brief      analog_out functions
38  *  @{
39  */
40 
41 
42 #if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
43 ///@name Ameba1 Only
44 ///@{
45 
46 typedef struct dac_s dac_t;
47 
48 
49 /**
50  * @brief  Initialize DAC
51  * @param  obj: dac object define in application software.
52  * @param  pin: dac PinName according to pinmux spec.
53  * @retval none
54  */
55 void analogout_init(dac_t *obj, PinName pin);
56 
57 /**
58  * @brief  Free DAC
59  * @param  obj: dac object define in application software.
60  * @retval none
61  */
62 void analogout_free(dac_t *obj);
63 
64 /**
65  * @brief Execute analog output
66  * @para obj: dac object define in application software.
67  * @para value: analog ratio value, should be transfered to register value.
68  * @retval none
69  * @note This function is mainly to execute analog output and the value is a ratio.
70  *       The upper/lower bound of DAC register input value is defined by
71  *       DAC_XXXXX_FULL_SCALE. The parameter "value" of this function should be
72  *       transfered to register value.
73  */
74 void analogout_write(dac_t *obj, float value);
75 
76 /**
77  * @brief Execute analog output 16bit
78  * @para obj: dac object define in application software.
79  * @para value: analog ratio value, should be transfered to register value.
80  * @retval none
81  * @note The register value of DAC input is a format of 2's complement.
82  *       The most maximum value of positive value drives DAC to output a voltage about 3.3V.
83  *       The most mimimum value of negative value drives DAC to output a voltage about 0.
84  *       And the middle value of 0x000 will drive DAC to output a voltage of half of max voltage.
85  */
86 void analogout_write_u16(dac_t *obj, uint16_t value);
87 
88 ///@}
89 #endif //CONFIG_PLATFORM_8195A
90 
91 /**@}*/
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif//MBED_ANALOGOUT_API_H
98