PRU User Space API  v1.0.0
An API to control the BeagleBone PRUs using the RemoteProc and RPMsg framework.
pruss.h
1 #ifndef PRUSS_H_
2 #define PRUSS_H_
3 
4 #include <stdlib.h>
5 #include <linux/limits.h> // realpath
6 #include <string> // string handling
7 #include <sys/socket.h> // socket
8 #include <sys/un.h> // socket
9 #include <unistd.h> // close()
10 #include <errno.h> // error codes
11 
12 //enumeration which describes the states of a PRU Core
13 enum State
14 {
15  NONE,
16  STOPPED,
17  RUNNING,
18  HALTED
19 };
20 
21 //enumeration which describes which memory access is required
22 enum Memory
23 {
24  DATA0 = 0,
25  DATA1 = 1,
26  SHARED = 3
27 };
28 
32 class Socket
33 {
34  private:
35  const char* socketpath;
36  struct sockaddr_un addr;
37  int fd;
38  Socket();
39  bool conn();
40  bool disconn();
41  std::string sendcmd(std::string);
42  friend class PRUSS; //Only these classes have access to the Socket class
43  friend class PRU; //Only these classes have access to the Socket class
44 };
45 
49 class PRU
50 {
51  private:
52  int number;
53  int chanPort;
54  std::string chanName;
55  Socket sock;
56  State state = NONE;
57  PRU(int);
58  PRU(int, std::string);
59  friend class PRUSS; //Only PRUSS class can call the PRU class constructors
60  public:
61  int enable();
62  int disable();
63  int reset();
64  int pause();
65  int resume();
66  std::string showRegs();
67  int load(std::string);
68  void setChannel();
69  int setChannel(int, std::string);
70  State getState();
71  int sendMsg_string(std::string);
72  void sendMsg_raw(std::string);
73  std::string getMsg();
74  int waitForEvent();
75  int waitForEvent(int);
76  std::string mem_read(Memory mem, std::string);
77  std::string mem_write(Memory mem, std::string, std::string);
78 };
79 
83 class PRUSS
84 {
85  private:
86  bool on = false;
87  Socket sock;
88  PRUSS();
89  ~PRUSS();
90  public:
91  static PRUSS& get();
92  PRU pru0;
93  PRU pru1;
94  bool isOn();
95  int bootUp();
96  int shutDown();
97  void restart();
98 
99 };
100 #endif
class Socket
Definition: pruss.h:32
class PRU
Definition: pruss.h:49
class PRUSS
Definition: pruss.h:83