mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-27 17:18:53 +00:00
49b4b8597d
This patch equips the pin-driver framework with support for the time-multiplexed operation of a pin as output or input. This is needed when implementing I2C communication via a bit-banging driver. To operate pin in both directions, a driver obtains both a pin-state and a pin-control session for the same pin. The pin-state session can be used to sense the current pin state. The control session allows the client to set the pin to high or low (using the 'state' method), or to set it to high-impedance via the 'yield' method. Once switched to high-impedance, the pin can be used as input. Issue genodelabs/genode-allwinner#10
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/*
|
|
* \brief Connection to pin-control service
|
|
* \author Norman Feske
|
|
* \date 2021-04-20
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2021 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__PIN_CONTROL_SESSION__CONNECTION_H_
|
|
#define _INCLUDE__PIN_CONTROL_SESSION__CONNECTION_H_
|
|
|
|
#include <pin_control_session/pin_control_session.h>
|
|
#include <base/rpc_client.h>
|
|
#include <base/connection.h>
|
|
|
|
namespace Pin_control { struct Connection; }
|
|
|
|
struct Pin_control::Connection : private Genode::Connection<Session>,
|
|
private Rpc_client<Session>
|
|
{
|
|
enum { RAM_QUOTA = 8*1024UL };
|
|
|
|
Connection(Env &env, char const *label = "")
|
|
:
|
|
Genode::Connection<Session>(env,
|
|
session(env.parent(),
|
|
"ram_quota=%u, cap_quota=%u, label=\"%s\"",
|
|
RAM_QUOTA, CAP_QUOTA, label)),
|
|
Rpc_client<Session>(cap())
|
|
{ }
|
|
|
|
void state(bool enabled) override { call<Rpc_state>(enabled); }
|
|
|
|
void yield() override { call<Rpc_yield>(); }
|
|
};
|
|
|
|
#endif /* _INCLUDE__PIN_CONTROL_SESSION__CONNECTION_H_ */
|