# Welcome to python-periphery’s documentation!

python-periphery is a pure Python library for GPIO, LED, PWM, SPI, I2C, MMIO, and Serial peripheral I/O interface access in userspace Linux. It is useful in embedded Linux environments (including Raspberry Pi, BeagleBone, etc. platforms) for interfacing with external peripherals. python-periphery is compatible with Python 2 and Python 3, is written in pure Python, and is MIT licensed.

## Contents

- GPIO
  - Code Example
  - API
    - `periphery.GPIO`
      - `periphery.GPIO.CdevGPIO`
    - `periphery.GPIO`
      - `periphery.GPIO.SysfsGPIO`
    - `GPIO`
      - `GPIO.read()`
      - `GPIO.write()`
      - `GPIO.poll()`
      - `GPIO.read_event()`
      - `GPIO.poll_multiple()`
      - `GPIO.close()`
      - `GPIO.devpath`
      - `GPIO.fd`
      - `GPIO.line`
      - `GPIO.name`
      - `GPIO.label`
      - `GPIO.chip_fd`
      - `GPIO.chip_name`
      - `GPIO.chip_label`
      - `GPIO.direction`
      - `GPIO.edge`
      - `GPIO.bias`
      - `GPIO.drive`
      - `GPIO.inverted`
    - `EdgeEvent`
    - `GPIOError`
- LED
  - Code Example
  - API
    - `LED`
      - `LED.read()`
      - `LED.write()`
      - `LED.close()`
      - `LED.devpath`
      - `LED.fd`
      - `LED.name`
      - `LED.max_brightness`
      - `LED.brightness`
    - `LEDError`
- PWM
  - Code Example
  - API
    - `PWM`
      - `PWM.close()`
      - `PWM.enable()`
      - `PWM.disable()`
      - `PWM.devpath`
      - `PWM.chip`
      - `PWM.channel`
      - `PWM.period_ns`
      - `PWM.duty_cycle_ns`
      - `PWM.period`
      - `PWM.duty_cycle`
      - `PWM.frequency`
      - `PWM.polarity`
      - `PWM.enabled`
    - `PWMError`
- SPI
  - Code Example
  - API
    - `SPI`
      - `SPI.transfer()`
      - `SPI.close()`
      - `SPI.fd`
      - `SPI.devpath`
      - `SPI.mode`
      - `SPI.max_speed`
      - `SPI.bit_order`
      - `SPI.bits_per_word`
      - `SPI.extra_flags`
    - `SPIError`
- I2C
  - Code Example
  - API
    - `I2C`
      - `I2C.transfer()`
      - `I2C.close()`
      - `I2C.fd`
      - `I2C.devpath`
      - `I2C.Message`
    - `I2CError`
- MMIO
  - Code Example
  - API
    - `MMIO`
      - `MMIO.read32()`
      - `MMIO.read16()`
      - `MMIO.read8()`
      - `MMIO.read()`
      - `MMIO.write32()`
      - `MMIO.write16()`
      - `MMIO.write8()`
      - `MMIO.write()`
      - `MMIO.close()`
      - `MMIO.base`
      - `MMIO.size`
      - `MMIO.pointer`
    - `MMIOError`
- Serial
  - Code Example
  - API
    - `Serial`
      - `Serial.read()`
      - `Serial.write()`
      - `Serial.poll()`
      - `Serial.flush()`
      - `Serial.input_waiting()`
      - `Serial.output_waiting()`
      - `Serial.close()`
      - `Serial.fd`
      - `Serial.devpath`
      - `Serial.baudrate`
      - `Serial.databits`
      - `Serial.parity`
      - `Serial.stopbits`
      - `Serial.xonxoff`
      - `Serial.rtscts`
      - `Serial.vmin`
      - `Serial.vtime`
    - `SerialError`
- Version and Helper Functions
  - `__version__`
  - `version`
  - `sleep()`
  - `sleep_ms()`
  - `sleep_us()`