Arkadi Rafalovich
/
STM32_Print_PC-Xbee
xbee shield simple test code
main.cpp
- Committer:
- Arkadi
- Date:
- 2019-02-04
- Revision:
- 1:2b7034eb3015
- Parent:
- 0:1b9c87e81f07
File content as of revision 1:2b7034eb3015:
#include "mbed.h" /*------------------------------------------------------------------------------ Before to use this example, ensure that you an hyperterminal installed on your computer. More info here: https://developer.mbed.org/handbook/Terminals The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their definition in the PinNames.h file). The default serial configuration in this case is 9600 bauds, 8-bit data, no parity If you want to change the baudrate for example, you have to redeclare the serial object in your code: Serial pc(SERIAL_TX, SERIAL_RX); Then, you can modify the baudrate and print like this: pc.baud(115200); pc.printf("Hello World !\n"); ------------------------------------------------------------------------------*/ DigitalOut led(LED1); Serial pc(SERIAL_TX, SERIAL_RX); Serial xbee(PA_9, PA_10); int main() { pc.baud(9600); xbee.baud(9600); int i = 1; pc.printf("Hello World pc!\r\n"); xbee.printf("Hello World Xbee!\r\n"); while(1) { wait(1); // 1 second led = !led; // Toggle LED pc.printf("PC - This program runs since %d seconds.\r\n", i++); xbee.printf("Xbee - This program runs since %d seconds.\r\n", i++); } }