View Source grisp (grisp v2.8.0)

GRiSP Runtime API.

This module contains the main API for working with the GRiSP runtime.

Summary

Types

An object representing the running device.

Designates a hardware slot on the GRiSP board. This should be the lower case version of the slot names printed on the board itself.

Functions

Add and start the device instance for a connected device.

Return the device instance at the specified slot (if any).

List all running devices instances.

Remove and stop the device instance for a device.

Types

device()

-opaque device()

An object representing the running device.

slot()

-type slot() :: atom().

Designates a hardware slot on the GRiSP board. This should be the lower case version of the slot names printed on the board itself.

E.g. spi1 for SPI1 or gpio2 for GPIO2.

Functions

add_device(Slot, Driver)

-spec add_device(slot(), module()) -> device().

Equivalent to add_device/3.

add_device(Slot, Driver, Opts)

-spec add_device(slot(), module(), map()) -> device().

Add and start the device instance for a connected device.

This starts a device driver instance of the specified module and connected to the specified slot. No hardware validation is possible to check that the correct device is actually connected, but many drivers run an initialization check for specific device IDs and other similar characteristics which will fail if no device or the wrong device is connected.

The set of options is passed to the driver and is specific to each driver.

Returns the created device instance.

device(Slot)

-spec device(slot()) -> device().

Return the device instance at the specified slot (if any).

Errors

  • {no_device_connected, Slot}.

devices()

-spec devices() -> [device()].

List all running devices instances.

Returns a list of all running device instances as device objects.

remove_device(Device)

-spec remove_device(device()) -> ok.

Remove and stop the device instance for a device.

This will gracefully stop the device instance and remove it from the runtime. This includes running any termination code inside the device driver module (see the specific driver module for your device for more information).