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

95 lines
1.2 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
};
Pin();
~Pin();
void setMode(mode mode);
void setOutputState(state state);
void setPullUpDonw(pullUpDown resistance);
void setSpeed(speed speed);
void config(mode mode, state state, pullUpDown resistance, speed speed);
bool read();
bool toggle();
void write(bool state);
void init();
void deInit();
void hardwareInfo();
private:
void throwError(uint16_t line, errors errNo);
};
#endif // _GPIO_H_