Exploring the Raspberry Pi 2 with C++

Book description

You have a Pi 2, but what exactly can you do with it? This book takes you on a tour of the Pi 2 hardware and all of the fantastic things that you can do to create innovative and useful projects with your Pi. Start with creating a workstation that does actual work, and move into installing a custom kernel, creating a clock, learning the ins and outs of the GPIO interface, and pick up some useful C++ skills along the way.

Warren Gay, author of Mastering the Raspberry Pi, takes you through a set of experiments to show just what the Pi 2 is capable of and how you can use it to make your own fantastic creations.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. Acknowledgments
  9. Chapter 1: Introduction
    1. Overview
    2. Software for This Book
    3. Software Installation
    4. Installation Notes
    5. Thank You
  10. Chapter 2: Workstation
    1. The Raspberry Pi 2 Arrives
    2. The Raspberry Pi 2 pcb
    3. Constructing the Workstation
    4. Breadboard Breakout
    5. RS-232 Connection
    6. Panel Meter
    7. Arduino/AVR
    8. Summary
  11. Chapter 3: The Matrix (CPU Utilization)
    1. The LED Matrix
    2. Level Converters
    3. Interfacing GPIO to MAX7219
    4. Absolute Maximum Ratings
    5. MAX7219 Commands
      1. Display Data Commands
      2. Decode Mode Command
    6. Intensity Command
      1. Scan-Limit Command
      2. Shutdown Command
      3. Test Mode Command
      4. No Operation Command
    7. Matrix Signals
    8. CPU Meter
    9. The mtop Command
    10. Bibliography
  12. Chapter 4: Installing a Kernel
    1. Overall Procedure
    2. Disk Space
    3. Downloading the Source
    4. Raspberry Tools
    5. Prepare Configuration
    6. Build Configuration
    7. Kernel Compile
    8. Modules Build
    9. Installing the Kernel
    10. Reboot
    11. Recovering from Boot Failure
    12. Installing the rpidma Kernel Module
    13. Autoloading rpidma
    14. Specific Kernel Releases
    15. Summary
    16. Bibliography
  13. Chapter 5: 3 GPIO gp Command
    1. Unix Command Line Convention
    2. The gp Command
    3. Displaying GPIO Settings
      1. Configuring GPIO as Input
      2. Configuring GPIO as Output
      3. Configuring GPIO as Alternate Function
      4. Chart of Alternate Functions
      5. Configuring GPIO Pullup/Pulldown
      6. Setting GPIO Output
      7. Reading GPIO Input
      8. Returning GPIO Value to Shell
      9. Reading 32 GPIOs
      10. Read GPIO Alternate Function
      11. Blinking Output GPIO
      12. Monitoring GPIO Input
      13. Configuring GPIO Slew Rate
      14. Configuring GPIO Hysteresis
      15. Configuring GPIO Drive Level
    4. Summary
    5. Bibliography
  14. Chapter 6: General Purpose Clock
    1. The piclk Command
    2. Displaying Clock Settings
    3. Clock Source
    4. Clock DIVI
    5. MASH and DIVF
    6. Determining DIVI and DIVF
    7. Beat Frequency Oscillator
    8. Audio Coverage
    9. Maximum GPIO Output Frequency
    10. RF Generation
    11. Summary
    12. Bibliography
  15. Chapter 7: Pulse Width Modulation
    1. The pipwm Command
    2. Displaying PWM Settings
    3. PWM Modes
    4. M/S and PWM Data Mode
    5. M/P = M/S Mode (-Am)
    6. M/P = PWM Mode (-Ap)
    7. Data Modes
    8. Summary
    9. Bibliography
  16. Chapter 8: Physics of the GPIO Interface
    1. CMOS
      1. MOSFETs in Action
      2. CMOS Configuration
      3. CMOS Inputs
      4. Input Protection
    2. CMOS Outputs
    3. Logic Levels
    4. GPIO Drive
    5. CMOS Usage Rules
    6. Summary
    7. Bibliography
  17. Chapter 9: PiSpy
    1. Introduction to pispy
    2. pispy Command Options
    3. Capture Length
    4. Capture Resolution
    5. Verbose Option
    6. Option -x
    7. Triggers
    8. GtkWave
    9. Invoking GTKWave
    10. Using GTKWave
    11. Testing PiSpy
    12. GTKWave Hints
    13. PiSpy in a Nutshell
    14. Summary
    15. Bibliography
  18. Chapter 10: Debouncing
    1. Introduction
    2. Momentary Debouncing
    3. Toggled Debouncing
    4. The MC14490
    5. Summary
  19. Chapter 11: C++ Quick Start
    1. C++ Standards
    2. From C to C++
    3. Classes and Structs
    4. Standard Template Library
    5. Container std::vector
    6. STL Iterators
    7. Container::operator[ ]
    8. Container::at( )
    9. Ordered and Unordered Maps
    10. Initializer Lists
    11. Iterating Maps
    12. References
    13. Map vs. Set
    14. Container std::deque
    15. Safe Iterators
    16. Containers of Containers
    17. C++ Strings
    18. String Streams
    19. Predefined Compiler Macros
    20. Summary
    21. Bibliography
  20. Chapter 12: Multicore Web Server
    1. libevent
    2. Class WebMain
    3. WebMain::start()
    4. Worker Design
    5. Server Shutdown
    6. HTTP Processing
    7. Permissions
    8. How Many Threads?
    9. To Do
    10. Summary
  21. Appendix A: Class GPIO 1
    1. Assertion Macro Note
    2. Include File
    3. Linking with the GPIO Library
    4. Class Definition (Part 1)
      1. GPIO::GPIO Constructor
      2. GPIO::get_error
      3. GPIO::configure
      4. GPIO::events_off
      5. GPIO::read
      6. GPIO::write
      7. GPIO::read_event
      8. GPIO::clear_event
      9. GPIO::read_events
      10. GPIO::alt_function
      11. GPIO::get_drive_strength
      12. GPIO::set_drive_strength
  22. Appendix B: Class GPIO 2
    1. Class Definition (Part 2)
      1. GPIO::config_clock
      2. GPIO::start_clock
      3. GPIO::stop_clock
      4. GPIO::pwm_configure
      5. GPIO::pwm_ratio
      6. GPIO::pwm_enable
      7. GPIO::pwm_clear_status
      8. GPIO::pwm_write_fifo
      9. GPIO::pwm_fifo_full
      10. GPIO::pwm_fifo_empty
      11. GPIO::get_pwm_ratio
      12. GPIO::pwm_control
      13. GPIO::pwm_status
  23. Appendix C: Class GPIO 3
    1. Class Definition (Part 3)
      1. GPIO::pwm
      2. GPIO::delay
      3. GPIO::peripheral_base
      4. GPIO::source_name
      5. GPIO::alt_name
      6. GPIO::gpio_alt_func
  24. Appendix D: Class MAX7219
    1. Include File
    2. Linking
    3. Class Definition
      1. MAX7219::MAX7219
      2. MAX7219::enable
      3. MAX7219::config_intensity
      4. MAX7219::config_digits
      5. MAX7219::config_decode
      6. MAX7219::data
      7. MAX7219::test
      8. MAX7219::shutdown
      9. MAX7219::nop
    4. Initialization Procedure
  25. Appendix E: Class Matrix
    1. Include File
    2. Linking
    3. Class Definition
      1. Matrix::Matrix
      2. Matrix::display
      3. Matrix::Pi
      4. Matrix::set_meter
      5. Matrix::set_deflection
  26. Appendix F: Class MTop and Diskstat
    1. Include Files
    2. Linking
    3. MTop Class Definition
      1. MTop::MTop
      2. MTop::sample
      3. MTop::total_cpu_pct
      4. MTop::memory_pct
      5. MTop::swap_pct
    4. MTop Sampling Loop Timing
    5. Diskstat Class Definition
      1. Diskstat::Diskstat
      2. Diskstat::pct_io
  27. Appendix G: Other librpi2 Classes
    1. DMA Allocation
    2. Warning
  28. Index

Product information

  • Title: Exploring the Raspberry Pi 2 with C++
  • Author(s):
  • Release date: November 2015
  • Publisher(s): Apress
  • ISBN: 9781484217399