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
analogout_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_ANALOGOUT_API_H 00021 #define MBED_ANALOGOUT_API_H 00022 00023 #include "device.h" 00024 #include "pinmap.h" 00025 00026 #if DEVICE_ANALOGOUT 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 /** Analogout hal structure. dac_s is declared in the target's hal 00033 */ 00034 typedef struct dac_s dac_t; 00035 00036 /** 00037 * \defgroup hal_analogout Analogout hal functions 00038 * 00039 * # Defined behaviour 00040 * * The function ::analogout_init initializes the dac_t control structure 00041 * * The function ::analogout_write sets the output voltage, specified as a percentage (float) in range [0.0 (GND), 1.0 (VCC)] 00042 * * The function ::analogout_write_u16 sets the output voltage, specified as unsigned 16-bit value [0 (GND), MAX_UINT16 (VCC)] 00043 * * 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)] 00044 * * 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)] 00045 * * The accuracy of the DAC is +/- 10% 00046 * * The DAC operations ::analogout_write, ::analogout_write_u16, ::analogout_read, ::analogout_read_u16 take less than 20us to complete 00047 * * The function ::analogout_free releases the analogout object 00048 * 00049 * # Undefined behaviour 00050 * 00051 * * ::analogout_init is called with invalid pin (which does not support analog output function) 00052 * * Calling other functions before ::analogout_init 00053 * @{ 00054 */ 00055 00056 /** 00057 * \defgroup hal_analogin_tests Analogout hal tests 00058 * The Analogout HAL tests ensure driver conformance to defined behaviour. 00059 * 00060 * To run the Analogout hal tests use the command: 00061 * 00062 * mbed test -t <toolchain> -m <target> -n tests-mbed_hal_fpga_ci_test_shield-analogout 00063 * 00064 */ 00065 00066 /** Initialize the analogout peripheral 00067 * 00068 * Configures the pin used by analogout. 00069 * @param obj The analogout object to initialize 00070 * @param pinmap pointer to structure which holds static pinmap 00071 */ 00072 void analogout_init_direct(dac_t *obj, const PinMap *pinmap); 00073 00074 /** Initialize the analogout peripheral 00075 * 00076 * Configures the pin used by analogout. 00077 * @param obj The analogout object to initialize 00078 * @param pin The analogout pin name 00079 */ 00080 void analogout_init(dac_t *obj, PinName pin); 00081 00082 /** Release the analogout object 00083 * 00084 * @param obj The analogout object 00085 */ 00086 void analogout_free(dac_t *obj); 00087 00088 /** Set the output voltage, specified as a percentage (float) 00089 * 00090 * @param obj The analogin object 00091 * @param value The floating-point output voltage to be set 00092 */ 00093 void analogout_write(dac_t *obj, float value); 00094 00095 /** Set the output voltage, specified as unsigned 16-bit 00096 * 00097 * @param obj The analogin object 00098 * @param value The unsigned 16-bit output voltage to be set 00099 */ 00100 void analogout_write_u16(dac_t *obj, uint16_t value); 00101 00102 /** Read the current voltage value on the pin 00103 * 00104 * @param obj The analogin object 00105 * @return A floating-point value representing the current voltage on the pin, 00106 * measured as a percentage 00107 */ 00108 float analogout_read(dac_t *obj); 00109 00110 /** Read the current voltage value on the pin, as a normalized unsigned 16bit value 00111 * 00112 * @param obj The analogin object 00113 * @return An unsigned 16-bit value representing the current voltage on the pin 00114 */ 00115 uint16_t analogout_read_u16(dac_t *obj); 00116 00117 /** Get the pins that support analogout 00118 * 00119 * Return a PinMap array of pins that support analogout. The 00120 * array is terminated with {NC, NC, 0}. 00121 * 00122 * @return PinMap array 00123 */ 00124 const PinMap *analogout_pinmap(void); 00125 00126 /**@}*/ 00127 00128 #ifdef __cplusplus 00129 } 00130 #endif 00131 00132 #endif 00133 00134 #endif 00135 00136 /** @}*/
Generated on Tue Jul 12 2022 13:54:01 by
