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: mbed BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Diff: main.cpp
- Revision:
- 0:9cac1b16cf93
- Child:
- 1:6e255a933812
diff -r 000000000000 -r 9cac1b16cf93 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Jun 06 19:26:15 2017 +0000
@@ -0,0 +1,113 @@
+#include<string>
+#include "mbed.h"
+
+//-------------------------------------------- definicion de uarts
+
+//Serial pc(USBTX, USBRX); //activar para manejar las dos conexiones uart.(no olvidar ordenar los cambios)
+
+Serial uart(USBTX, USBRX); //cambiar por el de abajo a la ahora de cargarlo en la placa, para testear con los modulos.
+//Serial uart(PC_6, PC_7);
+
+
+//-------------------------------------------- definicion de etiquetas
+
+InterruptIn button(BUTTON1);
+DigitalOut myled(LED1);
+
+//-------------------------------------------- definicion de variables globales
+
+string ID="C1",ST="OK",AC="";
+//char IDs[]="",STs[]="",ACs[]="",AKs[]="";
+
+char buffer[32]="";
+char* aux[8];
+int SP=1;
+int OP=1;
+
+//-------------------------------------------- definicion de funciones
+
+void blinkled(){
+ myled = 1; // LED is ON
+ wait(0.2); // 200 ms
+ myled = 0; // LED is OFF
+ wait(0.2); // 200 ms
+ };
+
+void speed(){
+
+ //------------ variables locales
+
+
+ //------------ programa
+
+ uart.printf("<%s;%s;S%i;2F>",ID,ST,SP);
+
+ SP++;
+
+ if(SP==4){
+ SP=1;
+ }
+ };
+
+
+
+void borrar_buffer(char *cadena){
+
+ //------------ variables locales
+
+ int i=0;
+
+ //------------ programa
+
+ for(i=0;i<31;i++){
+ cadena[i]=0x00;
+ }
+ };
+
+void interrup(){
+
+ //------------ variables locales
+
+ char c;
+ int i=0;
+
+ //------------ programa
+
+ c=uart.getc();
+ if(c=='<'){
+ while(c!='>'){
+ c=uart.getc();
+ if(c!='>'){
+ buffer[i++]=c;
+ }
+ }
+ i=0;
+ aux[i]=strtok(buffer,";");
+ do{
+ i++;
+ aux[i]=strtok(NULL, ";");
+ }while(aux[i]!=NULL);
+ if(strcmp(aux[2],"CN") == 0){
+ uart.printf("<%s;%s;YE;2F>",ID,ST);
+ }
+ }
+ borrar_buffer(buffer);
+ };
+
+//codigo principal
+
+int main() {
+
+ uart.printf("Inicio de programa\n"); //cambiar uart de destino al final
+
+ //------------------------------ Interrupciones
+
+ button.rise(&speed);
+ uart.attach(&interrup);
+
+ //------------------------------ programa
+
+ while(1) {
+ blinkled();
+ }
+}