Embedded Artists


We are the leading providers of products and services around prototyping, evaluation and OEM platforms using NXP's ARM-based microcontrollers.

LPC4088DM Using Ethernet

The display modules come with 100/10Mbps Ethernet, RJ45 connector and unique MAC address.

The MAC address is unique (read from an onboard EEPROM with EUI-48) between the display modules. The actual address is retrieved by the Ethernet Interface through the mbed_mac_address() function in the mbed SDK, which is handled in the DMSupport library. No special setup needed.

Simple network example

The example below shows how to setup a network using DHCP and then retrieve IP addresses:

#include "EthernetInterface.h"
...
EthernetInterface eth;
...
void foo() {
  RtosLog* log = DMBoard::instance().logger();
  log->printf("EthernetInterface Setting up...\n");
  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);
  }
  else {
  
    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("MAC Address is %s\n", eth.get_mac_address());
    log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n");
  
  }    
  
}


And with a static IP address:

#include "EthernetInterface.h"
...
EthernetInterface eth;
...
void foo() {
  nsapi_error_t net_err;
  RtosLog* log = DMBoard::instance().logger();
  log->printf("EthernetInterface Setting up...\n");
  
  do {
    net_err = eth.set_network("192.168.0.10", "255.255.255.0", "192.168.0.1");   
    if (net_err != NSAPI_ERROR_OK) {
      log->printf(NET_TASK_PREFIX"EthernetInterface set_network failed %d\r\n", net_err);
      break;
    }

    net_err = eth.connect();
    if (net_err != NSAPI_ERROR_OK) {
      log->printf(NET_TASK_PREFIX"EthernetInterface connect failed %d\r\n", net_err);
      break;
    }

    log->printf(NET_TASK_PREFIX"EthernetInterface connected\r\n");

  } while(false);

}


HttpServer

The DMSupport library contains a fork of the HttpServer library by Yasushi TAUCHI.

Warning

The HttpServer library was implemented for mbed OS 2 and not mbed OS 5. It has been updated to compile with mbed OS 5, but it has not been fully tested. If you experience problems it might be better to look for other implementations that has been written for mbed OS 5. The http-webserver-example might be an alternative.

The Http server start function will run forever, so the code should be executed in it's own thread like this:

#include "EthernetInterface.h"
#include "HTTPServer.h"


void netTask(void)
{
  RtosLog* log = DMBoard::instance().logger();
  log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n"); 

  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);
  }
  else {

      ethInitialized = true;
      ethUsingDHCP = true;
    
      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("/mci", "/");
      HTTPServerAddHandler<FSHandler>("/");
      //lcd.locate(0,0);
      //lcd.printf("%s",eth.getIPAddress());
      HTTPServerStart(80);

  }     
}

void main() {
  ...
  Thread tNetwork(osPriorityNormal, 8192);
  tNetwork.start(netTask);
  ...
}



All wikipages