24 #include "MFEEdgeGpio.hpp"
26 #include <ccut/async.hpp>
27 #include <edge/edge.h>
29 #include "Exception.hpp"
30 #include "MFEPlatform.hpp"
33 using namespace smc::internal;
37 MFEEdgeGpio::MFEEdgeGpio(
const std::string &uid,
38 const std::shared_ptr<MFEPlatform> &mfe) :
47 std::shared_ptr<MFEPlatform> mfe(m_mfe.lock());
49 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
51 const std::string
uid{this->
uid()};
52 return mfe->run<
void>([
uid,
59 throw Exception(ErrorCode::Runtime,
"invalid gpio uid: " +
uid);
60 else if (info.reg->reg_attr->rwmode == EDGE_MODE_RO ||
61 info.reg->reg_attr->rwmode == EDGE_MODE_RC)
62 throw Exception(ErrorCode::InvalidArguments,
63 "Register is read-only");
65 throw Exception(ErrorCode::Runtime,
"edge driver not available");
66 uint32_t value = uint32_t(state.
value);
72 ctx.edge->write(info.reg, value);
73 cmd.prom->get<
void>().set_value();
78 return ccut::make_future_error(ex);
86 std::shared_ptr<MFEPlatform> mfe(m_mfe.lock());
88 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
90 const std::string
uid{this->
uid()};
98 "invalid gpio uid: " +
uid);
101 "edge driver not available");
103 ctx.edge->read(info.reg, value);
105 value >>= info.shift;
115 return ccut::make_future_error<units::io_port_t>(ex);
DeviceId uid() const
Get the address of device.
Exception thrown by MotionController in case of issues with command.
std::future< units::io_port_t > getIoState() const override
Get current state of this GPIO.
main motion-lib namespace
bool getRegInfo(const std::string &uid, RegInfo &info) const
Get the RegInfo object.
value_type value
port value