-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9f7991
commit 0ca1fa9
Showing
17 changed files
with
424 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
# Sending state of button using RPMSG | ||
# Sending state of button using RPMSG | ||
|
||
!!! info "Schematic" | ||
=== "Pocket Beagle" | ||
 | ||
|
||
=== "BeagleBone Black / Beagle Bone Black Wireless" | ||
 | ||
|
||
## Code | ||
|
||
```python | ||
init_message_channel(); | ||
|
||
while : true { | ||
if : digital_read(P1_29) { | ||
send_message(1); | ||
} | ||
else { | ||
send_message(0); | ||
} | ||
delay(100); | ||
} | ||
``` | ||
|
||
* Following code works on PocketBeagle, to use on other boards, please change the pins accordingly. | ||
|
||
## Explaination | ||
|
||
`init_message_channel` is needed to setup communication channel between ARM<->PRU. It only needs to be called once, before using RPMSG functions. | ||
|
||
`while : true` loop runs endlessly, inside this, we check for value of header pin P1_29, if it reads HIGH, 1 is sent to the ARM core using `send_message` and if it is LOW, 0 is sent to ARM core using `send_message`. Then PRU waits for 100ms, and repeats the steps again and again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,65 @@ | ||
# HCSR04 Distance Sensor example (sending distance data to ARM using RPMSG) | ||
|
||
!!! info "Schematic" | ||
=== "Pocket Beagle" | ||
 | ||
|
||
=== "BeagleBone Black / Beagle Bone Black Wireless" | ||
 | ||
|
||
## Code | ||
|
||
```python | ||
def measure : int : { | ||
bool timeout := false; | ||
int echo := -1; | ||
|
||
start_counter(); | ||
|
||
while : read_counter() <= 2000 { | ||
digital_write(5, true); | ||
} | ||
digital_write(5, false); | ||
stop_counter(); | ||
|
||
start_counter(); | ||
while : not (digital_read(6)) and true { | ||
if : read_counter() > 200000000 { | ||
timeout := true; | ||
break; | ||
} | ||
} | ||
stop_counter(); | ||
|
||
if : not(timeout) and true { | ||
start_counter(); | ||
while : digital_read(6) and true { | ||
if : read_counter() > 200000000 { | ||
timeout := true; | ||
break; | ||
} | ||
echo := read_counter(); | ||
} | ||
stop_counter(); | ||
} | ||
|
||
if : timeout and true { | ||
echo := 0; | ||
} | ||
|
||
return echo; | ||
} | ||
|
||
init_message_channel(); | ||
|
||
while : true { | ||
int ping:= measure(); | ||
|
||
send_message(ping); | ||
delay(1000); | ||
} | ||
``` | ||
|
||
* Following code works on PocketBeagle, to use on other boards, please change the pins accordingly. | ||
|
||
## Explaination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.