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