1- // Licensed to the .NET Foundation under one or more agreements.
2- // The .NET Foundation licenses this file to you under the MIT license.
3- // See the LICENSE file in the project root for more information.
1+ //
2+ // Copyright (c) .NET Foundation and Contributors
3+ // See LICENSE file in the project root for full license information.
4+ //
45
6+ using System . Diagnostics ;
57using System . Runtime . CompilerServices ;
68
79namespace System . Device . I2s
@@ -11,27 +13,29 @@ namespace System.Device.I2s
1113 /// </summary>
1214 public class I2sDevice : IDisposable
1315 {
14- [ Diagnostics . DebuggerBrowsable ( Diagnostics . DebuggerBrowsableState . Never ) ]
15- private readonly I2sConnectionSettings _connectionSettings ;
16-
17- [ Diagnostics . DebuggerBrowsable ( Diagnostics . DebuggerBrowsableState . Never ) ]
16+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
1817 private bool _disposed ;
1918
19+ private readonly I2sConnectionSettings _connectionSettings ;
20+
2021 /// <summary>
21- /// The connection settings of a device on an I2s bus. The connection settings are immutable after the device is created
22- /// so the object returned will be a clone of the settings object.
22+ /// Create an I2s Device
2323 /// </summary>
24- public I2sConnectionSettings ConnectionSettings { get => _connectionSettings ; }
24+ /// <param name="settings">Connection settings</param>
25+ public I2sDevice ( I2sConnectionSettings settings )
26+ {
27+ _connectionSettings = settings ;
28+
29+ // call native init to allow HAL/PAL inits related with I2s hardware
30+ NativeInit ( ) ;
31+ }
2532
2633 /// <summary>
27- /// Reads data from the I2s device.
34+ /// The connection settings of a device on an I2s bus. The connection settings are immutable after the device is
35+ /// created
36+ /// so the object returned will be a clone of the settings object.
2837 /// </summary>
29- /// <param name="buffer">
30- /// The buffer to read the data from the I2s device.
31- /// The length of the buffer determines how much data to read from the I2s device.
32- /// </param>
33- [ MethodImpl ( MethodImplOptions . InternalCall ) ]
34- public extern void Read ( SpanByte buffer ) ;
38+ public I2sConnectionSettings ConnectionSettings => _connectionSettings ;
3539
3640 /// <summary>
3741 /// Reads data from the I2s device.
@@ -41,17 +45,7 @@ public class I2sDevice : IDisposable
4145 /// The length of the buffer determines how much data to read from the I2s device.
4246 /// </param>
4347 [ MethodImpl ( MethodImplOptions . InternalCall ) ]
44- public extern void Read ( ushort [ ] buffer ) ;
45-
46- /// <summary>
47- /// Writes a byte to the I2s device.
48- /// </summary>
49- /// <param name="buffer">
50- /// The buffer that contains the data to be written to the I2s device.
51- /// The data should not include the I2s device address.
52- /// </param>
53- [ MethodImpl ( MethodImplOptions . InternalCall ) ]
54- public extern void Write ( ushort [ ] buffer ) ;
48+ public extern void Read ( SpanByte buffer ) ;
5549
5650 /// <summary>
5751 /// Writes data to the I2s device.
@@ -73,18 +67,6 @@ public static I2sDevice Create(I2sConnectionSettings settings)
7367 return new I2sDevice ( settings ) ;
7468 }
7569
76- /// <summary>
77- /// Create an I2s Device
78- /// </summary>
79- /// <param name="settings">Connection settings</param>
80- public I2sDevice ( I2sConnectionSettings settings )
81- {
82- _connectionSettings = settings ;
83-
84- // call native init to allow HAL/PAL inits related with I2s hardware
85- NativeInit ( ) ;
86- }
87-
8870 #region IDisposable Support
8971
9072 private void Dispose ( bool disposing )
@@ -104,7 +86,7 @@ private void Dispose(bool disposing)
10486 }
10587
10688 /// <summary>
107- /// <inheritdoc cref="IDisposable.Dispose"/>
89+ /// <inheritdoc cref="IDisposable.Dispose" />
10890 /// </summary>
10991 public void Dispose ( )
11092 {
0 commit comments