Mercurial > hg > beaglert
comparison include/PRU.h @ 0:8a575ba3ab52
Initial commit.
author | andrewm |
---|---|
date | Fri, 31 Oct 2014 19:10:17 +0100 |
parents | |
children | a6beeba3a648 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8a575ba3ab52 |
---|---|
1 /* | |
2 * PRU.h | |
3 * | |
4 * Created on: May 27, 2014 | |
5 * Author: andrewm | |
6 */ | |
7 | |
8 #ifndef PRU_H_ | |
9 #define PRU_H_ | |
10 | |
11 #include <stdint.h> | |
12 | |
13 class PRU | |
14 { | |
15 private: | |
16 static const unsigned int kPruGPIODACSyncPin; | |
17 static const unsigned int kPruGPIOADCSyncPin; | |
18 static const unsigned int kPruGPIOTestPin; | |
19 static const unsigned int kPruGPIOTestPin2; | |
20 static const unsigned int kPruGPIOTestPin3; | |
21 | |
22 public: | |
23 // Constructor | |
24 PRU(); | |
25 | |
26 // Destructor | |
27 ~PRU(); | |
28 | |
29 // Prepare the GPIO pins needed for the PRU | |
30 int prepareGPIO(int use_spi, int include_test_pin, int include_led); | |
31 | |
32 // Clean up the GPIO at the end | |
33 void cleanupGPIO(); | |
34 | |
35 // Initialise and open the PRU | |
36 int initialise(int pru_num, int frames_per_buffer, bool xenomai_test_pin = false); | |
37 | |
38 // Run the code image in the specified file | |
39 int start(char * const filename); | |
40 | |
41 // Loop: read and write data from the PRU | |
42 void loop(); | |
43 | |
44 // Wait for an interrupt from the PRU indicate it is finished | |
45 void waitForFinish(); | |
46 | |
47 // Turn off the PRU when done | |
48 void disable(); | |
49 | |
50 // For debugging: | |
51 void setGPIOTestPin(); | |
52 void clearGPIOTestPin(); | |
53 | |
54 private: | |
55 int pru_number; // Which PRU we use | |
56 bool running; // Whether the PRU is running | |
57 bool spi_enabled; // Whether SPI ADC and DAC are used | |
58 bool gpio_enabled; // Whether GPIO has been prepared | |
59 bool led_enabled; // Whether a user LED is enabled | |
60 bool gpio_test_pin_enabled; // Whether the test pin was also enabled | |
61 | |
62 volatile uint32_t *pru_buffer_comm; | |
63 uint16_t *pru_buffer_spi_dac; | |
64 uint16_t *pru_buffer_spi_adc; | |
65 int16_t *pru_buffer_audio_dac; | |
66 int16_t *pru_buffer_audio_adc; | |
67 unsigned int spi_buffer_frames; | |
68 unsigned int audio_buffer_frames; | |
69 | |
70 int xenomai_gpio_fd; // File descriptor for /dev/mem for fast GPIO | |
71 uint32_t *xenomai_gpio; // Pointer to GPIO registers | |
72 }; | |
73 | |
74 | |
75 #endif /* PRU_H_ */ |