RPICSIO
A C# I/O Library for the Raspberry Pi
Overview
About RPICSIO
RPICSIO is a free and open source .NET v4 library which provides a comprehensive C# input/output solution for the Raspberry Pi 2 Mono environment.
Using RPICSIO, you can easily read and write to the GPIO pins (and trigger interrupt events from state changes) and
control SPI, I2C, PWM and UART devices. RPICSIO is intended to be a comprehensive solution for I/O on the Raspberry Pi 2. At the current time support for the Raspberry Pi 3 and Raspberry Pi 0 remains to be implemented. Besides the downloadable
DLL library and
source code
the RPICSIO contains complete
Help Files
and
Examples
.
Note: In order to use the RPICSIO library, C# and Mono must be installed on the Raspberry Pi. A
separate project
documents that installation procedure.
License, Cost and Disclaimer
The RPICSIO software is free and open source and is released under the MIT License. Be sure to read the
license text before you use the software. Your use of the RPICSIO software is entirely at your own risk.
What RPICSIO Does
- Provides simple and transparent read/write access (including the
triggering of events)
to the GPIO pins of a Raspberry Pi. A maximum output frequency of about 2.4MHz (yes, mega Hz) is possible when using a memory mapped port class and about 1 Khz when using the SYSFS class.
- The SPI port is fully supported. It is possible to use GPIO pins to provide a large number of SPI device select lines.
- The I2C port is fully supported.
- The Serial/UART port is fully supported.
- The Pulse Width Modulation (PWM) device is fully supported. The PWM duty
cycle can be specified in nano-seconds or as a percentage of the base frequency.
- Developed on Raspbian Linux v4.4.32 freely available for the Raspberry Pi.
- 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 RPICSIO Does Not Do
- The Raspbian Debian Linux running on the Raspberry Pi 2 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.
- The SPI, I2C, PWM, and UART devices are all supported as of version 01.00.
- The RPICSIO 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 RPICSIO Library must run as root.
- The RPICSIO Library does not adjust the PinMux in order to enable devices which may be available on the chip but which are not available by default.
Having said that, it will set the GPIO pins to an input or output state (as appropriate) and can also enable or disable the pull-up/pull-down resistors.
- 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
Poll()
call.
Download
The latest version of the RPICSIO software can be found on this page. The source
code is also available in browseable form.
Installation and System Requirements
If you download only the RPICSIO.dll
(rather than the source) you can use it like any other .NET dll library. Either place the RPICSIO.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 RPICSIO.proj
into your .NET solution in the usual way and the software should compile.
As for system requirements, the RPICSIO was tested on a Raspberry Pi 2 model B rev 1.1 board with the standard Raspbian Debian Linux v4.4.32 operating system installed. You will also
need Mono and the MCS compiler - testing occurred on Mono 3.2.8.