We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 38e4adc commit b944544Copy full SHA for b944544
1 file changed
Sources/SwiftIO/SPI.swift
@@ -183,5 +183,33 @@ import CSwiftIO
183
print("SPI\(id) write error!")
184
}
185
186
+
187
+ /**
188
+ Write an buffer of data to the slave device.
189
+ - Parameter data: A UInt8 buffer to be sent to the slave device.
190
+ */
191
+ @inline(__always)
192
+ public func write(_ data: UnsafeBufferPointer<UInt8>, count: Int? = nil) {
193
+ let ret: Int32
194
+ let byteCount: Int
195
196
+ if let count = count {
197
+ byteCount = min(data.count, count)
198
+ } else {
199
+ byteCount = data.count
200
+ }
201
202
+ if byteCount <= 0 {
203
+ return
204
205
206
+ csEnable()
207
+ ret = swifthal_spi_write(obj, data.baseAddress, Int32(byteCount))
208
+ csDisable()
209
210
+ if ret != 0 {
211
+ print("SPI\(id) write error!")
212
213
214
215
0 commit comments