Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
analogin_api.h
00001 00002 /** \addtogroup hal */ 00003 /** @{*/ 00004 /* mbed Microcontroller Library 00005 * Copyright (c) 2006-2013 ARM Limited 00006 * SPDX-License-Identifier: Apache-2.0 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 */ 00020 #ifndef MBED_ANALOGIN_API_H 00021 #define MBED_ANALOGIN_API_H 00022 00023 #include "device.h" 00024 #include "pinmap.h" 00025 00026 #if DEVICE_ANALOGIN 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 /** Analogin hal structure. analogin_s is declared in the target's hal 00033 */ 00034 typedef struct analogin_s analogin_t; 00035 00036 /** 00037 * \defgroup hal_analogin Analogin hal functions 00038 * 00039 * # Defined behaviour 00040 * * The function ::analogin_init initializes the analogin_t control structure 00041 * * The function ::analogin_free returns the pin owned by the Analogin object to its reset state 00042 * * The function ::analogin_read reads the input voltage, represented as a float in the range [0.0 (GND), 1.0 (VCC)] 00043 * * The function ::analogin_read_u16 reads the value from analogin pin, represented as an unsigned 16bit value [0.0 (GND), MAX_UINT16 (VCC)] 00044 * * The accuracy of the ADC is +/- 10% 00045 * * The ADC operations ::analogin_read, ::analogin_read_u16 take less than 20us to complete 00046 * 00047 * # Undefined behaviour 00048 * 00049 * * ::analogin_init is called with invalid pin (which does not support analog input function) 00050 * * Calling ::analogin_read, ::analogin_read_u16 before ::analogin_init 00051 * @{ 00052 */ 00053 00054 /** 00055 * \defgroup hal_analogin_tests Analogin hal tests 00056 * The Analogin HAL tests ensure driver conformance to defined behaviour. 00057 * 00058 * To run the Analogin hal tests use the command: 00059 * 00060 * mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-analogin 00061 * 00062 */ 00063 00064 /** Initialize the analogin peripheral 00065 * 00066 * Configures the pin used by analogin. 00067 * @param obj The analogin object to initialize 00068 * @param pinmap pointer to structure which holds static pinmap 00069 */ 00070 void analogin_init_direct(analogin_t *obj, const PinMap *pinmap); 00071 00072 /** Initialize the analogin peripheral 00073 * 00074 * Configures the pin used by analogin. 00075 * @param obj The analogin object to initialize 00076 * @param pin The analogin pin name 00077 */ 00078 void analogin_init(analogin_t *obj, PinName pin); 00079 00080 /** Release the analogin peripheral 00081 * 00082 * Releases the pin used by analogin. 00083 * @param obj The analogin object to initialize 00084 */ 00085 void analogin_free(analogin_t *obj); 00086 00087 /** Read the input voltage, represented as a float in the range [0.0, 1.0] 00088 * 00089 * @param obj The analogin object 00090 * @return A floating value representing the current input voltage 00091 */ 00092 float analogin_read(analogin_t *obj); 00093 00094 /** Read the value from analogin pin, represented as an unsigned 16bit value 00095 * 00096 * @param obj The analogin object 00097 * @return An unsigned 16bit value representing the current input voltage 00098 */ 00099 uint16_t analogin_read_u16(analogin_t *obj); 00100 00101 /** Get the pins that support analogin 00102 * 00103 * Return a PinMap array of pins that support analogin. The 00104 * array is terminated with {NC, NC, 0}. 00105 * 00106 * @return PinMap array 00107 */ 00108 const PinMap *analogin_pinmap(void); 00109 00110 /**@}*/ 00111 00112 #ifdef __cplusplus 00113 } 00114 #endif 00115 00116 #endif 00117 00118 #endif 00119 00120 /** @}*/
Generated on Tue Jul 12 2022 13:54:01 by
1.7.2