Mercurial > hg > beaglert
comparison include/PRU.h @ 108:3068421c0737 ultra-staging
Merged default into ultra-staging
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 18 Aug 2015 00:35:15 +0100 |
parents | 4255ecbb9bec 92145ba7aabf |
children |
comparison
equal
deleted
inserted
replaced
54:d3f869b98147 | 108:3068421c0737 |
---|---|
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 "../include/RTAudio.h" // to schedule lower prio parallel process | 12 #include <native/intr.h> |
13 #include "../include/intervals.h" | 13 #include "../include/BeagleRT.h" |
14 | |
14 class PRU | 15 class PRU |
15 { | 16 { |
16 private: | 17 private: |
17 static const unsigned int kPruGPIODACSyncPin; | 18 static const unsigned int kPruGPIODACSyncPin; |
18 static const unsigned int kPruGPIOADCSyncPin; | 19 static const unsigned int kPruGPIOADCSyncPin; |
20 static const unsigned int kPruGPIOTestPin2; | 21 static const unsigned int kPruGPIOTestPin2; |
21 static const unsigned int kPruGPIOTestPin3; | 22 static const unsigned int kPruGPIOTestPin3; |
22 | 23 |
23 public: | 24 public: |
24 // Constructor | 25 // Constructor |
25 PRU(); | 26 PRU(BeagleRTContext *input_context); |
26 | 27 |
27 // Destructor | 28 // Destructor |
28 ~PRU(); | 29 ~PRU(); |
29 | 30 |
30 // Prepare the GPIO pins needed for the PRU | 31 // Prepare the GPIO pins needed for the PRU |
31 int prepareGPIO(int use_spi, int use_digital, int include_test_pin, int include_led); | 32 int prepareGPIO(int include_test_pin, int include_led); |
32 | 33 |
33 // Clean up the GPIO at the end | 34 // Clean up the GPIO at the end |
34 void cleanupGPIO(); | 35 void cleanupGPIO(); |
35 | 36 |
36 // Initialise and open the PRU | 37 // Initialise and open the PRU |
37 int initialise(int pru_num, int frames_per_buffer, int spi_channels, | 38 int initialise(int pru_num, int frames_per_buffer, |
38 bool xenomai_test_pin = false); | 39 int spi_channels, bool xenomai_test_pin = false); |
39 | 40 |
40 // Run the code image in pru_rtaudio_bin.h | 41 // Run the code image in pru_rtaudio_bin.h |
41 int start(char * const filename); | 42 int start(char * const filename); |
42 | 43 |
43 // Loop: read and write data from the PRU | 44 // Loop: read and write data from the PRU |
44 void loop(); | 45 void loop(RT_INTR *pru_interrupt, void *userData); |
45 | 46 |
46 // Wait for an interrupt from the PRU indicate it is finished | 47 // Wait for an interrupt from the PRU indicate it is finished |
47 void waitForFinish(); | 48 void waitForFinish(); |
48 | 49 |
49 // Turn off the PRU when done | 50 // Turn off the PRU when done |
50 void disable(); | 51 void disable(); |
51 | 52 |
52 // For debugging: | 53 // For debugging: |
53 void setGPIOTestPin(); | 54 void setGPIOTestPin(); |
54 void clearGPIOTestPin(); | 55 void clearGPIOTestPin(); |
55 Interval renderTimer; | |
56 Interval sleepTimer; | |
57 AuxiliaryTask printIntervalsTask; | |
58 | 56 |
59 private: | 57 private: |
58 BeagleRTContext *context; // Overall settings | |
59 | |
60 int pru_number; // Which PRU we use | 60 int pru_number; // Which PRU we use |
61 bool running; // Whether the PRU is running | 61 bool running; // Whether the PRU is running |
62 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 | 63 bool digital_enabled; // Whether digital is used |
64 bool gpio_enabled; // Whether GPIO has been prepared | 64 bool gpio_enabled; // Whether GPIO has been prepared |
65 bool led_enabled; // Whether a user LED is enabled | 65 bool led_enabled; // Whether a user LED is enabled |
66 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 |
67 int spi_num_channels; // How many channels to use for SPI ADC/DAC | |
68 | 67 |
69 volatile uint32_t *pru_buffer_comm; | 68 volatile uint32_t *pru_buffer_comm; |
70 uint16_t *pru_buffer_spi_dac; | 69 uint16_t *pru_buffer_spi_dac; |
71 uint16_t *pru_buffer_spi_adc; | 70 uint16_t *pru_buffer_spi_adc; |
72 uint32_t *pru_buffer_digital; | 71 uint32_t *pru_buffer_digital; |
73 int16_t *pru_buffer_audio_dac; | 72 int16_t *pru_buffer_audio_dac; |
74 int16_t *pru_buffer_audio_adc; | 73 int16_t *pru_buffer_audio_adc; |
75 unsigned int spi_buffer_frames; | 74 |
76 unsigned int digital_buffer_frames; | 75 float *last_analog_out_frame; |
77 unsigned int audio_buffer_frames; | 76 uint32_t *digital_buffer0, *digital_buffer1, *last_digital_buffer; |
78 | 77 |
79 int xenomai_gpio_fd; // File descriptor for /dev/mem for fast GPIO | 78 int xenomai_gpio_fd; // File descriptor for /dev/mem for fast GPIO |
80 uint32_t *xenomai_gpio; // Pointer to GPIO registers | 79 uint32_t *xenomai_gpio; // Pointer to GPIO registers |
81 | |
82 }; | 80 }; |
83 | 81 |
84 | 82 |
85 #endif /* PRU_H_ */ | 83 #endif /* PRU_H_ */ |