| 5214 | | } |
| 5215 | | |
| 5216 | | # $_[0]: A reference to the file descriptor to access this chip. |
| 5217 | | # $_[1]: Address |
| 5218 | | # Returns: undef if not detected, 1 if detected |
| 5219 | | # Detection is rather difficult, since the PCA9540 has a single register. |
| 5220 | | # Fortunately, no other device is known to live at this address. |
| 5221 | | sub pca9540_detect |
| 5222 | | { |
| 5223 | | my ($file, $addr) = @_; |
| 5224 | | my $reg = i2c_smbus_read_byte($file); |
| 5225 | | |
| 5226 | | return if ($reg & 0xfa); |
| 5227 | | return if $reg != i2c_smbus_read_byte($file); |
| 5228 | | return if $reg != i2c_smbus_read_byte($file); |
| 5229 | | return if $reg != i2c_smbus_read_byte($file); |
| 5230 | | |
| 5231 | | return 1; |