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
ccdc2e6e
Commit
ccdc2e6e
authored
Jul 17, 2019
by
Christos Gentsos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
I2C: simple I2C slave test (works)
parent
56e9fa22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
9 deletions
+29
-9
atmel_start_config.atstart
main_fw/atmel_start_prj/atmel_start_config.atstart
+1
-1
hpl_sercom_config.h
main_fw/atmel_start_prj/config/hpl_sercom_config.h
+1
-1
main.c
main_fw/src/main.c
+27
-7
No files found.
main_fw/atmel_start_prj/atmel_start_config.atstart
View file @
ccdc2e6e
...
...
@@ -247,7 +247,7 @@ drivers:
functionality: I2C
api: HAL:Driver:I2C_Slave_Async
configuration:
i2c_slave_address:
26
i2c_slave_address:
18
i2c_slave_address_mask: 0
i2c_slave_advanced: true
i2c_slave_amode: Mask
...
...
main_fw/atmel_start_prj/config/hpl_sercom_config.h
View file @
ccdc2e6e
...
...
@@ -20,7 +20,7 @@
// <i> In 7-bit addressing mode the range is 0x00 to 0x7F, in 10-bit addressing mode the range is 0x000 to 0x3FF
// <id> i2c_slave_address
#ifndef CONF_SERCOM_3_I2CS_ADDRESS
#define CONF_SERCOM_3_I2CS_ADDRESS 0x1
a
#define CONF_SERCOM_3_I2CS_ADDRESS 0x1
2
#endif
// </h>
...
...
main_fw/src/main.c
View file @
ccdc2e6e
...
...
@@ -38,6 +38,24 @@ void jump_to_mockbl()
asm
(
"bx %0"
::
"r"
(
app_start_address
));
}
static
struct
io_descriptor
*
io
;
static
void
I2C_0_rx_complete
(
const
struct
i2c_s_async_descriptor
*
const
descr
)
{
uint8_t
c
;
io_read
(
io
,
&
c
,
1
);
debug
(
"got character %c"
,
c
);
delay_ms
(
10
);
}
void
I2C_0_example
(
void
)
{
i2c_s_async_get_io_descriptor
(
&
I2C_0
,
&
io
);
i2c_s_async_register_callback
(
&
I2C_0
,
I2C_S_RX_COMPLETE
,
I2C_0_rx_complete
);
i2c_s_async_enable
(
&
I2C_0
);
}
int
main
(
void
)
{
/* Initializes MCU, drivers and middleware */
...
...
@@ -52,6 +70,8 @@ int main(void)
uint16_t
checksum
;
checksum
=
comp_sysv_checksum
();
I2C_0_example
();
/* Replace with your application code */
while
(
1
)
{
delay_ms
(
500
);
...
...
@@ -59,14 +79,14 @@ 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
);
debug
(
"
slave
iter %d, temp=%.1f"
,
i
/
2
,
adc_temp
);
}
if
(
i
==
10
)
{
usbdc_detach
();
usbdc_stop
();
usbdc_deinit
();
/* if (i == 10) { */
/* usbdc_detach (); */
/* usbdc_stop (); */
/* usbdc_deinit (); */
jump_to_mockbl
();
}
/* jump_to_mockbl(); */
/* } */
}
}
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