Robot Control Library
pru.h
Go to the documentation of this file.
1/**
2 * <rc/pru.h>
3 *
4 * @brief Start and stop the PRU from userspace.
5 *
6 * This is primarily for the PRU-dependent servo and encoder functions to use,
7 * however the user may elect to use their own PRU routines separately from
8 * those.
9 *
10 * @addtogroup PRU
11 * @{
12 */
13
14#ifndef RC_PRU_H
15#define RC_PRU_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <stdint.h>
22
23/**
24 * Starts a single specified PRU core running a provided firmware name.
25 *
26 * This function requires root privileges and your custom firmware must exist in
27 * "/lib/firmware/". The default name for the two firmwares are "am335x-pru0-fw"
28 * and "am335x-pru1-fw", please don't overwrite these if they exist. Name your
29 * firmware image something like "am335x-pru0-mycustom-fw".
30 *
31 * @param[in] ch pru core to start (0 or 1)
32 * @param[in] fw_name The firmware image name, e.g. "am335x-pru0-fw", do not
33 * include '/lib/firmware' in the path, only the file name.
34 *
35 * @return 0 on success, -1 on failure.
36 */
37int rc_pru_start(int ch, const char* fw_name);
38
39/**
40 * @brief fetches a pointer to the beginning of the PRU shared memory.
41 *
42 * This is done by mapping to /dev/mem and therefore requires root privileges
43 * but provides extremely low-latency memory access to communicate with the PRU.
44 *
45 * @return memory pointer on success, NULL on failure
46 */
47volatile uint32_t* rc_pru_shared_mem_ptr(void);
48
49
50/**
51 * Unloads pru binaries
52 *
53 * @param[in] ch pru core to stop (0 or 1)
54 *
55 * @return 0 on success, -1 on failure.
56 */
57int rc_pru_stop(int ch);
58
59
60#ifdef __cplusplus
61}
62#endif
63
64#endif // RC_PRU_H
65
66/** @} end group PRU */
int rc_pru_stop(int ch)
volatile uint32_t * rc_pru_shared_mem_ptr(void)
fetches a pointer to the beginning of the PRU shared memory.
int rc_pru_start(int ch, const char *fw_name)