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 #include "mbed_globals.h" 00004 #include "interrupts.h" 00005 #include "serial.h" 00006 #include "leds.h" 00007 00008 void serialOut(unsigned char c) { 00009 SERIAL_PUTCHAR(c); 00010 } 00011 00012 void serialOutString(const char * c) { 00013 while (*c) { 00014 SERIAL_PUTCHAR(*c); 00015 c++; 00016 } 00017 } 00018 00019 void serialOutHex32(unsigned int i) 00020 { 00021 for(int j = 0; j < 8; j++) 00022 { 00023 unsigned char c = (i & 0xF0000000) >> 28; 00024 if(c < 10) 00025 serialOut('0' + c); 00026 else 00027 serialOut('A' + c - 10); 00028 i = i << 4; 00029 } 00030 } 00031 00032 SERIAL_INTERRUPT_HANDLER(void) { 00033 // Check if interrupt is pending 00034 if(!SERIAL_CHECK_INTERRUPT()) 00035 return; 00036 00037 // While some data to read 00038 while (SERIAL_DATA_TO_READ()) { 00039 char c = SERIAL_GETCHAR(); 00040 serialOut('['); 00041 serialOut(c); 00042 serialOut(']'); 00043 } 00044 } 00045 00046 int main() { 00047 // Hardware Init 00048 SERIAL_INIT(); 00049 SERIAL_SETBAUD(9600); 00050 SERIAL_ENABLE_INTERRUPT(SERIAL_INT_RX); 00051 00052 serialOutString("Simple UART Sample Code\r\n"); 00053 00054 while (1); 00055 }
Generated on Sat Jul 23 2022 02:39:54 by
1.7.2