spi.py 文件源码

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

项目:PyLetMeCreate 作者: CreatorDev 项目源码 文件源码
def transfer(tx_data):
    """Transfers data using the current SPI bus. Returns a list of bytes.

    tx_data: A list of bytes to send.

    Note: An exception is thrown if an error occurs during the transfer.
    """
    length = len(tx_data)
    tx_buffer = (ctypes.c_uint8 * length)(*tx_data)
    rx_buffer = (ctypes.c_uint8 * length)()
    ret = _LIB.spi_transfer(tx_buffer, rx_buffer, length)
    if ret < 0:
        raise Exception("spi transfer failed")
    return [rx_buffer[i] for i in range(length)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号