Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
Author: Jacaranda

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

[Copy link]

1

Threads

23

Posts

172

Credits

Registered member

Rank: 2

Credits
172
 Author| Post time 2015-10-19 11:26:22 | Show all posts
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 the 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 the 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

172

Credits

Registered member

Rank: 2

Credits
172
 Author| Post time 2015-10-19 11:51:49 | Show all posts
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

172

Credits

Registered member

Rank: 2

Credits
172
 Author| Post time 2015-10-19 16:59:30 | Show all posts
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 the Code


10

Threads

448

Posts

3851

Credits

Moderator

Rank: 7Rank: 7Rank: 7

Credits
3851
Post time 2015-10-19 20:02:09 | Show all posts
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

172

Credits

Registered member

Rank: 2

Credits
172
 Author| Post time 2015-10-21 16:43:16 | Show all posts
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
Post time 2015-12-18 21:18:55 | Show all posts
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
Post time 2016-1-27 15:24:06 | Show all posts
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
Post time 2016-2-4 04:35:50 | Show all posts
This is HDMI connection interface for generic LCD display. For less than $30 I would try my luck.

1

Threads

9

Posts

277

Credits

Intermediate member

Rank: 3Rank: 3

Credits
277
Post time 2016-2-5 20:06:36 | Show all posts
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
Post time 2016-5-26 20:55:33 | Show all posts
Hi, has anybody get this touchscreen working?
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2019-9-19 03:41 GMT+8 , Processed in 0.038130 second(s), 20 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list