Development

Mote Runner:

General / Interruptions

This is the development section of the Waspmote Mote Runner platform. You can navigate through the examples with the left bar.

If you actually want to see examples about the original Waspmote platform, please go its specific development section.

» MR-General 04: Interruptions

In this example is shown the way to configure and use the interruptions in Mote Runner.

Required Materials

1 x Waspmote PRO
1 x MiniUSB wire
1 x Battery

Notes

* Please, note that the output is in Hexadecimal
* Remember to connect the battery to Waspmote for proper operation.
* To compile this example: mrc --assembly=ints-1.0 --system=waspmote --ref=logger-#.# InterruptionsExample.java

Code

/**
 *  Copyright (C) 2013 Libelium Comunicaciones Distribuidas S.L.
 * http://www.libelium.com
 *
 * This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 3.0 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-3.0.html
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Design: David Gascón
 * 
 * @version 0.1
 * @author Anartz Nuin Jiménez, Diego López Pérez and Ignacio Ruiz Martín
 */
package com.libelium.examples.general;

import com.ibm.saguaro.logger.Logger;
import com.ibm.saguaro.system.DevCallback;
import com.ibm.saguaro.system.GPIO;
import com.ibm.saguaro.system.Mote;
import com.ibm.saguaro.system.csr;
import com.ibm.waspmote.WASPMOTE;

public class InterruptionsExample {

	static GPIO gpio = new GPIO();
	
	static{
		gpio.open();
		gpio.configureInput(WASPMOTE.PIN_MUX_RX, GPIO.IRQ_FALLING,(byte)0);
		
		gpio.setEventHandler(new DevCallback(null) {
			
			@Override
			public int invoke(int flags, byte[] data, int len, int info, long time) {
				return InterruptionsExample.onInterrupt(flags, data, len, info, time);
			}
		});
	}
	
	private static int onInterrupt(int flags, byte[] data, int len, int info, long time){
		Logger.appendString(csr.s2b("Interruption captured"));
		Logger.flush(Mote.INFO);
		
		//Reconfigure pin
		gpio.configureInput(WASPMOTE.PIN_MUX_RX, GPIO.IRQ_FALLING,(byte)0);
		
		return 0;
	}
}

Output

category: log
evname: MAPP
id: 7d
time: 11:21:10.830'000
severity: 5
module: MAPP
logmsg: MAPP: Interruption captured

Quick Publish: