1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef AOS_HAL_DAC_H 6 #define AOS_HAL_DAC_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #include <stdint.h> 13 14 typedef struct { 15 uint8_t port; /* dac port */ 16 void *priv; /* priv data */ 17 } dac_dev_t; 18 19 /** 20 * Initialises an dac interface 21 * 22 * @param[in] dac the interface which should be initialised 23 * 24 * @return 0 : on success, EIO : if an error occurred with any step 25 */ 26 int32_t aos_hal_dac_init(dac_dev_t *dac); 27 28 /** 29 * Start output dac 30 * 31 * @param[in] dac the interface which should be started 32 * @param[out] channel the channel to output dac 33 * 34 * @return 0 : on success, EIO : if an error occurred with any step 35 */ 36 int32_t aos_hal_dac_start(dac_dev_t *dac, uint32_t channel); 37 38 /** 39 * Stop output dac 40 * 41 * @param[in] dac the interface which should be stopped 42 * @param[out] channel the channel to output dac 43 * 44 * @return 0 : on success, EIO : if an error occurred with any step 45 */ 46 int32_t aos_hal_dac_stop(dac_dev_t *dac, uint32_t channel); 47 48 /** 49 * Output a value to an dac interface 50 * 51 * @param[in] dac the interface to set value 52 * @param[out] channel the channel to output dac 53 * @param[in] data the value to output 54 * 55 * @return 0 : on success, EIO : if an error occurred with any step 56 */ 57 int32_t aos_hal_dac_set_value(dac_dev_t *dac, uint32_t channel, uint32_t data); 58 59 /** 60 * Returns the last data output value of the selected dac channel 61 * 62 * @param[in] dac the interface to get value 63 * @param[out] channel channel the channel to output dac 64 * 65 * @return dac output value 66 */ 67 int32_t aos_hal_dac_get_value(dac_dev_t *dac, uint32_t channel); 68 69 /** 70 * De-initialises an dac interface, Turns off an dac hardware interface 71 * 72 * @param[in] dac the interface which should be de-initialised 73 * 74 * @return 0 : on success, EIO : if an error occurred with any step 75 */ 76 int32_t aos_hal_dac_finalize(dac_dev_t *dac); 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif /* AOS_HAL_DAC_H */ 83 84