Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
non-destructive text micropython
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
badge fixer
non-destructive text micropython
Commits
647b27d0
Commit
647b27d0
authored
May 8, 2019
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
zephyr/machine_i2c: Update to support new C-level I2C API.
parent
bb29bde1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ports/zephyr/machine_i2c.c
+5
-13
5 additions, 13 deletions
ports/zephyr/machine_i2c.c
with
5 additions
and
13 deletions
ports/zephyr/machine_i2c.c
+
5
−
13
View file @
647b27d0
...
@@ -92,7 +92,7 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
...
@@ -92,7 +92,7 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
return
MP_OBJ_FROM_PTR
(
self
);
return
MP_OBJ_FROM_PTR
(
self
);
}
}
STATIC
int
machine_hard_i2c_transfer
(
mp_obj_base_t
*
self_in
,
uint16_t
addr
,
uint8_t
*
buf
,
size_t
len
,
bool
stop
,
bool
read
)
{
STATIC
int
machine_hard_i2c_transfer
_single
(
mp_obj_base_t
*
self_in
,
uint16_t
addr
,
size_t
len
,
uint8_t
*
buf
,
unsigned
int
flags
)
{
machine_hard_i2c_obj_t
*
self
=
(
machine_hard_i2c_obj_t
*
)
self_in
;
machine_hard_i2c_obj_t
*
self
=
(
machine_hard_i2c_obj_t
*
)
self_in
;
struct
i2c_msg
msg
;
struct
i2c_msg
msg
;
int
ret
;
int
ret
;
...
@@ -101,7 +101,7 @@ STATIC int machine_hard_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, uint
...
@@ -101,7 +101,7 @@ STATIC int machine_hard_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, uint
msg
.
len
=
len
;
msg
.
len
=
len
;
msg
.
flags
=
0
;
msg
.
flags
=
0
;
if
(
read
)
{
if
(
flags
&
MP_MACHINE_I2C_FLAG_READ
)
{
msg
.
flags
|=
I2C_MSG_READ
;
msg
.
flags
|=
I2C_MSG_READ
;
}
else
{
}
else
{
msg
.
flags
|=
I2C_MSG_WRITE
;
msg
.
flags
|=
I2C_MSG_WRITE
;
...
@@ -111,7 +111,7 @@ STATIC int machine_hard_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, uint
...
@@ -111,7 +111,7 @@ STATIC int machine_hard_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, uint
msg
.
flags
|=
I2C_MSG_RESTART
;
msg
.
flags
|=
I2C_MSG_RESTART
;
}
}
if
(
stop
)
{
if
(
flags
&
MP_MACHINE_I2C_FLAG_STOP
)
{
msg
.
flags
|=
I2C_MSG_STOP
;
msg
.
flags
|=
I2C_MSG_STOP
;
self
->
restart
=
false
;
self
->
restart
=
false
;
}
else
{
}
else
{
...
@@ -122,17 +122,9 @@ STATIC int machine_hard_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, uint
...
@@ -122,17 +122,9 @@ STATIC int machine_hard_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, uint
return
(
ret
<
0
)
?
-
MP_EIO
:
len
;
return
(
ret
<
0
)
?
-
MP_EIO
:
len
;
}
}
STATIC
int
machine_hard_i2c_readfrom
(
mp_obj_base_t
*
self_in
,
uint16_t
addr
,
uint8_t
*
dest
,
size_t
len
,
bool
stop
)
{
return
machine_hard_i2c_transfer
(
self_in
,
addr
,
dest
,
len
,
stop
,
true
);
}
STATIC
int
machine_hard_i2c_writeto
(
mp_obj_base_t
*
self_in
,
uint16_t
addr
,
const
uint8_t
*
src
,
size_t
len
,
bool
stop
)
{
return
machine_hard_i2c_transfer
(
self_in
,
addr
,
(
uint8_t
*
)
src
,
len
,
stop
,
false
);
}
STATIC
const
mp_machine_i2c_p_t
machine_hard_i2c_p
=
{
STATIC
const
mp_machine_i2c_p_t
machine_hard_i2c_p
=
{
.
readfrom
=
machine_
hard_i2c_readfrom
,
.
transfer
=
mp_
machine_
i2c_transfer_adaptor
,
.
writeto
=
machine_hard_i2c_
writeto
,
.
transfer_single
=
machine_hard_i2c_
transfer_single
,
};
};
STATIC
const
mp_obj_type_t
machine_hard_i2c_type
=
{
STATIC
const
mp_obj_type_t
machine_hard_i2c_type
=
{
...
...
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