Mistake on this page?
Report an issue in GitHub or email us
analogout_api.h
1 
2 /** \addtogroup hal */
3 /** @{*/
4 /* mbed Microcontroller Library
5  * Copyright (c) 2006-2013 ARM Limited
6  * SPDX-License-Identifier: Apache-2.0
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef MBED_ANALOGOUT_API_H
21 #define MBED_ANALOGOUT_API_H
22 
23 #include "device.h"
24 #include "pinmap.h"
25 
26 #if DEVICE_ANALOGOUT
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /** Analogout hal structure. dac_s is declared in the target's hal
33  */
34 typedef struct dac_s dac_t;
35 
36 /**
37  * \defgroup hal_analogout Analogout hal functions
38  *
39  * # Defined behaviour
40  * * The function ::analogout_init initializes the dac_t control structure
41  * * The function ::analogout_write sets the output voltage, specified as a percentage (float) in range [0.0 (GND), 1.0 (VCC)]
42  * * The function ::analogout_write_u16 sets the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)]
43  * * The function ::analogout_read reads the current voltage value on the pin and returns a floating-point value representing the current voltage in range [0.0 (GND), 1.0 (VCC)]
44  * * The function ::analogout_read_u16 reads the current voltage value on the pin and returns the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)]
45  * * The accuracy of the DAC is +/- 10%
46  * * The DAC operations ::analogout_write, ::analogout_write_u16, ::analogout_read, ::analogout_read_u16 take less than 20us to complete
47  * * The function ::analogout_free releases the analogout object
48  *
49  * # Undefined behaviour
50  *
51  * * ::analogout_init is called with invalid pin (which does not support analog output function)
52  * * Calling other functions before ::analogout_init
53  * @{
54  */
55 
56 /**
57  * \defgroup hal_analogin_tests Analogout hal tests
58  * The Analogout HAL tests ensure driver conformance to defined behaviour.
59  *
60  * To run the Analogout hal tests use the command:
61  *
62  * mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-analogout
63  *
64  */
65 
66 /** Initialize the analogout peripheral
67  *
68  * Configures the pin used by analogout.
69  * @param obj The analogout object to initialize
70  * @param pin The analogout pin name
71  */
72 void analogout_init(dac_t *obj, PinName pin);
73 
74 /** Release the analogout object
75  *
76  * @param obj The analogout object
77  */
78 void analogout_free(dac_t *obj);
79 
80 /** Set the output voltage, specified as a percentage (float)
81  *
82  * @param obj The analogin object
83  * @param value The floating-point output voltage to be set
84  */
85 void analogout_write(dac_t *obj, float value);
86 
87 /** Set the output voltage, specified as unsigned 16-bit
88  *
89  * @param obj The analogin object
90  * @param value The unsigned 16-bit output voltage to be set
91  */
92 void analogout_write_u16(dac_t *obj, uint16_t value);
93 
94 /** Read the current voltage value on the pin
95  *
96  * @param obj The analogin object
97  * @return A floating-point value representing the current voltage on the pin,
98  * measured as a percentage
99  */
100 float analogout_read(dac_t *obj);
101 
102 /** Read the current voltage value on the pin, as a normalized unsigned 16bit value
103  *
104  * @param obj The analogin object
105  * @return An unsigned 16-bit value representing the current voltage on the pin
106  */
107 uint16_t analogout_read_u16(dac_t *obj);
108 
109 /** Get the pins that support analogout
110  *
111  * Return a PinMap array of pins that support analogout. The
112  * array is terminated with {NC, NC, 0}.
113  *
114  * @return PinMap array
115  */
116 const PinMap *analogout_pinmap(void);
117 
118 /**@}*/
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif
125 
126 #endif
127 
128 /** @}*/
void analogout_write(dac_t *obj, float value)
Set the output voltage, specified as a percentage (float)
void analogout_free(dac_t *obj)
Release the analogout object.
struct dac_s dac_t
Analogout hal structure.
Definition: analogout_api.h:34
float analogout_read(dac_t *obj)
Read the current voltage value on the pin.
void analogout_init(dac_t *obj, PinName pin)
Initialize the analogout peripheral.
Definition: pinmap.h:30
uint16_t analogout_read_u16(dac_t *obj)
Read the current voltage value on the pin, as a normalized unsigned 16bit value.
const PinMap * analogout_pinmap(void)
Get the pins that support analogout.
void analogout_write_u16(dac_t *obj, uint16_t value)
Set the output voltage, specified as unsigned 16-bit.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.