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 pinmap pointer to structure which holds static pinmap
71  */
72 void analogout_init_direct(dac_t *obj, const PinMap *pinmap);
73 
74 /** Initialize the analogout peripheral
75  *
76  * Configures the pin used by analogout.
77  * @param obj The analogout object to initialize
78  * @param pin The analogout pin name
79  */
80 void analogout_init(dac_t *obj, PinName pin);
81 
82 /** Release the analogout object
83  *
84  * @param obj The analogout object
85  */
86 void analogout_free(dac_t *obj);
87 
88 /** Set the output voltage, specified as a percentage (float)
89  *
90  * @param obj The analogin object
91  * @param value The floating-point output voltage to be set
92  */
93 void analogout_write(dac_t *obj, float value);
94 
95 /** Set the output voltage, specified as unsigned 16-bit
96  *
97  * @param obj The analogin object
98  * @param value The unsigned 16-bit output voltage to be set
99  */
100 void analogout_write_u16(dac_t *obj, uint16_t value);
101 
102 /** Read the current voltage value on the pin
103  *
104  * @param obj The analogin object
105  * @return A floating-point value representing the current voltage on the pin,
106  * measured as a percentage
107  */
108 float analogout_read(dac_t *obj);
109 
110 /** Read the current voltage value on the pin, as a normalized unsigned 16bit value
111  *
112  * @param obj The analogin object
113  * @return An unsigned 16-bit value representing the current voltage on the pin
114  */
115 uint16_t analogout_read_u16(dac_t *obj);
116 
117 /** Get the pins that support analogout
118  *
119  * Return a PinMap array of pins that support analogout. The
120  * array is terminated with {NC, NC, 0}.
121  *
122  * @return PinMap array
123  */
124 const PinMap *analogout_pinmap(void);
125 
126 /**@}*/
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif
133 
134 #endif
135 
136 /** @}*/
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:31
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_init_direct(dac_t *obj, const PinMap *pinmap)
Initialize the analogout peripheral.
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.