Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT Monitoring Module
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
DIOT Monitoring Module
Commits
e71f0ac4
Commit
e71f0ac4
authored
Jul 17, 2019
by
Christos Gentsos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Master: simple I2C sending test (works)
parent
f1ef0e20
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
main.c
src/main.c
+8
-1
No files found.
src/main.c
View file @
e71f0ac4
...
...
@@ -13,6 +13,12 @@ int main(void)
uint16_t
adc_val
;
float
adc_temp
;
struct
io_descriptor
*
I2C_0_io
;
int
n_written
=
0
;
i2c_m_sync_get_io_descriptor
(
&
I2C_0
,
&
I2C_0_io
);
i2c_m_sync_enable
(
&
I2C_0
);
i2c_m_sync_set_slaveaddr
(
&
I2C_0
,
0x12
,
I2C_M_SEVEN
);
/* Replace with your application code */
while
(
1
)
{
...
...
@@ -21,7 +27,8 @@ int main(void)
if
(
i
++
%
2
)
{
adc_sync_read_channel
(
&
ADC_0
,
0
,
(
uint8_t
*
)
&
adc_val
,
2
);
adc_temp
=
((
adc_val
/
4095
.
0
)
-
0
.
6
)
/
0
.
01
;
debug
(
"iter %d, temp=%.1f"
,
i
/
2
,
adc_temp
);
n_written
=
io_write
(
I2C_0_io
,
(
uint8_t
*
)
"Hello World!"
,
12
);
debug
(
"iter %d, temp=%.1f, written=%d"
,
i
/
2
,
adc_temp
,
n_written
);
}
}
}
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