예제 #1
0
    def __init__(self, firmware=None, mcu=None, f_cpu=None, avcc=5, vcc=5):
        '''

        :param mcu: mcu name
        :param f_cpu: frequency in hertz
        :param avcc: avcc in Volt
        :param vcc: vcc in Volt
        '''
        if get_simavr_logger() is None:
            init_simavr_logger()  # Only init logger when it was not initialized before
        self.callbacks_keepalive = [] # External callback instances are stored here just to avoid GC destroying them too early
        self._irq_helper = IRQHelper(self)
        self.avrsize = None
        self.time_marker = 0.0
        self.mcu = mcu
        self.f_cpu = f_cpu
        self._avcc = avcc
        self._vcc = vcc

        if firmware:
            if not self.mcu:
                self.mcu = str(firmware.mcu)
            if not self.f_cpu:
                self.f_cpu = firmware.frequency

        assert self.mcu
        assert self.f_cpu

        log.debug('mcu=%s f_cpu=%s' % (self.mcu, self.f_cpu))

        self.backend = avr_make_mcu_by_name(self.mcu)
        if not self.backend:
            raise UnkwownAvrError('unknown AVR: ' + self.mcu)

        avr_init(self.backend)
        self.backend.frequency = self.f_cpu  # Propagate the freq to the backend

        self._set_voltages()

        avr_start_thread(self.backend)
        self.pause()
        if firmware:
            self.load_firmware(firmware)
        self.uart = Uart(self)
        self.uart.connect()
예제 #2
0
파일: avr.py 프로젝트: sanakhan22/pysimavr
    def __init__(self, firmware=None, mcu=None, f_cpu=None, avcc=5, vcc=5):
        '''

        :param mcu: mcu name
        :param f_cpu: frequency in hertz
        :param avcc: avcc in Volt
        :param vcc: vcc in Volt
        '''
        init_simavr_logger()
        self.avrsize = None
        self.time_marker = 0.0
        self.mcu = mcu
        self.f_cpu = f_cpu
        self._avcc = avcc
        self._vcc = vcc

        if firmware:
            if not self.mcu:
                self.mcu = str(firmware.mcu)
            if not self.f_cpu:
                self.f_cpu = firmware.frequency

        assert self.mcu
        assert self.f_cpu

        log.debug('mcu=%s f_cpu=%s' % (self.mcu, self.f_cpu))

        self.backend = avr_make_mcu_by_name(self.mcu)
        if not self.backend:
            raise UnkwownAvrError('unknown AVR: ' + self.mcu)

        avr_init(self.backend)

        self._set_voltages()

        avr_start_thread(self.backend)
        self.pause()
        if firmware:
            self.load_firmware(firmware)
        self.uart = Uart(self)
        self.uart.connect()