You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KED/bsl/csl/interfaces/pin.hpp

93 lines
1.3 KiB

#ifndef _GPIO_H_
#define _GPIO_H_
#include <unistd.h>
#include <stdint.h>
#include <memory>
class Pin
{
public:
enum mode
{
undefined,
input,
output,
analog,
alternate
};
enum state
{
floating,
pushPull,
openDrain
};
enum pullUpDown
{
none,
pullUp,
pullDown
};
enum speed
{
slow,
normal,
fast,
veryFast
};
enum interrupt
{
disabled,
enabled
};
struct configuration
{
mode md;
state st;
pullUpDown pud;
speed sp;
interrupt intr;
};
enum errors
{
notValidMode,
notValidOut,
OutOfRange,
NotDeclared,
NotReachable,
NoPullUpDown,
NotAnalog,
NotDigital,
TooFast,
Bocked,
AlreadyUsed,
NotGpio
};
virtual void setMode(mode mode) = 0;
virtual void setOutputState(state state) = 0;
virtual void setPullUpDonw(pullUpDown resistance) = 0;
virtual void setSpeed(speed speed) = 0;
virtual void config(mode mode, state state, pullUpDown resistance, speed speed) = 0;
virtual bool read() = 0;
virtual bool toggle() = 0;
virtual void write(bool state) = 0;
virtual void init() = 0;
virtual void deInit() = 0;
virtual void hardwareInfo() = 0;
private:
virtual void throwError(uint16_t line, errors errNo) = 0;
};
#endif // _GPIO_H_