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
00001 #include "mbed.h" 00002 00003 /* to test if code loaded properly 00004 */ 00005 DigitalOut myled(LED2); 00006 00007 // to power the rf module 00008 DigitalOut power(p30); 00009 DigitalOut powerStatus(LED1); 00010 00011 /* for time division multiplexing. 00012 * when an rf tx requires to send signals, 00013 * it request the other own operating at the same 00014 * freqeuncy to shut itself down. The other module also 00015 * follows the same behavioural code! 00016 */ 00017 InterruptIn inRequest(p5); 00018 DigitalOut outRequest(p6); 00019 00020 00021 Serial tx(p9, p10); 00022 Serial pc(USBTX, USBRX); 00023 00024 // turn RF tx off 00025 void turnOffRF() { 00026 power = 0; 00027 powerStatus = 0; 00028 } 00029 00030 // turn RF tx on 00031 void turnOnRF() { 00032 power = 1; 00033 powerStatus = 1; 00034 } 00035 00036 // send a request to the other RF tx to kindly shut down 00037 void sendRequest() { 00038 outRequest = 0; 00039 wait(0.1); 00040 outRequest = 1; 00041 } 00042 00043 int main() 00044 { 00045 power = 0; // power to the RF tx 00046 powerStatus = 0; // power status of the RF tx 00047 myled = 1; 00048 char msg[10]; 00049 00050 tx.baud(2400); 00051 00052 /* turn RF tx off when requested by the other tx 00053 */ 00054 inRequest.rise(turnOffRF); 00055 00056 turnOffRF(); 00057 00058 /* read messages from the serial port of the computer 00059 * and broadcast them 00060 */ 00061 while (1) { 00062 while (pc.readable()) { 00063 if (power == 0) { 00064 sendRequest(); // send request to the other RF tx to shut itself down. 00065 turnOnRF(); 00066 } 00067 msg[0] = pc.getc(); 00068 tx.putc(msg[0]); 00069 pc.putc(msg[0]); 00070 } 00071 00072 } 00073 }
Generated on Thu Jul 28 2022 18:07:00 by
1.7.2