This is a simple sample you could use for a quick test of interrupt service routine.
Demonstrate how to react on an external event with an ISR (Interrupt Service Routine), which will run independently of the main program flow using the MRAA library.
Use a platform with GPIO Interrupt capabilities. Any button or sensor that can generate a voltage transition from ground to Vcc or vice versa can be used with this example code. Suitable ones in the Grove* Starter Kit are the Button and Touch Sensor, connected to digital a pin.
This sample has been tested on
- Up Squared* board
- IEI* TANK AIoT Dev Kit
The sample might need minor modifications depending on the board and shield you are using. Note: This sample does not work for the GPIO pins on the GrovePi+* shield.
This version of the sample has been tested on Ubuntu Linux. It requires the mraa library.
This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be found here.
Create a new project on Intel(R) System Studio using this sample. Connect the input device to a GPIO pin on your IoT board (pin 13 is used by default on most boards).
Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs not commonly granted to normal users by default. To avoid permission issues:
-
You can run your application as root. If you've already connected to your target, click the disconnect button to kill the target tcf-agent on the device, or manually kill the process named 'agent' on the device. You can reboot the board or reconnect with elevated privileges as root. More information is available here.
-
Connect to the target using passwordless (recommended) or with password-based SSH.
Passwordless Public Key-based Method (recommended): First, generate the public keys. For instructions, see Set up a new connection for your target. Second, use the generated keys to connect to the target. For instructions, see Login using public key.
Password-based Method: Log in as the root user to connect to the target. For instructions, see Authentication using password. Because of security concerns, this method is not recommended.
IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments.