Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Iot
提交
293ce364
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,发现更多精彩内容 >>
未验证
提交
293ce364
编写于
11月 28, 2018
作者:
J
John Tasler
提交者:
GitHub
11月 28, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement the Windows I2C device (#46)
* Implement the Windows I2C device
上级
929287df
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
85 addition
and
2 deletion
+85
-2
src/System.Device.Gpio/System/Device/I2c/Windows10I2cDevice.Linux.cs
...Device.Gpio/System/Device/I2c/Windows10I2cDevice.Linux.cs
+22
-0
src/System.Device.Gpio/System/Device/I2c/Windows10I2cDevice.Windows.cs
...vice.Gpio/System/Device/I2c/Windows10I2cDevice.Windows.cs
+60
-0
src/System.Device.Gpio/System/Device/Spi/Windows10SpiDevice.Linux.cs
...Device.Gpio/System/Device/Spi/Windows10SpiDevice.Linux.cs
+2
-1
src/System.Device.Gpio/System/Device/Spi/Windows10SpiDevice.Windows.cs
...vice.Gpio/System/Device/Spi/Windows10SpiDevice.Windows.cs
+1
-1
未找到文件。
src/System.Device.Gpio/System/Device/I2c/Windows10I2cDevice.Linux.cs
0 → 100644
浏览文件 @
293ce364
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace
System.Device.I2c
{
public
class
Windows10I2cDevice
:
I2cDevice
{
public
Windows10I2cDevice
(
I2cConnectionSettings
settings
)
=>
throw
new
PlatformNotSupportedException
(
$"The
{
GetType
().
Name
}
class is not available on Linux."
);
public
override
I2cConnectionSettings
ConnectionSettings
=>
throw
new
PlatformNotSupportedException
();
public
override
byte
ReadByte
()
=>
throw
new
PlatformNotSupportedException
();
public
override
void
Read
(
Span
<
byte
>
buffer
)
=>
throw
new
PlatformNotSupportedException
();
public
override
void
WriteByte
(
byte
data
)
=>
throw
new
PlatformNotSupportedException
();
public
override
void
Write
(
Span
<
byte
>
data
)
=>
throw
new
PlatformNotSupportedException
();
}
}
src/System.Device.Gpio/System/Device/I2c/Windows10I2cDevice.Windows.cs
0 → 100644
浏览文件 @
293ce364
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Windows.Devices.Enumeration
;
using
WinI2c
=
Windows
.
Devices
.
I2c
;
namespace
System.Device.I2c
{
public
class
Windows10I2cDevice
:
I2cDevice
{
private
readonly
I2cConnectionSettings
_settings
;
private
WinI2c
.
I2cDevice
_winDevice
;
public
Windows10I2cDevice
(
I2cConnectionSettings
settings
)
{
_settings
=
settings
;
var
winSettings
=
new
WinI2c
.
I2cConnectionSettings
(
settings
.
DeviceAddress
);
string
deviceSelector
=
WinI2c
.
I2cDevice
.
GetDeviceSelector
(
$"I2C
{
settings
.
BusId
}
"
);
DeviceInformationCollection
deviceInformationCollection
=
DeviceInformation
.
FindAllAsync
(
deviceSelector
).
GetResults
();
_winDevice
=
WinI2c
.
I2cDevice
.
FromIdAsync
(
deviceInformationCollection
[
0
].
Id
,
winSettings
).
GetResults
();
}
public
override
I2cConnectionSettings
ConnectionSettings
=>
_settings
;
public
override
byte
ReadByte
()
{
byte
[]
buffer
=
new
byte
[
1
];
_winDevice
.
Read
(
buffer
);
return
buffer
[
0
];
}
public
override
void
Read
(
Span
<
byte
>
buffer
)
{
byte
[]
byteArray
=
new
byte
[
buffer
.
Length
];
_winDevice
.
Read
(
byteArray
);
new
Span
<
byte
>(
byteArray
).
CopyTo
(
buffer
);
}
public
override
void
WriteByte
(
byte
data
)
{
_winDevice
.
Write
(
new
[]
{
data
});
}
public
override
void
Write
(
Span
<
byte
>
data
)
{
_winDevice
.
Write
(
data
.
ToArray
());
}
public
override
void
Dispose
(
bool
disposing
)
{
_winDevice
?.
Dispose
();
_winDevice
=
null
;
base
.
Dispose
(
disposing
);
}
}
}
src/System.Device.Gpio/System/Device/Spi/Windows10SpiDevice.Linux.cs
浏览文件 @
293ce364
...
...
@@ -6,7 +6,8 @@ namespace System.Device.Spi
{
public
class
Windows10SpiDevice
:
SpiDevice
{
public
Windows10SpiDevice
(
SpiConnectionSettings
settings
)
=>
throw
new
PlatformNotSupportedException
();
public
Windows10SpiDevice
(
SpiConnectionSettings
settings
)
=>
throw
new
PlatformNotSupportedException
(
$"The
{
GetType
().
Name
}
class is not available on Linux."
);
public
override
SpiConnectionSettings
ConnectionSettings
=>
throw
new
PlatformNotSupportedException
();
...
...
src/System.Device.Gpio/System/Device/Spi/Windows10SpiDevice.Windows.cs
浏览文件 @
293ce364
...
...
@@ -9,7 +9,7 @@ namespace System.Device.Spi
{
public
class
Windows10SpiDevice
:
SpiDevice
{
private
SpiConnectionSettings
_settings
;
private
readonly
SpiConnectionSettings
_settings
;
private
WinSpi
.
SpiDevice
_winDevice
;
public
Windows10SpiDevice
(
SpiConnectionSettings
settings
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录