nanoFramework.Iot.Device.At24cxx 1.0.372
前缀已预留
dotnet add package nanoFramework.Iot.Device.At24cxx --version 1.0.372
NuGet\Install-Package nanoFramework.Iot.Device.At24cxx -Version 1.0.372
此命令 intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.At24cxx" Version="1.0.372" />
对于支持 PackageReference 的项目,将此 XML 节点复制到项目文件以引用包。
paket add nanoFramework.Iot.Device.At24cxx --version 1.0.372
NuGet 团队不提供对此客户端的支持。请联系其 维护者 获取支持。
#r "nuget: nanoFramework.Iot.Device.At24cxx, 1.0.372"
#r 指令可用于 F# Interactive 和多语言笔记本。将此复制到交互式工具或脚本的源代码以引用包。
// Install nanoFramework.Iot.Device.At24cxx as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.At24cxx&version=1.0.372 // Install nanoFramework.Iot.Device.At24cxx as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.At24cxx&version=1.0.372
NuGet 团队不提供对此客户端的支持。请联系其 维护者 获取支持。
AT24C32/AT24C64/AT24C128/AT24C256 系列 I2C EEPROM
At24cxx 是一种利用 I2C (2 线) 串行接口的串行 EEPROM 系列。
文档
此实现支持以下设备
用法
重要: 在创建 I2cDevice
之前,必须正确设置 ESP32 的 I2C 引脚。为此,请确保安装 nanoFramework.Hardware.Esp32
NuGet 包,并使用 Configuration
类设置引脚
// When connecting with an ESP32 device you will need to configure the I2C GPIOs used for the bus.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);
对于 STM32 等其他设备,请确保您正在使用您想要使用的 I2C 总线的预设引脚。
using Iot.Device.At24cxx;
using nanoFramework.Hardware.Esp32;
using System.Device.I2c;
using System.Diagnostics;
using System.Text;
using System.Threading;
// Setup ESP32 I2C port.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);
// Setup At24c32c device.
I2cConnectionSettings settings = new I2cConnectionSettings(1, At24c32.DefaultI2cAddress);
I2cDevice i2cDevice = new I2cDevice(settings);
At24c32 eeprom = new At24c32(i2cDevice);
// Write string to device.
string message = "Hello from nanoFramework!";
byte[] encodedMessage = Encoding.UTF8.GetBytes(message);
int messageAddress = 0x0;
uint writeResult = eeprom.Write(messageAddress, encodedMessage);
Debug.WriteLine($"\"{message}\" written to EEPROM at 0x{messageAddress:X} ({writeResult} bytes)");
Thread.Sleep(100);
// Read back message from device.
byte[] receivedData = eeprom.Read(messageAddress, message.Length);
string decodedMessage = Encoding.UTF8.GetString(receivedData, 0, receivedData.Length);
Debug.WriteLine($"\"{decodedMessage}\" read from EEPROM at 0x{messageAddress:X}");
Thread.Sleep(100);
// Write byte to end of available device memory.
byte value = 0xA9;
int byteAddress = eeprom.Size - 1;
uint writeByteResult = eeprom.WriteByte(byteAddress, value);
Debug.WriteLine($"0x{value:X} written to EEPROM at 0x{byteAddress:X} ({writeByteResult} byte)");
Thread.Sleep(100);
// Read back byte from end of available device memory.
byte receivedByte = eeprom.ReadByte(byteAddress);
Debug.WriteLine($"0x{receivedByte:X} read from EEPROM at 0x{byteAddress:X}");
Thread.Sleep(100);
// Sequentially read back message from device byte-by-byte using the devices internal address counter.
// Since our last read from the device was at its last available byte, the internal address counter has now rolled over to point at the first byte.
byte[] receivedCharacter = new byte[1];
for (int i = 0; i < message.Length; i++)
{
receivedCharacter[0] = eeprom.ReadByte();
char[] character = Encoding.UTF8.GetChars(receivedCharacter, 0, 1);
Debug.WriteLine($"'{character[0]}' read from EEPROM");
}
产品 | 版本 兼容和附加计算目标框架版本。 |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Device.I2c (>= 1.1.16)
NuGet 包
此包未被任何 NuGet 包使用。
GitHub 仓库
此包未被任何流行的 GitHub 仓库存用。
版本 | 下载 | 最后更新 |
---|---|---|
1.0.372 | 69 | 7/24/2024 |
1.0.347 | 93 | 6/14/2024 |
1.0.337 | 92 | 5/29/2024 |
1.0.329 | 90 | 5/17/2024 |
1.0.325 | 81 | 5/15/2024 |
1.0.313 | 88 | 4/15/2024 |
1.0.291 | 104 | 3/22/2024 |
1.0.213 | 208 | 11/10/2023 |
1.0.161 | 127 | 9/6/2023 |
1.0.106 | 120 | 5/26/2023 |
1.0.93 | 115 | 5/16/2023 |
1.0.90 | 113 | 5/12/2023 |
1.0.85 | 118 | 5/11/2023 |
1.0.79 | 127 | 5/10/2023 |
1.0.74 | 115 | 5/3/2023 |
1.0.50 | 204 | 3/17/2023 |
1.0.30 | 220 | 2/22/2023 |
1.0.1 | 244 | 1/13/2023 |