示例#1
0
def main():
    tft = st7789.ST7789(SPI(1,
                            SPI.MASTER,
                            baudrate=30000000,
                            polarity=1,
                            phase=0),
                        240,
                        320,
                        reset=Pin('X3', Pin.OUT),
                        cs=Pin('X5', Pin.OUT),
                        dc=Pin('X4', Pin.OUT),
                        backlight=Pin('X2', Pin.OUT),
                        rotation=3)

    tft.init()

    while True:
        for rotation in range(4):
            tft.rotation(rotation)
            tft.fill(0)
            col_max = tft.width() - font.WIDTH * 6
            row_max = tft.height() - font.HEIGHT

            for _ in range(250):
                tft.text(
                    font, "Hello!", random.randint(0, col_max),
                    random.randint(0, row_max),
                    st7789.color565(random.getrandbits(8),
                                    random.getrandbits(8),
                                    random.getrandbits(8)),
                    st7789.color565(random.getrandbits(8),
                                    random.getrandbits(8),
                                    random.getrandbits(8)))
示例#2
0
    def __init__(self, cs='PE3', spi=1, debug=False):
        self._debug = debug
        self.cs_pin = Pin(cs, Pin.OUT_PP, Pin.PULL_NONE)
        self.cs_pin.high()
        self.spi = SPI(spi,
                       SPI.MASTER,
                       baudrate=328125,
                       polarity=0,
                       phase=1,
                       bits=8)

        self.read_id()
        # First SPI read always returns 255 --> discard and read ID again
        self.who_am_i = self.read_id()
        self.debug("Accel-ID: %s" % self.who_am_i)

        if self.who_am_i == LIS302DL_WHO_AM_I_VAL:
            self.write_bytes(LIS302DL_CTRL_REG1_ADDR, LIS302DL_CONF)
            self.sensitivity = 18
        elif self.who_am_i == LIS3DSH_WHO_AM_I_VAL:
            self.write_bytes(LIS3DSH_CTRL_REG4_ADDR, LIS3DSH_CTRL_REG4_CONF)
            self.write_bytes(LIS3DSH_CTRL_REG5_ADDR, LIS3DSH_CTRL_REG5_CONF)
            self.sensitivity = 0.06 * 256
        else:
            msg = 'LIS302DL or LIS3DSH accelerometer not present'

            if self._debug:
                self.debug(msg)
            else:
                raise IOError(msg)
 def __init__(self,
              name: str,
              size: int,
              page_size: int,
              addr_bytes_num: int,
              spi: int,
              cs: str,
              wp: str,
              block_size=None,
              sector_size=None,
              is_chip_erase=False,
              conn_chk: bool = False) -> None:
     self.name = name
     self.size = size
     self.sector_size = sector_size
     self.block_size = block_size
     self.page_size = page_size
     self.addr_bytes_num = addr_bytes_num
     self.cs = Pin(cs, Pin.OUT_PP)
     self.wp = Pin(wp, Pin.OUT_PP)
     self.spi = SPI(spi, SPI.MASTER, prescaler=128, polarity=0, phase=0)
     self.conn_chk = conn_chk
     self.is_chip_erase = is_chip_erase
     self._pages_count = size // page_size
     self._sectors_count = size // sector_size if sector_size is not None else None
     self._blocks_count = size // block_size if block_size is not None else None
示例#4
0
def main():
    '''
    Decode and draw jpg on display
    '''
    try:
        spi = SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2)

        # initialize display
        tft = st7789.ST7789(spi,
                            240,
                            320,
                            reset=Pin('X3', Pin.OUT),
                            cs=Pin('X5', Pin.OUT),
                            dc=Pin('X4', Pin.OUT),
                            backlight=Pin('X2', Pin.OUT),
                            rotation=3)

        # enable display and clear screen
        tft.init()

        # display jpg
        tft.jpg("bigbuckbunny.jpg", 0, 0, st7789.SLOW)

    finally:
        # shutdown spi
        spi.deinit()
