This program can detect the type(mbed or LPCXpresso) of platform. The sample recognizes mbed or LPCXpresso.

Dependencies:   mbed

This program detects the LPCXpresso and mbed at run time.

There is a difference in the value of the CoreDebugRegister LPCXpresso and mbed.

The program check those bits and select platform type.

#include "mbed.h"
#include "PlatformInfo.h"
DigitalOut mbedled(LED1);
DigitalOut lpcxled(P0_22);
using namespace MiMic;
int main(){
    switch(PlatformInfo::getPlatformType()){
    case PlatformInfo::PF_MBED:
        while(1) {
            mbedled = 1;
            wait(0.2);
            mbedled = 0;
            wait(0.2);
        }
    case PlatformInfo::PF_LPCXPRESSO:
        while(1) {
            lpcxled = 1;
            wait(0.1);
            lpcxled = 0;
            wait(0.1);
        }
    }    
}

If program run on mbed, LED1(blue) will be blinking. If it run on LPCXpresso, LED2(red) will be blinking.

PlatformInfo.h

Committer:
nyatla
Date:
2013-05-05
Revision:
0:ef577a5fd78f

File content as of revision 0:ef577a5fd78f:

#pragma once

namespace MiMic
{
    #define PlatformInfo_DETECTION_MODE_AUTO 1
    #define PlatformInfo_DETECTION_MODE_MBED 2
    #define PlatformInfo_DETECTION_MODE_LPCXPRESSO 3
    #define PlatformInfo_DETECTION_MODE PlatformInfo_DETECTION_MODE_AUTO

    class PlatformInfo
    {
    public:
        const static int PF_UNKNOWN=0;
        const static int PF_MBED=1;
        const static int PF_LPCXPRESSO=2;
        /**
         * This function returns platform type value.
         */
        static int getPlatformType();
    private:
        static void check();
        static int _pftype;
        PlatformInfo(){};
    };
}