Mercurial > hg > beaglert
comparison core/PRU.cpp @ 43:4cd9a8ca5745 staging
Fixed bug that was causing pointer corruption
| author | Giulio Moro <giuliomoro@yahoo.it> |
|---|---|
| date | Tue, 19 May 2015 16:54:10 +0100 |
| parents | a9af130097e8 |
| children |
comparison
equal
deleted
inserted
replaced
| 40:419ce4ebfc4c | 43:4cd9a8ca5745 |
|---|---|
| 487 for(unsigned int n = 0; n < spi_num_channels * spi_buffer_frames; n++) | 487 for(unsigned int n = 0; n < spi_num_channels * spi_buffer_frames; n++) |
| 488 analogInBuffer[n] = (float)pru_buffer_spi_adc[n] / 65536.0; | 488 analogInBuffer[n] = (float)pru_buffer_spi_adc[n] / 65536.0; |
| 489 //initialize the output buffer with the values that were in the last frame of the previous output | 489 //initialize the output buffer with the values that were in the last frame of the previous output |
| 490 for(int n = 0; n < spi_num_channels; n++){ | 490 for(int n = 0; n < spi_num_channels; n++){ |
| 491 for(unsigned int j = 0; j < spi_buffer_frames; j++){ | 491 for(unsigned int j = 0; j < spi_buffer_frames; j++){ |
| 492 analogOutBuffer[j*spi_buffer_frames + n] = lastAnalogOutFrame[n]; | 492 analogOutBuffer[j*spi_num_channels + n] = lastAnalogOutFrame[n]; |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 //use past digital values to initialize the array properly. | 495 //use past digital values to initialize the array properly. |
| 496 //For each frame: | 496 //For each frame: |
| 497 //- pins previously set as outputs will keep the output value they had in the last frame of the previous buffer, | 497 //- pins previously set as outputs will keep the output value they had in the last frame of the previous buffer, |
| 565 analogInBuffer[n] = (float)pru_buffer_spi_adc[n + spi_buffer_frames * spi_num_channels] / 65536.0; | 565 analogInBuffer[n] = (float)pru_buffer_spi_adc[n + spi_buffer_frames * spi_num_channels] / 65536.0; |
| 566 } | 566 } |
| 567 //initialize the output buffer with the values that were in the last frame of the previous output | 567 //initialize the output buffer with the values that were in the last frame of the previous output |
| 568 for(int n = 0; n < spi_num_channels; n++){ | 568 for(int n = 0; n < spi_num_channels; n++){ |
| 569 for(unsigned int j = 0; j < spi_buffer_frames; j++){ | 569 for(unsigned int j = 0; j < spi_buffer_frames; j++){ |
| 570 analogOutBuffer[j*spi_buffer_frames + n] = lastAnalogOutFrame[n]; | 570 analogOutBuffer[j*spi_num_channels + n] = lastAnalogOutFrame[n]; |
| 571 } | 571 } |
| 572 } | 572 } |
| 573 if(digital_enabled){ | 573 if(digital_enabled){ |
| 574 for(unsigned int n = 0; n < digital_buffer_frames; n++){ | 574 for(unsigned int n = 0; n < digital_buffer_frames; n++){ |
| 575 uint16_t inputs=lastDigitalBuffer[n]&0xffff;//half-word, has 1 for inputs and 0 for outputs | 575 uint16_t inputs=lastDigitalBuffer[n]&0xffff;//half-word, has 1 for inputs and 0 for outputs |
