O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Android for the BeagleBone Black

Book Description

Design and implement Android apps that interface with your own custom hardware circuits and the BeagleBone Black

In Detail

This book explores using the Android OS on the BeagleBone Black hardware platform and provides an introduction to Android's unique approach to hardware interfacing. You'll be walked through the process of installing and configuring Android on your BeagleBone Black, as well as preparing your PC development environment to create Android applications that directly interface with hardware devices. Several example projects within this book introduce you to using the GPIO, SPI, and I2C hardware interfaces of the BeagleBone Black.

You'll create Android apps that communicate directly with actual hardware components such as sensors, memory chips, switches, and LEDs. Step-by-step guidance through both the software and hardware portions of these projects is provided. Combining all of the previous projects into a single project that uses GPIO, SPI, and I2C together, you will explore the details of creating an advanced hardware interfacing app. Finally, you'll be provided with information on transitioning prototype code into code suitable for deployment on an Android-based device. With a variety of example apps that demonstrate key hardware communication concepts, this book will help you become an Android hardware interfacing pro in no time.

What You Will Learn

  • Install Android on your BeagleBone Black
  • Explore the three primary hardware interfaces of the BeagleBone Black—GPIO, SPI, and I2C
  • Construct circuits that interface the BeagleBone Black with high-speed sensors, external memory chips, and more
  • Discover the advantages and disadvantages of using GPIO, I2C, and SPI components in your interfacing projects
  • Modify Android to recognize and interface with your own custom and prototype hardware
  • Develop multithreaded apps that communicate directly with custom circuitry

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Android for the BeagleBone Black
    1. Table of Contents
    2. Android for the BeagleBone Black
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Introduction to Android and the BeagleBone Black
      1. Looking back on Android and BeagleBone Black development
      2. Shopping for the hardware essentials
        1. The FTDI cable
        2. Power supply
        3. Breadboard and the mounting plate
        4. MicroSD cards
      3. Learning about the hardware you'll interface with
        1. General-purpose components
        2. The AdaFruit memory breakout board
        3. The AdaFruit sensor breakout board
        4. Preparing the breakout boards
      4. Installing Android on the BeagleBone Black
        1. Downloading a premade Android image
        2. Creating your Android microSD card using Windows
        3. Creating your Android microSD card using Linux
      5. Summary
    9. 2. Interfacing with Android
      1. Understanding the Android HAL
        1. Android managers
        2. The HAL development workflow
        3. Working with PacktHAL
      2. Installing PacktHAL
        1. Preparing PacktHAL under Linux
        2. Preparing PacktHAL under Windows
        3. The PacktHAL directory structure
        4. Preparing Android for PacktHAL
        5. Pushing PacktHAL files under Linux
        6. Pushing PacktHAL files under Windows
      3. Setting up the Android NDK for PacktHAL
        1. Adding the header to the NDK under Linux
        2. Adding the header to the NDK under Windows
      4. Multiplexing the BBB pins
        1. The kernel Device Tree and capemgr
        2. Defining a cape
      5. Summary
    10. 3. Handling Inputs and Outputs with GPIOs
      1. Understanding GPIOs
        1. Nuts and bolts of GPIO
        2. GPIO access methods under Android
          1. Pros and cons of the file I/O method
          2. Pros and cons of the memory-mapping method
        3. Preparing Android for GPIO use
      2. Building a GPIO-interfacing circuit
        1. Constructing the circuit
        2. Checking your wiring
      3. Including PacktHAL within your apps
        1. Understanding the Java Native Interface
        2. Creating a new app project that uses PacktHAL
          1. Building PacktHAL under Windows
          2. Building PacktHAL under Linux
      4. Exploring the GPIO example app
        1. Installing the app and source under Windows
        2. Installing the app and source under Linux
        3. The app's user interface
        4. Calling the PacktHAL functions
        5. Using the PacktHAL GPIO functions
      5. Summary
    11. 4. Storing and Retrieving Data with I2C
      1. Understanding I2C
        1. Devices that use I2C
      2. Multiplexing for I2C on the BBB
        1. Connecting to I2C via the P9 header
        2. Multiplexing for I2C
      3. Representing I2C devices in the Linux kernel
        1. Preparing Android for FRAM use
      4. Building an I2C-interfacing circuit
        1. Connecting the FRAM
        2. Checking the FRAM connection with I2C tools
      5. Exploring the I2C FRAM example app
        1. The app's user interface
        2. Calling the PacktHAL FRAM functions
        3. Understanding the AsyncTask class
        4. Learning the details of the HardwareTask class
      6. Summary
    12. 5. Interfacing with High-speed Sensors Using SPI
      1. Understanding SPI
      2. Multiplexing for SPI on the BBB
      3. Representing SPI devices in the Linux kernel
        1. Preparing Android for SPI sensor use
      4. Building an SPI interface circuit
        1. Connecting the sensor
      5. Exploring the SPI sensor example app
        1. The app's user interface
        2. Calling the PacktHAL sensor functions
        3. Using the HardwareTask class
      6. Summary
    13. 6. Creating a Complete Interfacing Solution
      1. Building the complete interface circuit
      2. Exploring the complete example app
        1. The app's user interface
        2. Understanding hardware polling in an app
        3. Using AsyncTask with long-lived threads
        4. Using the HardwareTask class
      3. Summary
    14. 7. Where to Go from Here
      1. Integrating your solution with Android
        1. Creating a custom kernel and Device Tree
        2. Adding hardware communication into the kernel
        3. Integrating into existing managers
        4. Creating new managers for custom hardware
      2. Combining your project with other hardware
        1. Constructing your own prototype capes
        2. Commercial capes that interface with Android
      3. Exploring the BBB's other interfaces
        1. Programmable real-time units
        2. Serial communications
        3. Controller area network
        4. The analog-to-digital converter
        5. Pulse width modulation
      4. Summary
    15. Index