# HG changeset patch # User Giulio Moro # Date 1431470917 -3600 # Node ID a9af130097e8d95bea2862a95949c4c4d535dee1 # Parent 46571f8f04a1a270e9a543e93ecd730be61a7892 GPIO pins are initialised as inputs by ARM to avoid spikes at startup, through gpio_set_dir. The buffers are set to 0x000ffff during initialisation. LastDigitalBuffer is initialized to 0x0000ffff. diff -r 46571f8f04a1 -r a9af130097e8 .cproject --- a/.cproject Mon May 11 20:11:20 2015 +0100 +++ b/.cproject Tue May 12 23:48:37 2015 +0100 @@ -92,7 +92,7 @@ - + @@ -177,7 +177,7 @@ - + diff -r 46571f8f04a1 -r a9af130097e8 core/PRU.cpp --- a/core/PRU.cpp Mon May 11 20:11:20 2015 +0100 +++ b/core/PRU.cpp Tue May 12 23:48:37 2015 +0100 @@ -56,7 +56,7 @@ #define PRU_FRAME_COUNT 8 #define PRU_USE_SPI 9 #define PRU_SPI_NUM_CHANNELS 10 -#define PRU_USE_GPIO_ANALOG 11 +#define PRU_USE_DIGITAL 11 short int digitalPins[NUM_DIGITALS]={ GPIO_NO_BIT_0, @@ -170,16 +170,11 @@ for(int i=0; iref_dac_buf0 + LSL r4, r4, 2 //length of four buffers (DAC0, DAC1, ADC0, ADC1) + ADD r4, reg_dac_buf0, r4 //total offset + MOV r2, 0// value to store + MOV r3, 0 // offset counter +SPI_INIT_BUFFER_LOOP: + SBCO r2, C_ADC_DAC_MEM, r3, 4 + ADD r3, r3, 4 + QBGT SPI_INIT_BUFFER_LOOP, r3, r4 +SPI_INIT_BUFFER_DONE: + +//Initialize audio buffers +//compute the memory offset of the end of the audio buffer and store it in r4 + SUB r4, reg_mcasp_buf1, reg_mcasp_buf0 // length of the buffer, assumes reg_mcasp_buf1>ref_mcasp_buf0 + LSL r4, r4, 2 //length of four buffers (DAC0, DAC1, ADC0, ADC1) + ADD r4, reg_mcasp_buf0, r4 //total offset + MOV r2, 0 // value to store + MOV r3, 0 // offset counter + MCASP_INIT_BUFFER_LOOP: + SBCO r2, C_MCASP_MEM, r3, 4 + ADD r3, r3, 4 + QBGT MCASP_INIT_BUFFER_LOOP, r3, r4 +*/ // Here we are out of sync by one TDM slot since the 0 word transmitted above will have occupied // the first output slot. Send one more word before jumping into the loop. MCASP_DAC_WAIT_BEFORE_LOOP: @@ -778,6 +823,7 @@ MCASP_REG_READ_EXT MCASP_RBUF, r2 WRITE_ONE_BUFFER: + // Write a single buffer of DAC samples and read a buffer of ADC samples // Load starting positions MOV reg_dac_current, reg_dac_buf0 // DAC: reg_dac_current is current pointer @@ -792,13 +838,11 @@ MOV reg_frame_current, 0 QBBS DIGITAL_BASE_CHECK_SET, reg_flags, FLAG_BIT_BUFFER1 //check which buffer we are using for DIGITAL // if we are here, we are using buffer0 - MOV r2, 0 //so adjust offset appropriately + MOV reg_digital_current, MEM_DIGITAL_BASE QBA DIGITAL_BASE_CHECK_DONE DIGITAL_BASE_CHECK_SET: //if we are here, we are using buffer1 - MOV r2, MEM_DIGITAL_BUFFER1_OFFSET //so adjust offset appropriately + MOV reg_digital_current, MEM_DIGITAL_BASE+MEM_DIGITAL_BUFFER1_OFFSET //so adjust offset appropriately DIGITAL_BASE_CHECK_DONE: - MOV reg_digital_current, MEM_DIGITAL_BASE - ADD reg_digital_current, reg_digital_current, r2 WRITE_LOOP: // Write N channels to DAC from successive values in memory @@ -899,6 +943,7 @@ LSL r8, r8, AD7699_CHANNEL_OFFSET MOV r7, AD7699_CFG_MASK OR r7, r7, r8 + //ssssssssssssssssssssssssssss ADC_WRITE_GPIO r7, r7, r1