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.
Diff: main.cpp
- Revision:
- 0:3eda4839be5c
- Child:
- 1:7f5f80b47892
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 23 14:11:40 2018 +0000 @@ -0,0 +1,192 @@ + +#include "mbed.h" +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "Serial.h" +#include "ATCmdParser.h" +#include "UARTSerial.h" + +// Diumensione massima del vettore TxB e del vettore RxB +#define TxBDIM 20 +#define RxBDIM 20 + +// Numero dei byte da inviare allo SLAVE per l'accensione del led +#define NumByte 16 + +// Configurazione della porta seriale del computer +Serial pc(USBTX, USBRX); + +DigitalOut led(LED1); + +// Configurazione della porta UART +// UARTSerial UART(PA_2,PA_3,9600); + +UARTSerial serial = UARTSerial(PA_2, PA_3); +ATCmdParser at = ATCmdParser(&serial, "\r\n"); + +char buffer[100]; + +char TxB[TxBDIM]; +char RxB[RxBDIM]; +char x[10]; + +// Vettore che conterrà i byte da trasmettere al led +// uint8_t VettoreLED[NumByte]; + +int i=0; +int j=0; + +int TxSIZE; +int RxSIZE; + +volatile char input; +volatile bool bStop; + + +int main() +{ + pc.baud(9600); + + + +while(1) +{ + if ((at.send("AT") && at.recv("OK"))==1) + { + printf("Rilevato"); + led=1; + } +} + /* at.send("AT\r\n"); + + if (at.recv("OK")==true) + { + printf("Rilevato"); + } + + else + { + at.read(buffer,2); + printf("\r\nRisposta:%c",*buffer); + }*/ + + + + // reset vettore in trasmissione + /* for(i=0;i<TxBDIM;i++) + { + TxB[i]='\0'; + } + + // reset vettore in ricezione + for(j=0;i<RxBDIM;j++) + { + RxB[i]='\0'; + }*/ + + + /* + // Configurazione dei parametri della SPI + SPI myspi(PA_7, PA_6, PA_5, NC); + myspi.format(16, 0); + myspi.frequency(3333333.3);*/ + + /* + // Il primo led emette la luce verde + for(i = 0; i <= 3; i++) + VettoreLED[i]=136; + + for(i = 4; i <= 7; i++) + VettoreLED[i]=136; + + for(i = 8; i <= 11; i++) + VettoreLED[i]=136; + + for(i = 12; i <= NumByte-1; i++) + VettoreLED[i]=136; + + // Ciclo per l'invio dei frame al primo led + for(j = 0; j < NumByte; j++) + myspi.write(VettoreLED[j]); */ + + + /*if ((RxB[0]=='O') && (RxB[1]=='K')) + for(j = 0; j < RxBDIM; j++) + { + if (RxB[j]==NULL) + { + L=1; + } + }*/ + + + + + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +