Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetNetIf HTTPServer QEI_hw RPCInterface mbed
Revision 9:6976ac1a430e, committed 2012-04-03
- Comitter:
- Yo_Robot
- Date:
- Tue Apr 03 00:55:48 2012 +0000
- Parent:
- 8:958dfe5052b9
- Child:
- 12:c02b08dacc45
- Commit message:
- v0.2 Eth RPC. Compilo falta probar y algunas funciones mas
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| setup.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Apr 03 00:31:03 2012 +0000
+++ b/main.cpp Tue Apr 03 00:55:48 2012 +0000
@@ -8,18 +8,23 @@
#include "RPCVariable.h"
#include "SerialRPCInterface.h"
+
+DigitalOut pin_son( p30 ); // SON
+DigitalOut pin_dir( p29 ); // SIGN+
+InterruptIn pin_alm( p14 ); // ALM
+AnalogOut aout( p18 ); // 0.0 a 1.0 float
+
LocalFileSystem fs("webfs");
EthernetNetIf eth;
HTTPServer svr;
-void setFq( char * input, char * output ); //Cambiar frecuencia
-void setPTO( char * input, char * output ); // Encender/Apagar Pulse Train Output
-
+void setAout_eth( char * input, char * output ); //Cambiar frecuencia
+void setPTO_eth( char * input, char * output ); // Encender/Apagar Pulse Train Output
//Set up custom RPC
-RPCFunction SetFQ(&setPTO, "PTO");
-RPCFunction SetAout(&setAOUT, "AOUT");
+RPCFunction SetFQ(&setPTO_eth, "PTO");
+RPCFunction SetAout(&setAout_eth, "AOUT");
int main() {
@@ -41,7 +46,7 @@
EthernetErr ethErr = eth.setup();
if( ethErr )
{
- printf( "Error %d in setup\n", ethErr );
+ printf( "Error %d en setup\n", ethErr );
return -1;
}
@@ -69,33 +74,28 @@
}
-void setAOUT( char * input, char * output )
+void setAout_eth( char * input, char * output )
{
- int vout = atoi( input );
-
+ int vout = atoi( input );
aout = (float)( vout + 100 ) / 200;
-
- sprintf(" Ok, Aout = %f ", aout.read() );
-
+ sprintf( output, " Ok, Aout = %f ", aout.read() );
}
-void setPTO( char * input, char * output )
+void setPTO_eth( char * input, char * output )
{
int freq = atoi( input );
- if( freq != 0 )
- {
+ if( freq != 0 ){
+ LPC_TIM2->TC = 0x00; // Resetear Timer
+ setMR2( getMRvalue( freq ) ); // Cambiar frefuencia
+ startTimer2(); // Iniciar Timer
+ sprintf( output, "Ok, Freq = %d", freq );
+
+ }else{
+ stopTimer2();
LPC_TIM2->TC = 0x00; // Resetear Timer
- setMR2( getMRvalue( frequency ) ); //Cambiar frefuencia
- startTimer2();
- sprintf( output, "Ok, Freq = %d", frequency);
- } else {
-
- LPC_TIM2->TC = 0x00; // Resetear Timer
- stopTimer2();
sprintf( output, "Ok, ALTO" );
- }
-
+ }
}
--- a/setup.cpp Tue Apr 03 00:31:03 2012 +0000
+++ b/setup.cpp Tue Apr 03 00:55:48 2012 +0000
@@ -57,9 +57,7 @@
exact = (24000000 /(fout*2) ) -1;
toRegister = exact; // Valor redondeado;
error = exact - toRegister;
-
- printf( "\n\n MR value: %d\n error: %f\n" ,toRegister ,error );
-
+// printf( "\n\n MR value: %d\n error: %f\n" ,toRegister ,error );
return toRegister;
}