DirectSPI test program

Dependencies:   DirectSPI mbed

Files at this revision

API Documentation at this revision

Comitter:
mimi3
Date:
Sun Feb 26 20:50:58 2017 +0900
Parent:
8:e11a0361f57f
Commit message:
update: mbed-scli v0.5

Changed in this revision

Makefile Show annotated file Show diff for this revision Revisions of this file
makelib.py Show annotated file Show diff for this revision Revisions of this file
diff -r e11a0361f57f -r 7dfa4f5adf42 Makefile
--- a/Makefile	Sat Feb 25 16:11:44 2017 +0900
+++ b/Makefile	Sun Feb 26 20:50:58 2017 +0900
@@ -1,6 +1,6 @@
 #
 # Super light weight command line compile script using mbed-sdk sources.
-# v0.4
+# v0.5
 # 2017/02 made by dinau
 #
 
@@ -28,6 +28,7 @@
 # These are must be changed according to your environment.
 ##########################
 TARGET		?= NUCLEO_F030R8
+#TARGET		?= NUCLEO_L152RE
 
 # GCC_ARM or uARM or ARM
 TC			?= GCC_ARM
@@ -39,10 +40,12 @@
 MBED_ROOT	= /d/mbed-os
 
 # Specify [ "default" or "debug" or "small" ]
-PROFILE		= --profile default
+PROFILE		= default
 
 # Verbose display
-#VERBOSE		= -v
+ifeq (${v},1)
+	VERBOSE		= -v
+endif
 
 ##########################
 # Fixed setting.
@@ -54,7 +57,7 @@
 MACROS		= "-D NDEBUG=1"
 #CFLAGS		= "--cflags NDEBUG=1"
 BUILD_DIR	= .build/${TARGET}/${TC}
-COMFLAG		= --color -m ${TARGET} -t ${TC} ${VERBOSE} ${PROFILE}
+COMFLAG		= --color -m ${TARGET} -t ${TC} ${VERBOSE} --profile ${PROFILE}
 PROG_NAME	= -n ${PROG}
 
 ##########################
diff -r e11a0361f57f -r 7dfa4f5adf42 makelib.py
--- a/makelib.py	Sat Feb 25 16:11:44 2017 +0900
+++ b/makelib.py	Sun Feb 26 20:50:58 2017 +0900
@@ -1,8 +1,7 @@
 ####  lib.py for mbed ####
-# v0.4
+# v0.5
 # 2017/02 made by dinau
 #
-
 # Notice: Unsupported libraries.
 #         These libraries must be specified in Makefile.
 #   mbed-os
@@ -14,54 +13,102 @@
 # or
 #   $ python makelib.py
 #
-
 import os,sys
 import commands
+from urlparse import urlparse
+HG              = 1
+GIT             = 2
+MBEDOS          = 3
+CMD_HG_CLONE    = 'hg clone -q '
+CMD_GIT_CLONE   = 'git clone -q '
+CMD_GIT_CHECKOUT= 'git checkout -q '
 
-def getlibs(cdir):
+def hgClone(param):
+    cmd = CMD_HG_CLONE + param
+    return os.system( cmd )
+
+def gitClone(param):
+    cmd = CMD_GIT_CLONE + param
+    return os.system( cmd )
+
+def gitCheckout(param):
+    cmd = CMD_GIT_CHECKOUT + param
+    return os.system( cmd )
+
+def getDvcs(url):
+    if ('developer.mbed.org' in url) or ('mbed.org' in url) or ('bitbucke.org' in url):
+        return HG;
+    elif 'mbed-os' in url:
+        return MBEDOS
+    elif 'github.com' in url:
+        return GIT
+    else:
+        return 0
+
+def getLibs(target_dir):
+    savedir = os.getcwd()
+    os.chdir(target_dir)
     liblist=[]
-    for f in os.listdir(cdir):
-        if os.path.isfile(f):
-            name, ext = os.path.splitext(f)
+    for fname in os.listdir('.'):
+        if os.path.isfile(fname):
+            name, ext = os.path.splitext(fname)
             if ext == '.lib':
                 if name != 'mbed-os':
-                    liblist.append(f)
+                    liblist.append(fname)
     if len( liblist )  > 0:
-        for f in liblist:
-            subdir, ext = os.path.splitext(f)
+        #print liblist
+        for libfile in liblist:
+            subdir, ext = os.path.splitext(libfile)
             print subdir
-            url = open(f).read()
+            url = open(libfile).read()
             print url
             sys.stdout.flush()
-            if ('developer.mbed.org' in url) or ('mbed.org' in url):
-                cmd = 'hg clone -q ' + url
-                res = os.system( cmd )
-                os.chdir(subdir)
-                getlibs(cdir)
-            elif 'mbed-os' in url:
-                print 'mbed-os is unsupported at this moment.'
-            elif 'github.com' in url:
-                urllist = url.split('#')
-                if len(urllist) == 1:
-                    cmd = 'git clone ' + urllist[0]
-                    res = os.system( cmd )
-                    os.chdir(subdir)
-                    getlibs(cdir)
-                elif len(urllist) == 2:
-                    cmd = 'git clone -q ' + urllist[0]
-                    print cmd
-                    sys.stdout.flush()
-                    res = os.system( cmd )
+            dvcs = getDvcs(url)
+            if dvcs == HG:
+                hgClone( url )
+                getLibs(subdir)
+            elif dvcs == MBEDOS:
+                # Nothing is downloaded if mbed-os lib be.
+                print 'mbed-os'
+                sys.stdout.flush()
+            elif dvcs == GIT:
+                params = url.split('#')
+                if len(params) == 1:
+                    gitClone( params[0] )
+                    getLibs(subdir)
+                elif len(params) == 2:
+                    gitClone( params[0] )
                     os.chdir(subdir)
                     print 'cd %s' % (subdir)
                     sys.stdout.flush()
-                    cmd = 'git checkout -q ' + urllist[1]
-                    print cmd
-                    sys.stdout.flush()
-                    res = os.system( cmd )
-                    getlibs(cdir)
-
-print '--- Getting libraries ----'
-getlibs('.')
-print '--- end ---'
-
+                    gitCheckout( params[1] )
+                    getLibs(subdir)
+    os.chdir(savedir)
+###################
+# main prog
+###################
+if len(sys.argv) >= 2:
+    url = sys.argv[1]
+    dvcs = getDvcs( url )
+    if dvcs == HG:
+        p = urlparse( url )
+        path = p.path
+        if path[-1:] == '/':
+            path = path[:-1]
+        libdir = os.path.basename(path)
+        hgClone( url )
+        getLibs(libdir)
+    elif dvcs == GIT:
+        params = url.split('#')
+        if len(params) == 1:
+            gitClone( params[0] )
+        elif len(params) == 2:
+            gitClone( params[0] )
+            os.chdir(subdir)
+            print 'cd %s' % (subdir)
+            sys.stdout.flush()
+            gitCheckout( params[1] )
+else:
+    print '--- Getting libraries ----'
+    getLibs('.')
+    print '--- end ---'