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.
mbed-dev/hal/analogout_api.h@1:d0dfbce63a89, 2017-02-24 (annotated)
- Committer:
- elmot
- Date:
- Fri Feb 24 21:13:56 2017 +0000
- Revision:
- 1:d0dfbce63a89
Ready-to-copy
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| elmot | 1:d0dfbce63a89 | 1 | |
| elmot | 1:d0dfbce63a89 | 2 | /** \addtogroup hal */ |
| elmot | 1:d0dfbce63a89 | 3 | /** @{*/ |
| elmot | 1:d0dfbce63a89 | 4 | /* mbed Microcontroller Library |
| elmot | 1:d0dfbce63a89 | 5 | * Copyright (c) 2006-2013 ARM Limited |
| elmot | 1:d0dfbce63a89 | 6 | * |
| elmot | 1:d0dfbce63a89 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| elmot | 1:d0dfbce63a89 | 8 | * you may not use this file except in compliance with the License. |
| elmot | 1:d0dfbce63a89 | 9 | * You may obtain a copy of the License at |
| elmot | 1:d0dfbce63a89 | 10 | * |
| elmot | 1:d0dfbce63a89 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| elmot | 1:d0dfbce63a89 | 12 | * |
| elmot | 1:d0dfbce63a89 | 13 | * Unless required by applicable law or agreed to in writing, software |
| elmot | 1:d0dfbce63a89 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| elmot | 1:d0dfbce63a89 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| elmot | 1:d0dfbce63a89 | 16 | * See the License for the specific language governing permissions and |
| elmot | 1:d0dfbce63a89 | 17 | * limitations under the License. |
| elmot | 1:d0dfbce63a89 | 18 | */ |
| elmot | 1:d0dfbce63a89 | 19 | #ifndef MBED_ANALOGOUT_API_H |
| elmot | 1:d0dfbce63a89 | 20 | #define MBED_ANALOGOUT_API_H |
| elmot | 1:d0dfbce63a89 | 21 | |
| elmot | 1:d0dfbce63a89 | 22 | #include "device.h" |
| elmot | 1:d0dfbce63a89 | 23 | |
| elmot | 1:d0dfbce63a89 | 24 | #if DEVICE_ANALOGOUT |
| elmot | 1:d0dfbce63a89 | 25 | |
| elmot | 1:d0dfbce63a89 | 26 | #ifdef __cplusplus |
| elmot | 1:d0dfbce63a89 | 27 | extern "C" { |
| elmot | 1:d0dfbce63a89 | 28 | #endif |
| elmot | 1:d0dfbce63a89 | 29 | |
| elmot | 1:d0dfbce63a89 | 30 | /** Analogout hal structure. dac_s is declared in the target's hal |
| elmot | 1:d0dfbce63a89 | 31 | */ |
| elmot | 1:d0dfbce63a89 | 32 | typedef struct dac_s dac_t; |
| elmot | 1:d0dfbce63a89 | 33 | |
| elmot | 1:d0dfbce63a89 | 34 | /** |
| elmot | 1:d0dfbce63a89 | 35 | * \defgroup hal_analogout Analogout hal functions |
| elmot | 1:d0dfbce63a89 | 36 | * @{ |
| elmot | 1:d0dfbce63a89 | 37 | */ |
| elmot | 1:d0dfbce63a89 | 38 | |
| elmot | 1:d0dfbce63a89 | 39 | /** Initialize the analogout peripheral |
| elmot | 1:d0dfbce63a89 | 40 | * |
| elmot | 1:d0dfbce63a89 | 41 | * Configures the pin used by analogout. |
| elmot | 1:d0dfbce63a89 | 42 | * @param obj The analogout object to initialize |
| elmot | 1:d0dfbce63a89 | 43 | * @param pin The analogout pin name |
| elmot | 1:d0dfbce63a89 | 44 | */ |
| elmot | 1:d0dfbce63a89 | 45 | void analogout_init(dac_t *obj, PinName pin); |
| elmot | 1:d0dfbce63a89 | 46 | |
| elmot | 1:d0dfbce63a89 | 47 | /** Release the analogout object |
| elmot | 1:d0dfbce63a89 | 48 | * |
| elmot | 1:d0dfbce63a89 | 49 | * Note: This is not currently used in the mbed-drivers |
| elmot | 1:d0dfbce63a89 | 50 | * @param obj The analogout object |
| elmot | 1:d0dfbce63a89 | 51 | */ |
| elmot | 1:d0dfbce63a89 | 52 | void analogout_free(dac_t *obj); |
| elmot | 1:d0dfbce63a89 | 53 | |
| elmot | 1:d0dfbce63a89 | 54 | /** Set the output voltage, specified as a percentage (float) |
| elmot | 1:d0dfbce63a89 | 55 | * |
| elmot | 1:d0dfbce63a89 | 56 | * @param obj The analogin object |
| elmot | 1:d0dfbce63a89 | 57 | * @param value The floating-point output voltage to be set |
| elmot | 1:d0dfbce63a89 | 58 | */ |
| elmot | 1:d0dfbce63a89 | 59 | void analogout_write(dac_t *obj, float value); |
| elmot | 1:d0dfbce63a89 | 60 | |
| elmot | 1:d0dfbce63a89 | 61 | /** Set the output voltage, specified as unsigned 16-bit |
| elmot | 1:d0dfbce63a89 | 62 | * |
| elmot | 1:d0dfbce63a89 | 63 | * @param obj The analogin object |
| elmot | 1:d0dfbce63a89 | 64 | * @param value The unsigned 16-bit output voltage to be set |
| elmot | 1:d0dfbce63a89 | 65 | */ |
| elmot | 1:d0dfbce63a89 | 66 | void analogout_write_u16(dac_t *obj, uint16_t value); |
| elmot | 1:d0dfbce63a89 | 67 | |
| elmot | 1:d0dfbce63a89 | 68 | /** Read the current voltage value on the pin |
| elmot | 1:d0dfbce63a89 | 69 | * |
| elmot | 1:d0dfbce63a89 | 70 | * @param obj The analogin object |
| elmot | 1:d0dfbce63a89 | 71 | * @return A floating-point value representing the current voltage on the pin, |
| elmot | 1:d0dfbce63a89 | 72 | * measured as a percentage |
| elmot | 1:d0dfbce63a89 | 73 | */ |
| elmot | 1:d0dfbce63a89 | 74 | float analogout_read(dac_t *obj); |
| elmot | 1:d0dfbce63a89 | 75 | |
| elmot | 1:d0dfbce63a89 | 76 | /** Read the current voltage value on the pin, as a normalized unsigned 16bit value |
| elmot | 1:d0dfbce63a89 | 77 | * |
| elmot | 1:d0dfbce63a89 | 78 | * @param obj The analogin object |
| elmot | 1:d0dfbce63a89 | 79 | * @return An unsigned 16-bit value representing the current voltage on the pin |
| elmot | 1:d0dfbce63a89 | 80 | */ |
| elmot | 1:d0dfbce63a89 | 81 | uint16_t analogout_read_u16(dac_t *obj); |
| elmot | 1:d0dfbce63a89 | 82 | |
| elmot | 1:d0dfbce63a89 | 83 | /**@}*/ |
| elmot | 1:d0dfbce63a89 | 84 | |
| elmot | 1:d0dfbce63a89 | 85 | #ifdef __cplusplus |
| elmot | 1:d0dfbce63a89 | 86 | } |
| elmot | 1:d0dfbce63a89 | 87 | #endif |
| elmot | 1:d0dfbce63a89 | 88 | |
| elmot | 1:d0dfbce63a89 | 89 | #endif |
| elmot | 1:d0dfbce63a89 | 90 | |
| elmot | 1:d0dfbce63a89 | 91 | #endif |
| elmot | 1:d0dfbce63a89 | 92 | |
| elmot | 1:d0dfbce63a89 | 93 | /** @}*/ |