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
main.cpp
- Committer:
- pinofal
- Date:
- 2018-01-23
- Revision:
- 2:eeab69a684ad
- Parent:
- 1:ce08f1d8140c
File content as of revision 2:eeab69a684ad:
#include "mbed.h"
// dimensione del pacchetto di comunicazione tra PC e uC
#define PACKETDIM 33
DigitalOut led(LED1);
Serial pc(SERIAL_TX, SERIAL_RX);
// indice per i cicli
int nIndex;
// indice dell'array caRxPacket[]
volatile int nRxIndex;
// carattere in arrivo dal PC
volatile char caReadChar;
// paccchetto ricevuto dal PC
char caRxPacket[PACKETDIM];
int nRxPacketSize;
void RxInterrupt(void)
{
// reset pacchetto ricevuto
nIndex=0;
for(nIndex=0;nIndex<PACKETDIM;nIndex++)
{
caRxPacket[nIndex]='\0';
}
// ricevi caratteri su seriale, se disponibili
while((pc.readable()))
{
pc.gets(caRxPacket,sizeof(caRxPacket));
nRxPacketSize = strlen(caRxPacket);
//pc.printf("*** pc.readable = %2d \n\r",nRxPacketSize);
//pc.scanf("%s", &caRxPacket);
//+++pc.putc(pc.getc()); // read data from UART
}
//+++pc.printf("%s",caRxPacket);
pc.printf("You also say goodbye to yours tk");
}
int main()
{
// configura velocità della comunicazione seriale su USB-VirtualCom e invia messaggio di benvenuto
//pc.baud(921600); //921600 bps
pc.baud(256000); //9600 bps
//pc.printf("*** SineWave Generation ***\n\r");
pc.attach(&RxInterrupt,Serial::RxIrq);
while(true)
{
led = !led; // Toggle LED
}
}