Simply UART communication for STM32F0 Discovery using mbed. Received char is sent back to the computer.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:edbb83dae353
- Parent:
- 2:3f9a1eb39b79
- Child:
- 4:61f0ff55c75d
--- a/main.cpp Sat Apr 04 11:15:32 2015 +0000 +++ b/main.cpp Sat Apr 04 14:32:38 2015 +0000 @@ -34,23 +34,6 @@ DigitalOut blue(PC_8); // inicialize blue LED on STM32F0 discovery DigitalOut green(PC_9); // inicialize green LED on STM32F0 discovery -//-------------------------------------- -// Hyperterminal configuration is default -// 9600 bauds, 8-bit data, no parity -//-------------------------------------- -// Communication settings: -// pc.format(bits,parity,stop_bits) -// bits: 5-8 -// parity: SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0 -// stop_bits: 1 or 2 -// pc.baudrate(baud) -// baud: The desired baudrate (speed) -//-------------------------------------- -// Example for default settings: -// pc.format(8,SerialBase::None,1); -// pc.baud(9600); -//-------------------------------------- - /* Functions----------------------------------------------------------------------*/ /******************************************************************************* @@ -77,7 +60,24 @@ * Return : None. ***********************************************************************************/ int main() -{ +{ +//-------------------------------------- +// Hyperterminal configuration is default +// 9600 bauds, 8-bit data, no parity +//-------------------------------------- +// Communication settings: +// pc.format(bits,parity,stop_bits) +// bits: 5-8 +// parity: SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0 +// stop_bits: 1 or 2 +// pc.baudrate(baud) +// baud: The desired baudrate (speed) +//-------------------------------------- +// Example for default settings: +// pc.format(8,SerialBase::None,1); +// pc.baud(9600); +//-------------------------------------- + int i = 1; // inkrements every second pc.printf("Program started !\r\n"); // text displayed on a computer pc.attach(&serialRx,Serial::RxIrq); // Attach a function serialRx to call whenever a serial interrupt is generated