world leader in high performance signal processing
Trace: » demos

ADSP-BF548 EZ-KIT Quick Start: Peripheral Demos

www.analog.com_static_imported-files_images_product_descriptions_680755565image1a.jpg

Introduction to Demos

The demos that come with the customised Ubuntu distribution demonstrate each of the main peripherals on the BF548 EZ-KIT. Most are written in C and several of them use the SDL library to make the code as simple as possible.

Each demo's information page will break down the code sketch into an explanation and discuss other methods and approaches.

You can download the demos in one compressed file (demos-R1.tar.gz) at bf548-quick-start under the files tab.

LCD Demo

The four LCD demo applications included are:

  • jpegview
    An application that uses SDL_image to load a jpeg, resizes it to fit the LCD and then displays it on the LCD until the program is terminated.
  • shapes
    An application that uses SDL_gfx to draw some simple shapes on the LCD. It demonstrates some very basic primitive drawing using SDL_gfx.
  • animated
    An application that uses SDL_gfx to draw a black box that bounces around on the screen. It demonstrates some very basic primitive drawing using SDL_gfx.
  • text
    An application that uses SDL_ttf to draw some basic text on a drawing buffer for the LCD. It demonstrates some very basic text rasterisation using SDL_ttf.

Click the list item to find out more information about that demo.

These demo programs will show how you can utilise the SDL libraries to create some simple graphical manipulations on the LCD. SDL is a very large topic, but it is well documented and you can learn more at www.libsdl.org. Please note that SDL is not the only way to go about creating a graphical display on the LCD as you can also write directly to the frame buffer or use another graphics engine such as Qt or DirectFB. However these are much more complex, and to keep this guide simple it is suggested that you investigate these other ways further elsewhere. They are documented on the wiki at Working with Frame Buffers, QT Embedded and DirectFB and have strong online documentation.

Touch Screen Demo

The two demo touchscreen applications included are:

  • touch_simple
    An application that uses SDL_gfx to draw two boxes on the screen, when a user presses a box, that box will change colours. This program will do so until it is terminated.
  • touch_advanced
    An application that uses SDL_gfx to draw a box on the screen, when the user touches the box and drags it on the screen with a finger, the box will follow the finger. This program will do so until it is terminated.

Click the list item to find out more information about that demo.

These demo programs will show how you can utilise the SDL libraries to handle the touchscreen as if it were a mouse. SDL is a very large topic, but it is well documented and you can learn more at www.libsdl.org. Please note that SDL is not the only way to go about utilising the touchscreen as any library that can use tslib can also be used. You can also just read events directly from the input event buffer which will provide x and y coordinates as well as touch pressure readings. To learn more about reading from the event buffer please look into the push buttons demo as it would be a similar methodology to that demo.

Rotary Demo

The demo rotary applications included are:

  • rotary
    This demo program will use SDL_gfx to draw a bar on the LCD screen. When the user spins the rotary left or right, it will shrink or grow the bar respectively. When the user pushes the rotary down it will change the bars colour. The program will operate until it is terminated (Ctrl + C).

Click the list item to find out more information about that demo.

This is only a simple demo, just to show you that the rotary encoder can be used as a program input.

Keypad Demo

The demo keypad applications included are:

  • keypad
    This demo program will use SDL_gfx and SDL_ttf to draw the buttons character being pressed on the keypad onto LCD screen. When the user pushes a button on the keypad, it will appear on the LCD. When the user lets go of the button, it will disappear from the LCD. If the user pushes the red 2nd button it will toggle the alternative characters and a symbol will appear on the LCD screen. When the user pushes the red 2nd button again, it will go back to normal. The program will operate until it is terminated (Ctrl + C).

Click the list item to find out more information about that demo.

This is only a simple demo, just to show you that the keypad can be used as a program input.

Push Buttons Demo

The demo push button applications included are:

  • gpiokeys
    This demo program will use SDL_gfx to draw four boxes on the LCD. When a user pushes a gpio push button it will draw the box going down as long as the user is holding it. When the user lets go of the button, the box will return to the top. The program will operate until it is terminated (Ctrl + C).

Click the list item to find out more information about that demo.

This is only a simple demo, just to show you that the push buttons can be used as a program input.

LEDs Demo

The demo LED applications included are:

  • blink
    This demo program will use simply blink the User LEDs on and off every second. The program will operate until it is terminated (Ctrl + C).

