File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ JNIEXPORT jbyte JNICALL Java_com_cacaosd_i2c_core_I2cPort_openConnection
12
12
i2c.openConnection ();
13
13
}
14
14
15
+ JNIEXPORT jbyte JNICALL Java_com_cacaosd_i2c_core_I2cPort_closeConnection
16
+ (JNIEnv *env, jobject obj) {
17
+ i2c.closeConnection ();
18
+ }
19
+
15
20
JNIEXPORT void JNICALL Java_com_cacaosd_i2c_core_I2cPort_setDeviceAddress (
16
21
JNIEnv *env, jobject obj, jbyte device_address) {
17
22
i2c.setDeviceAddress (device_address);
Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ extern "C" {
20
20
JNIEXPORT jbyte JNICALL Java_com_cacaosd_i2c_core_I2cPort_openConnection
21
21
(JNIEnv *, jobject);
22
22
23
+ /*
24
+ * Class: com_cacaosd_i2c_core_I2cPort
25
+ * Method: closeConnection
26
+ * Signature: ()V
27
+ */
28
+ JNIEXPORT jbyte JNICALL Java_com_cacaosd_i2c_core_I2cPort_closeConnection
29
+ (JNIEnv *, jobject);
30
+
23
31
/*
24
32
* Class: com_cacaosd_i2c_core_I2cPort
25
33
* Method: setDeviceAddress
Original file line number Diff line number Diff line change @@ -28,13 +28,19 @@ public class I2cPort {
28
28
public I2cPort (byte device_address , byte bus ) {
29
29
setBusAddress (bus );
30
30
setDeviceAddress (device_address );
31
+ openConnection ();
31
32
}
32
33
33
34
/**
34
35
* Open I2C connection.
35
36
*/
36
37
public native void openConnection ();
37
38
39
+ /**
40
+ * Close I2C connection.
41
+ */
42
+ public native void closeConnection ();
43
+
38
44
/**
39
45
* Set slave device address.
40
46
*
You can’t perform that action at this time.
0 commit comments