DW1000.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:DW1000_Python_library 作者: ThingType 项目源码 文件源码
def begin(irq):
    """
    This function opens the SPI connection available on the Raspberry Pi using the chip select #0. Normally, spidev can auto enable chip select when necessary. However, in our case, the dw1000's chip select is connected to GPIO16 so we have to enable/disable it manually.
    It also sets up the interrupt detection event on the rising edge of the interrupt pin.

    Args:
            irq : The GPIO pin number managing interrupts.
    """
    global _deviceMode
    # Wait 5 us to open spi connection to let the chip enter idle state, see 2.3.2 of the DW1000 user manual (INIT).
    time.sleep(C.INIT_DELAY)
    GPIO.setmode(GPIO.BCM)
    spi.open(0, 0)
    # spi.max_speed_hz = 4000000
    _deviceMode = C.IDLE_MODE
    GPIO.setup(irq, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    GPIO.add_event_detect(irq, GPIO.RISING, callback=handleInterrupt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号