In my previous post I gave some instructions on how to rebuild the BeagleBone Black device-tree to allow for run-time override I also teased you with a little video of some activity on the Nokia 3330 LCD I attached to the BeagleBone. Today I’m back with some detailed information on:
- The wiring of the BBB and the LCD
- The device tree overlay file
- Source code of the demo
I’ve been playing with Fritzing. It’s a nice tool that allows you to go from a prototype on a breadboard to a PCB in a seamless experience. I encourage you to give it a try. I used it to generate a schematic of the wiring between the LCD and the BBB. I used the BeagleBone Black symbol available here.
The breadboard view:
Without waiting any longer here is the “beast”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
As you can see the file is split in 4 segments.
- Defines the pinmux for the pins that are used by the spi0 port, note that the clock has to be an input to work !
- Overrides the spi0 driver properties and enable it by setting it’s status to “okay”. Inform the Kernel that the spidev driver must be used for that port. The reg property indicates that we use the chip select 0 for the LCD.
- Defines the pinmux for the gpio pins that are used to control the reset and the data/command pins
- Uses the bone-pinmux-helper driver to configure the GPIO pins as defined by lcd_ctrl_pinmux
There are a few concepts to grasp here:
Defining just a pinmux setting is not enough for the pins to be configured. You need a driver that uses the pinctrl framework for the pinmux to be configured. At the moment only a limited number of drivers make use of the pinctrl framework so if your driver doesn’t support it or if you just want to pinmux some GPIO pins you have to use the bone-pinmux-helper which handles the pinctrl for you.
It took me some time to get these rights so hopefully this should make your life easier.
I hacked together some code to control the LCD and draw some animation on the display. Use at your own risk. Get it HERE. Before running the demo you’ll have to execute the following commands once:
1 2 3 4 5
They enable the device-tree overlay and export the gpio to sysfs. Note that there is an extra GPIO used for a buzzer that I beep everytime there is a collision on the screen. I’ll be pushing that to github at some point. [UPDATED: Now available on github]
You can see the result here:
Hope you’ll enjoy it.