forked from Yona-Appletree/LEDscape
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pru.h
executable file
·73 lines (58 loc) · 1.38 KB
/
pru.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/** \file
* Simplified interface to the ARM PRU.
*
*/
#ifndef _pru_h_
#define _pru_h_
#include <stdio.h>
#include <inttypes.h>
#include "util.h"
/** Mapping of the PRU memory spaces.
*
* The PRU has a small, fast local data RAM that is mapped into ARM memory,
* as well as slower access to the DDR RAM of the ARM.
*/
typedef struct
{
unsigned pru_num;
void * data_ram; // PRU data ram in ARM space
size_t data_ram_size; // size in bytes of the PRU's data RAM
void * ddr; // PRU DMA address (in ARM space)
uintptr_t ddr_addr; // PRU DMA address (in PRU space)
size_t ddr_size; // Size in bytes of the shared space
} pru_t;
extern pru_t *
pru_init(
const unsigned short pru_num
);
extern void
pru_exec(
pru_t * const pru,
const char * const program
);
extern void
pru_close(
pru_t * const pru
);
/**
* Await an interrupt from one of the PRUs. Note that as far as I can tell, we have not way of telling
* which PRU an interrupt comes from; we only receive them on the EVTOUT_NUM passed to prussdrv_open()
*/
extern void
pru_wait_interrupt();
/** Configure a GPIO pin.
*
* Since the device tree won't do it for us, we need to do it via
* /sys/class/gpio to set the direction and initial value for
* all of the pins that we use.
*
* Direction 0 == in, 1 == out.
*/
extern int
pru_gpio(
unsigned gpio,
unsigned pin,
unsigned direction,
const unsigned initial_value
);
#endif