Mercurial > hg > beaglert
changeset 34:46d87f680da5 matrix_gpio
Merged bbb_network and the so-called "matrix_gpio" branches
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 11 May 2015 19:50:48 +0100 |
parents | 83baffda5786 (diff) 12ee9a61e81d (current diff) |
children | 46571f8f04a1 006a8500863f |
files | .cproject core/RTAudioCommandLine.cpp |
diffstat | 4 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/.cproject Mon May 11 12:10:53 2015 +0100 +++ b/.cproject Mon May 11 19:50:48 2015 +0100 @@ -38,7 +38,6 @@ <option id="gnu.cpp.compiler.option.other.other.1516989263" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -Wpointer-arith -Wunused-result -D_GNU_SOURCE -D_REENTRANT -D__XENO__" valueType="string"/> <option id="gnu.cpp.compiler.option.warnings.allwarn.1392851614" name="All warnings (-Wall)" superClass="gnu.cpp.compiler.option.warnings.allwarn" useByScannerDiscovery="false" value="true" valueType="boolean"/> <option id="gnu.cpp.compiler.option.dialect.std.904910934" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/> - <option id="gnu.cpp.compiler.option.optimization.flags.1529774472" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" value="" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1166892316" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> <tool command="arm-linux-gnueabihf-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.917207395" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"> @@ -53,7 +52,6 @@ </option> <option id="gnu.c.compiler.option.misc.other.835792865" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -Wpointer-arith -Wunused-result -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -std=gnu99" valueType="string"/> <option id="gnu.c.compiler.option.warnings.allwarn.1145989346" name="All warnings (-Wall)" superClass="gnu.c.compiler.option.warnings.allwarn" useByScannerDiscovery="false" value="true" valueType="boolean"/> - <option id="gnu.c.compiler.option.optimization.flags.458386628" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.308014221" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> </tool> <tool command="arm-linux-gnueabihf-g++ " id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.214461086" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> @@ -114,14 +112,14 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1521194538" name="Release" parent="cdt.managedbuild.config.gnu.exe.release" postannouncebuildStep="Stopping process on BBB and copying new binary" postbuildStep="ssh root@192.168.7.2 "kill -s 2 \`pidof ${BuildArtifactFileName}\` 2>/dev/null"; scp ${BuildArtifactFilePrefix}${BuildArtifactFileName} root@192.168.7.2:~/beaglert/ && echo 'done copying' | wall || echo 'error' | wall"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1521194538" name="Release" parent="cdt.managedbuild.config.gnu.exe.release" postannouncebuildStep="Stopping process on BBB and copying new binary" postbuildStep="ssh root@192.168.7.2 "kill -s 2 \`pidof ${BuildArtifactFileName}\` 2>/dev/null"; scp ${BuildArtifactFilePrefix}${BuildArtifactFileName} root@192.168.7.2:~/beaglert/ ; echo 'done copying' | wall"> <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1521194538." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1612059942" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.908983575" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> <builder buildPath="${workspace_loc:/BBB_audio+input/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.511190290" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/> <tool command="arm-linux-gnueabihf-g++ " id="cdt.managedbuild.tool.gnu.archiver.base.810674388" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> <tool command="arm-linux-gnueabihf-g++ " commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.163790048" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"> - <option id="gnu.cpp.compiler.exe.release.option.optimization.level.2031085570" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="gnu.cpp.compiler.exe.release.option.optimization.level.2031085570" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.more" valueType="enumerated"/> <option id="gnu.cpp.compiler.exe.release.option.debugging.level.701035863" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.include.paths.823255770" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value="/usr/xenomai/include"/> @@ -131,11 +129,10 @@ <listOptionValue builtIn="false" value="/usr/arm-linux-gnueabihf/include/ne10"/> </option> <option id="gnu.cpp.compiler.option.dialect.std.776548502" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/> - <option id="gnu.cpp.compiler.option.optimization.flags.536899313" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" value="" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.601059736" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> <tool command="arm-linux-gnueabihf-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1302828968" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"> - <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1118673208" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1118673208" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" value="gnu.c.optimization.level.more" valueType="enumerated"/> <option id="gnu.c.compiler.exe.release.option.debugging.level.1329456558" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> <option id="gnu.c.compiler.option.include.paths.1269113471" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value="/usr/xenomai/include"/> @@ -145,7 +142,6 @@ <listOptionValue builtIn="false" value="/usr/arm-linux-gnueabihf/include/ne10"/> </option> <option id="gnu.c.compiler.option.include.files.40806287" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files"/> - <option id="gnu.c.compiler.option.optimization.flags.1921373993" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.574072828" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> </tool> <tool command="arm-linux-gnueabihf-g++ " id="cdt.managedbuild.tool.gnu.c.linker.exe.release.281634187" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
--- a/core/RTAudioCommandLine.cpp Mon May 11 12:10:53 2015 +0100 +++ b/core/RTAudioCommandLine.cpp Mon May 11 19:50:48 2015 +0100 @@ -213,6 +213,7 @@ std::cerr << " --use-analog [-m] val: Set whether to use ADC/DAC analog (default: yes)\n"; std::cerr << " --use-digital [-g] val: Set whether to use digital GPIO channels (default: yes)\n"; std::cerr << " --analog-channels [-C] val: Set the number of ADC/DAC channels (default: 8)\n"; + std::cerr << " --digital-channels [-G] val: Set the number of GPIO channels (default: 16)\n"; std::cerr << " --digital-channels [-G] val: Set the number of digital GPIO channels (default: 16)\n"; std::cerr << " --receive-port [-r] val: Set the receive port (default: 9998)\n"; std::cerr << " --transmit-port [-t] val: Set the transmit port (default: 9999)\n";
--- a/include/Utilities.h Mon May 11 12:10:53 2015 +0100 +++ b/include/Utilities.h Mon May 11 19:50:48 2015 +0100 @@ -29,14 +29,18 @@ #define getBit(word,bit) (((word)>>(bit))&1) #define changeBit(word,bit,value) ((clearBit((word),(bit))) | ((value)<<(bit))) //digital API: -#define setDigitalDirectionFrame(pin,frame,direction) digital[(frame)]=changeBit(digital[(frame)],(pin),(direction)) -#define setDigitalDirection(pin,frame,direction) (for(int _privateI=(frame);_privateI<gNumGpioFrames;_privateI++) digital[_privateI]=changeBit(digital[(_privateI)],(pin),(direction))),void(0) +#define setDigitalDirectionFrame(pin,frame,direction) digital[(frame)]=changeBit(digital[(frame)],(pin),(direction)),void(0) +#define setDigitalDirection(pin,frame,direction)\ + (({do {\ + for(int _privateI=(frame); _privateI<numDigitalFrames; _privateI++)\ + setDigitalDirectionFrame(pin,_privateI,direction);\ + } while (0);}), (void)0) #define digitalWriteAll(frame,value) digital[(frame)]=0xffff0000*(!(!value)); //sets the bit in the high word, clears the bit in the low word (just in case the direction was not previously set) #define digitalWriteFrame(pin, frame, value) digital[(frame)]=( changeBit(digital[(frame)], (pin+16), (value)) & (0xffffffff-(1<<(pin))) ) //could have been done with two subsequent assignments #define digitalWrite(pin, frame, value) \ (({do {\ - for (int _privateI=(frame); _privateI<gNumDigitalFrames; _privateI++) \ + for (int _privateI=(frame); _privateI<numDigitalFrames; _privateI++) \ digitalWriteFrame(pin,_privateI,value); \ } while (0);}),(void)0)\
--- a/projects/analogDigitalDemo/render.cpp Mon May 11 12:10:53 2015 +0100 +++ b/projects/analogDigitalDemo/render.cpp Mon May 11 19:50:48 2015 +0100 @@ -26,7 +26,7 @@ int numAnalogFramesPerPeriod, int numAudioFramesPerPeriod, float analogSampleRate, float audioSampleRate, - void *userData) + void *userData, RTAudioSettings* settings) { gNumAnalogChannels=numAnalogChannels; gNumDigitalChannels=numDigitalChannels; @@ -45,8 +45,6 @@ we assume that gNumAnalogChannels=8, numAnalogFrames==8 and numDigitalFrames==numAudioFrames * */ { - gNumDigitalFrames=numDigitalFrames; - if((gCountFrames&31)==0){ //every 32 frames... //ANALOG channels analogWrite(0, 0, analogRead(0,0)); // read the input0 at frame0 and write it to output0 frame0. Using analogWrite will fill the rest of the buffer with the same value @@ -66,6 +64,7 @@ digitalWrite(P8_08,2,GPIO_LOW); digitalWrite(P8_08,4,GPIO_HIGH); digitalWrite(P8_08,5,GPIO_LOW); + setDigitalDirection(P9_16,0,GPIO_INPUT); // set channel 10 to input // in this buffer the frames of channel 1 will look like this: 1 1 0 0 1 0 0 0 .... 0 // in the next buffer each frame of channel 1 will be initialized to 0 (the last value of this buffer) } @@ -73,10 +72,14 @@ for(int c=0; c<gNumAudioChannels; c++){ audioOut[n*gNumAudioChannels + c]=audioIn[n*gNumAudioChannels + c]; } - //use digital channels 2-5 to create a 4 bit binary counter - digital[n]=digital[n] & (~0b111100); // set to zero (GPIO_OUTPUT) the bits in the lower word - digital[n]=digital[n] & (~0b111100<<16); //initialize to zero the bits in the higher word (output value) - digital[n]=digital[n] | (n<<(16+2)); // set the bits in the higher word to the desired output value + //use digital channels 2-8 to create a 7 bit binary counter + digital[n]=digital[n] & (~0b111111100); // set to zero (GPIO_OUTPUT) the bits in the lower word + digital[n]=digital[n] & ((~0b111111100<<16) | 0xffff ); //initialize to zero the bits in the higher word (output value) + digital[n]=digital[n] | ( ((gCountFrames&0b1111111)<<(16+2)) ) ; // set the bits in the higher word to the desired output value, keeping the lower word unchanged + digitalWriteFrame(P8_29,n,digitalRead(P8_30,n)); // echo the input from from channel 15 to channel 14 + digitalWriteFrame(P8_28,n,digitalRead(P9_16,n)); // echo the input from from channel 10 to channel 13 + setDigitalDirection(P8_30,0,GPIO_INPUT); //set channel 15 to input + gCountFrames++; } for(int n=0; n<numAnalogFrames; n++){ @@ -86,7 +89,6 @@ // for(int c=0; c<gNumAnalogChannels; c++) // rt_printf("%.1f ",analogOut[n*gNumAnalogChannels + c]); // rt_printf("\n"); - gCountFrames++; } return;