This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PlatformInfo.cpp Source File

PlatformInfo.cpp

00001 #include "PlatformInfo.h"
00002 #define REG_HCSR 0xe000edf0
00003 #define REG_DEMCR 0xE000EDFC
00004 
00005 #include "mbed.h"
00006 #include "NyLPC_os.h"
00007 namespace MiMic
00008 {
00009     int PlatformInfo::_pftype=PF_UNKNOWN;
00010 #if PlatformInfo_DETECTION_MODE==PlatformInfo_DETECTION_MODE_MBED
00011     void PlatformInfo::check()
00012     {
00013         _pftype=PF_MBED;
00014         return;
00015     }
00016 #elif PlatformInfo_DETECTION_MODE==PlatformInfo_DETECTION_MODE_LPCXPRESSO
00017     void PlatformInfo::check()
00018     {
00019         _pftype=PF_LPCXPRESSO;
00020         return;
00021     }
00022 #elif PlatformInfo_DETECTION_MODE==PlatformInfo_DETECTION_MODE_AUTO    
00023     void PlatformInfo::check()
00024     {
00025 #   ifdef TARGET_K64F
00026         _pftype=PF_MBED;        
00027 #   else
00028         //LPCXpresso is return S_RESET_ST==1 when standalone.
00029         wait_ms(200);
00030         unsigned int v;
00031         v=*(unsigned int*)REG_HCSR;
00032         //check Debug Halting Control and Status::S_RESET_ST sticky bit
00033         if((v & 0x02000000)!=0){
00034             //may be LPC-Standalone
00035             _pftype=PF_LPCXPRESSO;        
00036             return;
00037         }
00038         v=(*(unsigned int*)REG_DEMCR);
00039         if((v & 0x01000000)==0x0){
00040             //may be mbed
00041             _pftype=PF_MBED;
00042             return;
00043         }
00044         _pftype=PF_LPCXPRESSO;
00045         return;
00046 #   endif        
00047     }
00048 #else
00049     #error "ERROR!"
00050 #endif
00051     
00052     int PlatformInfo::getPlatformType()
00053     {
00054         if(_pftype==PF_UNKNOWN){
00055             check();
00056         }
00057         return _pftype;
00058     }
00059 }