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.

Committer:
nyatla
Date:
Sun May 05 11:29:12 2013 +0000
Revision:
0:ef577a5fd78f
Sample of platform detection

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 0:ef577a5fd78f 1 #include "mbed.h"
nyatla 0:ef577a5fd78f 2 #include "PlatformInfo.h"
nyatla 0:ef577a5fd78f 3 DigitalOut mbedled(LED1);
nyatla 0:ef577a5fd78f 4 DigitalOut lpcxled(P0_22);
nyatla 0:ef577a5fd78f 5 using namespace MiMic;
nyatla 0:ef577a5fd78f 6 int main(){
nyatla 0:ef577a5fd78f 7
nyatla 0:ef577a5fd78f 8
nyatla 0:ef577a5fd78f 9
nyatla 0:ef577a5fd78f 10 switch(PlatformInfo::getPlatformType()){
nyatla 0:ef577a5fd78f 11 case PlatformInfo::PF_MBED:
nyatla 0:ef577a5fd78f 12 while(1) {
nyatla 0:ef577a5fd78f 13 mbedled = 1;
nyatla 0:ef577a5fd78f 14 wait(0.2);
nyatla 0:ef577a5fd78f 15 mbedled = 0;
nyatla 0:ef577a5fd78f 16 wait(0.2);
nyatla 0:ef577a5fd78f 17 }
nyatla 0:ef577a5fd78f 18 case PlatformInfo::PF_LPCXPRESSO:
nyatla 0:ef577a5fd78f 19 while(1) {
nyatla 0:ef577a5fd78f 20 lpcxled = 1;
nyatla 0:ef577a5fd78f 21 wait(0.1);
nyatla 0:ef577a5fd78f 22 lpcxled = 0;
nyatla 0:ef577a5fd78f 23 wait(0.1);
nyatla 0:ef577a5fd78f 24 }
nyatla 0:ef577a5fd78f 25 }
nyatla 0:ef577a5fd78f 26 }