comparison include/PRU.h @ 45:579c86316008 newapi

Major API overhaul. Moved to a single data structure for handling render functions. Functionally, generally similar except for scheduling within PRU loop function, which now uses interrupts from the PRU rather than polling. This requires an updated kernel.
author andrewm
date Thu, 28 May 2015 14:35:55 -0400
parents c98863e63174
children 92145ba7aabf
comparison
equal deleted inserted replaced
40:419ce4ebfc4c 45:579c86316008
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 use_digital, 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(char * const filename); 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
59 bool digital_enabled; // Whether digital is used 63 bool digital_enabled; // Whether digital is used
60 bool gpio_enabled; // Whether GPIO has been prepared 64 bool gpio_enabled; // Whether GPIO has been prepared
61 bool led_enabled; // Whether a user LED is enabled 65 bool led_enabled; // Whether a user LED is enabled
62 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
63 int spi_num_channels; // How many channels to use for SPI ADC/DAC
64 67
65 volatile uint32_t *pru_buffer_comm; 68 volatile uint32_t *pru_buffer_comm;
66 uint16_t *pru_buffer_spi_dac; 69 uint16_t *pru_buffer_spi_dac;
67 uint16_t *pru_buffer_spi_adc; 70 uint16_t *pru_buffer_spi_adc;
68 uint32_t *pru_buffer_digital; 71 uint32_t *pru_buffer_digital;
69 int16_t *pru_buffer_audio_dac; 72 int16_t *pru_buffer_audio_dac;
70 int16_t *pru_buffer_audio_adc; 73 int16_t *pru_buffer_audio_adc;
71 unsigned int spi_buffer_frames;
72 unsigned int digital_buffer_frames;
73 unsigned int audio_buffer_frames;
74 74
75 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
76 uint32_t *xenomai_gpio; // Pointer to GPIO registers 76 uint32_t *xenomai_gpio; // Pointer to GPIO registers
77 }; 77 };
78 78