Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
portal-core
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
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
portal
portal-core
Commits
8ba5fe4b
Commit
8ba5fe4b
authored
13 years ago
by
da1l6
Browse files
Options
Downloads
Patches
Plain Diff
Control: Add speed i2c switching to keystore code for eeprom access.
parent
80805e6d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Control/keystore.c
+12
-8
12 additions, 8 deletions
Control/keystore.c
with
12 additions
and
8 deletions
Control/keystore.c
+
12
−
8
View file @
8ba5fe4b
...
@@ -201,10 +201,11 @@ uint8_t keystore_enable_slot(uint16_t index){
...
@@ -201,10 +201,11 @@ uint8_t keystore_enable_slot(uint16_t index){
uint8_t
keystore_read_slot_status
(
uint16_t
index
){
uint8_t
keystore_read_slot_status
(
uint16_t
index
){
uint8_t
key_status
=
KEYSLOT_ERROR
;
uint8_t
key_status
=
KEYSLOT_ERROR
;
uint8_t
ret
;
uint8_t
ret
;
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
&
key_status
,
1
);
i2c_master_set_speed
(
I2C_BITRATE_REG_1M
);
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
sizeof
(
uint16_t
),
&
key_status
,
sizeof
(
uint8_t
));
if
(
ret
!=
I2C_SUCCESS
)
{
if
(
ret
!=
I2C_SUCCESS
)
{
printf_P
(
PSTR
(
"Key status read error %02x, retry...
\n
"
),
ret
);
printf_P
(
PSTR
(
"Key status read error %02x, retry...
\n
"
),
ret
);
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
&
key_status
,
1
);
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
sizeof
(
uint16_t
),
&
key_status
,
sizeof
(
uint8_t
)
);
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key status read error %02x (fatal)
\n
"
),
ret
);
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key status read error %02x (fatal)
\n
"
),
ret
);
}
}
return
(
ret
==
I2C_SUCCESS
)
?
key_status
:
KEYSLOT_ERROR
;
return
(
ret
==
I2C_SUCCESS
)
?
key_status
:
KEYSLOT_ERROR
;
...
@@ -214,10 +215,11 @@ uint8_t keystore_write_slot_status(uint16_t index, uint8_t key_status){
...
@@ -214,10 +215,11 @@ uint8_t keystore_write_slot_status(uint16_t index, uint8_t key_status){
uint8_t
ret
;
uint8_t
ret
;
EEPROM_WRITE_PROTECT_PORT
&=
~
EEPROM_WRITE_PROTECT_MAIN
;
EEPROM_WRITE_PROTECT_PORT
&=
~
EEPROM_WRITE_PROTECT_MAIN
;
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
&
key_status
,
1
);
i2c_master_set_speed
(
I2C_BITRATE_REG_1M
);
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
sizeof
(
uint16_t
),
&
key_status
,
sizeof
(
uint8_t
));
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
printf_P
(
PSTR
(
"Key status write error %02x, retry...
\n
"
),
ret
);
printf_P
(
PSTR
(
"Key status write error %02x, retry...
\n
"
),
ret
);
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
&
key_status
,
1
);
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_TABLE_OFFSET
+
index
,
sizeof
(
uint16_t
)
,
&
key_status
,
1
);
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key status write error %02x (fatal)
\n
"
),
ret
);
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key status write error %02x (fatal)
\n
"
),
ret
);
}
}
...
@@ -228,10 +230,11 @@ uint8_t keystore_write_slot_status(uint16_t index, uint8_t key_status){
...
@@ -228,10 +230,11 @@ uint8_t keystore_write_slot_status(uint16_t index, uint8_t key_status){
uint8_t
keystore_read_key
(
uint16_t
index
,
KEY
key
){
uint8_t
keystore_read_key
(
uint16_t
index
,
KEY
key
){
uint8_t
ret
;
uint8_t
ret
;
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
key
,
sizeof
(
KEY
));
i2c_master_set_speed
(
I2C_BITRATE_REG_1M
);
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
sizeof
(
uint16_t
),
key
,
sizeof
(
KEY
));
if
(
ret
!=
I2C_SUCCESS
)
{
if
(
ret
!=
I2C_SUCCESS
)
{
printf_P
(
PSTR
(
"Key read error %02x, retry...
\n
"
),
ret
);
printf_P
(
PSTR
(
"Key read error %02x, retry...
\n
"
),
ret
);
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
key
,
sizeof
(
KEY
));
ret
=
i2c_master_read
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
sizeof
(
uint16_t
),
key
,
sizeof
(
KEY
));
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key read error %02x (fatal)
\n
"
),
ret
);
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key read error %02x (fatal)
\n
"
),
ret
);
}
}
return
(
ret
==
I2C_SUCCESS
);
return
(
ret
==
I2C_SUCCESS
);
...
@@ -241,10 +244,11 @@ uint8_t keystore_write_key(uint16_t index, KEY key){
...
@@ -241,10 +244,11 @@ uint8_t keystore_write_key(uint16_t index, KEY key){
uint8_t
ret
;
uint8_t
ret
;
EEPROM_WRITE_PROTECT_PORT
&=
~
EEPROM_WRITE_PROTECT_MAIN
;
EEPROM_WRITE_PROTECT_PORT
&=
~
EEPROM_WRITE_PROTECT_MAIN
;
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
key
,
sizeof
(
KEY
));
i2c_master_set_speed
(
I2C_BITRATE_REG_1M
);
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
sizeof
(
uint16_t
),
key
,
sizeof
(
KEY
));
if
(
ret
!=
I2C_SUCCESS
)
{
if
(
ret
!=
I2C_SUCCESS
)
{
printf_P
(
PSTR
(
"Key write error %02x, retry...
\n
"
),
ret
);
printf_P
(
PSTR
(
"Key write error %02x, retry...
\n
"
),
ret
);
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
key
,
sizeof
(
KEY
));
ret
=
i2c_master_write
(
KEY_MAIN_EEPROM
,
EEPROM_KEY_OFFSET
+
(
index
*
sizeof
(
KEY
)),
sizeof
(
uint16_t
),
key
,
sizeof
(
KEY
));
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key write error %02x (fatal)
\n
"
),
ret
);
if
(
ret
!=
I2C_SUCCESS
)
printf_P
(
PSTR
(
"Key write error %02x (fatal)
\n
"
),
ret
);
}
}
...
...
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