#pragma once
#include <cstdint>
typedef uint8_t byte;
// Eine Klasse die "/dev/gpiomem" wie ein Array aus DWORDs-äh-uint32_t abbildet:
static struct Gpiomem{
int handle;
volatile uint32_t*base;
Gpiomem();
~Gpiomem();
// Array-Lesezugriff mit Wiederholung
uint32_t operator()(unsigned o) const{
uint32_t b,a = base[o];
while ((b=base[o])!=a) a=b; // so oft lesen wiederholen bis gleich
return b;
}
// Für Array-Schreibzugriff (oder auch einfacher Lesezugriff)
volatile uint32_t& operator[](unsigned o) {return base[o];}
}gpiomem;
namespace gpio{
void clr(byte); // Bit am Port löschen
void set(byte); // Bit am Port setzen
byte fsel(byte,byte); // Modus am Port festlegen
bool get(byte); // Portzustand (Hi oder Lo) einlesen, unabhängig vom Modus
uint32_t cycle(); // Zykluszähler lesen (wenn per Kernelmodul freigegeben)
bool i2c_xfer(unsigned addr,const void*s,int sl,void*r,int rl);
enum{
SDA_PIN = 2,
SCL_PIN = 3,
};
}
Detected encoding: UTF-8 | 0
|