Files
mraa/examples/python/spi_loopback.py
Thomas Ingleby 170bdd104f spdx: add spdx tags to most files
Large change that removes the duplicated MIT notice withe a spdx tag

Signed-off-by: Thomas Ingleby <thomas.ingleby@intel.com>
2019-05-23 10:09:12 -07:00

26 lines
545 B
Python

#!/usr/bin/env python
# Author: Brendan Le Foll <brendan.le.foll@intel.com>
# Copyright (c) 2015 Intel Corporation.
#
# SPDX-License-Identifier: MIT
#
# Example Usage: Loopbacks data between MISO and MOSI 100 times
import mraa as m
import random as rand
# intialise SPI
dev = m.Spi(0)
for x in range(0,100):
txbuf = bytearray(4)
for y in range(0,4):
txbuf[y] = rand.randrange(0, 256)
# send and receive data through SPI
rxbuf = dev.write(txbuf)
if rxbuf != txbuf:
print("Data mismatch!")
exit(1)