NetBurner 3.5.6
PDF Version
General Purpose I/O Service

Example to control GPIO pins though command interface.

GPIO Service Application

A NetBurner embedded system application for controlling General Purpose I/O (GPIO) pins through a command-line interface.

Note
For platform-specific GPIO examples and advanced usage, refer to the "Example Applications > Platform Specific" section in the NetBurner Documentation.

Overview

This application provides a serial command interface for configuring and controlling GPIO signals on NetBurner modules. It sets up a command parser on the default serial port, allowing users to interact with GPIO pins in real-time through simple text commands.

Features

  • Real-time GPIO pin control via serial terminal
  • Support for multiple NetBurner platforms with automatic connector detection
  • Command history with navigation (Ctrl+D, Ctrl+U, Ctrl+R)
  • Interactive help system
  • Web server integration for network diagnostics

Supported Operations

The application supports the following GPIO operations:

  • HI - Set a pin to logic high (3.3V/5V)
  • LO - Set a pin to logic low (0V)
  • TGL - Toggle a pin's current state
  • OUT - Configure a pin as an output
  • IN - Configure a pin as an input (high impedance)
  • RD - Read the current state of a pin
  • HELP - Display available commands

Platform Support

The application automatically adapts to different NetBurner platforms:

  • MODM7AE70: Uses P2 connector with PinIO::PIN_FN_OUT function
  • NANO54415 & SB800EX: Uses main connector (Pins) with PIN_GPIO function
  • Other platforms: Uses J2 connector with PIN_GPIO function

Hardware Requirements

  • NetBurner development module
  • Serial terminal connection (debug/status port)
  • GPIO-capable pins on the target connector
Warning
Not all pins on every NetBurner device can function as GPIO. Consult your specific device datasheet for GPIO capabilities and pin assignments.

Software Requirements

  • NetBurner NNDK (NetBurner Network Development Kit)
  • MTTTY or compatible serial terminal software
  • Network connection for web server functionality (optional)

Building and Installation

  1. Build the project using the NetBurner development environment
  2. Load the compiled application onto your NetBurner device
  3. Connect to the device's debug/status port using a serial terminal
  4. The application will automatically start and display the command prompt

Usage Examples

Basic Pin Control

> HI 5 # Set pin 5 high
P2[5]_out: 1
> LO 3 # Set pin 3 low
P2[3]_out: 0
> TGL 7 # Toggle pin 7
P2[7]_out: 1

Pin Configuration

> OUT 2 # Configure pin 2 as output
> IN 4 # Configure pin 4 as input
> RD 4 # Read pin 4 state
P2[4]_in: 0

Interactive Features

  • Press Enter on empty line to repeat last command
  • Use Ctrl+D to navigate to previous command in history
  • Use Ctrl+U to navigate to next command in history
  • Use Ctrl+R to recall and execute previous command
  • Use Backspace to edit current command

Command Reference

Command Syntax Description
HI HI <pin> Set specified pin to logic high
LO LO <pin> Set specified pin to logic low
TGL TGL <pin> Toggle pin state (repeatable with Enter)
OUT OUT <pin> Configure pin as output driver
IN IN <pin> Configure pin as high-impedance input
RD RD <pin> Read pin state (repeatable with Enter)
HELP HELP Display command help

Application Architecture

Key Components

  • Command Parser: Processes serial input and maps to function calls
  • GPIO Abstraction: Platform-independent pin control interface
  • Command History: Circular buffer storing recent commands
  • Network Stack: Built-in web server for diagnostics

Memory Usage

  • Command buffers: 5 buffers x 80 characters each
  • Read buffer: 256 bytes
  • Minimal stack usage for embedded operation

Network Features

The application includes built-in network functionality:

  • HTTP web server on port 80
  • DHCP client for automatic IP assignment
  • System diagnostics accessible via web interface
  • 5-second network initialization timeout

Error Handling

  • Graceful handling of invalid commands with "Unrecognized command" message
  • Parameter validation for pin numbers
  • Safe defaults for missing parameters
  • Non-blocking serial input processing

Development Notes

  • All commands are case-insensitive (automatically converted to uppercase)
  • Pin numbers are parsed as decimal integers
  • The application runs in an infinite loop with 1-second intervals
  • Platform-specific macros handle connector and function differences