コード例 #1
0
    def read(self, meth):
        meth.args = [OArg("pin", BYTE)]
        self.sr = OSwitch("pin")

        meth << "uint8_t ret=0;"
        meth << self.sr
        meth << "return ret;"
コード例 #2
0
ファイル: config.py プロジェクト: j-a-r-i/CodeGen
class Port(OClass):
    def __init__(self):
        OClass.__init__(self, "io")
        self.pin_id = 1
        self.ss = None
        self.sc = None

    @export(VOID)
    def init(self, meth):
        self.m = meth

    @export(VOID)
    def set(self, meth):
        meth.args = [OArg("pin", BYTE)]
        self.ss = OSwitch("pin")
        meth << self.ss

    @export(VOID)
    def clear(self, meth):
        meth.args = [OArg("pin", BYTE)]
        self.sc = OSwitch("pin")
        meth << self.sc

    @export(VOID)
    def mode(self, meth):
        meth.args = [OArg("pin", BYTE), OArg("out", BYTE)]
        self.sm = OSwitch("pin")
        meth << self.sm

    @export(BYTE)
    def read(self, meth):
        meth.args = [OArg("pin", BYTE)]
        self.sr = OSwitch("pin")

        meth << "uint8_t ret=0;"
        meth << self.sr
        meth << "return ret;"
 
    def add(self, name, oper_set, oper_clear):
        if self.ss:
            self.ss.add("PIN_"+name, [oper_set + ";"])
        if self.sc:
            self.sc.add("PIN_"+name, [oper_clear + ";"])
        self << OMacro("PIN_"+name, str(self.pin_id))
        self.pin_id += 1


    def add_in(self, name, oper):
        self.sr.add("PIN_"+name, ["ret = " + oper + ";"])
コード例 #3
0
 def clear(self, meth):
     meth.args = [OArg("pin", BYTE)]
     self.sc = OSwitch("pin")
     meth << self.sc
コード例 #4
0
 def set(self, meth):
     meth.args = [OArg("pin", BYTE)]
     self.ss = OSwitch("pin")
     meth << self.ss