update_periph_lib.py

00001 #!/usr/bin/env python
00002 
00003 import urllib, zipfile, StringIO
00004 from os import path, mkdir
00005 
00006 extra_headers = ['stm32f10x.h','core_cm3.h','cortexm3_macro.h','system_stm32f10x.h']
00007 extra_sources = ['core_cm3.c','cortexm3_macro.s','system_stm32f10x.c']
00008 startup_files = ['startup_stm32f10x_hd.s']
00009 
00010 stm32liburl = 'http://www.st.com/stonline/products/support/micro/files/stm32f10x_stdperiph_lib.zip'
00011 
00012 webFile = urllib.urlopen(stm32liburl)
00013 print 'Downloading Peripheral Library...'
00014 stm32lib = zipfile.ZipFile(StringIO.StringIO(webFile.read()))
00015 
00016 if not path.exists('FWlib'):
00017   mkdir('FWlib')
00018 
00019 print 'Extracting...'
00020 for file in stm32lib.filelist:
00021   if path.split(path.dirname(file.filename))[0][-26:] == 'STM32F10x_StdPeriph_Driver':
00022      if file.filename[-1] == 'c' or file.filename[-1] == 'h':
00023        file.filename = path.join('FWlib',path.split(path.dirname(file.filename))[1], path.basename(file.filename))
00024        print file.filename
00025        stm32lib.extract(file)
00026   if path.basename(file.filename) in extra_headers:
00027     file.filename = path.join('FWlib','inc',path.basename(file.filename))
00028     print file.filename
00029     stm32lib.extract(file)
00030   if path.basename(file.filename) in extra_sources:
00031     file.filename = path.join('FWlib','src',path.basename(file.filename))
00032     print file.filename
00033     stm32lib.extract(file)
00034   if path.basename(file.filename) in startup_files:
00035     if path.split(path.dirname(file.filename))[1] == 'gcc':
00036       file.filename = path.join('FWlib','src',path.basename(file.filename))
00037       print file.filename
00038       stm32lib.extract(file)

Generated on Mon Oct 18 07:40:47 2010 for Python-on-a-chip by  doxygen 1.5.9