| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 /// I2C support for Linux. | 5 /// I2C support for Linux. |
| 6 /// | 6 /// |
| 7 /// Currently this has only been tested with a Raspberry Pi 2. | 7 /// Currently this has only been tested with a Raspberry Pi 2. |
| 8 /// | 8 /// |
| 9 /// Usage | 9 /// Usage |
| 10 /// ----- | 10 /// ----- |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 /// print('Pressure: ${lps25h.readPressure()}'); | 33 /// print('Pressure: ${lps25h.readPressure()}'); |
| 34 /// os.sleep(1000); | 34 /// os.sleep(1000); |
| 35 /// } | 35 /// } |
| 36 /// } | 36 /// } |
| 37 /// ``` | 37 /// ``` |
| 38 /// Reporting issues | 38 /// Reporting issues |
| 39 /// ---------------- | 39 /// ---------------- |
| 40 /// Please file an issue [in the issue tracker](https://github.com/dartino/sdk/i
ssues/new?title=Add%20title&labels=Area-Package&body=%3Cissue%20description%3E%0
A%3Crepro%20steps%3E%0A%3Cexpected%20outcome%3E%0A%3Cactual%20outcome%3E). | 40 /// Please file an issue [in the issue tracker](https://github.com/dartino/sdk/i
ssues/new?title=Add%20title&labels=Area-Package&body=%3Cissue%20description%3E%0
A%3Crepro%20steps%3E%0A%3Cexpected%20outcome%3E%0A%3Cactual%20outcome%3E). |
| 41 library i2c; | 41 library i2c; |
| 42 | 42 |
| 43 import 'dart:fletch'; | 43 import 'dart:dartino'; |
| 44 import 'dart:fletch.ffi'; | 44 import 'dart:dartino.ffi'; |
| 45 | 45 |
| 46 import 'src/process_object.dart'; | 46 import 'src/process_object.dart'; |
| 47 | 47 |
| 48 // Foreign functions used. | 48 // Foreign functions used. |
| 49 final ForeignFunction _open = ForeignLibrary.main.lookup('open'); | 49 final ForeignFunction _open = ForeignLibrary.main.lookup('open'); |
| 50 final ForeignFunction _close = ForeignLibrary.main.lookup('close'); | 50 final ForeignFunction _close = ForeignLibrary.main.lookup('close'); |
| 51 final ForeignFunction _ioctl = ForeignLibrary.main.lookup('ioctl'); | 51 final ForeignFunction _ioctl = ForeignLibrary.main.lookup('ioctl'); |
| 52 | 52 |
| 53 /// Address of an I2C bus. | 53 /// Address of an I2C bus. |
| 54 /// | 54 /// |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } finally { | 302 } finally { |
| 303 data.free(); | 303 data.free(); |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Close the connection to the I2C bus freeing up system resources. | 307 // Close the connection to the I2C bus freeing up system resources. |
| 308 void close() { | 308 void close() { |
| 309 _close.icall$1Retry(_fd); | 309 _close.icall$1Retry(_fd); |
| 310 } | 310 } |
| 311 } | 311 } |
| OLD | NEW |