forked from toroidal-code/PixelBone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pru.h
52 lines (42 loc) · 1.22 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
/** \file
* Simplified interface to the ARM PRU.
*
*/
#ifndef _pru_h_
#define _pru_h_
#ifdef __cplusplus
extern "C" {
#endif
#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);
/** 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);
#ifdef __cplusplus
}
#endif
#endif