Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
97114129
Commit
97114129
authored
May 05, 2019
by
schneider
Browse files
feat(helloworld): Also scan 7 bit i2c bus
parent
0c0ddc14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Hello_World/main.c
View file @
97114129
...
...
@@ -103,8 +103,8 @@ int main(void)
printf
(
"Hello World!
\n
"
);
//Setup the I2CM
I2C_Shutdown
(
I2C_DEVICE
);
I2C_Init
(
I2C_DEVICE
,
I2C_FAST_MODE
,
NULL
);
I2C_Shutdown
(
MXC_I2C0_BUS0
);
I2C_Init
(
MXC_I2C0_BUS0
,
I2C_FAST_MODE
,
NULL
);
I2C_Shutdown
(
MXC_I2C1_BUS0
);
I2C_Init
(
MXC_I2C1_BUS0
,
I2C_FAST_MODE
,
NULL
);
...
...
@@ -117,9 +117,14 @@ int main(void)
// "7-bit addresses 0b0000xxx and 0b1111xxx are reserved"
for
(
int
addr
=
0x8
;
addr
<
0x78
;
++
addr
)
{
// A 0 byte write does not seem to work so always send a single byte.
int
res
=
I2C_MasterWrite
(
I2C_DEVICE
,
addr
<<
1
,
dummy
,
1
,
0
);
int
res
=
I2C_MasterWrite
(
MXC_I2C0_BUS0
,
addr
<<
1
,
dummy
,
1
,
0
);
if
(
res
==
1
)
{
printf
(
"Found (7 bit) address 0x%02x
\n
"
,
addr
);
printf
(
"Found (7 bit) address 0x%02x on I2C0
\n
"
,
addr
);
}
res
=
I2C_MasterWrite
(
MXC_I2C1_BUS0
,
addr
<<
1
,
dummy
,
1
,
0
);
if
(
res
==
1
)
{
printf
(
"Found (7 bit) address 0x%02x on I2C1
\n
"
,
addr
);
}
}
...
...
Write
Preview
Supports
Markdown
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