obj
I2C.swift:147This declaration is gated by at least one @_spi attribute.
let obj: UnsafeMutableRawPointer
This declaration is gated by at least one @_spi attribute.
let obj: UnsafeMutableRawPointer
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
final class I2C
Inter-Integrated Circuit, I2C (I squared C) for short, is a two wire protocol for short distance communication between different devices.
@frozen struct UnsafeMutableRawPointer
A raw pointer for accessing and manipulating untyped data.
init(_ idName: Id, speed: Speed = .standard)
Initializes a specific I2C interface with specified speed.
func getSpeed() -> Speed
Gets the current clock speed of the data transmission.
@discardableResult func read(into buffer: inout [UInt8], count: Int? = nil, from address: UInt8) -> Result<(), Errno>
Reads bytes from the specified slave device with the given address and store them in the buffer.
@discardableResult func read(into byte: inout UInt8, from address: UInt8) -> Result<(), Errno>
Reads a byte from the specified slave device with the given address.
func setSpeed(_ speed: Speed) -> Result<(), Errno>
Changes the clock speed over I2C bus.
@discardableResult func write(_ data: [UInt8], count: Int? = nil, to address: UInt8) -> Result<(), Errno>
Writes an array of UInt8 to the specified slave device with the given address.
@discardableResult func write(_ byte: UInt8, to address: UInt8) -> Result<(), Errno>
Writes a UInt8 to the specified slave device with the given address.
@discardableResult func writeRead(_ byte: UInt8, into buffer: inout UInt8, address: UInt8) -> Result<(), Errno>
Writes a UInt8 to the specified slave device with the given address and then read a UInt8 from it.
@discardableResult func writeRead(_ byte: UInt8, into buffer: inout [UInt8], readCount: Int? = nil, address: UInt8) -> Result<(), Errno>
Writes a UInt8 to the specified slave device with the given address and then read bytes from it.
@discardableResult func writeRead(_ data: [UInt8], writeCount: Int? = nil, into buffer: inout [UInt8], readCount: Int? = nil, address: UInt8) -> Result<(), Errno>
Writes an array of UInt8 to the slave device with the given address and then read bytes from it.
enum Speed
The clock speed used to synchronize the data transmission between devices.