![]() |
PRU User Space API
v1.0.0
An API to control the BeagleBone PRUs using the RemoteProc and RPMsg framework.
|
#include <pruss.h>
Public Member Functions | |
int | enable () |
Enable the PRU. More... | |
int | disable () |
Disable the PRU. More... | |
int | reset () |
Reset the PRU. More... | |
int | pause () |
Pause the PRU execution. More... | |
int | resume () |
Resume PRU execution in single step mode. More... | |
std::string | showRegs () |
Show PRU register values. More... | |
int | load (std::string) |
Install compiled firmware to the PRU. More... | |
void | setChannel () |
Set the RPMsg communication channel according to the "pruss_api" driver. More... | |
int | setChannel (int, std::string) |
State | getState () |
Get the current state of the PRU object. More... | |
int | sendMsg_string (std::string) |
Send a message to PRU in the form of characters. More... | |
void | sendMsg_raw (std::string) |
Send a raw integer value to PRU. More... | |
std::string | getMsg () |
Receive message from PRU. More... | |
int | waitForEvent () |
Wait till an event occurs at the RPMsg channel of the given PRU. More... | |
int | waitForEvent (int) |
Wait till an event occurs at the RPMsg channel of the given PRU. More... | |
std::string | mem_read (Memory mem, std::string) |
Read from PRU SRAM/DRAM0/DRAM1. More... | |
std::string | mem_write (Memory mem, std::string, std::string) |
Write to PRU SRAM/DRAM0/DRAM1. More... | |
Friends | |
class | PRUSS |
class PRU
int PRU::disable | ( | ) |
int PRU::enable | ( | ) |
string PRU::getMsg | ( | ) |
State PRU::getState | ( | ) |
int PRU::load | ( | std::string | ) |
Install compiled firmware to the PRU.
Installs compiled PRU firmware by copying it into /lib/firmware and echoing the name of the elf file into /sys/class/remoteproc/remoteprocN/firmware
fw | is the relative path/absolute path to the firmware that is to be loaded to the PRU. |
string PRU::mem_read | ( | Memory | mem, |
std::string | |||
) |
Read from PRU SRAM/DRAM0/DRAM1.
Read a 1-byte integer value from the PRU memory block specified in the parameter. The 1-byte integer value will be read as a string.
mem | describes which PRU memory block is to be used from the enumeration Memory. |
offset | sets the address offset for the memory block. |
string PRU::mem_write | ( | Memory | mem, |
std::string | , | ||
std::string | |||
) |
Write to PRU SRAM/DRAM0/DRAM1.
Write a 1-byte integer value to the PRU memory block specified in the parameter. The 1-byte integer value must be specified as a string.
mem | describes which PRU memory block is to be used from the enumeration Memory. |
offset | sets the address offset for the memory block. |
data | the integer data that needs to be written to that address offset. |
int PRU::pause | ( | ) |
Pause the PRU execution.
This function pauses the PRU execution in such a way that the execution can be resumed from the same point where it stopped. (This is not the case when echoing stop
into /sys/class/remoteproc/remoteprocN because then the PRU would have to re start from its first instruction)
The PRU is paused by echoing '1' into /sys/kernel/debug/remoteproc/remoteprocN/single_step
int PRU::reset | ( | ) |
Reset the PRU.
Completely stops the PRU execution and starts again from first instruction.
int PRU::resume | ( | ) |
void PRU::sendMsg_raw | ( | std::string | ) |
Send a raw integer value to PRU.
It is difficult to reconstruct data on the PRU side if data is sent as a string. This is because the PRU compilers have limited memory and can't perform string operations.
Sending data in raw form makes it easier for it to be reconstructed on the PRU side.
message | string representing 1-byte integer that needs to be passed to the PRU. The string will be converted to integer once passed to the daemon. |
int PRU::sendMsg_string | ( | std::string | ) |
Send a message to PRU in the form of characters.
Send a string of characters through pruss_api_pruN to the PRUN of maximum length of 496 bytes (512 limit - 16 header size) The firmware that uses RPMsg MUST be running so that the communication channel is created.
message | of not more than 496 characters. |
void PRU::setChannel | ( | ) |
Set the RPMsg communication channel according to the "pruss_api" driver.
This driver creates "pruss_api_pru0" channel for PRU0 and "pruss_api_pru1" for PRU1.
chanPort maps to which PRU object is being used. chanName specifies the channel name that is common for both the PRUs.
string PRU::showRegs | ( | ) |
int PRU::waitForEvent | ( | ) |
Wait till an event occurs at the RPMsg channel of the given PRU.
Waits indefinitely on the RPMsg channel pruss_api_pruN in /dev until an event occurs.
int PRU::waitForEvent | ( | int | time | ) |
Wait till an event occurs at the RPMsg channel of the given PRU.
Waits on the RPMsg channel pruss_api_pruN in /dev until an event occurs within the specified time limit.
time | integer that specifies for how much time to wait for any event before returning. |