Mercurial > hg > beaglert
changeset 346:c6a15a8dee02 prerelease
Remapped analog output channels to match 01234567 order on cape. Note: this will change the behaviour of all these existing examples using analog out, notably d-box and cape_test.
author | andrewm |
---|---|
date | Tue, 07 Jun 2016 18:37:11 +0100 |
parents | 0e1e0dfe24c5 |
children | 09397ded8966 |
files | include/pru_rtaudio_bin.h pru_rtaudio.p |
diffstat | 2 files changed, 65 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/include/pru_rtaudio_bin.h Tue Jun 07 03:40:01 2016 +0100 +++ b/include/pru_rtaudio_bin.h Tue Jun 07 18:37:11 2016 +0100 @@ -669,14 +669,21 @@ 0x12e3efef, 0x80f73c8f, 0x0104f7f7, - 0xc901f889, + 0xc901f897, 0x24ffffe2, 0x10e2ece7, 0x0904e7e7, 0x240300c8, 0x24000088, 0x12e8e7e7, - 0x0914e1e8, + 0xd102e104, + 0x1503e1e8, + 0x0901e8e8, + 0x79000004, + 0x1103e1e8, + 0x0901e8e8, + 0x0101e8e8, + 0x0914e8e8, 0x12e8e7e7, 0x240020fb, 0x2444e0dc, @@ -707,7 +714,7 @@ 0x4902e904, 0x1101eafb, 0x6900fb08, - 0x2102c100, + 0x2102c800, 0x1103e1fb, 0x6900fb05, 0xf100269b, @@ -730,7 +737,14 @@ 0x240300c8, 0x24000088, 0x12e8e7e7, - 0x0914e1e8, + 0xd102e104, + 0x1503e1e8, + 0x0901e8e8, + 0x79000004, + 0x1103e1e8, + 0x0901e8e8, + 0x0101e8e8, + 0x0914e8e8, 0x12e8e7e7, 0x240020fb, 0x2444e0dc, @@ -804,13 +818,13 @@ 0x10fcfcfe, 0x1504f8f8, 0x0101e1e1, - 0x6ee9e151, + 0x6ee9e143, 0x79000004, 0x1504f8f8, 0x0102e1e1, - 0x6ee9e14d, + 0x6ee9e13f, 0x0101eaea, - 0x6eebea4a, + 0x6eebea3c, 0x10f0f0e2, 0x10f1f1f0, 0x10e2e2f1, @@ -818,6 +832,11 @@ 0x10f5f5f4, 0x10e2e2f5, 0x1501f8f8, + 0x240300e2, + 0x10e2f8e2, + 0x5100e203, + 0x1103fee2, + 0xe1383982, 0x1101f8e2, 0xe1043982, 0x2400241f, @@ -839,7 +858,7 @@ 0x00e1e3e3, 0xe1002382, 0xf1003982, - 0x5700e21d, + 0x5700e20a, 0x240000fb, 0xe1443d9b, 0xc901f80c,
--- a/pru_rtaudio.p Tue Jun 07 03:40:01 2016 +0100 +++ b/pru_rtaudio.p Tue Jun 07 18:37:11 2016 +0100 @@ -85,7 +85,8 @@ #define COMM_USE_DIGITAL 44 // Whether or not to use DIGITAL #define COMM_PRU_NUMBER 48 // Which PRU this code is running on #define COMM_MUX_CONFIG 52 // Whether to use the mux capelet, and how many channels - +#define COMM_MUX_END_CHANNEL 56 // Which mux channel the last buffer ended on + // General constants for McASP peripherals (used for audio codec) #define MCASP0_BASE 0x48038000 #define MCASP1_BASE 0x4803C000 @@ -191,12 +192,7 @@ #define FLAG_BIT_MUX_CONFIG0 8 // Mux capelet configuration: #define FLAG_BIT_MUX_CONFIG1 9 // 00 = off, 01 = 2 ch., 10 = 4 ch., 11 = 8 ch. #define FLAG_MASK_MUX_CONFIG 0x0300 - -#define FLAG_BIT_MUX_STATE0 10 // Current state of the mux channels -#define FLAG_BIT_MUX_STATE1 11 -#define FLAG_BIT_MUX_STATE2 12 -#define FLAG_MASK_MUX_STATE 0x1C00 - + // Registers used throughout // r1, r2, r3 are used for temporary storage @@ -445,6 +441,27 @@ DAC_DISCARD_RX .endm +// Transform channel order on DAC +// (in) 01234567 --> (out) 64201357 +// This is to make the pin order on the Bela cape +// make sense +.macro DAC_CHANNEL_REORDER +.mparam out, in + QBBS DAC_CHANNEL_REORDER_HIGH, in, 2 +// Input channels 0,1,2,3 --> 6,4,2,0 +// out = (3 - in) << 1 + XOR out, in, 0x03 + LSL out, out, 1 + QBA DAC_CHANNEL_REORDER_DONE +DAC_CHANNEL_REORDER_HIGH: +// Input channels 4,5,6,7 --> 1,3,5,7 +// out = ((in & 0x03) << 1) + 1 + AND out, in, 0x03 + LSL out, out, 1 + ADD out, out, 1 +DAC_CHANNEL_REORDER_DONE: +.endm + // Bring CS line low to write to ADC .macro ADC_CS_ASSERT MOV r27, ADC_CS_PIN @@ -988,7 +1005,8 @@ LSL r7, r7, AD5668_DATA_OFFSET MOV r8, (0x03 << AD5668_COMMAND_OFFSET) OR r7, r7, r8 - LSL r8, r1, AD5668_ADDRESS_OFFSET + DAC_CHANNEL_REORDER r8, r1 + LSL r8, r8, AD5668_ADDRESS_OFFSET OR r7, r7, r8 DAC_WRITE r7 @@ -1016,7 +1034,8 @@ LSL r7, r7, AD5668_DATA_OFFSET MOV r8, (0x03 << AD5668_COMMAND_OFFSET) OR r7, r7, r8 - LSL r8, r1, AD5668_ADDRESS_OFFSET + DAC_CHANNEL_REORDER r8, r1 + LSL r8, r8, AD5668_ADDRESS_OFFSET OR r7, r7, r8 DAC_WRITE r7 @@ -1083,6 +1102,16 @@ MOV reg_mcasp_buf1, r2 XOR reg_flags, reg_flags, (1 << FLAG_BIT_BUFFER1) //flip the buffer flag + // If multiplexer capelet is enabled, save which channel we got to + // Muxes 0-3 change at a different time than muxes 4-7 but the first + // of these is sufficient to capture where we are + MOV r2, FLAG_MASK_MUX_CONFIG + AND r2, reg_flags, r2 + QBEQ MUX_CHANNEL_SAVE_DONE, r2, 0 + AND r2, reg_pru1_mux_pins, 0x03 + SBBO r2, reg_comm_addr, COMM_MUX_END_CHANNEL, 4 +MUX_CHANNEL_SAVE_DONE: + // Notify ARM of buffer swap AND r2, reg_flags, (1 << FLAG_BIT_BUFFER1) // Mask out every but low bit SBBO r2, reg_comm_addr, COMM_CURRENT_BUFFER, 4