Permalink
Browse files

Added --disable-led option to suppress blinking LED, and made LED alw…

…ays turn off on program end
  • Loading branch information...
Andrew McPherson
Andrew McPherson committed Aug 3, 2016
1 parent eb3134c commit 33464e04885df1d4c5f3a5914d22168f571d1cda
Showing with 25 additions and 1 deletion.
  1. +1 −1 core/RTAudio.cpp
  2. +7 −0 core/RTAudioCommandLine.cpp
  3. +2 −0 include/Bela.h
  4. +6 −0 include/pru_rtaudio_bin.h
  5. +9 −0 pru_rtaudio.p
View
@@ -259,7 +259,7 @@ int Bela_initAudio(BelaInitSettings *settings, void *userData)
gAudioCodec = new I2c_Codec();
// Initialise the GPIO pins, including possibly the digital pins in the render routines
if(gPRU->prepareGPIO(1, 1)) {
if(gPRU->prepareGPIO(1, settings->enableLED)) {
cout << "Error: unable to prepare GPIO for PRU audio\n";
return 1;
}
@@ -15,6 +15,7 @@
#define OPT_PGA_GAIN_LEFT 1001
#define OPT_PGA_GAIN_RIGHT 1002
#define OPT_PRU_NUMBER 1003
#define OPT_DISABLE_LED 1004
enum {
@@ -42,6 +43,7 @@ struct option gDefaultLongOptions[] =
{"mux-channels", 1, NULL, 'X'},
{"pru-file", 1, NULL, OPT_PRU_FILE},
{"pru-number", 1, NULL, OPT_PRU_NUMBER},
{"disable-led", 0, NULL, OPT_DISABLE_LED},
{NULL, 0, NULL, 0}
};
@@ -72,6 +74,7 @@ void Bela_defaultSettings(BelaInitSettings *settings)
settings->verbose = 0;
settings->pruNumber = 1;
settings->pruFilename[0] = '\0';
settings->enableLED = 1;
// These two deliberately have no command-line flags by default.
// A given program might prefer one mode or another, but it's unlikely
@@ -248,6 +251,9 @@ int Bela_getopt_long(int argc, char *argv[], const char *customShortOptions, con
case OPT_PRU_NUMBER:
settings->pruNumber = atoi(optarg);
break;
case OPT_DISABLE_LED:
settings->enableLED = 0;
break;
case '?':
default:
return c;
@@ -276,6 +282,7 @@ void Bela_usage()
std::cerr << " --mux-channels [-X] val: Set the number of channels to use on the multiplexer capelet (default: not used)\n";
std::cerr << " --pru-file val: Set an optional external file to use for the PRU binary code\n";
std::cerr << " --pru-number val: Set the PRU to use for I/O (options: 0 or 1, default: 0)\n";
std::cerr << " --disable-led Disable the blinking LED indicator\n";
std::cerr << " --verbose [-v]: Enable verbose logging information\n";
}
View
@@ -142,6 +142,8 @@ typedef struct {
char pruFilename[MAX_PRU_FILENAME_LENGTH];
/// Whether to use verbose logging
int verbose;
/// Whether to use the blinking LED to indicate Bela is running
int enableLED;
// These items are application-dependent but should probably be
// determined by the programmer rather than the user
@@ -873,6 +873,12 @@ const unsigned int PRUcode[] = {
0xf1002382,
0x1d01e2e2,
0xe1002382,
0xf1183983,
0x5100e305,
0xf11c3982,
0x240190e1,
0x00e1e3e3,
0xe1002382,
0x2400231f,
0x2a000000 };
View
@@ -1160,6 +1160,15 @@ CLEANUP:
CLR r2, r2, 1
SBBO r2, r3, 0, 4
SPI_CLEANUP_DONE:
// Turn the LED off, if enabled
LBBO r3, reg_comm_addr, COMM_LED_ADDRESS, 4
QBEQ CLEANUP_DONE, r3, 0
LBBO r2, reg_comm_addr, COMM_LED_PIN_MASK, 4
MOV r1, GPIO_CLEARDATAOUT
ADD r3, r3, r1 // Address for GPIO clear register
SBBO r2, r3, 0, 4 // Clear GPIO pin
CLEANUP_DONE:
// Signal the ARM that we have finished
MOV R31.b0, PRU0_ARM_INTERRUPT + 16
HALT

0 comments on commit 33464e0

Please sign in to comment.