Author: Jacaranda

5" Display For Raspberry Pi Pi2 Model B+ A+ used for OragePi 2

[Copy link]

1

threads

23

posts

174

credits

Registered member

Rank: 2

credits
174
 Author| Published in 2015-10-19 11:26:22 | Show all floors
Edited by Jacaranda at 2015-10-19 18:53

You need compile ADS7846 touchscreen as a module.

fex:
  1. [spi0]
  2. spi_used = 1
  3. spi_cs_bitmap = 1
  4. spi_mosi = port:PC00<3><default><default><default>
  5. spi_miso = port:PC01<3><default><default><default>
  6. spi_sclk = port:PC02<3><default><default><default>
  7. spi_cs0 = port:PA21<1><1><default><default>

  8. [spi_devices]
  9. spi_dev_num = 1

  10. [spi_board0]
  11. modalias = "ads7846"
  12. max_speed_hz = 1500000
  13. bus_num = 0
  14. chip_select = 0
  15. mode = 0
  16. full_duplex = 1
  17. manual_cs = 0
Copy code


drivers/input/touchscreen/ads7846.c:
  1. diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads
  2. index f02028e..0a3f610 100644
  3. --- a/drivers/input/touchscreen/ads7846.c
  4. +++ b/drivers/input/touchscreen/ads7846.c
  5. @@ -59,6 +59,22 @@
  6. #define TS_POLL_DELAY  1       /* ms delay before the first sample */
  7. #define TS_POLL_PERIOD 5       /* ms delay between samples */

  8. +
  9. +static struct ads7846_platform_data ads7846_chip_info =
  10. +{
  11. +    .gpio_pendown      = 2,
  12. +    .pressure_max      = 255,
  13. +    .x_plate_ohms      = 180,
  14. +    .x_min             = 176,
  15. +    .x_max             = 3913,
  16. +    .y_min             = 300,
  17. +    .y_max             = 3947,
  18. +    .debounce_max      = 10,
  19. +    .debounce_tol      = 3,
  20. +    .debounce_rep      = 1,
  21. +    .keep_vref_on      = 1
  22. +};
  23. +
  24. /* this driver doesn't aim at the peak continuous sample rate */
  25. #define        SAMPLE_BITS     (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after

  26. @@ -970,6 +986,7 @@ static int __devinit ads7846_setup_pendown(struct spi_device
  27.                 ts->get_pendown_state = pdata->get_pendown_state;
  28.         } else if (gpio_is_valid(pdata->gpio_pendown)) {

  29. +               // try to get gpio for pendown
  30.                 err = gpio_request_one(pdata->gpio_pendown, GPIOF_IN,
  31.                                        "ads7846_pendown");
  32.                 if (err) {
  33. @@ -1197,17 +1214,27 @@ static int __devinit ads7846_probe(struct spi_device *sp
  34.         struct ads7846 *ts;
  35.         struct ads7846_packet *packet;
  36.         struct input_dev *input_dev;
  37. +
  38. +       if (!spi->dev.platform_data) {
  39. +               spi->dev.platform_data = &ads7846_chip_info;
  40. +       }
  41. +
  42.         struct ads7846_platform_data *pdata = spi->dev.platform_data;
  43.         unsigned long irq_flags;
  44.         int err;

  45. -       if (!spi->irq) {
  46. -               dev_dbg(&spi->dev, "no IRQ?\n");
  47. +       if (!pdata) {
  48. +               dev_dbg(&spi->dev, "no platform data?\n");
  49.                 return -ENODEV;
  50.         }

  51. -       if (!pdata) {
  52. -               dev_dbg(&spi->dev, "no platform data?\n");
  53. +       // try to grab irq for pendown
  54. +       if (pdata->gpio_pendown) {
  55. +               spi->irq = gpio_to_irq(pdata->gpio_pendown);
  56. +       }
  57. +
  58. +       if (!spi->irq) {
  59. +               dev_dbg(&spi->dev, "no IRQ?\n");
  60.                 return -ENODEV;
  61.         }

Copy code



worked with PA21 - CS0 and PA02 - IRQ pendown.
Need some trics with platform_data, touch worked but no so cool.

1

threads

23

posts

174

credits

Registered member

Rank: 2

credits
174
 Author| Published in 2015-10-19 11:51:49 | Show all floors
platform_data in ads7846 driver module it's not true way. If any body know how made it right, please correct me. Thanks

1

threads

23

posts

174

credits

Registered member

Rank: 2

credits
174
 Author| Published in 2015-10-19 16:59:30 | Show all floors
Edited by Jacaranda at 2015-10-19 18:47

PA21 - is CS0 and PA02 - is IRQ for pendown You need turn off uart2 used PA02

  1. [uart2]
  2. uart_used = 0
  3. uart_port = 2
  4. uart_type = 4
  5. uart_tx = port:PA00<2><1><default><default>
  6. uart_rx = port:PA01<2><1><default><default>
  7. uart_rts = port:PA02<2><1><default><default>
  8. uart_cts = port:PA03<2><1><default><default>
Copy code


10

threads

448

posts

5115

credits

Moderator

Rank: 7Rank: 7Rank: 7

credits
5115
Published in 2015-10-19 20:02:09 | Show all floors
Jacaranda replied at 2015-10-19 04:06
Wow thank you very much, can you share timig changes ?) thanks. Later i give driver code changes and ...

Thank you for sharing the code.
My display has USB touchscreen, but I would like to test the spi driver too.
You can get my sources at GitHub.


1

threads

23

posts

174

credits

Registered member

Rank: 2

credits
174
 Author| Published in 2015-10-21 16:43:16 | Show all floors
loboris replied at 2015-10-19 20:02
Thank you for sharing the code.
My display has USB touchscreen, but I would like to test the spi d ...

Thanks for sources all work perfect.

0

threads

8

posts

68

credits

Registered member

Rank: 2

credits
68
Published in 2015-12-18 21:18:55 | Show all floors
Any idea how to get this display work with Android maybe Beelink_X2-SC_V1.1-Custom_ROM ? Its seems to be forced to use 1280x720 resolution...

0

threads

3

posts

100

credits

Registered member

Rank: 2

credits
100
Published in 2016-1-27 15:24:06 | Show all floors
loboris replied at 2015-10-19 20:02
Thank you for sharing the code.
My display has USB touchscreen, but I would like to test the spi d ...

Hi!"Orange PI PC" will work with this display ( http://www.aliexpress.com/item/I ... MI/32583337754.html ) if I use your drivers?

3

threads

60

posts

258

credits

Intermediate member

Rank: 3Rank: 3

credits
258
Published in 2016-2-4 04:35:50 | Show all floors
This is HDMI connection interface for generic LCD display. For less than $30 I would try my luck.

1

threads

9

posts

278

credits

Intermediate member

Rank: 3Rank: 3

credits
278
Published in 2016-2-5 20:06:36 | Show all floors
Jacaranda replied at 2015-10-19 07:51
platform_data in ads7846 driver module it's not true way. If any body know how made it right, please ...

Lay out please, the script.bin and ads7846.ko

4

threads

7

posts

140

credits

Registered member

Rank: 2

credits
140
Published in 2016-5-26 20:55:33 | Show all floors
Hi, has anybody get this touchscreen working?
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list