示例#5
0
def main():

    spi = SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2)
    print(spi)

    # configure display
    tft = st7789.ST7789(spi,
                        240,
                        320,
                        reset=Pin('X3', Pin.OUT),
                        cs=Pin('X5', Pin.OUT),
                        dc=Pin('X4', Pin.OUT),
                        backlight=Pin('X2', Pin.OUT),
                        rotation=3)

    tft.init()
    tft.fill(st7789.BLACK)

    start = utime.ticks_ms()
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 0, st7789.WHITE)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 32, st7789.RED)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 64, st7789.GREEN)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 96, st7789.BLUE)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 128, st7789.WHITE)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 160, st7789.RED)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 192, st7789.GREEN)
    tft.text(font, "MicroPython MicroPython MicroPython", 0, 224, st7789.BLUE)

    print("time:", utime.ticks_ms() - start, "ms")
示例#6
0
def main():
    '''
    Draw greetings on display cycling thru hershey fonts and colors
    '''
    tft = st7789.ST7789(SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2),
                        240,
                        320,
                        reset=Pin('X3', Pin.OUT),
                        cs=Pin('X5', Pin.OUT),
                        dc=Pin('X4', Pin.OUT),
                        backlight=Pin('X2', Pin.OUT),
                        rotation=3)

    tft.init()
    tft.fill(st7789.BLACK)
    width = tft.width()
    row = 0

    while True:
        row += 32
        color = next(COLORS)
        tft.fill_rect(0, row - 16, width, 32, st7789.BLACK)
        tft.draw(next(FONTS), next(GREETINGS), 0, row, color)

        if row > 192:
            row = 0

        utime.sleep(0.25)
示例#7
0
 def __init__(self, cs=Pin.cpu.C0):
     self.__SPI = spi_ic_interface(spi=SPI(1,
                                           SPI.MASTER,
                                           baudrate=5000,
                                           polarity=0,
                                           phase=0),
                                   cs=Pin.cpu.C0)
示例#8
0
 def create(*args, **kwargs):
     if DynamicSPI._spi:
         DynamicSPI._spi.deinit()
         del DynamicSPI._spi
     DynamicSPI._spi = SPI(2, mode=SPI.MASTER, **kwargs)
     DynamicSPI._hash_arguments = hash(frozenset(kwargs.items()))
     return DynamicSPI._hash_arguments
示例#9
0
def main():
    tft = st7789.ST7789(SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2),
                        240,
                        320,
                        reset=Pin('X3', Pin.OUT),
                        cs=Pin('X5', Pin.OUT),
                        dc=Pin('X4', Pin.OUT),
                        backlight=Pin('X2', Pin.OUT),
                        rotation=3)

    tft.init()

    while True:
        for font in (font1, font2, font3, font4):
            tft.fill(st7789.BLUE)
            line = 0
            col = 0
            for char in range(font.FIRST, font.LAST):
                tft.text(font, chr(char), col, line, st7789.WHITE, st7789.BLUE)
                col += font.WIDTH
                if col > tft.width() - font.WIDTH:
                    col = 0
                    line += font.HEIGHT

                    if line > tft.height() - font.HEIGHT:
                        utime.sleep(3)
                        tft.fill(st7789.BLUE)
                        line = 0
                        col = 0

            utime.sleep(3)
示例#10
0
def slave():
    nrf = NRF24L01(SPI(2), Pin('Y5'), Pin('Y4'), payload_size=8)

    nrf.open_tx_pipe(pipes[1])
    nrf.open_rx_pipe(1, pipes[0])
    nrf.start_listening()

    print('NRF24L01 slave mode, waiting for packets... (ctrl-C to stop)')

    while True:
        pyb.wfi()
        if nrf.any():
            while nrf.any():
                buf = nrf.recv()
                millis, led_state = struct.unpack('ii', buf)
                print('received:', millis, led_state)
                for i in range(4):
                    if led_state & (1 << i):
                        pyb.LED(i + 1).on()
                    else:
                        pyb.LED(i + 1).off()
                pyb.delay(15)

            nrf.stop_listening()
            try:
                nrf.send(struct.pack('i', millis))
            except OSError:
                pass
            print('sent response')
            nrf.start_listening()
