6 # print s+" --- "+ re.sub(".*/([0-9]*) .*",r"\1",s)
7 return re.sub(".*/([0-9]*).*",r"\1",s.split("\n")[0])
11 timer=re.sub("CS([0-3n])0.*",r"\1",s.split("\n")[0])
13 cut=re.search("CS[^%s]"%timer, s)
18 separators=[" CK", "PCK", "clkI/O", "clkT0S", "clkT2S"]
19 separators=map(lambda x:(s.count(x),x), separators)
20 separators.sort(cmp=lambda x,y:cmp(x[0],y[0]))
34 if x<prev_x: newlist=[timer, 0, 1] # reinit
36 if x!=1:newlist.append(x)
39 if re.match(".*[fF]alling.*[rR]ising.*", s):
50 out+="/* prescalers timer %s */\n"%n
55 line="#define TIMER%s_PRESCALER_DIV_%d"%(n,d)
56 out+="%s%s%d\n"%(line, (35-len(line))*" ", i)
58 line="#define TIMER%s_PRESCALER_EXT_FALL"%(n)
59 out+="%s%s%d\n"%(line, (35-len(line))*" ", i)
61 line="#define TIMER%s_PRESCALER_EXT_RISE"%(n)
62 out+="%s%s%d\n"%(line, (35-len(line))*" ", i)
68 out+="#define TIMER%s_PRESCALER_REG_%d %d\n"%(n,i,d)
76 if len(sys.argv) != 3:
77 print "bad args. usage: parse_doc.py DOC_DIR DST_DIR"
80 for name in os.listdir(sys.argv[1]):
81 f=open(os.path.join(sys.argv[1],name))
84 list+=(re.findall('CS00.*topped.' + '.*\n'*15, s))
85 list+=(re.findall('CS10.*topped.' + '.*\n'*15, s))
86 list+=(re.findall('CS20.*topped.' + '.*\n'*15, s))
87 list+=(re.findall('CS30.*topped.' + '.*\n'*15, s))
88 list+=(re.findall('CSn0.*topped.' + '.*\n'*15, s))
89 print "---- %s ----"%name
91 g=open(os.path.join(sys.argv[2],name),"w")
103 clks.sort(cmp=lambda x,y:cmp(int(x[0]),int(y[0])))
104 defines=get_defs(clks)
105 g.write("%s\n"%defines)