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.
main.cpp
- Committer:
- dshin
- Date:
- 2022-05-22
- Revision:
- 0:0d96af962118
File content as of revision 0:0d96af962118:
// ======================================================================
#include "mbed.h"
RawSerial PC(USBTX, USBRX); // PC = (USBTX=TX, USBRX=RX)
RawSerial ESP(D1, D0); // ESP = (D1=TX, D0=RX)
/// ======================================================================
// ISR for redirecting PC RX to ESP TX
void ISR_PC_to_ESP()
{
while(PC.readable()) {
ESP.putc(PC.getc());
}
}
// ======================================================================
// ISR for redirecting ESP RX to PC TX
void ISR_ESP_to_PC()
{
while(ESP.readable()) {
PC.putc(ESP.getc());
}
}
// ======================================================================
// Main thread
int main()
{
PC.baud(115200);
ESP.baud(115200);
PC.attach(&ISR_PC_to_ESP, Serial::RxIrq);
ESP.attach(&ISR_ESP_to_PC, Serial::RxIrq);
while(1) {
sleep();
}
}
// ======================================================================