Skip to content

Commit

Permalink
Added rpmsg examples
Browse files Browse the repository at this point in the history
  • Loading branch information
VedantParanjape committed Jul 17, 2020
1 parent 218af00 commit 079c59c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
11 changes: 11 additions & 0 deletions examples/button_click_rpmsg.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
init_message_channel();

while : true {
if : digital_read(6) {
send_message(1);
}
else {
send_message(0);
}
delay(100);
}
16 changes: 8 additions & 8 deletions examples/hcsr04_example_rpmsg.sim
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
def measure : int : {
bool timeout := false;
int echo := 0;
int echo := -1;

start_counter();

while : read_counter() <= 2000 {
digital_write(7, true);
digital_write(5, true);
}
digital_write(7, false);
digital_write(5, false);
stop_counter();

start_counter();
while : not (digital_read(1)) and true {
while : not (digital_read(6)) and true {
if : read_counter() > 200000000 {
timeout := true;
break;
Expand All @@ -21,7 +21,7 @@ def measure : int : {

if : not(timeout) and true {
start_counter();
while : digital_read(1) and true {
while : digital_read(6) and true {
if : read_counter() > 200000000 {
timeout := true;
break;
Expand All @@ -38,11 +38,11 @@ def measure : int : {
return echo;
}

init_message_channel();

while : true {
int ping:= measure()*1000;
init_message_channel();
int ping:= measure();

send_message(ping);

delay(1000);
}

0 comments on commit 079c59c

Please sign in to comment.