Mercurial > hg > beaglert
comparison include/PRU.h @ 67:472e892c6e41
Merge newapi into default
author | Andrew McPherson <a.mcpherson@qmul.ac.uk> |
---|---|
date | Fri, 17 Jul 2015 15:28:18 +0100 |
parents | 579c86316008 |
children | 92145ba7aabf |
comparison
equal
deleted
inserted
replaced
21:0d80ff9e2227 | 67:472e892c6e41 |
---|---|
7 | 7 |
8 #ifndef PRU_H_ | 8 #ifndef PRU_H_ |
9 #define PRU_H_ | 9 #define PRU_H_ |
10 | 10 |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 #include <native/intr.h> | |
13 #include "../include/BeagleRT.h" | |
12 | 14 |
13 class PRU | 15 class PRU |
14 { | 16 { |
15 private: | 17 private: |
16 static const unsigned int kPruGPIODACSyncPin; | 18 static const unsigned int kPruGPIODACSyncPin; |
19 static const unsigned int kPruGPIOTestPin2; | 21 static const unsigned int kPruGPIOTestPin2; |
20 static const unsigned int kPruGPIOTestPin3; | 22 static const unsigned int kPruGPIOTestPin3; |
21 | 23 |
22 public: | 24 public: |
23 // Constructor | 25 // Constructor |
24 PRU(); | 26 PRU(BeagleRTContext *input_context); |
25 | 27 |
26 // Destructor | 28 // Destructor |
27 ~PRU(); | 29 ~PRU(); |
28 | 30 |
29 // Prepare the GPIO pins needed for the PRU | 31 // Prepare the GPIO pins needed for the PRU |
30 int prepareGPIO(int use_spi, int include_test_pin, int include_led); | 32 int prepareGPIO(int include_test_pin, int include_led); |
31 | 33 |
32 // Clean up the GPIO at the end | 34 // Clean up the GPIO at the end |
33 void cleanupGPIO(); | 35 void cleanupGPIO(); |
34 | 36 |
35 // Initialise and open the PRU | 37 // Initialise and open the PRU |
36 int initialise(int pru_num, int frames_per_buffer, int spi_channels, | 38 int initialise(int pru_num, int frames_per_buffer, |
37 bool xenomai_test_pin = false); | 39 int spi_channels, bool xenomai_test_pin = false); |
38 | 40 |
39 // Run the code image in pru_rtaudio_bin.h | 41 // Run the code image in pru_rtaudio_bin.h |
40 int start(); | 42 int start(char * const filename); |
41 | 43 |
42 // Loop: read and write data from the PRU | 44 // Loop: read and write data from the PRU |
43 void loop(); | 45 void loop(RT_INTR *pru_interrupt, void *userData); |
44 | 46 |
45 // Wait for an interrupt from the PRU indicate it is finished | 47 // Wait for an interrupt from the PRU indicate it is finished |
46 void waitForFinish(); | 48 void waitForFinish(); |
47 | 49 |
48 // Turn off the PRU when done | 50 // Turn off the PRU when done |
51 // For debugging: | 53 // For debugging: |
52 void setGPIOTestPin(); | 54 void setGPIOTestPin(); |
53 void clearGPIOTestPin(); | 55 void clearGPIOTestPin(); |
54 | 56 |
55 private: | 57 private: |
58 BeagleRTContext *context; // Overall settings | |
59 | |
56 int pru_number; // Which PRU we use | 60 int pru_number; // Which PRU we use |
57 bool running; // Whether the PRU is running | 61 bool running; // Whether the PRU is running |
58 bool spi_enabled; // Whether SPI ADC and DAC are used | 62 bool analog_enabled; // Whether SPI ADC and DAC are used |
63 bool digital_enabled; // Whether digital is used | |
59 bool gpio_enabled; // Whether GPIO has been prepared | 64 bool gpio_enabled; // Whether GPIO has been prepared |
60 bool led_enabled; // Whether a user LED is enabled | 65 bool led_enabled; // Whether a user LED is enabled |
61 bool gpio_test_pin_enabled; // Whether the test pin was also enabled | 66 bool gpio_test_pin_enabled; // Whether the test pin was also enabled |
62 int spi_num_channels; // How many channels to use for SPI ADC/DAC | |
63 | 67 |
64 volatile uint32_t *pru_buffer_comm; | 68 volatile uint32_t *pru_buffer_comm; |
65 uint16_t *pru_buffer_spi_dac; | 69 uint16_t *pru_buffer_spi_dac; |
66 uint16_t *pru_buffer_spi_adc; | 70 uint16_t *pru_buffer_spi_adc; |
71 uint32_t *pru_buffer_digital; | |
67 int16_t *pru_buffer_audio_dac; | 72 int16_t *pru_buffer_audio_dac; |
68 int16_t *pru_buffer_audio_adc; | 73 int16_t *pru_buffer_audio_adc; |
69 unsigned int spi_buffer_frames; | |
70 unsigned int audio_buffer_frames; | |
71 | 74 |
72 int xenomai_gpio_fd; // File descriptor for /dev/mem for fast GPIO | 75 int xenomai_gpio_fd; // File descriptor for /dev/mem for fast GPIO |
73 uint32_t *xenomai_gpio; // Pointer to GPIO registers | 76 uint32_t *xenomai_gpio; // Pointer to GPIO registers |
74 }; | 77 }; |
75 | 78 |