2012-07-16 13:13:35 +00:00
|
|
|
/*
|
|
|
|
* \brief Gpio session interface
|
|
|
|
* \author Ivan Loskutov <ivan.loskutov@ksyslabs.org>
|
2013-05-06 12:33:30 +00:00
|
|
|
* \author Stefan Kalkowski <stefan.kalkowski@genode-labs.com>
|
2012-07-16 13:13:35 +00:00
|
|
|
* \date 2012-06-23
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Ksys Labs LLC
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-07-16 13:13:35 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-07-16 13:13:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_
|
|
|
|
#define _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_
|
|
|
|
|
|
|
|
#include <base/signal.h>
|
|
|
|
#include <dataspace/capability.h>
|
|
|
|
#include <session/session.h>
|
2015-04-14 11:56:26 +00:00
|
|
|
#include <irq_session/capability.h>
|
2012-07-16 13:13:35 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Gpio { struct Session; }
|
|
|
|
|
|
|
|
|
|
|
|
struct Gpio::Session : Genode::Session
|
|
|
|
{
|
2017-05-24 12:41:19 +00:00
|
|
|
/**
|
|
|
|
* \noapi
|
|
|
|
*/
|
2015-03-04 20:12:14 +00:00
|
|
|
static const char *service_name() { return "Gpio"; }
|
|
|
|
|
2017-05-07 20:03:25 +00:00
|
|
|
enum { CAP_QUOTA = 2 };
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
enum Direction { IN, OUT };
|
|
|
|
|
|
|
|
enum Irq_type { LOW_LEVEL, HIGH_LEVEL, FALLING_EDGE, RISING_EDGE };
|
|
|
|
|
|
|
|
virtual ~Session() { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure direction of the GPIO pin
|
|
|
|
*
|
|
|
|
* \param d direction of the pin
|
|
|
|
*/
|
|
|
|
virtual void direction(Direction d) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write the logic level of the GPIO pin
|
|
|
|
*
|
|
|
|
* \param enable logic level on the pin
|
|
|
|
*/
|
|
|
|
virtual void write(bool enable) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read the logic level on a specified GPIO pin
|
|
|
|
*
|
|
|
|
* \return level on specified GPIO pin
|
|
|
|
*/
|
|
|
|
virtual bool read() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the debouncing time
|
|
|
|
*
|
|
|
|
* \param us debouncing time in microseconds, zero means no debouncing
|
|
|
|
*/
|
|
|
|
virtual void debouncing(unsigned int us) = 0;
|
|
|
|
|
|
|
|
/**
|
2015-04-14 11:56:26 +00:00
|
|
|
* Rquest IRQ session
|
2015-03-04 20:12:14 +00:00
|
|
|
*
|
2015-04-14 11:56:26 +00:00
|
|
|
* \param type type of IRQ
|
2015-03-04 20:12:14 +00:00
|
|
|
*/
|
2015-04-14 11:56:26 +00:00
|
|
|
virtual Genode::Irq_session_capability irq_session(Irq_type type) = 0;
|
2015-03-04 20:12:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
** RPC interface **
|
|
|
|
*******************/
|
|
|
|
|
2015-04-14 11:56:26 +00:00
|
|
|
GENODE_RPC(Rpc_direction, void, direction, Direction);
|
|
|
|
GENODE_RPC(Rpc_write, void, write, bool);
|
|
|
|
GENODE_RPC(Rpc_read, bool, read);
|
|
|
|
GENODE_RPC(Rpc_debouncing, void, debouncing, unsigned int);
|
|
|
|
GENODE_RPC(Rpc_irq_session, Genode::Irq_session_capability,
|
|
|
|
irq_session, Irq_type);
|
2015-03-04 20:12:14 +00:00
|
|
|
|
|
|
|
GENODE_RPC_INTERFACE(Rpc_direction, Rpc_write, Rpc_read,
|
2015-04-14 11:56:26 +00:00
|
|
|
Rpc_debouncing, Rpc_irq_session);
|
2015-03-04 20:12:14 +00:00
|
|
|
};
|
2012-07-16 13:13:35 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__GPIO_SESSION__GPIO_SESSION_H_ */
|