示例#11
0
 def __init__(self, cs = Pin.cpu.C0, spi = 1, fault_pin =  Pin.cpu.C1, ready_pin =  Pin.cpu.A13, latch_pin= Pin.cpu.A14):
     self.__SPI = spi_ic_interface(spi=SPI(spi, SPI.MASTER, baudrate=1000, polarity=0, phase=0), cs=cs)
     self.READY  =   Pin(ready_pin, Pin.IN)
     self.FAULT  =   Pin(fault_pin, Pin.IN)
     self.LATCH  =   Pin(latch_pin, Pin.OUT_PP)
     while(self.READY.value() == 1):
         time.sleep(0.1)
     self.set_latch_pin(1)    
示例#12
0
文件: lcd_py.py 项目: mfauziz/openmv
    def __init__(self, madctl=0xC0):
        self.rst = Pin('P7', Pin.OUT_PP, Pin.PULL_UP)
        self.rs = Pin('P8', Pin.OUT_PP, Pin.PULL_UP)
        self.cs = Pin('P3', Pin.OUT_PP, Pin.PULL_UP)
        self.bl = Pin('P6', Pin.OUT_PP, Pin.PULL_UP)
        self.spi = SPI(2, SPI.MASTER, baudrate=22500000, polarity=0, phase=0)

        # LCD init sequence
        self.reset()  # uHW reset
        self.write_command(0x11)  #Sleep exit
        sleep(120)

        # ST7735R Frame Rate
        self.write_command(0xB1, 0x01, 0x2C, 0x2D)
        self.write_command(0xB2, 0x01, 0x2C, 0x2D)
        self.write_command(0xB3, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D)

        #Column inversion
        self.write_command(0xB4, 0x07)

        #ST7735R Power Sequence
        self.write_command(0xC0, 0xA2, 0x02, 0x84)
        self.write_command(0xC1, 0xC5)
        self.write_command(0xC2, 0x0A, 0x00)
        self.write_command(0xC3, 0x8A, 0x2A)
        self.write_command(0xC4, 0x8A, 0xEE)

        # VCOM
        self.write_command(0xC5, 0x0E)

        # MX, MY, MV, RGB mode
        self.write_command(0x36, madctl)

        # ST7735R Gamma Sequence
        self.write_command(0xe0, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20,
                           0x22, 0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02,
                           0x10)
        self.write_command(0xe1, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29,
                           0x2e, 0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03,
                           0x10)

        # Set column address
        self.write_command(0x2a, 0x00, 0x00, 0x00, 128 - 1)

        # Set row address
        self.write_command(0x2b, 0x00, 0x00, 0x00, 160 - 1)

        # Enable test command
        self.write_command(0xF0, 0x01)

        # Disable ram power save mode
        self.write_command(0xF6, 0x00)

        # 65k mode
        self.write_command(0x3A, 0x05)

        # Display on
        self.write_command(0x29)
示例#13
0
 def __init__(self, cs=Pin.cpu.A4, cout=None):
     self.__SPI = spi_ic_interface(spi=SPI(1,
                                           SPI.MASTER,
                                           baudrate=10000,
                                           polarity=0,
                                           phase=0),
                                   cs=cs)
     if cout:
         self.__COUT = Pin(cout, Pin.IN)
示例#14
0
 def __init__(self):
     self.cs_pin = Pin('PE3', Pin.OUT_PP, Pin.PULL_NONE)
     self.cs_pin.high()
     self.spi = SPI(1,
                    SPI.MASTER,
                    baudrate=328125,
                    polarity=0,
                    phase=1,
                    bits=8)
