Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
1c788487
Commit
1c788487
authored
Apr 06, 2020
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev/i2c_eeprom: support for 2-byte address devices
parent
9a6b3b5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
i2c_eeprom.c
dev/i2c_eeprom.c
+20
-3
i2c_eeprom.h
include/dev/i2c_eeprom.h
+3
-0
No files found.
dev/i2c_eeprom.c
View file @
1c788487
...
...
@@ -11,6 +11,14 @@
#include "dev/bb_i2c.h"
#include "dev/i2c_eeprom.h"
int
i2c_eeprom_create
(
struct
i2c_eeprom_device
*
dev
,
struct
i2c_bus
*
bus
,
uint8_t
i2c_addr
,
int
offset_bytes
)
{
dev
->
bus
=
bus
;
dev
->
offset_bytes
=
offset_bytes
;
dev
->
addr
=
i2c_addr
;
return
0
;
}
int
i2c_eeprom_read
(
struct
i2c_eeprom_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
)
{
int
i
;
...
...
@@ -21,7 +29,10 @@ int i2c_eeprom_read(struct i2c_eeprom_device *dev, int offset, void *buf, int co
bb_i2c_stop
(
dev
->
bus
);
return
-
1
;
}
bb_i2c_put_byte
(
dev
->
bus
,
(
offset
>>
8
)
&
0xff
);
if
(
dev
->
offset_bytes
==
2
)
bb_i2c_put_byte
(
dev
->
bus
,
(
offset
>>
8
)
&
0xff
);
bb_i2c_put_byte
(
dev
->
bus
,
offset
&
0xff
);
bb_i2c_repeat_start
(
dev
->
bus
);
bb_i2c_put_byte
(
dev
->
bus
,
(
dev
->
addr
<<
1
)
|
1
);
...
...
@@ -48,7 +59,10 @@ int i2c_eeprom_write(struct i2c_eeprom_device *dev, int offset, void *buf, int c
bb_i2c_stop
(
dev
->
bus
);
return
-
1
;
}
bb_i2c_put_byte
(
dev
->
bus
,
(
offset
>>
8
)
&
0xff
);
if
(
dev
->
offset_bytes
==
2
)
bb_i2c_put_byte
(
dev
->
bus
,
(
offset
>>
8
)
&
0xff
);
bb_i2c_put_byte
(
dev
->
bus
,
offset
&
0xff
);
bb_i2c_put_byte
(
dev
->
bus
,
*
cb
++
);
offset
++
;
...
...
@@ -75,7 +89,10 @@ int i2c_eeprom_erase(struct i2c_eeprom_device *dev, int offset, int count)
bb_i2c_stop
(
dev
->
bus
);
return
-
1
;
}
bb_i2c_put_byte
(
dev
->
bus
,
(
offset
>>
8
)
&
0xff
);
if
(
dev
->
offset_bytes
==
2
)
bb_i2c_put_byte
(
dev
->
bus
,
(
offset
>>
8
)
&
0xff
);
bb_i2c_put_byte
(
dev
->
bus
,
offset
&
0xff
);
bb_i2c_put_byte
(
dev
->
bus
,
0xff
);
offset
++
;
...
...
include/dev/i2c_eeprom.h
View file @
1c788487
...
...
@@ -15,8 +15,11 @@
struct
i2c_eeprom_device
{
struct
i2c_bus
*
bus
;
uint8_t
addr
;
int
offset_bytes
;
};
int
i2c_eeprom_create
(
struct
i2c_eeprom_device
*
dev
,
struct
i2c_bus
*
bus
,
uint8_t
i2c_addr
,
int
offset_bytes
);
int
i2c_eeprom_read
(
struct
i2c_eeprom_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
);
int
i2c_eeprom_write
(
struct
i2c_eeprom_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
);
int
i2c_eeprom_erase
(
struct
i2c_eeprom_device
*
dev
,
int
offset
,
int
count
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment