Mbed Shield for mbed LPC1768
.
The Mbed Shield is an extention board for mbed LPC1768 to use a large number of Grove and Shield products. It integrates a series of interfaces, such as Ethernet, USB Host, CAN and 4 Grove connectors.
Features
- Standard shield shape
- 4 Grove connectors
- Ethernet, USB Host and CAN
Order
Get one from Seeed Studio.
Get Started
Import program
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 00004 int main() { 00005 EthernetInterface eth; 00006 eth.init(); //Use DHCP 00007 eth.connect(); 00008 printf("IP Address is %s\n", eth.getIPAddress()); 00009 00010 TCPSocketConnection sock; 00011 sock.connect("mbed.org", 80); 00012 00013 char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; 00014 sock.send_all(http_cmd, sizeof(http_cmd)-1); 00015 00016 char buffer[300]; 00017 int ret; 00018 while (true) { 00019 ret = sock.receive(buffer, sizeof(buffer)-1); 00020 if (ret <= 0) 00021 break; 00022 buffer[ret] = '\0'; 00023 printf("Received %d chars from server:\n%s\n", ret, buffer); 00024 } 00025 00026 sock.close(); 00027 00028 eth.disconnect(); 00029 00030 while(1) {} 00031 }
Import program
00001 #include "mbed.h" 00002 #include "USBHostMSD.h" 00003 00004 DigitalOut led(LED1); 00005 00006 void msd_task(void const *) { 00007 00008 USBHostMSD msd("usb"); 00009 int i = 0; 00010 00011 while(1) { 00012 00013 // try to connect a MSD device 00014 while(!msd.connect()) { 00015 Thread::wait(500); 00016 } 00017 00018 // in a loop, append a file 00019 // if the device is disconnected, we try to connect it again 00020 while(1) { 00021 00022 // append a file 00023 FILE * fp = fopen("/usb/test1.txt", "a"); 00024 00025 if (fp != NULL) { 00026 fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++); 00027 printf("Goodbye World!\r\n"); 00028 fclose(fp); 00029 } else { 00030 printf("FILE == NULL\r\n"); 00031 } 00032 00033 Thread::wait(500); 00034 00035 // if device disconnected, try to connect again 00036 if (!msd.connected()) 00037 break; 00038 } 00039 00040 } 00041 } 00042 00043 00044 int main() { 00045 Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4); 00046 while(1) { 00047 led=!led; 00048 Thread::wait(500); 00049 } 00050 }
Resource
Please log in to post comments.