Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
battery_monitor
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
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
labrobotica
drivers
battery_monitor
Commits
c4abadad
Commit
c4abadad
authored
13 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Removed the hardcoded I2C address. Now it is using the value read from the EEPROM at startup.
parent
1a7ffd04
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
micro/fuel_gauge.c
+5
-5
5 additions, 5 deletions
micro/fuel_gauge.c
with
5 additions
and
5 deletions
micro/fuel_gauge.c
+
5
−
5
View file @
c4abadad
...
...
@@ -11,7 +11,7 @@ float output_current;
// battery I2C slave address
unsigned
char
battery_id
;
unsigned
char
EEMEM
ee_battery_id
=
0x
31
;
unsigned
char
EEMEM
ee_battery_id
=
0x
60
;
// remaining_capacity
volatile
unsigned
short
int
remaining_capacity
;
...
...
@@ -102,9 +102,9 @@ void get_voltage(unsigned char *voltage)
// read the voltage registers of the battery
// send the read request
read_cmd
=
0x30
;
if
(
i2cMasterSendNI
(
0x62
,
1
,
&
read_cmd
)
==
I2C_OK
)
if
(
i2cMasterSendNI
(
battery_id
,
1
,
&
read_cmd
)
==
I2C_OK
)
{
if
(
i2cMasterReceiveNI
(
0x62
,
18
,
voltage_data
)
==
I2C_OK
)
if
(
i2cMasterReceiveNI
(
battery_id
,
18
,
voltage_data
)
==
I2C_OK
)
{
for
(
i
=
0
;
i
<
16
;
i
++
)
voltage
[
i
]
=
voltage_data
[
i
+
2
];
...
...
@@ -118,9 +118,9 @@ void get_temperature(unsigned char *temp1, unsigned char *temp2)
unsigned
char
read_cmd
;
read_cmd
=
0x4A
;
// device start read address
if
(
i2cMasterSendNI
(
0x62
,
1
,
&
read_cmd
)
==
I2C_OK
)
if
(
i2cMasterSendNI
(
battery_id
,
1
,
&
read_cmd
)
==
I2C_OK
)
{
if
(
i2cMasterReceiveNI
(
0x62
,
6
,
temp_data
)
==
I2C_OK
)
if
(
i2cMasterReceiveNI
(
battery_id
,
6
,
temp_data
)
==
I2C_OK
)
{
temp1
[
0
]
=
temp_data
[
2
];
temp1
[
1
]
=
temp_data
[
3
];
...
...
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