if mname == "init": for cl in ccode: m << cl if mname.startswith("_"): m = OMethod(mname[1:], "void", args, mods={PRIVATE}) c << m write_file(c, PATH) # Read MSP430 pin configuration from text file and generate macros to access output pins. # p = ParseOrg("launchpad.org") #sc = OClass("port_sim") c = Port() gen.handleExports(c) spi = Spi() gen.handleExports(spi) for i in [1, 2]: pdir = [] pname = "P"+str(i) for bit, direction, name in p.parse()[1:]: bname = "BIT"+str(bit) if direction in ["OUT", "IN/OUT"]: c << OMacro("set_"+name, pname+"OUT |= "+bname) c << OMacro("clr_"+name, pname+"OUT &= ~"+bname) c << OMacro("toggle_"+name, pname+"OUT ^= "+bname) pdir.append(bname)
m = OMethod(mname, tpe, args) if mname == "init": for cl in ccode: m << cl if mname.startswith("_"): m = OMethod(mname[1:], "void", args, mods={PRIVATE}) c << m writeFile2(s, c) # Read STM32 pin configuration from text file and generate macros to access output pins. # p = ParseOrg("stm32.org") c = Port() gen.handleExports(c) spi = Spi() gen.handleExports(spi) c.m << "GPIO_InitTypeDef ioInit;" pins = [] for i in ['A', 'B', 'C']: pout = [] pin = [] paf = [] for bit, af, desc, direction in p.parse()[1:]: af = af.strip() #print "AF:",af,len(af)
def macro(self, func, reg): return OMacro(func+"_"+self.desc, "GPIO"+self.port+"->"+reg+" GPIO_Pin_"+self.pin) def pin_name(self): return "GPIO_PIN_" + self.pin def reg(self, reg): return "GPIO" + self.port + "->" + reg # Read STM32 pin configuration from text file and generate macros to access output pins. # p = ParseOrg(FILENAME) c = Port() gen.handleExports(c) spi = Spi() gen.handleExports(spi) c.m << "GPIO_InitTypeDef ioInit;" p.parse() table = p.items[0].items[0] table2 = [PinDef(x) for x in table[1:] if len(x[2]) > 0 and x[2][0] != "["] ports = list(set([pin.port for pin in table2])) # all unique ports in the pins ports.sort() pins = []