BBBCSIO - A C# I/O Library for the Beaglebone Black
BBBCSIO is a free and open source .NET v4 library which provides a comprehensive C# input/output solution for the Beaglebone Black Mono environment.
Using BBBCSIO, you can easily read and write to the GPIO pins (and trigger interrupt events from state changes), launch and interact with PRU programs and
control SPI, I2C, PWM, UART and A2D devices. BBBCSIO is intended to be a comprehensive solution for I/O on the Beaglebone Black. At the current time only a few minor OCP devices remain to be implemented. Besides the downloadable
DLL library and
the BBBCSIO contains complete
. There is also a
section which provides more information on numerous topics such
as the Device Tree and the
Note: In order to use the BBBCSIO library, C# and Mono must be installed on the Beaglebone Black. A
documents that installation procedure.
Example BBBCSIO Code which Toggles a GPIO Pin at 1Hz
- Provides simple and transparent read/write access (including the
triggering of events)
to the GPIO pins of a Beaglebone Black. A maximum output frequency of about 1.8MHz is possible when using a memory mapped port class and about 1.2Khz when using the SYSFS class.
- The SPI ports are fully supported. It is possible to use GPIO ports to provide a large number of SPI device select lines.
- The I2C ports are fully supported.
- The Serial/UART ports are fully supported.
- The Pulse Width Modulation (PWM) devices are fully supported. The PWM duty
cycle can be specified in nano-seconds or as a percentage of the base frequency.
- The Analog to Digital Conversion (A2D) devices are fully supported. A sample rate of about 1000 samples/sec has been observed.
- Full PRU support is included. The BBBCSIO PRU_Driver
class can launch PRU binary code and interact with running PRU programs to
or receive interrupt events
etc. The PRU can read from or write to I/O lines at speeds of up to 50Mhz.
- Developed on armhf Debian Linux v3.08 freely available for the Beaglebone Black.
- Tested with the Mono JIT compiler v3.2.8 but is probably also compatible with other versions.
- The software is written in C# and a .NET project is included with the source code.
What BBBCSIO Does Not Do
- The armhf Debian Linux running on the Beaglebone Black is not a real-time operating system. This means, for example, although you might set a port
to output a 100Khz square wave the actual timing of some of the pulses may vary (and there may be gaps) as the process is pre-emptively swapped in and out by the kernel.
If you need extremely accurate timing you can use the BBBCSIO
PRU_Driver class to launch code which will run in the Programmable Realtime Units (PRUs) and this
will be absolutely deterministic in terms of timing (and probably a lot faster as well).
- The SPI, I2C, PWM, A2D, UART and PRU devices are supported as of version 01.05 but relatively little used OCP devices such as the quadrature encoders and McASP system have not yet been implemented in the BBBCSIO library, although they are planned to be added.
- The BBBCSIO Library cannot do much in the way of I/O unless the process it is running in has root privileges. This is enforced by the Linux O/S and means
that any code which incorporates the BBBCSIO Library must run as root.
- The BBBCSIO Library cannot adjust the PinMux
in order to enable specific OCP devices or GPIO pins. This cannot be done from user space and must be done by
setting the Device Tree or by somehow calling a kernel mode device driver to do it for you.
- The InterruptPort functionality is a pseudo interrupt. It operates by monitoring the designated GPIOs out of band in a separate, continuously computable,
thread. In concept, it is not dissimilar to the C
- The interrupt events sent by the PRU to a user space C# program are also not true interrupts. The PRU, of course, is completely realtime but by the time
the interrupt filters down the C# program (where it is received as an C# event) the kernel may have swapped that process in and out of memory an arbitrary number of times.
Help Files and Manual
The Help Pages discuss the usage of the BBBCSIO software and calling conventions for the classes it contains.
The BBBCSIO software zip files (below) also contain these help files.
The BBBCSIO help pages contain an Example Code section which illustrates the usage of the BBBCSIO library.
A web browsable version of the BBBCSIO Source Code is available.
If you download only the
BBBCSIO.dll (rather than the source) you can use it like any other .NET dll library. Either place the
BBBCSIO.dll in the same directory
as the exe file or copy the dll into the
/usr/lib directory where it will be available to all programs that need it. Of course, you will need to
reference it in the .NET solution just as you would any other library.
If you download the source code you can include the
BBBCSIO.proj into your .NET solution in the usual way and the software should compile.
Note: There is a separate project
on this website which describes how to set up a remote compilation and debugging toolchain for Mono on the Beaglebone Black.
The contents of the BBBCSIO web pages, the help pages, the downloadable executables and the source code are are provided "as is" without any warranty of any
kind and without any claim to being error free or complete.
Please be aware that the documentation, executables or source code provided may be out-of-date, incomplete, erroneous or simply unsuitable
for your purposes. Any use you make
of the BBBCSIO documentation, source code and executables is entirely at your
discretion and any consequences of that use are entirely your responsibility.
All source code and executable libraries are provided under the terms of the MIT License.