-
Notifications
You must be signed in to change notification settings - Fork 17
ads7846_device
ads7846_device is a kernel module for registering an ads7846 device.
sudo modprobe ads7846_device arguments
- busnum - SPI bus number (default=0)
- cs - SPI chip select (default=1)
- speed - SPI speed (default 2MHz)
- irq
- mode - SPI mode (default: SPI_MODE_0)
- verbose - 0-2
- model - 7843, 7845, 7846, 7873 (default: 7846)
-
vref_delay_usecs - 0 for external vref; etc
micro seconds to delay between SPI transfers (spi_transfer.delay_usecs) -
vref_mv - external vref value, milliVolts ads7846: if 0, use internal vref
used for hwmon sensor code -
keep_vref_on - set to keep vref on for differential measurements as well
used in ads7846_setup_spi_msg(). READ_X(vref) ==ADS_START | ADS_A2A1A0_d_ x | ADS_12_BIT | ADS_DFR | ADS_PD10_ADC_ON | (vref ? ADS_PD10_REF_ON : 0)
#define ADS_PD10_REF_ON (2 << 0) /* vREF on + penirq */
- swap_xy - swap x and y axes
-
settle_delay_usecs - Settling time of the analog signals; a function of Vcc and the capacitance on the X/Y drivers.
If set to non-zero, two samples are taken with settle_delay us apart, and the second one is used. ~150 uSec with 0.01uF caps.
micro seconds to delay between SPI transfers (spi_transfer.delay_usecs) -
penirq_recheck_delay_usecs - If set to non-zero, after samples are taken this delay is applied and penirq is rechecked,
to help avoid false events. This value is affected by the material used to build the touch layer.
used in ads7846_report_stateudelay(ts->penirq_recheck_delay_usecs);
-
x_plate_ohms - Used to calculate pressure in
ads7846_report_state()
(default: 400) - y_plate_ohms - Not used by driver
- x_min - Minimum value for x-axis (default: 0)
-
x_max - Maximum value for x-axis (default: MAX_12BIT == 0x0FFF == 4095)
input_set_abs_params(input_dev, ABS_X, pdata->x_min ? : 0, pdata->x_max ? : MAX_12BIT, 0, 0);
frominclude/uapi/linux/input.h
: Resolution for main axes (ABS_X, ABS_Y, ABS_Z) is reported in units per millimeter (units/mm) - y_min - Minimum value for y-axis (default: 0)
-
y_max - Maximum value for y-axis (default: MAX_12BIT == 0x0FFF == 4095)
input_set_abs_params(input_dev, ABS_Y, pdata->y_min ? : 0, pdata->y_max ? : MAX_12BIT, 0, 0);
-
pressure_min, pressure_max - (pressure_max default: ~0 == 0xFFFF)
input_set_abs_params(input_dev, ABS_PRESSURE, pdata->pressure_min, pdata->pressure_max, 0, 0);
-
debounce_max - max number of additional readings per sample (0,1,2)
if filter is not defined and debounce_max is non-zero, filter will beads7846_debounce_filter()
-
debounce_tol - tolerance used for filtering
used in ads7846_debounce_filter -
debounce_rep - additional consecutive good readings required after the first two
used in ads7846_debounce_filter - gpio_pendown - the GPIO used to decide the pendown state if get_pendown_state == NULL
- irq_flags - (default: IRQF_TRIGGER_FALLING)
Max SPI speed is: 125000 * (8+16+2) Hz = 125000 * 26 Hz = 3250 kHz
On the Raspberry Pi, we have two close values on this list: 1.9 MHz and 3.9 MHz
Asking for 2 MHz will rount down to neares value which i 1.935 MHz
The value 125000 probably comes from Datasheet - ELECTRICAL CHARACTERISTICS:
|-----------------------------------------------------------| | | ADS7846E | | | PARAMETER | CONDITIONS | MIN | TYP | MAX | UNITS | |-----------------------------------------------------------| | Throughput Rate | | | | 125 | kHz | |-----------------------------------------------------------|
Excerpt from ads7846.c
/* this driver doesn't aim at the peak continuous sample rate */
#define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */)
static int __devinit ads7846_probe(struct spi_device *spi)
/* don't exceed max specified sample rate */
if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
(spi->max_speed_hz/SAMPLE_BITS)/1000);
return -EINVAL;
}
Try both finger and stylus when calibrating.
Pressure
x_plate_ohms controls pressure.
Load driver with x_plate_ohms=400.
Tip: Hook up a LED to IRQ to see when the controller detects something.
Monitor pressure events
evtest /dev/input/eventX | egrep ABS_PRESSURE
If no event is detected, lower the value by half and reload the driver until a satisfying value is found.
x_min, x_max, y_min, y_max
Load driver with the x_plate_ohm value, and without x_ and y_ values.
Monitor positioning events
evtest /dev/input/eventX | grep ABS_X
evtest /dev/input/eventX | grep ABS_Y
Press a stylus at the outher edges of the display to record the min/max x and y value.
swap_xy
Swaps the X and Y axis. Used in landscape mode.
Application notes:
Inversion pathces