Giter Club home page Giter Club logo

libpseudogpio's Introduction

PseudoGPIO

PseudoGPIO is a C++ library that allows an application running on a computer to control and use GPIO pins of an Arduino (or similar) board connected through USB through an API similar to the Arduino/Wiring one.

Protocol

PseudoGPIO is based on a simple protocol based on the exchange of single-byte packets through a serial port.

General Packet Format

The protocol allows for 8 different commands, encoded in the 3 higher-order bits of the packet. The remaining bits shall be interpreted differently, according to the command being issued.

Bit 7 6 5 4 3 2 1 0
Meaning Command [Command-Dependent]

Commands

No reply from the target shall be expected for any command, except where indicated.

Commands that do not provide a reply shall be assumed to have been executed correctly.

Hello

Bit 7 6 5 4 3 2 1 0
Meaning 0 0 0 Don't Care

This command checks if the target board is alive and interpreting commands correctly. It also allows to retrieve the protocol version implemented by the board. The reply shall be a single byte with the following format:

Bit 7 6 5 4 3 2 1 0
Meaning 1 1 0 1 Protocol Version

Currently, only version 1 of the protocol is defined.

PinMode

Bit 7 6 5 4 3 2 1 0
Meaning 0 0 1 Pseudopin # Mode

This command sets the mode of a pseudopin. Mode shall be interpreted as follows:

  • 0: Input
  • 1: Output

DigitalRead

Bit 7 6 5 4 3 2 1 0
Meaning 0 1 0 Pseudopin # Don't Care

This command requests the status of a digital pseudopin. The reply is a single byte, of which only the LSB shall be interpreted as follows:

  • 0: Low Level
  • 1: High Level

DigitalWrite

Bit 7 6 5 4 3 2 1 0
Meaning 0 1 1 Pseudopin # Level

This command sets the level of a digital pseudopin. Level shall be interpreted as in the DigitalRead command, i.e.:

  • 0: Low Level
  • 1: High Level

Pseudopin Numbers

All commands involving a pseudopin number expect an integer in the range 0-15, which is generally mapped to the correspondingly numbered physical pin on the target board, but there might be exceptions depending on the particular target.

  • Arduino Uno/Nano and other ATmega328-based Arduinos: Pseudopins are mapped to the correspondingly numbered pins
    • Pins 0 and 1 are used by the serial port and thus are not available
    • Pins 14 and 15 do not exist
      • Thus pseudopins 0/1/14/15 have no meaning on these boards
  • STM32F103xx-based boards, such as Blue Pill, Black Pill, etc: Pseudopins 0-15 are mapped to physical pins PA0-PA15, with the following exceptions:
    • PA11 and PA12 are used by the USB connection, thus pseudopins 11 and 12 are mapped to PB11 and PB12
      • Note that PB12 drives the onboard led on the Black Pill (with inverted logic)
    • PA13 and PA14 are only available through the SWD header on the Black Pill

libpseudogpio's People

Contributors

sukkopera avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.