Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
5cb11e56
Commit
5cb11e56
authored
10 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Plain Diff
Merge pull request #1469 from haukepetersen/fix_periph_adcif
drivers: some improvements to the ADC driver interface
parents
1fb02c27
378c0dfc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/include/periph/adc.h
+41
-11
41 additions, 11 deletions
drivers/include/periph/adc.h
with
41 additions
and
11 deletions
drivers/include/periph/adc.h
+
41
−
11
View file @
5cb11e56
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* @brief Low-level ADC peripheral driver
* @brief Low-level ADC peripheral driver
* @{
* @{
*
*
* @file
periph/adc.h
* @file
* @brief Low-level ADC peripheral driver interface definitions
* @brief Low-level ADC peripheral driver interface definitions
*
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#include
"periph_conf.h"
#include
"periph_conf.h"
/* guard file in case no ADC device is defined */
#if ADC_NUMOF
/**
/**
* @brief Definition available ADC devices
* @brief Definition available ADC devices
...
@@ -30,20 +32,31 @@
...
@@ -30,20 +32,31 @@
*/
*/
typedef
enum
{
typedef
enum
{
#if ADC_0_EN
#if ADC_0_EN
ADC_0
,
/*< ADC device 0 */
ADC_0
=
0
,
/*
*
< ADC device 0 */
#endif
#endif
#if ADC_1_EN
#if ADC_1_EN
ADC_1
,
/
*< ADC device 1 */
ADC_1
,
/*
*< ADC device 1 */
#endif
#endif
#if ADC_2_EN
#if ADC_2_EN
ADC_2
,
/
*< ADC device 2 */
ADC_2
,
/*
*< ADC device 2 */
#endif
#endif
#if ADC_3_EN
#if ADC_3_EN
ADC_3
,
/
*< ADC device 3 */
ADC_3
,
/*
*< ADC device 3 */
#endif
#endif
ADC_UNDEFINED
}
adc_t
;
}
adc_t
;
/**
* @brief Possible ADC precision settings
*/
typedef
enum
{
ADC_RES_6BIT
=
0
,
/**< ADC precision: 6 bit */
ADC_RES_8BIT
,
/**< ADC precision: 8 bit */
ADC_RES_10BIT
,
/**< ADC precision: 10 bit */
ADC_RES_12BIT
,
/**< ADC precision: 12 bit */
ADC_RES_14BIT
,
/**< ADC precision: 14 bit */
ADC_RES_16BIT
,
/**< ADC precision: 16 bit */
}
adc_precision_t
;
/**
/**
* @brief Initialization of a given ADC device
* @brief Initialization of a given ADC device
*
*
...
@@ -52,12 +65,12 @@ typedef enum {
...
@@ -52,12 +65,12 @@ typedef enum {
* range of some us).
* range of some us).
*
*
* @param[in] dev the device to initialize
* @param[in] dev the device to initialize
* @param[in] precision the conversion precision in bits, will LSBs will be stuffed if
* @param[in] precision the precision to use for conversion
* precision > max precision of hardware
*
*
* @return 1 on success, -1 on error
* @return 0 on success
* @return -1 on precision not available
*/
*/
int
adc_init
(
adc_t
dev
,
in
t
precision
);
int
adc_init
(
adc_t
dev
,
adc_precision_
t
precision
);
/**
/**
* @brief Start a new conversion by using the given channel.
* @brief Start a new conversion by using the given channel.
...
@@ -67,10 +80,25 @@ int adc_init(adc_t dev, int precision);
...
@@ -67,10 +80,25 @@ int adc_init(adc_t dev, int precision);
* @param[in] dev the ADC device to use for the conversion
* @param[in] dev the ADC device to use for the conversion
* @param[in] channel the channel to convert from
* @param[in] channel the channel to convert from
*
*
* @return the converted value with the defined precision, -1 on error
* @return the converted value
* @return -1 on invalid channel
*/
*/
int
adc_sample
(
adc_t
dev
,
int
channel
);
int
adc_sample
(
adc_t
dev
,
int
channel
);
/**
* @brief Enable the power for the given ADC device
*
* @param[in] dev the ADC device to power up
*/
void
adc_poweron
(
adc_t
dev
);
/**
* @brief Disable the power for the given ADC device
*
* @param[in] dev the ADC device to power down
*/
void
adc_poweroff
(
adc_t
dev
);
/**
/**
* @brief Helper function to map a converted value to the given integer range.
* @brief Helper function to map a converted value to the given integer range.
*
*
...
@@ -101,5 +129,7 @@ int adc_map(adc_t dev, int value, int min, int max);
...
@@ -101,5 +129,7 @@ int adc_map(adc_t dev, int value, int min, int max);
*/
*/
float
adc_mapf
(
adc_t
dev
,
int
value
,
float
min
,
float
max
);
float
adc_mapf
(
adc_t
dev
,
int
value
,
float
min
,
float
max
);
#endif
/* ADC_NUMOF */
#endif
/* __ADC_H */
#endif
/* __ADC_H */
/** @} */
/** @} */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment