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
034d7f0b
Commit
034d7f0b
authored
6 years ago
by
Vincent Dupont
Committed by
dylad
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
adcxx1c: adapt to new i2c API
parent
906a1977
No related branches found
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/adcxx1c/adcxx1c.c
+10
-18
10 additions, 18 deletions
drivers/adcxx1c/adcxx1c.c
with
10 additions
and
18 deletions
drivers/adcxx1c/adcxx1c.c
+
10
−
18
View file @
034d7f0b
...
@@ -27,8 +27,6 @@
...
@@ -27,8 +27,6 @@
#define ENABLE_DEBUG (0)
#define ENABLE_DEBUG (0)
#include
"debug.h"
#include
"debug.h"
#define I2C_SPEED I2C_SPEED_FAST
#define I2C (dev->params.i2c)
#define I2C (dev->params.i2c)
#define ADDR (dev->params.addr)
#define ADDR (dev->params.addr)
...
@@ -44,17 +42,11 @@ int adcxx1c_init(adcxx1c_t *dev, const adcxx1c_params_t *params)
...
@@ -44,17 +42,11 @@ int adcxx1c_init(adcxx1c_t *dev, const adcxx1c_params_t *params)
dev
->
cb
=
NULL
;
dev
->
cb
=
NULL
;
i2c_acquire
(
I2C
);
i2c_acquire
(
I2C
);
if
(
i2c_init_master
(
I2C
,
I2C_SPEED
)
<
0
)
{
i2c_release
(
I2C
);
DEBUG
(
"[adcxx1c] init - error: unable to initialize I2C bus
\n
"
);
return
ADCXX1C_NOI2C
;
}
uint8_t
reg
=
0
;
uint8_t
reg
=
0
;
/* Test communication write and read configuration register */
/* Test communication write and read configuration register */
i2c_write_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
CONF_TEST_VALUE
);
i2c_write_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
CONF_TEST_VALUE
,
0
);
i2c_read_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
&
reg
);
i2c_read_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
&
reg
,
0
);
if
(
reg
!=
CONF_TEST_VALUE
)
{
if
(
reg
!=
CONF_TEST_VALUE
)
{
i2c_release
(
I2C
);
i2c_release
(
I2C
);
...
@@ -63,7 +55,7 @@ int adcxx1c_init(adcxx1c_t *dev, const adcxx1c_params_t *params)
...
@@ -63,7 +55,7 @@ int adcxx1c_init(adcxx1c_t *dev, const adcxx1c_params_t *params)
}
}
reg
=
dev
->
params
.
cycle
<<
5
;
reg
=
dev
->
params
.
cycle
<<
5
;
i2c_write_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
reg
);
i2c_write_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
reg
,
0
);
i2c_release
(
I2C
);
i2c_release
(
I2C
);
adcxx1c_set_alert_parameters
(
dev
,
dev
->
params
.
low_limit
,
adcxx1c_set_alert_parameters
(
dev
,
dev
->
params
.
low_limit
,
...
@@ -79,9 +71,9 @@ int adcxx1c_read_raw(const adcxx1c_t *dev, int16_t *raw)
...
@@ -79,9 +71,9 @@ int adcxx1c_read_raw(const adcxx1c_t *dev, int16_t *raw)
int
status
;
int
status
;
i2c_acquire
(
I2C
);
i2c_acquire
(
I2C
);
status
=
i2c_read_regs
(
I2C
,
ADDR
,
ADCXX1C_CONV_RES_ADDR
,
buf
,
2
);
status
=
i2c_read_regs
(
I2C
,
ADDR
,
ADCXX1C_CONV_RES_ADDR
,
buf
,
2
,
0
);
i2c_release
(
I2C
);
i2c_release
(
I2C
);
if
(
status
<
2
)
{
if
(
status
<
0
)
{
return
ADCXX1C_NOI2C
;
return
ADCXX1C_NOI2C
;
}
}
...
@@ -104,10 +96,10 @@ int adcxx1c_enable_alert(adcxx1c_t *dev, adcxx1c_cb_t cb, void *arg)
...
@@ -104,10 +96,10 @@ int adcxx1c_enable_alert(adcxx1c_t *dev, adcxx1c_cb_t cb, void *arg)
uint8_t
reg
;
uint8_t
reg
;
i2c_acquire
(
I2C
);
i2c_acquire
(
I2C
);
i2c_read_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
&
reg
);
i2c_read_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
&
reg
,
0
);
reg
|=
(
dev
->
params
.
alert_pin
!=
GPIO_UNDEF
?
ADCXX1C_CONF_ALERT_PIN_EN
:
0
)
reg
|=
(
dev
->
params
.
alert_pin
!=
GPIO_UNDEF
?
ADCXX1C_CONF_ALERT_PIN_EN
:
0
)
|
ADCXX1C_CONF_ALERT_FLAG_EN
;
|
ADCXX1C_CONF_ALERT_FLAG_EN
;
i2c_write_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
reg
);
i2c_write_reg
(
I2C
,
ADDR
,
ADCXX1C_CONF_ADDR
,
reg
,
0
);
i2c_release
(
I2C
);
i2c_release
(
I2C
);
if
(
dev
->
params
.
alert_pin
!=
GPIO_UNDEF
)
{
if
(
dev
->
params
.
alert_pin
!=
GPIO_UNDEF
)
{
...
@@ -130,17 +122,17 @@ int adcxx1c_set_alert_parameters(const adcxx1c_t *dev, int16_t low_limit,
...
@@ -130,17 +122,17 @@ int adcxx1c_set_alert_parameters(const adcxx1c_t *dev, int16_t low_limit,
low_limit
<<=
(
12
-
dev
->
params
.
bits
);
low_limit
<<=
(
12
-
dev
->
params
.
bits
);
buf
[
0
]
=
low_limit
>>
8
;
buf
[
0
]
=
low_limit
>>
8
;
buf
[
1
]
=
low_limit
&
0xFF
;
buf
[
1
]
=
low_limit
&
0xFF
;
i2c_write_regs
(
I2C
,
ADDR
,
ADCXX1C_LOW_LIMIT_ADDR
,
buf
,
2
);
i2c_write_regs
(
I2C
,
ADDR
,
ADCXX1C_LOW_LIMIT_ADDR
,
buf
,
2
,
0
);
high_limit
<<=
(
12
-
dev
->
params
.
bits
);
high_limit
<<=
(
12
-
dev
->
params
.
bits
);
buf
[
0
]
=
high_limit
>>
8
;
buf
[
0
]
=
high_limit
>>
8
;
buf
[
1
]
=
high_limit
&
0xFF
;
buf
[
1
]
=
high_limit
&
0xFF
;
i2c_write_regs
(
I2C
,
ADDR
,
ADCXX1C_HIGH_LIMIT_ADDR
,
buf
,
2
);
i2c_write_regs
(
I2C
,
ADDR
,
ADCXX1C_HIGH_LIMIT_ADDR
,
buf
,
2
,
0
);
hysteresis
<<=
(
12
-
dev
->
params
.
bits
);
hysteresis
<<=
(
12
-
dev
->
params
.
bits
);
buf
[
0
]
=
hysteresis
>>
8
;
buf
[
0
]
=
hysteresis
>>
8
;
buf
[
1
]
=
hysteresis
&
0xFF
;
buf
[
1
]
=
hysteresis
&
0xFF
;
i2c_write_regs
(
I2C
,
ADDR
,
ADCXX1C_HYSTERESIS_ADDR
,
buf
,
2
);
i2c_write_regs
(
I2C
,
ADDR
,
ADCXX1C_HYSTERESIS_ADDR
,
buf
,
2
,
0
);
i2c_release
(
I2C
);
i2c_release
(
I2C
);
...
...
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