| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "ppport.h" |
|
6
|
|
|
|
|
|
|
#include "i2c-dev.h" |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
/* readI2CBlockData() must be defined in C to catch panic situations */ |
|
9
|
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
int I2C__readI2CBlockData(int file, int command, SV* output){ |
|
11
|
|
|
|
|
|
|
STRLEN len; |
|
12
|
0
|
0
|
|
|
|
|
char *buf = SvPV(output, len); |
|
13
|
|
|
|
|
|
|
int ret; |
|
14
|
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
ret = i2c_smbus_read_i2c_block_data(file, command, len, buf); |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
if (ret == -1){ |
|
18
|
0
|
|
|
|
|
|
croak("read_block() has invalid return. Is I2C device connected? Is the I2C bus speed set correctly?\n"); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
0
|
|
|
|
|
|
sv_setpvn(output, buf, ret); |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
return ret; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
MODULE = RPi::I2C PACKAGE = RPi::I2C PREFIX = I2C_ |
|
26
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
int I2C__readI2CBlockData(file, command, output) |
|
29
|
|
|
|
|
|
|
int file |
|
30
|
|
|
|
|
|
|
int command |
|
31
|
|
|
|
|
|
|
SV* output |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
int I2C__checkDevice(file, value) |
|
34
|
|
|
|
|
|
|
int file |
|
35
|
|
|
|
|
|
|
int value |
|
36
|
|
|
|
|
|
|
CODE: |
|
37
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_check_device(file, value); |
|
38
|
|
|
|
|
|
|
OUTPUT: |
|
39
|
|
|
|
|
|
|
RETVAL |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
int I2C__readByte(file) |
|
42
|
|
|
|
|
|
|
int file |
|
43
|
|
|
|
|
|
|
CODE: |
|
44
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_read_byte(file); |
|
45
|
|
|
|
|
|
|
OUTPUT: |
|
46
|
|
|
|
|
|
|
RETVAL |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
int I2C__writeByte(file, value) |
|
49
|
|
|
|
|
|
|
int file |
|
50
|
|
|
|
|
|
|
int value |
|
51
|
|
|
|
|
|
|
CODE: |
|
52
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_write_byte(file, value); |
|
53
|
|
|
|
|
|
|
OUTPUT: |
|
54
|
|
|
|
|
|
|
RETVAL |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
int I2C__readByteData(file,command) |
|
57
|
|
|
|
|
|
|
int file |
|
58
|
|
|
|
|
|
|
int command |
|
59
|
|
|
|
|
|
|
CODE: |
|
60
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_read_byte_data(file, command); |
|
61
|
|
|
|
|
|
|
OUTPUT: |
|
62
|
|
|
|
|
|
|
RETVAL |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
int I2C__writeByteData(file, command, value) |
|
65
|
|
|
|
|
|
|
int file |
|
66
|
|
|
|
|
|
|
int command |
|
67
|
|
|
|
|
|
|
int value |
|
68
|
|
|
|
|
|
|
CODE: |
|
69
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_write_byte_data(file, command, value); |
|
70
|
|
|
|
|
|
|
OUTPUT: |
|
71
|
|
|
|
|
|
|
RETVAL |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
int I2C__readWordData(file, command) |
|
74
|
|
|
|
|
|
|
int file |
|
75
|
|
|
|
|
|
|
int command |
|
76
|
|
|
|
|
|
|
CODE: |
|
77
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_read_word_data(file, command); |
|
78
|
|
|
|
|
|
|
OUTPUT: |
|
79
|
|
|
|
|
|
|
RETVAL |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
int I2C__writeWordData(file, command, value) |
|
82
|
|
|
|
|
|
|
int file |
|
83
|
|
|
|
|
|
|
int command |
|
84
|
|
|
|
|
|
|
int value |
|
85
|
|
|
|
|
|
|
CODE: |
|
86
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_write_word_data(file, command, value); |
|
87
|
|
|
|
|
|
|
OUTPUT: |
|
88
|
|
|
|
|
|
|
RETVAL |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
int I2C__processCall(file, command, value) |
|
91
|
|
|
|
|
|
|
int file |
|
92
|
|
|
|
|
|
|
int command |
|
93
|
|
|
|
|
|
|
int value |
|
94
|
|
|
|
|
|
|
CODE: |
|
95
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_process_call(file, command, value); |
|
96
|
|
|
|
|
|
|
OUTPUT: |
|
97
|
|
|
|
|
|
|
RETVAL |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
int I2C__readBlockData(file, command, output) |
|
100
|
|
|
|
|
|
|
int file |
|
101
|
|
|
|
|
|
|
int command |
|
102
|
|
|
|
|
|
|
SV * output |
|
103
|
|
|
|
|
|
|
INIT: |
|
104
|
|
|
|
|
|
|
char buf[ 32 ]; |
|
105
|
|
|
|
|
|
|
int ret; |
|
106
|
|
|
|
|
|
|
CODE: |
|
107
|
0
|
|
|
|
|
|
ret = i2c_smbus_read_block_data(file, command, buf); |
|
108
|
0
|
0
|
|
|
|
|
if (ret == -1) |
|
109
|
0
|
|
|
|
|
|
RETVAL = ret; |
|
110
|
0
|
|
|
|
|
|
sv_setpvn(output, buf, ret); |
|
111
|
0
|
|
|
|
|
|
RETVAL = ret; |
|
112
|
|
|
|
|
|
|
OUTPUT: |
|
113
|
|
|
|
|
|
|
RETVAL |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
int I2C__writeBlockData(file,command,value) |
|
116
|
|
|
|
|
|
|
int file |
|
117
|
|
|
|
|
|
|
int command |
|
118
|
|
|
|
|
|
|
SV * value |
|
119
|
|
|
|
|
|
|
INIT: |
|
120
|
|
|
|
|
|
|
STRLEN len; |
|
121
|
0
|
0
|
|
|
|
|
char *buf = SvPV(value, len); |
|
122
|
|
|
|
|
|
|
CODE: |
|
123
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_write_block_data(file, command, len, buf); |
|
124
|
|
|
|
|
|
|
OUTPUT: |
|
125
|
|
|
|
|
|
|
RETVAL |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
int I2C__blockProcessCall(file, command, value) |
|
128
|
|
|
|
|
|
|
int file |
|
129
|
|
|
|
|
|
|
int command |
|
130
|
|
|
|
|
|
|
SV * value |
|
131
|
|
|
|
|
|
|
INIT: |
|
132
|
|
|
|
|
|
|
STRLEN len; |
|
133
|
0
|
0
|
|
|
|
|
char *buf = SvPV(value, len); |
|
134
|
|
|
|
|
|
|
CODE: |
|
135
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_block_process_call(file, command, len, buf); |
|
136
|
|
|
|
|
|
|
OUTPUT: |
|
137
|
|
|
|
|
|
|
RETVAL |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
int I2C__writeI2CBlockData(file, command, value) |
|
140
|
|
|
|
|
|
|
int file |
|
141
|
|
|
|
|
|
|
int command |
|
142
|
|
|
|
|
|
|
SV * value |
|
143
|
|
|
|
|
|
|
INIT: |
|
144
|
|
|
|
|
|
|
STRLEN len; |
|
145
|
0
|
0
|
|
|
|
|
char *buf = SvPV(value, len); |
|
146
|
|
|
|
|
|
|
CODE: |
|
147
|
0
|
|
|
|
|
|
RETVAL = i2c_smbus_write_i2c_block_data(file, command, len, buf); |
|
148
|
|
|
|
|
|
|
OUTPUT: |
|
149
|
|
|
|
|
|
|
RETVAL |