Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Iot
提交
26e1b075
I
Iot
项目概览
jobily
/
Iot
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
26e1b075
编写于
5月 29, 2019
作者:
Z
Zhang Yuexin
提交者:
Jose Perez Rodriguez
5月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added WriteRead() method in I2cDevice (#452)
* added WriteRead() * add comments
上级
b829312e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
65 addition
and
0 deletion
+65
-0
src/System.Device.Gpio/System/Device/I2c/Drivers/UnixI2cDevice.Linux.cs
...ice.Gpio/System/Device/I2c/Drivers/UnixI2cDevice.Linux.cs
+27
-0
src/System.Device.Gpio/System/Device/I2c/Drivers/UnixI2cDevice.Windows.cs
...e.Gpio/System/Device/I2c/Drivers/UnixI2cDevice.Windows.cs
+2
-0
src/System.Device.Gpio/System/Device/I2c/Drivers/Windows10I2cDevice.Linux.cs
...pio/System/Device/I2c/Drivers/Windows10I2cDevice.Linux.cs
+2
-0
src/System.Device.Gpio/System/Device/I2c/Drivers/Windows10I2cDevice.Windows.cs
...o/System/Device/I2c/Drivers/Windows10I2cDevice.Windows.cs
+21
-0
src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs
src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs
+13
-0
未找到文件。
src/System.Device.Gpio/System/Device/I2c/Drivers/UnixI2cDevice.Linux.cs
浏览文件 @
26e1b075
...
...
@@ -214,6 +214,33 @@ namespace System.Device.I2c.Drivers
}
}
/// <summary>
/// Performs an atomic operation to write data to and then read data from the I2C bus on which the device is connected,
/// and sends a restart condition between the write and read operations.
/// </summary>
/// <param name="writeBuffer">
/// The buffer that contains the data to be written to the I2C device.
/// The data should not include the I2C device address.</param>
/// <param name="readBuffer">
/// The buffer to read the data from the I2C device.
/// The length of the buffer determines how much data to read from the I2C device.
/// </param>
public
override
unsafe
void
WriteRead
(
ReadOnlySpan
<
byte
>
writeBuffer
,
Span
<
byte
>
readBuffer
)
{
if
(
readBuffer
.
Length
==
0
)
throw
new
ArgumentException
(
$"
{
nameof
(
readBuffer
)}
cannot be empty."
);
Initialize
();
fixed
(
byte
*
writeBufferPointer
=
writeBuffer
)
{
fixed
(
byte
*
readBufferPointer
=
readBuffer
)
{
Transfer
(
writeBufferPointer
,
readBufferPointer
,
writeBuffer
.
Length
,
readBuffer
.
Length
);
}
}
}
public
override
void
Dispose
(
bool
disposing
)
{
if
(
_deviceFileDescriptor
>=
0
)
...
...
src/System.Device.Gpio/System/Device/I2c/Drivers/UnixI2cDevice.Windows.cs
浏览文件 @
26e1b075
...
...
@@ -19,5 +19,7 @@ namespace System.Device.I2c.Drivers
public
override
void
Write
(
ReadOnlySpan
<
byte
>
buffer
)
=>
throw
new
PlatformNotSupportedException
();
public
override
void
WriteByte
(
byte
value
)
=>
throw
new
PlatformNotSupportedException
();
public
override
void
WriteRead
(
ReadOnlySpan
<
byte
>
writeBuffer
,
Span
<
byte
>
readBuffer
)
=>
throw
new
PlatformNotSupportedException
();
}
}
src/System.Device.Gpio/System/Device/I2c/Drivers/Windows10I2cDevice.Linux.cs
浏览文件 @
26e1b075
...
...
@@ -18,5 +18,7 @@ namespace System.Device.I2c.Drivers
public
override
void
WriteByte
(
byte
value
)
=>
throw
new
PlatformNotSupportedException
();
public
override
void
Write
(
ReadOnlySpan
<
byte
>
buffer
)
=>
throw
new
PlatformNotSupportedException
();
public
override
void
WriteRead
(
ReadOnlySpan
<
byte
>
writeBuffer
,
Span
<
byte
>
readBuffer
)
=>
throw
new
PlatformNotSupportedException
();
}
}
src/System.Device.Gpio/System/Device/I2c/Drivers/Windows10I2cDevice.Windows.cs
浏览文件 @
26e1b075
...
...
@@ -94,6 +94,27 @@ namespace System.Device.I2c.Drivers
_winI2cDevice
.
Write
(
buffer
.
ToArray
());
}
/// <summary>
/// Performs an atomic operation to write data to and then read data from the I2C bus on which the device is connected,
/// and sends a restart condition between the write and read operations.
/// </summary>
/// <param name="writeBuffer">
/// The buffer that contains the data to be written to the I2C device.
/// The data should not include the I2C device address.</param>
/// <param name="readBuffer">
/// The buffer to read the data from the I2C device.
/// The length of the buffer determines how much data to read from the I2C device.
/// </param>
public
override
void
WriteRead
(
ReadOnlySpan
<
byte
>
writeBuffer
,
Span
<
byte
>
readBuffer
)
{
if
(
readBuffer
.
Length
==
0
)
throw
new
ArgumentException
(
$"
{
nameof
(
readBuffer
)}
cannot be empty."
);
byte
[]
byteArray
=
new
byte
[
readBuffer
.
Length
];
_winI2cDevice
.
WriteRead
(
writeBuffer
.
ToArray
(),
byteArray
);
new
Span
<
byte
>(
byteArray
).
CopyTo
(
readBuffer
);
}
public
override
void
Dispose
(
bool
disposing
)
{
_winI2cDevice
?.
Dispose
();
...
...
src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs
浏览文件 @
26e1b075
...
...
@@ -44,6 +44,19 @@ namespace System.Device.I2c
/// </param>
public
abstract
void
Write
(
ReadOnlySpan
<
byte
>
buffer
);
/// <summary>
/// Performs an atomic operation to write data to and then read data from the I2C bus on which the device is connected,
/// and sends a restart condition between the write and read operations.
/// </summary>
/// <param name="writeBuffer">
/// The buffer that contains the data to be written to the I2C device.
/// The data should not include the I2C device address.</param>
/// <param name="readBuffer">
/// The buffer to read the data from the I2C device.
/// The length of the buffer determines how much data to read from the I2C device.
/// </param>
public
abstract
void
WriteRead
(
ReadOnlySpan
<
byte
>
writeBuffer
,
Span
<
byte
>
readBuffer
);
public
void
Dispose
()
{
Dispose
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录