TizenRT Public API  v2.0 M2
iotbus_adc.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2019 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 
31 #ifndef IOTBUS_ADC_H_
32 #define IOTBUS_ADC_H_
33 
34 #include <stdint.h>
35 #include <sys/types.h>
36 
37 struct _iotbus_adc_s;
38 
42 typedef struct _iotbus_adc_wrapper_s *iotbus_adc_context_h;
43 
44 typedef void (*iotbus_adc_cb)(iotbus_adc_context_h);
45 
53 typedef enum {
54  IOTBUS_ADC_NONE = 0,
55  IOTBUS_ADC_RDY,
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 typedef void (*adc_read_cb)(int channel, uint32_t data);
65 
75 iotbus_adc_context_h iotbus_adc_init(int bus, uint8_t channel);
76 
86 
96 int iotbus_adc_set_channel(iotbus_adc_context_h hnd, uint8_t channel);
97 
107 
117 
127 int iotbus_adc_start(iotbus_adc_context_h hnd, const adc_read_cb read_cb);
128 
138 
148 int32_t iotbus_adc_get_sample(iotbus_adc_context_h hnd, int timeout);
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* IOTBUS_ADC_H_ */
155  // end of ADC group
int iotbus_adc_get_state(iotbus_adc_context_h hnd)
get the ADC state.
int iotbus_adc_set_channel(iotbus_adc_context_h hnd, uint8_t channel)
set the ADC channel.
iotbus_adc_state_e
Enumeration of ADC state.
Definition: iotbus_adc.h:53
int iotbus_adc_stop(iotbus_adc_context_h hnd)
stop adc asynchronous read.
int32_t iotbus_adc_get_sample(iotbus_adc_context_h hnd, int timeout)
adc synchronous read.
int iotbus_adc_start(iotbus_adc_context_h hnd, const adc_read_cb read_cb)
start adc asynchronous read.
iotbus_adc_context_h iotbus_adc_init(int bus, uint8_t channel)
initializes adc_context.
int iotbus_adc_deinit(iotbus_adc_context_h hnd)
deinitializes adc_context.
int iotbus_adc_get_channel(iotbus_adc_context_h hnd)
get the ADC channel.
struct _iotbus_adc_wrapper_s * iotbus_adc_context_h
Pointer definition to the internal struct _iotbus_adc_wrapper_s.
Definition: iotbus_adc.h:42