R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 1 | Kernel driver pcf8591 |
| 2 | ===================== |
| 3 | |
| 4 | Supported chips: |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 5 | * Philips/NXP PCF8591 |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 6 | Prefix: 'pcf8591' |
| 7 | Addresses scanned: I2C 0x48 - 0x4f |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 8 | Datasheet: Publicly available at the NXP website |
| 9 | http://www.nxp.com/pip/PCF8591_6.html |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 10 | |
| 11 | Authors: |
| 12 | Aurelien Jarno <aurelien@aurel32.net> |
| 13 | valuable contributions by Jan M. Sendler <sendler@sendler.de>, |
| 14 | Jean Delvare <khali@linux-fr.org> |
| 15 | |
| 16 | |
| 17 | Description |
| 18 | ----------- |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 19 | |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 20 | The PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 21 | analog output) for the I2C bus produced by Philips Semiconductors (now NXP). |
| 22 | It is designed to provide a byte I2C interface to up to 4 separate devices. |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 23 | |
| 24 | The PCF8591 has 4 analog inputs programmable as single-ended or |
| 25 | differential inputs : |
| 26 | - mode 0 : four single ended inputs |
| 27 | Pins AIN0 to AIN3 are single ended inputs for channels 0 to 3 |
| 28 | |
| 29 | - mode 1 : three differential inputs |
| 30 | Pins AIN3 is the common negative differential input |
| 31 | Pins AIN0 to AIN2 are positive differential inputs for channels 0 to 2 |
| 32 | |
| 33 | - mode 2 : single ended and differential mixed |
| 34 | Pins AIN0 and AIN1 are single ended inputs for channels 0 and 1 |
| 35 | Pins AIN2 is the positive differential input for channel 3 |
| 36 | Pins AIN3 is the negative differential input for channel 3 |
| 37 | |
| 38 | - mode 3 : two differential inputs |
| 39 | Pins AIN0 is the positive differential input for channel 0 |
| 40 | Pins AIN1 is the negative differential input for channel 0 |
| 41 | Pins AIN2 is the positive differential input for channel 1 |
| 42 | Pins AIN3 is the negative differential input for channel 1 |
| 43 | |
| 44 | See the datasheet for details. |
| 45 | |
| 46 | Module parameters |
| 47 | ----------------- |
| 48 | |
| 49 | * input_mode int |
| 50 | |
| 51 | Analog input mode: |
| 52 | 0 = four single ended inputs |
| 53 | 1 = three differential inputs |
| 54 | 2 = single ended and differential mixed |
| 55 | 3 = two differential inputs |
| 56 | |
| 57 | |
| 58 | Accessing PCF8591 via /sys interface |
| 59 | ------------------------------------- |
| 60 | |
| 61 | ! Be careful ! |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 62 | The PCF8591 is plainly impossible to detect! Stupid chip. |
| 63 | So every chip with address in the interval [0x48..0x4f] is |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 64 | detected as PCF8591. If you have other chips in this address |
| 65 | range, the workaround is to load this module after the one |
| 66 | for your others chips. |
| 67 | |
| 68 | On detection (i.e. insmod, modprobe et al.), directories are being |
| 69 | created for each detected PCF8591: |
| 70 | |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 71 | /sys/bus/i2c/devices/<0>-<1>/ |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 72 | where <0> is the bus the chip was detected on (e. g. i2c-0) |
| 73 | and <1> the chip address ([48..4f]) |
| 74 | |
| 75 | Inside these directories, there are such files: |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 76 | in0_input, in1_input, in2_input, in3_input, out0_enable, out0_output, name |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 77 | |
| 78 | Name contains chip name. |
| 79 | |
Jean Delvare | afc3187 | 2009-09-15 17:18:14 +0200 | [diff] [blame] | 80 | The in0_input, in1_input, in2_input and in3_input files are RO. Reading gives |
| 81 | the value of the corresponding channel. Depending on the current analog inputs |
| 82 | configuration, files in2_input and in3_input may not exist. Values range |
| 83 | from 0 to 255 for single ended inputs and -128 to +127 for differential inputs |
| 84 | (8-bit ADC). |
R.Marek@sh.cvut.cz | 7f15b66 | 2005-05-26 12:42:19 +0000 | [diff] [blame] | 85 | |
| 86 | The out0_enable file is RW. Reading gives "1" for analog output enabled and |
| 87 | "0" for analog output disabled. Writing accepts "0" and "1" accordingly. |
| 88 | |
| 89 | The out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send |
| 90 | the value to the digital-to-analog converter. Note that a voltage will |
| 91 | only appears on AOUT pin if aout0_enable equals 1. Reading returns the last |
| 92 | value written. |