Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Latest commit

 

History

History

board

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Board API

The Board API provides low level interfaces for I/O operations:

This API uses board pin names as defined in the corresponding board documentation. The names, values and semantics related to hardware pins are owned and encapsulated by the implementation. This API uses opaque values (strings and numbers) for Pin names.

The supported board documentations are listed in this directory:

The full Web IDL definition for Board and IO APIs can be found here.

The Board API object

The API entry point is a Board object that is exposed in a platform-specific manner. As an example, on Node.js it can be obtained by requiring the package that implements this API.

In the following example, the application requires an implementation that exposed Arduino 101 values and semantics for pins.

var board = require("board");

console.log("Connected to board: " + board.name);

On other platforms, e.g. in browsers, the API entry point can be exposed on another object, or constructed.

var board = new Board();  // provides an instance of the default board

If the functionality is not supported by the platform, require should throw NotSupportedError. If there is no permission for using the functionality, require should throw SecurityError.

The Pin interface

Represents a hardware pin on the board.

Property Type Optional Default value Represents
pin String or Number no undefined board name for the pin

The read-only pin property is the board-specific name or numeric value of a pin, as defined in the board documentation.

In future versions of the API the Pin object may be extended.

The Board interface

Represents a hardware board.

Property Type Optional Default value Represents
name String no undefined board name
version String no versions.board in package.json API version
Method signature Description
aio() request an AIO object
gpio() request a GPIO object
pwm() request a PWM object
i2c() request an I2C object
spi() request an SPI object
uart() request an UART object
Event name Event callback argument
error Error object

The name property is read-only, and provides the board name.

The version property is read-only, and provides the provides the Board API version, as specified in the versions.board property of package.json.

Board errors are represented as augmented Error objects. The following Error names are used for signaling issues:

  • BoardDisconnectError
  • BoardTimeoutError
  • BoardIOError.

Board methods

The aio(options) method

Configures an AIO pin. The method runs the following steps:

  • Return a Promise object promise and continue in parallel.
  • If the AIO functionality is not supported, reject promise with "NotSupportedError".
  • Run the internal AIO initialization algorithm with options as argument and let aio be the returned result.
  • If it throws an error, reject promise with that error.
  • Resolve promise with the aio object.

The gpio(options) method

Configures a GPIO pin or GPIO port. The method runs the following steps:

  • Return a Promise object promise and continue in parallel.
  • If the GPIO functionality is not supported, reject promise with "NotSupportedError".
  • Run the internal GPIO initialization algorithm with options as argument and let gpio be the returned result.
  • If it throws an error, reject promise with that error.
  • Resolve promise with the gpio object.

The pwm(options) method

Configures a PWM pin. The method runs the following steps:

  • Return a Promise object promise and continue in parallel.
  • If the PWM functionality is not supported, reject promise with "NotSupportedError".
  • Run the internal PWM initialization algorithm with options as argument and let pwm be the returned result.
  • If it throws an error, reject promise with that error.
  • Resolve promise with the pwm object.

The i2c(options) method

Configures I2C communication. The method runs the following steps:

  • Return a Promise object promise and continue in parallel.
  • If the I2C functionality is not supported, reject promise with "NotSupportedError".
  • Run the internal I2C initialization algorithm with options as argument and let i2c be the returned result.
  • If it throws an error, reject promise with that error.
  • Resolve promise with the i2c object.

The spi(options) method

Configures SPI communication. The method runs the following steps:

  • Return a Promise object promise and continue in parallel.
  • If the SPI functionality is not supported, reject promise with "NotSupportedError".
  • Run the SPI init steps with options as argument and let spi be the returned result.
  • If it throws an error, reject promise with that error.
  • Resolve promise with the spi object.

The uart(options) method

Configures UART communication. It takes a dictionary object as argument. The method runs the following steps:

  • Return a Promise object promise and continue in parallel.
  • If the UART functionality is not supported, reject promise with "NotSupportedError".
  • Run the UART init steps with options as argument and let uart be the returned result.
  • If it throws an error, reject promise with that error.
  • Resolve promise with the uart object.