Mistake on this page?
Report an issue in GitHub or email us
analogin_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_ANALOGIN_API_H
21 #define MBED_ANALOGIN_API_H
22 
23 #include "device.h"
24 #include "pinmap.h"
25 
26 #if DEVICE_ANALOGIN
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /** Analogin hal structure. analogin_s is declared in the target's hal
33  */
34 typedef struct analogin_s analogin_t;
35 
36 /**
37  * \defgroup hal_analogin Analogin hal functions
38  *
39  * # Defined behaviour
40  * * The function ::analogin_init initializes the analogin_t control structure
41  * * The function ::analogin_free returns the pin owned by the Analogin object to its reset state
42  * * The function ::analogin_read reads the input voltage, represented as a float in the range [0.0 (GND), 1.0 (VCC)]
43  * * The function ::analogin_read_u16 reads the value from analogin pin, represented as an unsigned 16bit value [0.0 (GND), MAX_UINT16 (VCC)]
44  * * The accuracy of the ADC is +/- 10%
45  * * The ADC operations ::analogin_read, ::analogin_read_u16 take less than 20us to complete
46  *
47  * # Undefined behaviour
48  *
49  * * ::analogin_init is called with invalid pin (which does not support analog input function)
50  * * Calling ::analogin_read, ::analogin_read_u16 before ::analogin_init
51  * @{
52  */
53 
54 /**
55  * \defgroup hal_analogin_tests Analogin hal tests
56  * The Analogin HAL tests ensure driver conformance to defined behaviour.
57  *
58  * To run the Analogin hal tests use the command:
59  *
60  * mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-analogin
61  *
62  */
63 
64 /** Initialize the analogin peripheral
65  *
66  * Configures the pin used by analogin.
67  * @param obj The analogin object to initialize
68  * @param pin The analogin pin name
69  */
70 void analogin_init(analogin_t *obj, PinName pin);
71 
72 /** Release the analogin peripheral
73  *
74  * Releases the pin used by analogin.
75  * @param obj The analogin object to initialize
76  */
77 void analogin_free(analogin_t *obj);
78 
79 /** Read the input voltage, represented as a float in the range [0.0, 1.0]
80  *
81  * @param obj The analogin object
82  * @return A floating value representing the current input voltage
83  */
84 float analogin_read(analogin_t *obj);
85 
86 /** Read the value from analogin pin, represented as an unsigned 16bit value
87  *
88  * @param obj The analogin object
89  * @return An unsigned 16bit value representing the current input voltage
90  */
91 uint16_t analogin_read_u16(analogin_t *obj);
92 
93 /** Get the pins that support analogin
94  *
95  * Return a PinMap array of pins that support analogin. The
96  * array is terminated with {NC, NC, 0}.
97  *
98  * @return PinMap array
99  */
100 const PinMap *analogin_pinmap(void);
101 
102 /**@}*/
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif
109 
110 #endif
111 
112 /** @}*/
struct analogin_s analogin_t
Analogin hal structure.
Definition: analogin_api.h:34
uint16_t analogin_read_u16(analogin_t *obj)
Read the value from analogin pin, represented as an unsigned 16bit value.
Definition: pinmap.h:30
void analogin_free(analogin_t *obj)
Release the analogin peripheral.
float analogin_read(analogin_t *obj)
Read the input voltage, represented as a float in the range [0.0, 1.0].
const PinMap * analogin_pinmap(void)
Get the pins that support analogin.
void analogin_init(analogin_t *obj, PinName pin)
Initialize the analogin peripheral.
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.