This is only a simple demo, just to show you that the user leds can be used as a program output.

Audio Demo

There two demo applications included are:

  • audio
    A simple application that uses SDL_mixer to play an mp3 file (fur ellise) through the audio output.
  • recorder
    An application that uses the alsa api to record audio coming in from the microphone port. It then writes this data out to a wav file as cd quality. This program will do so until it is terminated.

These demo programs will show you how to use SDL to play audio in a high level manner and also how to record audio in a low level manner using Alsa.

Networking Demo

The demo LED applications included are:

  • boa
    This demo is a cgi application that can be run by the built-in Boa web server. Boa is a light weight httpd server that can run on uClinux. This demo will use that web server and have it run a simple cgi hello world script that will let you see how the Blackfins networking support allows it to host dynamic web pages.

Later in the tutorial sections there is a TCP Server application that can demonstrate how the Blackfin has standard inet support.

Hard Drive Demo

The demo LED applications included are:

  • hddtest
    This demo program will check if the sda1 partition is mounted to /mnt and then will create a test file on the hard drive. You will need to prepare the hard drive for this demo by following the preparation text file.

This is only a simple demo, just to show you that files can be written to the hard drive and basic debugging can be performed.

USB Demo

The demo LED applications included are:

  • usb-keyboard
    This demo program will make the Blackfin EZ-KIT appear to be a usb keyboard when plugged into a PC. This is done by using the usb human interface device gadget driver.

This is only a simple demo, just to show you that the usb can be used to make your device act as a gadget.

Further Reading

LCD Notes

The LCD on the BF548 EZ-KIT is a 24bit lcd (8bit blue, 8bit green, 8bit red). This means some programs hard coded for the frame buffer do not work, for example pngview. If you run pngview and it appears wonky on the BF548 that is because it was made for the BF537 and a 16bit LCD. Since it does not write enough data to fill a pixel and will encode for rgb and not bgr, it will be interpreted wrongly, so be aware of this when working with programs that write directly to the frame buffer.

If the colour on the LCD screen appears wonky, this may be due to the LCD screen settings defined by SW17. These switches can set the bitrate of the LCD and if set differently than to what the program expecs will lead to a bit of mayham. Check the development environment page of this guide to make sure it is set to the default 24bit.

Information on the LCD driver for the BF548 EZ-KIT can be found here Linux framebuffer driver for ADSP-BF54x

Touchscreen Notes

The touch screen library is discussed on the Touchscreen Library. This page even includes details on setting it up and debugging.

The AD7877 driver page can be found on the analog wiki.

Make sure that libsdl has been configured to enable tslib as an input. This can be done by modifying the file “blackfin-linux-dist/lib/libsdl/Makefile” to add the flag ”--enable-input-tslib” for the CONF_OPTS. This has already been done on the custom Ubuntu ISO.

CONF_OPTS = \
        --disable-arts \
        --disable-esd \
        --disable-pth \
        --disable-video-directfb \
        --disable-video-x11 \
        --enable-input-tslib \

You must enable tslib to work with the touch screen. You also need to ensure that the ad7877 driver is installed in the kernel or available as a module. If it is a module, you should be able to install it when necessary using modprobe ad7877.

If the touch screen is not responding correctly to you, it is possible that tslib was not built correctly with SDL. This makes SDL use the pressure sensor reading as the x coordinate and the y coordinate will be random.

To correct this, you need to ensure tslib is built prior to SDL being built. The uClinux distribution provided on the custom Ubuntu ISO already has this modification permanently fixed in however if you are using a clean distribution, you will need to do two file edits:

  • “blackfin-linux-dist/lib/Kconfig.local”: Add LIB_TSLIB as a dependency for SDL

    ...
    config LIB_LIBSDL
    bool "Build libSDL"
    depends on LIB_TSLIB
    help
    ...
  • “blackfin-linux-dist/lib/Makefile.local”: Shift libsdl make to dir_4

    dir_3_$(CONFIG_LIB_LIBSDL) += libsdl
    
    to dir 4
    
    dir_4_$(CONFIG_LIB_LIBSDL) += libsdl #requires tslib(3)
  • “blackfin-linux-dist/lib/Makefile.local”: shift sdl_gfx to dir_5

    dir_4_$(CONFIG_LIB_SDL_GFX) += SDL_gfx
    
    to dir 5
    
    dir_5_$(CONFIG_LIB_SDL_GFX) += SDL_gfx

