Demo for Embedded World 2015.
Dependencies: DMBasicGUI DMSupport
Demo running on several LPC4088 Display Modules on the Embedded World 2015 exhibition.
Information
To run the demo first drag-n-drop the to_sync.fs3 file to the MBED drive and then drag-n-drop the demo itself. This way both the file system and software are up to date.
This is what the launcher will look like:
Diff: main.cpp
- Revision:
- 1:1a01ef434a72
- Parent:
- 0:6bd24cbb88a1
--- a/main.cpp Thu Feb 19 13:54:53 2015 +0000 +++ b/main.cpp Tue Nov 05 08:20:16 2019 +0000 @@ -7,7 +7,6 @@ #include "rtos.h" #include "EthernetInterface.h" #include "HTTPServer.h" -#include "mbed_rpc.h" #include "USBHostMSD.h" #include "USBHostMouse.h" #include "USBHostKeyboard.h" @@ -50,7 +49,7 @@ * Local functions *****************************************************************************/ -void aliveTask(void const* args) +void aliveTask(void) { DMBoard* board = &DMBoard::instance(); @@ -58,16 +57,16 @@ { board->setLED(DMBoard::Led4, false); board->setLED(DMBoard::Led1, true); - Thread::wait(300); + ThisThread::sleep_for(300); board->setLED(DMBoard::Led1, false); board->setLED(DMBoard::Led2, true); - Thread::wait(300); + ThisThread::sleep_for(300); board->setLED(DMBoard::Led2, false); board->setLED(DMBoard::Led3, true); - Thread::wait(300); + ThisThread::sleep_for(300); board->setLED(DMBoard::Led3, false); board->setLED(DMBoard::Led4, true); - Thread::wait(300); + ThisThread::sleep_for(300); } } @@ -125,7 +124,7 @@ } #define SWIM_TASK_PREFIX "[SWIM] " -void swimTask(void const* args) +void swimTask(void) { RtosLog* log = DMBoard::instance().logger(); @@ -162,34 +161,30 @@ #define NET_TASK_PREFIX "[NET] " -void netTask(void const* args) +void netTask(void) { RtosLog* log = DMBoard::instance().logger(); log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n"); - if(eth.init()!=0) { //for DHCP Server - //if(eth.init(IPAddress,NetMasks,Gateway)!=0) { //for Static IP Address - log->printf(NET_TASK_PREFIX"EthernetInterface Initialize Error \r\n"); - mbed_die(); + nsapi_error_t net_err = eth.connect(); + + if (net_err != NSAPI_ERROR_OK) { + log->printf(NET_TASK_PREFIX"EthernetInterface connect Error %d\r\n", net_err); } - while (eth.connect() != 0) { - Thread::wait(1000); - } + else { - ethInitialized = true; - ethUsingDHCP = true; + ethInitialized = true; + ethUsingDHCP = true; - log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.getIPAddress()); - log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.getNetworkMask()); - log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.getGateway()); - log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n"); + log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.get_ip_address()); + log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.get_netmask()); + log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.get_gateway()); + log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n"); - HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler - FSHandler::mount("/usb", "/"); - HTTPServerAddHandler<FSHandler>("/"); - //HTTPServerAddHandler<RPCHandler>("/rpc"); - //lcd.locate(0,0); - //lcd.printf("%s",eth.getIPAddress()); - HTTPServerStart(80); + HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler + FSHandler::mount("/mci", "/"); + HTTPServerAddHandler<FSHandler>("/"); + HTTPServerStart(80); + } } static volatile int8_t mouse_button, mouse_x, mouse_y, mouse_z; @@ -338,13 +333,14 @@ #define USB_TASK_PREFIX "[USB] " #define USB_CONNECTION_EVENT (1<<4) -void usbTask(void const* args) +void usbTask(void) { USBHostMSD* msd = new USBHostMSD("usb"); USBHostKeyboard* keyboard = new USBHostKeyboard(); USBHostMouse* mouse = new USBHostMouse(); USBHost* host = USBHost::getHostInst(); - host->signalOnConnections(Thread::gettid(), USB_CONNECTION_EVENT); + EventFlags connectionEvent; + host->signalOnConnections(&connectionEvent, USB_CONNECTION_EVENT); RtosLog* log = DMBoard::instance().logger(); @@ -354,7 +350,7 @@ while (true) { // wait for connect/disconnect message from USBHost - Thread::signal_wait(USB_CONNECTION_EVENT); + connectionEvent.wait_any(USB_CONNECTION_EVENT); log->printf(USB_TASK_PREFIX"got USB event\n"); if (msd->connected()) { @@ -432,30 +428,34 @@ if (err != DMBoard::Ok) { log->printf("Failed to initialize the board, got error %d\r\n", err); log->printf("\nTERMINATING\n"); - wait_ms(2000); // allow RtosLog to flush messages + ThisThread::sleep_for(2000); // allow RtosLog to flush messages mbed_die(); } board->buzzer(440,50); - wait_ms(30); + ThisThread::sleep_for(30); board->buzzer(660,50); - wait_ms(30); + ThisThread::sleep_for(30); board->buzzer(440,50); log->printf("\n\n---\nDemo for Embedded World 2015\nBuilt: " __DATE__ " at " __TIME__ "\n\n"); - Thread tAlive(aliveTask); + Thread tAlive; + tAlive.start(aliveTask); #if defined(DM_BOARD_USE_DISPLAY) - Thread tSwim(swimTask, NULL, osPriorityNormal, 8192); + Thread tSwim(osPriorityNormal, 8192); + tSwim.start(swimTask); #endif - Thread tNetwork(netTask, NULL, osPriorityNormal, 8192); - Thread tUSBHandler(usbTask, NULL, osPriorityNormal, 8192); + Thread tNetwork(osPriorityNormal, 8192); + tNetwork.start(netTask); + Thread tUSBHandler(osPriorityNormal, 8192); + tUSBHandler.start(usbTask); while(1) { // Wait forever (in 1h increments) to prevent the tAlive, tSwim, // tNetwork and tUSBHandler thread from being garbage collected. - Thread::wait(3600*1000); + ThisThread::sleep_for(3600*1000); } }