Mercurial > hg > beaglert
comparison core/RTAudioCommandLine.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 | 1fd334f64f0a |
children | e4392164b458 |
comparison
equal
deleted
inserted
replaced
278:3c3d042dad12 | 280:c55c6f6c233c |
---|---|
12 #include "../include/BeagleRT.h" | 12 #include "../include/BeagleRT.h" |
13 | 13 |
14 #define OPT_PRU_FILE 1000 | 14 #define OPT_PRU_FILE 1000 |
15 #define OPT_PGA_GAIN_LEFT 1001 | 15 #define OPT_PGA_GAIN_LEFT 1001 |
16 #define OPT_PGA_GAIN_RIGHT 1002 | 16 #define OPT_PGA_GAIN_RIGHT 1002 |
17 #define OPT_PRU_NUMBER 1003 | |
17 | 18 |
18 | 19 |
19 enum { | 20 enum { |
20 kAmplifierMutePin = 61 // P8-26 controls amplifier mute | 21 kAmplifierMutePin = 61 // P8-26 controls amplifier mute |
21 }; | 22 }; |
37 {"hp-level", 1, NULL, 'H'}, | 38 {"hp-level", 1, NULL, 'H'}, |
38 {"receive-port", 1, NULL, 'R'}, | 39 {"receive-port", 1, NULL, 'R'}, |
39 {"transmit-port", 1, NULL, 'T'}, | 40 {"transmit-port", 1, NULL, 'T'}, |
40 {"server-name", 1, NULL, 'S'}, | 41 {"server-name", 1, NULL, 'S'}, |
41 {"pru-file", 1, NULL, OPT_PRU_FILE}, | 42 {"pru-file", 1, NULL, OPT_PRU_FILE}, |
43 {"pru-number", 1, NULL, OPT_PRU_NUMBER}, | |
42 {NULL, 0, NULL, 0} | 44 {NULL, 0, NULL, 0} |
43 }; | 45 }; |
44 | 46 |
45 const char gDefaultShortOptions[] = "p:vN:M:C:D:A:H:G:B:R:T:S:"; | 47 const char gDefaultShortOptions[] = "p:vN:M:C:D:A:H:G:B:R:T:S:"; |
46 | 48 |
58 settings->dacLevel = DEFAULT_DAC_LEVEL; | 60 settings->dacLevel = DEFAULT_DAC_LEVEL; |
59 settings->adcLevel = DEFAULT_ADC_LEVEL; | 61 settings->adcLevel = DEFAULT_ADC_LEVEL; |
60 for(int n = 0; n < 2; n++) | 62 for(int n = 0; n < 2; n++) |
61 settings->pgaGain[n] = DEFAULT_PGA_GAIN; | 63 settings->pgaGain[n] = DEFAULT_PGA_GAIN; |
62 settings->headphoneLevel = DEFAULT_HP_LEVEL; | 64 settings->headphoneLevel = DEFAULT_HP_LEVEL; |
65 settings->numMuxChannels = 0; | |
63 | 66 |
64 settings->verbose = 0; | 67 settings->verbose = 0; |
68 settings->pruNumber = 0; | |
65 settings->pruFilename[0] = '\0'; | 69 settings->pruFilename[0] = '\0'; |
66 | 70 |
67 // These two deliberately have no command-line flags by default. | 71 // These two deliberately have no command-line flags by default. |
68 // A given program might prefer one mode or another, but it's unlikely | 72 // A given program might prefer one mode or another, but it's unlikely |
69 // the user would want to switch at runtime | 73 // the user would want to switch at runtime |
164 settings->numDigitalChannels = 0; | 168 settings->numDigitalChannels = 0; |
165 } | 169 } |
166 break; | 170 break; |
167 case 'C': | 171 case 'C': |
168 settings->numAnalogChannels = atoi(optarg); | 172 settings->numAnalogChannels = atoi(optarg); |
169 if(settings->numAnalogChannels >= 8) | 173 if(settings->numAnalogChannels >= 8) { |
174 // Use multiplexer capelet to run larger numbers of channels | |
175 if(settings->numAnalogChannels >= 64) | |
176 settings->numMuxChannels = 8; | |
177 else if(settings->numAnalogChannels >= 32) | |
178 settings->numMuxChannels = 4; | |
179 else if(settings->numAnalogChannels >= 16) | |
180 settings->numMuxChannels = 2; | |
170 settings->numAnalogChannels = 8; | 181 settings->numAnalogChannels = 8; |
182 } | |
171 else if(settings->numAnalogChannels >= 4) | 183 else if(settings->numAnalogChannels >= 4) |
172 settings->numAnalogChannels = 4; | 184 settings->numAnalogChannels = 4; |
173 else | 185 else |
174 settings->numAnalogChannels = 2; | 186 settings->numAnalogChannels = 2; |
175 break; | 187 break; |
217 case OPT_PGA_GAIN_LEFT: | 229 case OPT_PGA_GAIN_LEFT: |
218 settings->pgaGain[0] = atof(optarg); | 230 settings->pgaGain[0] = atof(optarg); |
219 break; | 231 break; |
220 case OPT_PGA_GAIN_RIGHT: | 232 case OPT_PGA_GAIN_RIGHT: |
221 settings->pgaGain[1] = atof(optarg); | 233 settings->pgaGain[1] = atof(optarg); |
234 break; | |
235 case OPT_PRU_NUMBER: | |
236 settings->pruNumber = atoi(optarg); | |
222 break; | 237 break; |
223 case '?': | 238 case '?': |
224 default: | 239 default: |
225 return c; | 240 return c; |
226 } | 241 } |
244 std::cerr << " --digital-channels [-B] val: Set the number of GPIO channels (default: 16)\n"; | 259 std::cerr << " --digital-channels [-B] val: Set the number of GPIO channels (default: 16)\n"; |
245 std::cerr << " --receive-port [-R] val: Set the receive port (default: 9998)\n"; | 260 std::cerr << " --receive-port [-R] val: Set the receive port (default: 9998)\n"; |
246 std::cerr << " --transmit-port [-T] val: Set the transmit port (default: 9999)\n"; | 261 std::cerr << " --transmit-port [-T] val: Set the transmit port (default: 9999)\n"; |
247 std::cerr << " --server-name [-S] val: Set the destination server name (default: '127.0.0.1')\n"; | 262 std::cerr << " --server-name [-S] val: Set the destination server name (default: '127.0.0.1')\n"; |
248 std::cerr << " --pru-file val: Set an optional external file to use for the PRU binary code\n"; | 263 std::cerr << " --pru-file val: Set an optional external file to use for the PRU binary code\n"; |
264 std::cerr << " --pru-number val: Set the PRU to use for I/O (options: 0 or 1, default: 0)\n"; | |
249 std::cerr << " --verbose [-v]: Enable verbose logging information\n"; | 265 std::cerr << " --verbose [-v]: Enable verbose logging information\n"; |
250 } | 266 } |
251 | 267 |