Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_adc.h
Go to the documentation of this file.
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://aws.amazon.com/freertos
23 * http://www.FreeRTOS.org
24 */
25
30#ifndef _IOT_ADC_H_
31#define _IOT_ADC_H_
32
36#define IOT_ADC_SUCCESS ( 0 )
37#define IOT_ADC_FAILED ( 1 )
38#define IOT_ADC_INVALID_VALUE ( 2 )
39#define IOT_ADC_NOT_OPEN ( 3 )
40#define IOT_ADC_FUNCTION_NOT_SUPPORTED ( 4 )
41#define IOT_ADC_CH_BUSY ( 5 )
47struct IotAdcDescriptor;
48
54typedef struct IotAdcDescriptor * IotAdcHandle_t;
55
65typedef void ( * IotAdcCallback_t )( uint16_t * pusConvertedData,
66 void * pvUserContext );
67
86
99int32_t iot_adc_close( IotAdcHandle_t const pxAdc );
100
129 uint8_t ucAdcChannel,
130 IotAdcCallback_t xAdcCallback,
131 void * pvUserContext );
132
192int32_t iot_adc_start( IotAdcHandle_t const pxAdc,
193 uint8_t ucAdcChannel );
194
206int32_t iot_adc_stop( IotAdcHandle_t const pxAdc,
207 uint8_t ucAdcChannel );
208
253 uint8_t ucAdcChannel,
254 uint16_t * pusAdcSample );
255
263typedef struct IotAdcConfig_s
264{
272
276typedef enum
277{
281
285typedef struct IotAdcChStatus_s
286{
287 uint8_t ucAdcChannel;
290
302typedef struct IotAdcChBuffer_s
303{
304 uint8_t ucAdcChannel;
305 void * pvBuffer;
306 uint8_t ucBufLen;
308
317typedef struct IoTAdcChain_s
318{
319 uint8_t ucAdcChannel;
322 void * pvBuffer;
324 uint8_t ucBufLen;
325 uint16_t usChainMask;
329
333typedef enum IotAdcIoctlRequest_s
334{
341
357int32_t iot_adc_ioctl( IotAdcHandle_t const pxAdc,
358 IotAdcIoctlRequest_t xRequest,
359 void * const pvBuffer );
360
361#endif /* _IOT_ADC_H_ */
int32_t iot_adc_read_sample(IotAdcHandle_t const pxAdc, uint8_t ucAdcChannel, uint16_t *pusAdcSample)
read one ADC data sample. This API will return one ADC sample.
int32_t iot_adc_start(IotAdcHandle_t const pxAdc, uint8_t ucAdcChannel)
Start data acquisition for ADC channel until iot_adc_stop API is called. Data will be passed back to ...
IotAdcChState_t
enum for ADC channel state (idle/busy)
Definition: iot_adc.h:277
@ eChStateIdle
Definition: iot_adc.h:278
@ eChStateBusy
Definition: iot_adc.h:279
int32_t iot_adc_close(IotAdcHandle_t const pxAdc)
Close ADC controller. All pending operation will be cancelled, put ADC module in reset state or low p...
void iot_adc_set_callback(IotAdcHandle_t const pxAdc, uint8_t ucAdcChannel, IotAdcCallback_t xAdcCallback, void *pvUserContext)
Sets channel callback on availability of channel scan data. On availability of ADC scan data,...
void(* IotAdcCallback_t)(uint16_t *pusConvertedData, void *pvUserContext)
ADC notification callback type.
Definition: iot_adc.h:65
IotAdcHandle_t iot_adc_open(int32_t lAdc)
Initializes ADC controller with default configuration. init ADC controller, enable ADC clock,...
struct IotAdcDescriptor * IotAdcHandle_t
IotAdcHandle_t is the handle type returned by calling iot_adc_open(). This is initialized in open and...
Definition: iot_adc.h:54
int32_t iot_adc_ioctl(IotAdcHandle_t const pxAdc, IotAdcIoctlRequest_t xRequest, void *const pvBuffer)
Used for various ADC control functions.
int32_t iot_adc_stop(IotAdcHandle_t const pxAdc, uint8_t ucAdcChannel)
Stop data acquisition for ADC channel.
IotAdcIoctlRequest_t
adc ioctl request types.
Definition: iot_adc.h:334
@ eGetChStatus
Definition: iot_adc.h:337
@ eGetAdcConfig
Definition: iot_adc.h:336
@ eSetAdcChain
Definition: iot_adc.h:339
@ eSetChBuffer
Definition: iot_adc.h:338
@ eSetAdcConfig
Definition: iot_adc.h:335
data structure for ioctl SetChBuffer setting channel data buffer is optional using this ioctl if clie...
Definition: iot_adc.h:303
uint8_t ucAdcChannel
Definition: iot_adc.h:304
void * pvBuffer
Definition: iot_adc.h:305
uint8_t ucBufLen
Definition: iot_adc.h:306
data structure for ioctl GetChStatus
Definition: iot_adc.h:286
uint8_t ucAdcChannel
Definition: iot_adc.h:287
IotAdcChState_t xAdcChState
Definition: iot_adc.h:288
Some ADC host controller supports grouping multiple ADC channels into a chain. When the chain is trig...
Definition: iot_adc.h:318
uint8_t ucBufLen
Definition: iot_adc.h:324
uint8_t ucAdcChannel
Definition: iot_adc.h:319
void * pvBuffer
Definition: iot_adc.h:322
uint16_t usChainMask
Definition: iot_adc.h:325
data structures for ioctl request
Definition: iot_adc.h:264
uint8_t ucAdcResolution
Definition: iot_adc.h:269
uint32_t ulAdcSampleTime
Definition: iot_adc.h:265