예제 #1
0
    def __init__(self,
                 port=2,
                 data_rate=None,
                 host_id=2,
                 module_id=1,
                 debug=False,
                 can_mode=CanModeNormal()):
        del data_rate
        tmcl_interface.__init__(self, host_id, module_id, debug)
        tmcl_host_interface.__init__(self, host_id, module_id, debug)

        self.__silent = Pin(Pin.cpu.B14, Pin.OUT_PP)
        self.__mode = can_mode
        self.__flag_recv = False

        self.__set_mode()

        CAN.initfilterbanks(14)

        self.__can = CAN(port, CAN.NORMAL)
        # PCLK1 = 42 MHz, Module_Bitrate = 1000 kBit/s
        # With prescaler = 3, bs1 = 11, bs2 = 2
        # Sample point at 85.7 %, accuracy = 100 %
        self.__can.init(CAN.NORMAL,
                        prescaler=3,
                        bs1=11,
                        bs2=2,
                        auto_restart=True)
        self.__can.setfilter(0, CAN.LIST16, 0,
                             (host_id, host_id, host_id, host_id))
        self.__can.rxcallback(0, self.__callback_recv)
    def __init__(self, port=0, data_rate=None, host_id=2, module_id=1, debug=False):
        del data_rate
        tmcl_module_interface.__init__(self, host_id, module_id, debug)
        tmcl_host_interface.__init__(self, host_id, module_id, debug)

        self.__vcp = USB_VCP(port)
        self.__vcp.init()
        self.__vcp.setinterrupt(-1)
예제 #3
0
    def __init__(self,
                 port=None,
                 data_rate=None,
                 host_id=2,
                 module_id=1,
                 debug=False):
        tmcl_interface.__init__(self, host_id, module_id, debug)
        tmcl_host_interface.__init__(self, host_id, module_id, debug)

        self.__buffer = bytearray()
예제 #4
0
    def __init__(self,
                 port=1,
                 data_rate=9600,
                 host_id=2,
                 module_id=1,
                 debug=False):
        tmcl_module_interface.__init__(self, host_id, module_id, debug)
        tmcl_host_interface.__init__(self, host_id, module_id, debug)

        self.__uart = UART(port, data_rate)
        self.__uart.init(baudrate=data_rate,
                         bits=8,
                         parity=None,
                         stop=1,
                         timeout=10000,
                         timeout_char=10000)
예제 #5
0
    def __init__(self,
                 port=1,
                 data_rate=None,
                 host_id=2,
                 module_id=1,
                 debug=False,
                 can_mode=CanModeNormal()):
        del data_rate
        tmcl_module_interface.__init__(self, host_id, module_id, debug)
        tmcl_host_interface.__init__(self, host_id, module_id, debug)

        self.__silent = Pin(Pin.cpu.B10, Pin.OUT_PP)
        self.__mode = can_mode
        self.__flag_recv = False
        self.__can = None

        CAN.initfilterbanks(14)

        # PCLK1 = 42 MHz, Module_Bitrate = 1000 kBit/s
        # With prescaler = 3, bs1 = 11, bs2 = 2
        # Sample point at 85.7 %, accuracy = 100 %

        if (isinstance(self.__mode, CanModeNormal)):
            self.__silent.low()
            self.__can = CAN(port, CAN.NORMAL)
            self.__can.init(CAN.NORMAL,
                            prescaler=3,
                            bs1=11,
                            bs2=2,
                            auto_restart=True)
            self.__can.setfilter(0, CAN.LIST16, 0,
                                 (host_id, host_id, module_id, module_id))
        elif (isinstance(self.__mode, CanModeSilent)):
            self.__silent.high()
            self.__can = CAN(port, CAN.SILENT)
            self.__can.init(CAN.SILENT,
                            prescaler=3,
                            bs1=11,
                            bs2=2,
                            auto_restart=True)
            self.__can.setfilter(0, CAN.LIST16, 0,
                                 (host_id, host_id, module_id, module_id))
        elif (isinstance(self.__mode, CanModeOff)):
            raise ValueError()  # Not supported by TJA1051T/3

        self.__can.rxcallback(0, self.__callback_recv)