示例#15
0
 def __init__(self, cs=Pin.cpu.A4, spi=1):
     self.__SPI = spi_ic_interface(spi=SPI(spi,
                                           SPI.MASTER,
                                           baudrate=10000,
                                           polarity=0,
                                           phase=0),
                                   cs=cs)
     self.buildCRCTable()
     """if cout:
def connect():
    nic = network.CC3K(SPI(2), Pin.board.Y5, Pin.board.Y4, Pin.board.Y3)
    # Replace the following with yout SSID and password
    print("Connecting...")
    nic.connect("YOUR_SSID", "YOUR_PASSWORD")
    while not nic.isconnected():
        delay(50)
    print("Connected!")
    print("My IP address is: {0}".format(nic.ifconfig()[0]))
    return True
示例#17
0
 def __init__(self):
     self.cs_pin = Pin('PE3', Pin.OUT_PP, Pin.PULL_NONE)
     self.cs_pin.high()
     self.spi = SPI(1,
                    SPI.MASTER,
                    baudrate=328125,
                    polarity=0,
                    phase=1,
                    bits=8)
     self.wr(LIS302DL_CTRL_REG1_ADDR, bytearray([LIS302DL_CONF]))
示例#18
0
 def __init__(self, bus=1, baudrate=328125, polarity=0, phase=0, ss='A4'):
     self.ss = Pin(ss, Pin.OUT)
     self.ss.high()
     self.spi = SPI(bus,
                    SPI.MASTER,
                    baudrate=baudrate,
                    polarity=polarity,
                    phase=phase)
     self.msgbuf = bytearray(32)
     self.status = bytearray(4)
示例#19
0
    def __init__(self):
        self.spi = SPI(1)
        self.SCK=Pin('PA5',Pin.OUT)
        self.DO = Pin('PA6',Pin.OUT)
        self.DI = Pin('PA7',Pin.OUT)
        self.CS = Pin('PA4',Pin.OUT)
        self.RESET = Pin('PC5',Pin.OUT)
        self.DRDY = Pin('PC4',Pin.OUT) 

        self.bsp_DelayMS(10)
def test(spi=3, cs='PB0'):
    print("SPI flash")
    cs = Pin(cs, Pin.OUT_PP)
    spi = SPI(spi, SPI.MASTER, baudrate=42000000, polarity=0, phase=0)
    flash = SPIFlash(spi, cs)

    print("Getting chip ID...")
    flash.wait()
    id_ = flash.getid()
    print("ID:", ubinascii.hexlify(id_))

    print("Reading block (32b) from address 0...")
    buf = bytearray(32)
    flash.read_block(0, buf)
    print(ubinascii.hexlify(buf))

    addr = 12 * 600 + 8
    print("Reading block (32b) from address {}...".format(addr))
    flash.read_block(addr, buf)
    print(ubinascii.hexlify(buf))

    addr = 524288
    print("Erasing 4k block at address {}...".format(addr))
    t1 = micros()
    flash.erase(addr, '4k')
    # flash.erase(addr, '32k')
    # flash.erase(addr, '64k')
    # flash.erase_chip()
    t = micros() - t1
    print("erase {} us".format(t))

    print("Writing blocks (256b) at address {}...".format(addr))
    buf = bytearray(range(256))
    t1 = micros()
    flash.write_block(addr, buf)
    t = micros() - t1
    mbs = len(buf) * 8. / t
    print("write({}) {} us, {} mbs".format(len(buf), t, mbs))

    print("Verifying write...")
    v = bytearray(256)
    flash.read_block(addr, v)
    if (v == buf):
        print("write/read ok")
    else:
        print("write/read FAILed")

    print("Timing 32k read from address 0...")
    gc.collect()
    buf = bytearray(32 * 1024)
    t1 = micros()
    flash.read_block(0, buf)
    t = micros() - t1
    mbs = len(buf) * 8. / t
    print("read({}) {} us, {} mbs".format(len(buf), t, mbs))
示例#21
0
def config(rotation=0, buffer_size=0, options=0):
    return st7789.ST7789(SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2),
                         240,
                         320,
                         reset=Pin('X3', Pin.OUT),
                         cs=Pin('X5', Pin.OUT),
                         dc=Pin('X4', Pin.OUT),
                         backlight=Pin('X2', Pin.OUT),
                         rotation=rotation,
                         options=options,
                         buffer_size=buffer_size)
示例#22
0
 def __init__(self, cs=Pin.cpu.C0):
     self.__SPI = spi_ic_interface(spi=SPI(1,
                                           SPI.MASTER,
                                           baudrate=5000,
                                           polarity=0,
                                           phase=0),
                                   cs=Pin.cpu.C0)
     self.outputs = 0x00
     buf = self.build_byte_array(self.MAX14912_SET_OUT_STATE_CMD,
                                 "00000000")
     self.__SPI.send_recv(buf, buf)
 def __init__(self, chan, cs, xdim, ydim):
     self.spi = SPI(chan, SPI.MASTER, baudrate=1000000, polarity=0, phase=0, firstbit=SPI.LSB)
     self.xdim = xdim
     self.ydim = ydim
     if not isinstance(cs, Pin):
         cs = Pin(cs)
     cs.value(0)
     cs.init(Pin.OUT_PP)
     self.cs = cs
     self.usleep = udelay
     self.lines = [bytearray(xdim//8) for i in range(ydim)]
     self.changed = set()
示例#24
0
def master():
    nrf = NRF24L01(SPI(2), Pin('Y5'), Pin('Y4'), payload_size=8)

    nrf.open_tx_pipe(pipes[0])
    nrf.open_rx_pipe(1, pipes[1])
    nrf.start_listening()

    num_needed = 16
    num_successes = 0
    num_failures = 0
    led_state = 0

    print('NRF24L01 master mode, sending %d packets...' % num_needed)

    while num_successes < num_needed and num_failures < num_needed:
        # stop listening and send packet
        nrf.stop_listening()
        millis = pyb.millis()
        led_state = max(1, (led_state << 1) & 0x0f)
        print('sending:', millis, led_state)
        try:
            nrf.send(struct.pack('ii', millis, led_state))
        except OSError:
            pass

        # start listening again
        nrf.start_listening()

        # wait for response, with 250ms timeout
        start_time = pyb.millis()
        timeout = False
        while not nrf.any() and not timeout:
            if pyb.elapsed_millis(start_time) > 250:
                timeout = True

        if timeout:
            print('failed, response timed out')
            num_failures += 1

        else:
            # recv packet
            got_millis, = struct.unpack('i', nrf.recv())

            # print response and round-trip delay
            print('got response:', got_millis, '(delay',
                  pyb.millis() - got_millis, 'ms)')
            num_successes += 1

        # delay then loop
        pyb.delay(250)

    print('master finished sending; successes=%d, failures=%d' %
          (num_successes, num_failures))
示例#25
0
def main():
    '''
    Draw on screen using map_bitarray_to_rgb565
    '''
    try:
        # initialize display spi port
        spi = SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2)

        # configure display
        tft = st7789.ST7789(spi,
                            240,
                            320,
                            reset=Pin('X3', Pin.OUT),
                            cs=Pin('X5', Pin.OUT),
                            dc=Pin('X4', Pin.OUT),
                            backlight=Pin('X2', Pin.OUT),
                            rotation=3)

        # enable display and clear screen
        tft.init()
        tft.fill(st7789.BLACK)
        sprite = bytearray(512)

        # create pacman spites in random positions
        sprites = []
        for man in range(SPRITES):
            sprites.append(
                pacman(random.randint(0,
                                      tft.width() - SPRITE_WIDTH),
                       random.randint(0,
                                      tft.height() - SPRITE_HEIGHT),
                       random.randint(0, SPRITE_STEPS - 1)))

        # move and draw sprites
        while True:
            for man in sprites:
                # move the sprite
                man.move()

                # convert bitmap into rgb565 blitable buffer
                tft.map_bitarray_to_rgb565(SPRITE_BITMAPS[man.step], sprite,
                                           SPRITE_WIDTH, st7789.YELLOW,
                                           st7789.BLACK)

                # blit the buffer to the display
                tft.blit_buffer(sprite, man.x, man.y, SPRITE_WIDTH,
                                SPRITE_HEIGHT)

            time.sleep(0.1)

    finally:
        # shutdown spi
        spi.deinit()
示例#26
0
def run():
    print('demo spi')
    spi = SPI(3, SPI.MASTER, baudrate=600000, polarity=1, phase=0, crc=0x7)
    while 1:
        tx = ''.join(chr(random.randint(50, 85)) for _ in range(4))
        rx = bytearray(4)

        spi.send_recv(tx, rx)

        print('tx: ' + str(tx))
        print('rx: ' + str(rx))

        time.sleep(2)
示例#27
0
def main():
    '''
    Draw and move sprite
    '''
    try:
        spi = SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2)

        # initialize display
        tft = st7789.ST7789(spi,
                            240,
                            320,
                            reset=Pin('X3', Pin.OUT),
                            cs=Pin('X5', Pin.OUT),
                            dc=Pin('X4', Pin.OUT),
                            backlight=Pin('X2', Pin.OUT),
                            rotation=3)

        # enable display and clear screen
        tft.init()
        tft.fill(st7789.BLACK)

        # create toast spites in random positions
        sprites = [
            toast(TOASTERS, 320 - 64, 0),
            toast(TOAST, 320 - 64 * 2, 80),
            toast(TOASTERS, 320 - 64 * 4, 160)
        ]

        # move and draw sprites
        while True:
            for man in sprites:
                bitmap = man.sprites[man.step]
                tft.fill_rect(man.x + bitmap.WIDTH - man.speed, man.y,
                              man.speed, bitmap.HEIGHT, st7789.BLACK)

                man.move()

                if man.x > 0:
                    tft.bitmap(bitmap, man.x, man.y)
                else:
                    tft.fill_rect(0, man.y, bitmap.WIDTH, bitmap.HEIGHT,
                                  st7789.BLACK)

            time.sleep(0.05)

    finally:
        # shutdown spi
        spi.deinit()
示例#28
0
    def __init__(self):
        self.cs_pin = Pin('PE3', Pin.OUT_PP, Pin.PULL_NONE)
        self.cs_pin.high()
        self.spi = SPI(1, SPI.MASTER, baudrate=328125, polarity=0, phase=1, bits=8)

        self.who_am_i = self.read_id()

        if self.who_am_i == LIS302DL_WHO_AM_I_VAL:
            self.write_bytes(LIS302DL_CTRL_REG1_ADDR, bytearray([LIS302DL_CONF]))
            self.sensitivity = 18
        elif self.who_am_i == LIS3DSH_WHO_AM_I_VAL:
            self.write_bytes(LIS3DSH_CTRL_REG4_ADDR, bytearray([LIS3DSH_CTRL_REG4_CONF]))
            self.write_bytes(LIS3DSH_CTRL_REG5_ADDR, bytearray([LIS3DSH_CTRL_REG5_CONF]))
            self.sensitivity = 0.06 * 256
        else:
            raise Exception('LIS302DL or LIS3DSH accelerometer not present')
    def __init__(self):
        # define pins
        self.spi = SPI(self.CHANNEL, SPI.MASTER, self.BAUDRATE, polarity=0, phase=0, firstbit=SPI.LSB)
        self.cs = Pin(self.CS, Pin.OUT_PP)
        self.set_cs(0)
        self.disp = Pin(self.DISP, Pin.OUT_PP)
        self.disp.value(1)

        # define structures, related info
        self._xdim = self.XDIM
        self._ydim = self.YDIM
        self.buffer = bytearray((self._xdim//8) * self._ydim)
        self.framebuffer = framebuf.FrameBuffer(self.buffer, self._xdim, self._ydim, framebuf.MONO_HMSB)
        self.vcom = 2

        # begin by clearing screen
        self.clear_screen()
示例#30
0
    def __init__(self, cs=Pin.cpu.A4, spi=1, intb=Pin.cpu.C6):
        """Initialization for MAX22007 class

        Args:
            cs (Pin, optional): Chip Select pin. Defaults to Pin.cpu.A4 on PMOD1
            spi (int, optional): Spi bus. Defaults to bus 1 on PMOD1
            intb (Pin, optional): Interrupt pin. Defaults to Pin.cpu.C6 on PMOD1
        """
        self.__SPI = spi_ic_interface(spi=SPI(spi, SPI.MASTER, baudrate=100000, polarity=0, phase=0), cs=cs)
        self.__SPI.__cs.high() #Set CS to idle high.
        
        #Initialize CRC flag
        self.crc_en = 0
        temp = self.read(self.MAX22007_CFG_adr)
        if temp[15] == '0':
            self.crc_en = 0
        else:
            self.crc_en = 1