132

Dependencies:   DMSupport DMemWin

Fork of Motor_Embedded_3rd_emwin by Wei Chang Shen

main.cpp

Committer:
Will_Lu
Date:
2017-07-12
Revision:
3:1823bfc913c1
Parent:
0:08606a13a816

File content as of revision 3:1823bfc913c1:

#include "mbed.h"
#include "DMBoard.h"
#include "EwHAL.h"
#include "WM.h"

void MainTask(void);


extern "C" void mbed_mac_address(char *mac)
{
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
};


int main()
{
//  set_time(1461971280);
  DMBoard::BoardError err;
  DMBoard* board = &DMBoard::instance();
  RtosLog* log = board->logger();
  Display* disp = board->display();

  do {
    err = board->init();
    if (err != DMBoard::Ok) {
      log->printf("Failed to initialize the board, got error %d\r\n", err);
      break;
    }

    log->printf("\n\nHello World!\r\n\n");

    // Create the HAL for emWin
    // - Use 3 frame buffers for tripple-buffering
    // - Allow emWin to use 12MByte of external SDRAM
    EwHAL hal(3, 12*1024*1024);

    // Start display in default mode (16-bit)
    Display::DisplayError disperr = disp->powerUp(hal.getFrameBufferAddress());
    if (disperr != Display::DisplayError_Ok) {
      log->printf("Failed to initialize the display, got error %d\r\n", disperr);
      break;
    }

    // Add extra options here
    // - Set WM_CF_MEMDEV option to use "Memory Devices" to reduce flickering
    WM_SetCreateFlags(WM_CF_MEMDEV);

    // Execute the emWin example and never return...
    MainTask();
  } while(false);

  mbed_die();
}