Mercurial > hg > beaglert
comparison core/PRU.cpp @ 280:c55c6f6c233c prerelease
Added support for multiplexer capelet and command-line support for choosing PRU
author | andrewm |
---|---|
date | Tue, 17 May 2016 17:49:23 +0100 |
parents | 8d80eda512cd |
children | e4392164b458 |
comparison
equal
deleted
inserted
replaced
278:3c3d042dad12 | 280:c55c6f6c233c |
---|---|
46 #define PRU_MEM_DAC_LENGTH 0x2000 // Length of ADC+DAC memory, in bytes | 46 #define PRU_MEM_DAC_LENGTH 0x2000 // Length of ADC+DAC memory, in bytes |
47 #define PRU_MEM_COMM_OFFSET 0x0 // Offset within PRU-SHARED RAM | 47 #define PRU_MEM_COMM_OFFSET 0x0 // Offset within PRU-SHARED RAM |
48 #define PRU_MEM_DIGITAL_OFFSET 0x1000 //Offset within PRU-SHARED RAM | 48 #define PRU_MEM_DIGITAL_OFFSET 0x1000 //Offset within PRU-SHARED RAM |
49 #define MEM_DIGITAL_BUFFER1_OFFSET 0x400 //Start pointer to DIGITAL_BUFFER1, which is 256 words. | 49 #define MEM_DIGITAL_BUFFER1_OFFSET 0x400 //Start pointer to DIGITAL_BUFFER1, which is 256 words. |
50 // 256 is the maximum number of frames allowed | 50 // 256 is the maximum number of frames allowed |
51 | |
52 // Offsets within CPU <-> PRU communication memory (4 byte slots) | |
51 #define PRU_SHOULD_STOP 0 | 53 #define PRU_SHOULD_STOP 0 |
52 #define PRU_CURRENT_BUFFER 1 | 54 #define PRU_CURRENT_BUFFER 1 |
53 #define PRU_BUFFER_FRAMES 2 | 55 #define PRU_BUFFER_FRAMES 2 |
54 #define PRU_SHOULD_SYNC 3 | 56 #define PRU_SHOULD_SYNC 3 |
55 #define PRU_SYNC_ADDRESS 4 | 57 #define PRU_SYNC_ADDRESS 4 |
59 #define PRU_FRAME_COUNT 8 | 61 #define PRU_FRAME_COUNT 8 |
60 #define PRU_USE_SPI 9 | 62 #define PRU_USE_SPI 9 |
61 #define PRU_SPI_NUM_CHANNELS 10 | 63 #define PRU_SPI_NUM_CHANNELS 10 |
62 #define PRU_USE_DIGITAL 11 | 64 #define PRU_USE_DIGITAL 11 |
63 #define PRU_PRU_NUMBER 12 | 65 #define PRU_PRU_NUMBER 12 |
64 | 66 #define PRU_MUX_CONFIG 13 |
65 short int digitalPins[NUM_DIGITALS]={ | 67 |
68 short int digitalPins[NUM_DIGITALS] = { | |
66 GPIO_NO_BIT_0, | 69 GPIO_NO_BIT_0, |
67 GPIO_NO_BIT_1, | 70 GPIO_NO_BIT_1, |
68 GPIO_NO_BIT_2, | 71 GPIO_NO_BIT_2, |
69 GPIO_NO_BIT_3, | 72 GPIO_NO_BIT_3, |
70 GPIO_NO_BIT_4, | 73 GPIO_NO_BIT_4, |
275 } | 278 } |
276 gpio_enabled = gpio_test_pin_enabled = false; | 279 gpio_enabled = gpio_test_pin_enabled = false; |
277 } | 280 } |
278 | 281 |
279 // Initialise and open the PRU | 282 // Initialise and open the PRU |
280 int PRU::initialise(int pru_num, int frames_per_buffer, int spi_channels, bool xenomai_test_pin) | 283 int PRU::initialise(int pru_num, int frames_per_buffer, int spi_channels, int mux_channels, bool xenomai_test_pin) |
281 { | 284 { |
282 uint32_t *pruMem = 0; | 285 uint32_t *pruMem = 0; |
283 | 286 |
284 if(!gpio_enabled) { | 287 if(!gpio_enabled) { |
285 rt_printf("initialise() called before GPIO enabled\n"); | 288 rt_printf("initialise() called before GPIO enabled\n"); |
335 pru_buffer_comm[PRU_BUFFER_FRAMES] = context->analogFrames; | 338 pru_buffer_comm[PRU_BUFFER_FRAMES] = context->analogFrames; |
336 pru_buffer_comm[PRU_SHOULD_SYNC] = 0; | 339 pru_buffer_comm[PRU_SHOULD_SYNC] = 0; |
337 pru_buffer_comm[PRU_SYNC_ADDRESS] = 0; | 340 pru_buffer_comm[PRU_SYNC_ADDRESS] = 0; |
338 pru_buffer_comm[PRU_SYNC_PIN_MASK] = 0; | 341 pru_buffer_comm[PRU_SYNC_PIN_MASK] = 0; |
339 pru_buffer_comm[PRU_PRU_NUMBER] = pru_number; | 342 pru_buffer_comm[PRU_PRU_NUMBER] = pru_number; |
343 | |
344 if(mux_channels == 2) | |
345 pru_buffer_comm[PRU_MUX_CONFIG] = 1; | |
346 else if(mux_channels == 4) | |
347 pru_buffer_comm[PRU_MUX_CONFIG] = 2; | |
348 else if(mux_channels == 8) | |
349 pru_buffer_comm[PRU_MUX_CONFIG] = 3; | |
350 else | |
351 pru_buffer_comm[PRU_MUX_CONFIG] = 0; | |
352 | |
340 if(led_enabled) { | 353 if(led_enabled) { |
341 pru_buffer_comm[PRU_LED_ADDRESS] = USERLED3_GPIO_BASE; | 354 pru_buffer_comm[PRU_LED_ADDRESS] = USERLED3_GPIO_BASE; |
342 pru_buffer_comm[PRU_LED_PIN_MASK] = USERLED3_PIN_MASK; | 355 pru_buffer_comm[PRU_LED_PIN_MASK] = USERLED3_PIN_MASK; |
343 } | 356 } |
344 else { | 357 else { |