mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 14:37:50 +00:00
c79687f5f4
- make GPIO server more robust on imx by not throwing exceptions for unknown pins, use '_with_gpio' instead - use 'Gpio::Pin' data type instead of POD 'unsigned' issue #3900
136 lines
2.8 KiB
C++
136 lines
2.8 KiB
C++
/*
|
|
* \brief GPIO driver interface
|
|
* \author Stefan Kalkowski
|
|
* \date 2013-05-03
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2011-2017 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
*/
|
|
|
|
#ifndef _INCLUDE__GPIO__DRIVER_H_
|
|
#define _INCLUDE__GPIO__DRIVER_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/log.h>
|
|
#include <base/signal.h>
|
|
|
|
namespace Gpio {
|
|
struct Driver;
|
|
struct Pin;
|
|
}
|
|
|
|
struct Gpio::Pin
|
|
{
|
|
unsigned value;
|
|
|
|
void print(Genode::Output &out) const { Genode::print(out, value); }
|
|
};
|
|
|
|
struct Gpio::Driver : Genode::Interface
|
|
{
|
|
/**
|
|
* Set direction of GPIO pin, whether it's an input or output one
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void direction(Pin gpio, bool input) = 0;
|
|
|
|
/**
|
|
* Set output level (high or low)
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void write(Pin gpio, bool enable) = 0;
|
|
|
|
/**
|
|
* Read input level (high or low)
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual bool read(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Enable/disable debounce logic for the GPIO pin
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void debounce_enable(Pin gpio, bool enable) = 0;
|
|
|
|
/**
|
|
* Set delay for debounce logic for the GPIO pin
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void debounce_time(Pin gpio, unsigned long us) = 0;
|
|
|
|
/**
|
|
* Set IRQ trigger state to falling edge-triggered
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void falling_detect(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Set IRQ trigger state to rising edge-triggered
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void rising_detect(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Set IRQ trigger state to high level-triggered
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void high_detect(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Set IRQ trigger state to low level-triggered
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void low_detect(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Enable/disable IRQ for specified GPIO pin
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void irq_enable(Pin gpio, bool enable) = 0;
|
|
|
|
/**
|
|
* Acknowledge IRQ for specified GPIO pin
|
|
*
|
|
* \param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void ack_irq(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Register signal handler for interrupts
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void register_signal(Pin gpio,
|
|
Genode::Signal_context_capability cap) = 0;
|
|
|
|
/**
|
|
* Unregister signal handler
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual void unregister_signal(Pin gpio) = 0;
|
|
|
|
/**
|
|
* Check whether GPIO number is valid
|
|
*
|
|
*\param gpio corresponding gpio pin number
|
|
*/
|
|
virtual bool gpio_valid(Pin gpio) = 0;
|
|
};
|
|
|
|
#endif /* _INCLUDE__GPIO__DRIVER_H_ */
|