Ejemplo n.º 1
0
#!/usr/bin/env python

import numpy as np
import ctypes
import struct
import time

from ioctl_numbers import _IOR, _IOW
from fcntl import ioctl

SPI_IOC_MAGIC = ord("k")

SPI_IOC_RD_MODE = _IOR(SPI_IOC_MAGIC, 1, "=B")
SPI_IOC_WR_MODE = _IOW(SPI_IOC_MAGIC, 1, "=B")

SPI_IOC_RD_LSB_FIRST = _IOR(SPI_IOC_MAGIC, 2, "=B")
SPI_IOC_WR_LSB_FIRST = _IOW(SPI_IOC_MAGIC, 2, "=B")

SPI_IOC_RD_BITS_PER_WORD = _IOR(SPI_IOC_MAGIC, 3, "=B")
SPI_IOC_WR_BITS_PER_WORD = _IOW(SPI_IOC_MAGIC, 3, "=B")

SPI_IOC_RD_MAX_SPEED_HZ = _IOR(SPI_IOC_MAGIC, 4, "=I")
SPI_IOC_WR_MAX_SPEED_HZ = _IOW(SPI_IOC_MAGIC, 4, "=I")

SPI_CPHA = 0x01  # /* clock phase */
SPI_CPOL = 0x02  # /* clock polarity */
SPI_MODE_0 = (0 | 0)  # /* (original MicroWire) */
SPI_MODE_1 = (0 | SPI_CPHA)
SPI_MODE_2 = (SPI_CPOL | 0)
SPI_MODE_3 = (SPI_CPOL | SPI_CPHA)
Ejemplo n.º 2
0
#!/usr/bin/env python

import numpy as np
import ctypes
import struct
import time

from ioctl_numbers import _IOR, _IOW
from fcntl import ioctl

SPI_IOC_MAGIC   = ord("k")

SPI_IOC_RD_MODE          = _IOR(SPI_IOC_MAGIC, 1, "=B")
SPI_IOC_WR_MODE          = _IOW(SPI_IOC_MAGIC, 1, "=B")

SPI_IOC_RD_LSB_FIRST     = _IOR(SPI_IOC_MAGIC, 2, "=B")
SPI_IOC_WR_LSB_FIRST     = _IOW(SPI_IOC_MAGIC, 2, "=B")

SPI_IOC_RD_BITS_PER_WORD = _IOR(SPI_IOC_MAGIC, 3, "=B")
SPI_IOC_WR_BITS_PER_WORD = _IOW(SPI_IOC_MAGIC, 3, "=B")

SPI_IOC_RD_MAX_SPEED_HZ  = _IOR(SPI_IOC_MAGIC, 4, "=I")
SPI_IOC_WR_MAX_SPEED_HZ  = _IOW(SPI_IOC_MAGIC, 4, "=I")

SPI_CPHA   = 0x01                 # /* clock phase */
SPI_CPOL   = 0x02                 # /* clock polarity */
SPI_MODE_0 = (0|0)                # /* (original MicroWire) */
SPI_MODE_1 = (0|SPI_CPHA)
SPI_MODE_2 = (SPI_CPOL|0)
SPI_MODE_3 = (SPI_CPOL|SPI_CPHA)