After these edits, “make clean” and “make” will correctly build libsdl with tslib support.

If you do not want to edit the files you can just run the following commands after building your uClinux distribution:

root:/> make lib/libsdl_clean
root:/> make lib/tslib-1.0_clean
root:/> make lib/tslib-1.0_only
root:/> make lib/libsdl_only
root:/> make

The new uClinux image built will now have SDL correctly linking to tslib.

Rotary Notes

The information on the rotary can be found on the wiki page Blackfin Rotary/Thumbwheel Input Device Driver

The keypad enter key provides the same response as pushing down the rotary key, so if you are using both in an application, you should look at reading directly from the event device node for event inputs. This is demonstrated in the gpiokeys demo. You can look up event device node for further information about this approach.

This demo only works if the rotary driver is set up to provide +/- keystroke events rather than relative events. This is disabled by default in the kernel, but you can enable it by editing the file 'blackfin-linux-dist/linux-2.6.x/arch/blackfin/mach-bf548/boards/ezkit.c' and uncommenting '.rotary_up_key = KEY_UP,' and '.rotary_down_key = KEY_DOWN,'. This has already been done on the custom Ubuntu ISO. You could also change what key the rotary button reports, if you need to make sure it doesn't conflict with the keypad.

Keypad Notes

The keypad driver page on the wiki is bf54x-keys

The keypad enter key provides the same response as pushing down the rotary key, so if you are using both in an application, you should look at reading directly from the event device node for event inputs. This is demonstrated in the gpiokeys demo. You can look up event device node for further information about this approach.

Push Button Notes

Information on the push button drivers can be found here: gpio-keys and this driver can be useful if you are making your own board and want to implement hardware buttons.

You can look up event device node for further information about the approach this demo takes to receiving the input.

User LEDs Notes

The gpio sys fs page on the wiki is located at GPIO sysfs Interface. You can actually do all these gpio settings via the terminal prompt as shown on that page. That is a good way to debug gpio.

The page Interrupts shows a mapping of ports to their aliases.

Audio Notes

SDL_mixer is documented on the main SDL site http://www.libsdl.org/projects/SDL_mixer/docs/index.html and you can read more up on it there.

Alsa Utils is expected to be installed for the aplay command to work. You can actually record and play audio using aplay and arecord from alsa utils if you want to have a simpler time. To enable alsa utils when compiling uClinux enable Blackfin app programs > ALSA utils.

You can read up on the alsa library at its official documentation http://www.alsa-project.org

If you cannot find your audio device on the BF548 with a fresh copy of the uClinux2011R1-RC3 release that is because in that release the audio drivers had a slight error. You can fix this by downloading the latest kernel updates from the Blackfin uClinux git repository or getting the upgrade.patch file from the custom Ubuntu ISO in the “Blackfin/blackfin-linux-dist/linux-2.6.x” folder and applying it to your distribution to run the updates automatically (patch -p1 < upgrade.patch).

To check that the alsa audio driver is running, check the dev directory for /dev/dsp. If it exists, the driver should be ready to go. If not, you'll need to determine whether the audio drivers are enabled or not.

root:/> ls /dev/dsp

Boa Notes

If you are having trouble setting up the network connection, visit this page setting_up_the_network to get further tips and debug information.

Running a web server isn't the only networking application possible on the BF548 EZ-KIT. It can perform any networking application that standard linux can perform, including TCP servers/clients, UDP servers/clients and any inet functions. More on this in the cross compiling tutorials.

There is a page in the wiki demonstrating even using shell scripts to run a cgi application with boa: cgi_hello_world

A port for PHP has been done previously, although it is not a full version of PHP, information can be found here boa-pp.html

If you are interested in the network drivers themselves, the wiki page Network Device Drivers discusses them.

Hard Drive Disk Notes

Information on the ATAPI drivers can be found here: Blackfin On-Chip ATAPI Controller and this driver can be useful if you are making your own board and want to learn more about the On-Chip ATAPI controller.

USB Notes

The usb gadget drivers are discussed on the USB Gadget API Framework page. You can research more about USB HID on pages such as www.usb.org/developers/devclass_docs/HID1_11.pdf.