diff 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
line wrap: on
line diff
--- a/include/PRU.h	Mon Jun 08 01:07:48 2015 +0100
+++ b/include/PRU.h	Tue Aug 18 00:35:15 2015 +0100
@@ -9,8 +9,9 @@
 #define PRU_H_
 
 #include <stdint.h>
-#include "../include/RTAudio.h"	// to schedule lower prio parallel process
-#include "../include/intervals.h"
+#include <native/intr.h>
+#include "../include/BeagleRT.h"
+
 class PRU
 {
 private:
@@ -22,26 +23,26 @@
 
 public:
 	// Constructor
-	PRU();
+	PRU(BeagleRTContext *input_context);
 
 	// Destructor
 	~PRU();
 
 	// Prepare the GPIO pins needed for the PRU
-	int prepareGPIO(int use_spi, int use_digital, int include_test_pin, int include_led);
+	int prepareGPIO(int include_test_pin, int include_led);
 
 	// Clean up the GPIO at the end
 	void cleanupGPIO();
 
 	// Initialise and open the PRU
-	int initialise(int pru_num, int frames_per_buffer, int spi_channels,
-				   bool xenomai_test_pin = false);
+	int initialise(int pru_num, int frames_per_buffer,
+				   int spi_channels, bool xenomai_test_pin = false);
 
 	// Run the code image in pru_rtaudio_bin.h
 	int start(char * const filename);
 
 	// Loop: read and write data from the PRU
-	void loop();
+	void loop(RT_INTR *pru_interrupt, void *userData);
 
 	// Wait for an interrupt from the PRU indicate it is finished
 	void waitForFinish();
@@ -52,19 +53,17 @@
 	// For debugging:
 	void setGPIOTestPin();
 	void clearGPIOTestPin();
-	Interval renderTimer;
-	Interval sleepTimer;
-	AuxiliaryTask printIntervalsTask;
 
 private:
+	BeagleRTContext *context;	// Overall settings
+
 	int pru_number;		// Which PRU we use
 	bool running;		// Whether the PRU is running
-	bool spi_enabled;	// Whether SPI ADC and DAC are used
+	bool analog_enabled;  // Whether SPI ADC and DAC are used
 	bool digital_enabled; // Whether digital is used
 	bool gpio_enabled;	// Whether GPIO has been prepared
 	bool led_enabled;	// Whether a user LED is enabled
 	bool gpio_test_pin_enabled; // Whether the test pin was also enabled
-	int spi_num_channels; // How many channels to use for SPI ADC/DAC
 
 	volatile uint32_t *pru_buffer_comm;
 	uint16_t *pru_buffer_spi_dac;
@@ -72,13 +71,12 @@
 	uint32_t *pru_buffer_digital;
 	int16_t *pru_buffer_audio_dac;
 	int16_t *pru_buffer_audio_adc;
-	unsigned int spi_buffer_frames;
-	unsigned int digital_buffer_frames;
-	unsigned int audio_buffer_frames;
+
+	float *last_analog_out_frame;
+	uint32_t *digital_buffer0, *digital_buffer1, *last_digital_buffer;
 
 	int xenomai_gpio_fd;	// File descriptor for /dev/mem for fast GPIO
 	uint32_t *xenomai_gpio;	// Pointer to GPIO registers
-
 };