annotate include/PRU.h @ 151:e9c9404e3d1f ClockSync

Pff partially working. No PID. When setting the audio clock on the bbb to 44098 the master and slave clock keep diverging instead of converging ...
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 22 Sep 2015 04:10:07 +0100
parents 3068421c0737
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 * PRU.h
andrewm@0 3 *
andrewm@0 4 * Created on: May 27, 2014
andrewm@0 5 * Author: andrewm
andrewm@0 6 */
andrewm@0 7
andrewm@0 8 #ifndef PRU_H_
andrewm@0 9 #define PRU_H_
andrewm@0 10
andrewm@0 11 #include <stdint.h>
andrewm@45 12 #include <native/intr.h>
andrewm@45 13 #include "../include/BeagleRT.h"
andrewm@0 14
andrewm@0 15 class PRU
andrewm@0 16 {
andrewm@0 17 private:
andrewm@0 18 static const unsigned int kPruGPIODACSyncPin;
andrewm@0 19 static const unsigned int kPruGPIOADCSyncPin;
andrewm@0 20 static const unsigned int kPruGPIOTestPin;
andrewm@0 21 static const unsigned int kPruGPIOTestPin2;
andrewm@0 22 static const unsigned int kPruGPIOTestPin3;
andrewm@0 23
andrewm@0 24 public:
andrewm@0 25 // Constructor
andrewm@45 26 PRU(BeagleRTContext *input_context);
andrewm@0 27
andrewm@0 28 // Destructor
andrewm@0 29 ~PRU();
andrewm@0 30
andrewm@0 31 // Prepare the GPIO pins needed for the PRU
andrewm@45 32 int prepareGPIO(int include_test_pin, int include_led);
andrewm@0 33
andrewm@0 34 // Clean up the GPIO at the end
andrewm@0 35 void cleanupGPIO();
andrewm@0 36
andrewm@0 37 // Initialise and open the PRU
andrewm@45 38 int initialise(int pru_num, int frames_per_buffer,
andrewm@45 39 int spi_channels, bool xenomai_test_pin = false);
andrewm@0 40
andrewm@15 41 // Run the code image in pru_rtaudio_bin.h
giuliomoro@16 42 int start(char * const filename);
andrewm@0 43
andrewm@0 44 // Loop: read and write data from the PRU
andrewm@45 45 void loop(RT_INTR *pru_interrupt, void *userData);
andrewm@0 46
andrewm@0 47 // Wait for an interrupt from the PRU indicate it is finished
andrewm@0 48 void waitForFinish();
andrewm@0 49
andrewm@0 50 // Turn off the PRU when done
andrewm@0 51 void disable();
andrewm@0 52
andrewm@0 53 // For debugging:
andrewm@0 54 void setGPIOTestPin();
andrewm@0 55 void clearGPIOTestPin();
andrewm@0 56
andrewm@0 57 private:
andrewm@45 58 BeagleRTContext *context; // Overall settings
andrewm@45 59
andrewm@0 60 int pru_number; // Which PRU we use
andrewm@0 61 bool running; // Whether the PRU is running
andrewm@45 62 bool analog_enabled; // Whether SPI ADC and DAC are used
giuliomoro@19 63 bool digital_enabled; // Whether digital is used
andrewm@0 64 bool gpio_enabled; // Whether GPIO has been prepared
andrewm@0 65 bool led_enabled; // Whether a user LED is enabled
andrewm@0 66 bool gpio_test_pin_enabled; // Whether the test pin was also enabled
andrewm@0 67
andrewm@0 68 volatile uint32_t *pru_buffer_comm;
andrewm@0 69 uint16_t *pru_buffer_spi_dac;
andrewm@0 70 uint16_t *pru_buffer_spi_adc;
giuliomoro@19 71 uint32_t *pru_buffer_digital;
andrewm@0 72 int16_t *pru_buffer_audio_dac;
andrewm@0 73 int16_t *pru_buffer_audio_adc;
andrewm@0 74
andrewm@81 75 float *last_analog_out_frame;
andrewm@81 76 uint32_t *digital_buffer0, *digital_buffer1, *last_digital_buffer;
andrewm@81 77
andrewm@0 78 int xenomai_gpio_fd; // File descriptor for /dev/mem for fast GPIO
andrewm@0 79 uint32_t *xenomai_gpio; // Pointer to GPIO registers
andrewm@0 80 };
andrewm@0 81
andrewm@0 82
andrewm@0 83 #endif /* PRU_H_ */