Remove GPIO methods from platform classes

This commit is contained in:
nanosonde 2019-10-28 12:08:01 +01:00
parent 1bf8874c05
commit 6e654d4bf5
7 changed files with 96 additions and 154 deletions

View File

@ -157,26 +157,6 @@ int ArduinoPlatform::readWriteSpi(uint8_t *data, size_t len)
return 0; return 0;
} }
void ArduinoPlatform::setupGpio(uint32_t dwPin, uint32_t dwMode)
{
pinMode(dwPin, dwMode);
}
void ArduinoPlatform::closeGpio(uint32_t dwPin)
{
// not used
}
void ArduinoPlatform::writeGpio(uint32_t dwPin, uint32_t dwVal)
{
digitalWrite(dwPin, dwVal);
}
uint32_t ArduinoPlatform::readGpio(uint32_t dwPin)
{
return digitalRead(dwPin);
}
void print(const char* s) void print(const char* s)
{ {
ArduinoPlatform::SerialDebug->print(s); ArduinoPlatform::SerialDebug->print(s);

View File

@ -40,11 +40,6 @@ class ArduinoPlatform : public Platform
void closeSpi() override; void closeSpi() override;
int readWriteSpi (uint8_t *data, size_t len) override; int readWriteSpi (uint8_t *data, size_t len) override;
virtual void setupGpio(uint32_t dwPin, uint32_t dwMode) override;
virtual void closeGpio(uint32_t dwPin) override;
virtual void writeGpio(uint32_t dwPin, uint32_t dwVal) override;
virtual uint32_t readGpio(uint32_t dwPin) override;
static Stream* SerialDebug; static Stream* SerialDebug;
protected: protected:

View File

@ -26,9 +26,11 @@
#define RISING 4 #define RISING 4
void delay(uint32_t millis); void delay(uint32_t millis);
void delayMicroseconds (unsigned int howLong);
uint32_t millis(); uint32_t millis();
void pinMode(uint32_t dwPin, uint32_t dwMode); void pinMode(uint32_t dwPin, uint32_t dwMode);
void digitalWrite(uint32_t dwPin, uint32_t dwVal); void digitalWrite(uint32_t dwPin, uint32_t dwVal);
uint32_t digitalRead(uint32_t dwPin);
typedef void (*voidFuncPtr)(void); typedef void (*voidFuncPtr)(void);
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode); void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);

View File

@ -33,11 +33,6 @@ class Platform
virtual void closeSpi() = 0; virtual void closeSpi() = 0;
virtual int readWriteSpi (uint8_t *data, size_t len) = 0; virtual int readWriteSpi (uint8_t *data, size_t len) = 0;
virtual void setupGpio(uint32_t dwPin, uint32_t dwMode) = 0;
virtual void closeGpio(uint32_t dwPin) = 0;
virtual void writeGpio(uint32_t dwPin, uint32_t dwVal) = 0;
virtual uint32_t readGpio(uint32_t dwPin) = 0;
virtual uint8_t* getEepromBuffer(uint16_t size) = 0; virtual uint8_t* getEepromBuffer(uint16_t size) = 0;
virtual void commitToEeprom() = 0; virtual void commitToEeprom() = 0;

View File

@ -250,9 +250,9 @@ void RfPhysicalLayer::spiWriteRegister(uint8_t spi_instr, uint8_t value)
tbuf[0] = spi_instr | WRITE_SINGLE_BYTE; tbuf[0] = spi_instr | WRITE_SINGLE_BYTE;
tbuf[1] = value; tbuf[1] = value;
uint8_t len = 2; uint8_t len = 2;
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
_platform.readWriteSpi(tbuf, len); _platform.readWriteSpi(tbuf, len);
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
} }
uint8_t RfPhysicalLayer::spiReadRegister(uint8_t spi_instr) uint8_t RfPhysicalLayer::spiReadRegister(uint8_t spi_instr)
@ -261,9 +261,9 @@ uint8_t RfPhysicalLayer::spiReadRegister(uint8_t spi_instr)
uint8_t rbuf[2] = {0}; uint8_t rbuf[2] = {0};
rbuf[0] = spi_instr | READ_SINGLE_BYTE; rbuf[0] = spi_instr | READ_SINGLE_BYTE;
uint8_t len = 2; uint8_t len = 2;
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
_platform.readWriteSpi(rbuf, len); _platform.readWriteSpi(rbuf, len);
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
value = rbuf[1]; value = rbuf[1];
//printf("SPI_arr_0: 0x%02X\n", rbuf[0]); //printf("SPI_arr_0: 0x%02X\n", rbuf[0]);
//printf("SPI_arr_1: 0x%02X\n", rbuf[1]); //printf("SPI_arr_1: 0x%02X\n", rbuf[1]);
@ -275,9 +275,9 @@ uint8_t RfPhysicalLayer::spiWriteStrobe(uint8_t spi_instr)
uint8_t tbuf[1] = {0}; uint8_t tbuf[1] = {0};
tbuf[0] = spi_instr; tbuf[0] = spi_instr;
//printf("SPI_data: 0x%02X\n", tbuf[0]); //printf("SPI_data: 0x%02X\n", tbuf[0]);
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
_platform.readWriteSpi(tbuf, 1); _platform.readWriteSpi(tbuf, 1);
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
return tbuf[0]; return tbuf[0];
} }
@ -285,9 +285,9 @@ void RfPhysicalLayer::spiReadBurst(uint8_t spi_instr, uint8_t *pArr, uint8_t len
{ {
uint8_t rbuf[len + 1]; uint8_t rbuf[len + 1];
rbuf[0] = spi_instr | READ_BURST; rbuf[0] = spi_instr | READ_BURST;
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
_platform.readWriteSpi(rbuf, len + 1); _platform.readWriteSpi(rbuf, len + 1);
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
for (uint8_t i=0; i<len ;i++ ) for (uint8_t i=0; i<len ;i++ )
{ {
pArr[i] = rbuf[i+1]; pArr[i] = rbuf[i+1];
@ -304,9 +304,9 @@ void RfPhysicalLayer::spiWriteBurst(uint8_t spi_instr, const uint8_t *pArr, uint
tbuf[i+1] = pArr[i]; tbuf[i+1] = pArr[i];
//printf("SPI_arr_write: 0x%02X\n", tbuf[i+1]); //printf("SPI_arr_write: 0x%02X\n", tbuf[i+1]);
} }
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
_platform.readWriteSpi(tbuf, len + 1); _platform.readWriteSpi(tbuf, len + 1);
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
} }
void RfPhysicalLayer::powerDownCC1101() void RfPhysicalLayer::powerDownCC1101()
@ -338,25 +338,25 @@ bool RfPhysicalLayer::InitChip()
{ {
// Setup SPI and GPIOs // Setup SPI and GPIOs
_platform.setupSpi(); _platform.setupSpi();
_platform.setupGpio(GPIO_GDO2_PIN, INPUT); pinMode(GPIO_GDO2_PIN, INPUT);
_platform.setupGpio(GPIO_GDO0_PIN, INPUT); pinMode(GPIO_GDO0_PIN, INPUT);
_platform.setupGpio(SPI_SS_PIN, OUTPUT); pinMode(SPI_SS_PIN, OUTPUT);
// Toggle chip select signal as described in CC11xx manual // Toggle chip select signal as described in CC11xx manual
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
delayMicroseconds(30); delayMicroseconds(30);
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
delayMicroseconds(30); delayMicroseconds(30);
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
delayMicroseconds(45); delayMicroseconds(45);
// Send SRES command // Send SRES command
_platform.writeGpio(SPI_SS_PIN, LOW); digitalWrite(SPI_SS_PIN, LOW);
delay(10); // Normally we would have to poll MISO here: while(_platform.readGpio(SPI_MISO_PIN)); delay(10); // Normally we would have to poll MISO here: while(_platform.readGpio(SPI_MISO_PIN));
spiWriteStrobe(SRES); spiWriteStrobe(SRES);
// Wait for chip to finish internal reset // Wait for chip to finish internal reset
delay(10); // Normally we would have to poll MISO here: while(_platform.readGpio(SPI_MISO_PIN)); delay(10); // Normally we would have to poll MISO here: while(_platform.readGpio(SPI_MISO_PIN));
_platform.writeGpio(SPI_SS_PIN, HIGH); digitalWrite(SPI_SS_PIN, HIGH);
// Flush the FIFOs // Flush the FIFOs
spiWriteStrobe(SFTX); spiWriteStrobe(SFTX);
@ -404,10 +404,6 @@ void RfPhysicalLayer::stopChip()
{ {
powerDownCC1101(); powerDownCC1101();
_platform.closeGpio(GPIO_GDO0_PIN);
_platform.closeGpio(GPIO_GDO2_PIN);
_platform.closeGpio(SPI_SS_PIN);
_platform.closeSpi(); _platform.closeSpi();
} }
@ -537,7 +533,7 @@ void RfPhysicalLayer::loop()
} }
// Detect falling edge 1->0 on GDO2 // Detect falling edge 1->0 on GDO2
statusGDO2 = _platform.readGpio(GPIO_GDO2_PIN); statusGDO2 = digitalRead(GPIO_GDO2_PIN);
if(prevStatusGDO2 != statusGDO2) if(prevStatusGDO2 != statusGDO2)
{ {
prevStatusGDO2 = statusGDO2; prevStatusGDO2 = statusGDO2;
@ -562,7 +558,7 @@ void RfPhysicalLayer::loop()
} }
// Detect falling edge 1->0 on GDO0 // Detect falling edge 1->0 on GDO0
statusGDO0 = _platform.readGpio(GPIO_GDO0_PIN); statusGDO0 = digitalRead(GPIO_GDO0_PIN);
if(prevStatusGDO0 != statusGDO0) if(prevStatusGDO0 != statusGDO0)
{ {
prevStatusGDO0 = statusGDO0; prevStatusGDO0 = statusGDO0;
@ -655,7 +651,7 @@ void RfPhysicalLayer::loop()
} }
// Detect rising edge 0->1 on GDO2 // Detect rising edge 0->1 on GDO2
statusGDO2 = _platform.readGpio(GPIO_GDO2_PIN); statusGDO2 = digitalRead(GPIO_GDO2_PIN);
if(prevStatusGDO2 != statusGDO2) if(prevStatusGDO2 != statusGDO2)
{ {
prevStatusGDO2 = statusGDO2; prevStatusGDO2 = statusGDO2;
@ -731,7 +727,7 @@ void RfPhysicalLayer::loop()
} }
// Detect falling edge 1->0 on GDO0 // Detect falling edge 1->0 on GDO0
statusGDO0 = _platform.readGpio(GPIO_GDO0_PIN); statusGDO0 = digitalRead(GPIO_GDO0_PIN);
if(prevStatusGDO0 != statusGDO0) if(prevStatusGDO0 != statusGDO0)
{ {
prevStatusGDO0 = statusGDO0; prevStatusGDO0 = statusGDO0;

View File

@ -572,10 +572,18 @@ void println(void)
void pinMode(uint32_t dwPin, uint32_t dwMode) void pinMode(uint32_t dwPin, uint32_t dwMode)
{ {
gpio_export(dwPin);
gpio_direction(dwPin, dwMode);
} }
void digitalWrite(uint32_t dwPin, uint32_t dwVal) void digitalWrite(uint32_t dwPin, uint32_t dwVal)
{ {
gpio_write(dwPin, dwVal);
}
uint32_t digitalRead(uint32_t dwPin)
{
return gpio_read(dwPin);
} }
typedef void (*voidFuncPtr)(void); typedef void (*voidFuncPtr)(void);
@ -593,47 +601,24 @@ void LinuxPlatform::cmdLineArgs(int argc, char** argv)
_args[argc] = 0; _args[argc] = 0;
} }
void LinuxPlatform::setupGpio(uint32_t dwPin, uint32_t dwMode) /* Buffer size for string operations (e.g. snprintf())*/
{
gpio_export(dwPin);
gpio_direction(dwPin, dwMode);
}
void LinuxPlatform::closeGpio(uint32_t dwPin)
{
gpio_unexport(dwPin);
// Set direction to input always if we do not need the GPIO anymore? Unsure...
//gpio_direction(dwPin, INPUT);
}
void LinuxPlatform::writeGpio(uint32_t dwPin, uint32_t dwVal)
{
gpio_write(dwPin, dwVal);
}
uint32_t LinuxPlatform::readGpio(uint32_t dwPin)
{
return gpio_read(dwPin);
}
/* Datenpuffer fuer die GPIO-Funktionen */
#define MAXBUFFER 100 #define MAXBUFFER 100
/* GPIO-Pin aktivieren /* Activate GPIO-Pin
* Schreiben der Pinnummer nach /sys/class/gpio/export * Write GPIO pin number to /sys/class/gpio/export
* Ergebnis: 0 = O.K., -1 = Fehler * Result: 0 = success, -1 = error
*/ */
int gpio_export(int pin) int gpio_export(int pin)
{ {
char buffer[MAXBUFFER]; /* Output Buffer */ char buffer[MAXBUFFER]; /* Output Buffer */
ssize_t bytes; /* Datensatzlaenge */ ssize_t bytes; /* Used Buffer length */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
int res; /* Ergebnis von write */ int res; /* Result from write() */
fd = open("/sys/class/gpio/export", O_WRONLY); fd = open("/sys/class/gpio/export", O_WRONLY);
if (fd < 0) if (fd < 0)
{ {
perror("Kann nicht auf export schreiben!\n"); perror("Could not export GPIO pin(open)!\n");
return(-1); return(-1);
} }
@ -642,7 +627,7 @@ int gpio_export(int pin)
if (res < 0) if (res < 0)
{ {
perror("Kann Pin nicht aktivieren (write)!\n"); perror("Could not export GPIO pin(write)!\n");
return(-1); return(-1);
} }
@ -652,21 +637,21 @@ int gpio_export(int pin)
return(0); return(0);
} }
/* GPIO-Pin deaktivieren /* Deactivate GPIO pin
* Schreiben der Pinnummer nach /sys/class/gpio/unexport * Write GPIO pin number to /sys/class/gpio/unexport
* Ergebnis: 0 = O.K., -1 = Fehler * Result: 0 = success, -1 = error
*/ */
int gpio_unexport(int pin) int gpio_unexport(int pin)
{ {
char buffer[MAXBUFFER]; /* Output Buffer */ char buffer[MAXBUFFER]; /* Output Buffer */
ssize_t bytes; /* Datensatzlaenge */ ssize_t bytes; /* Used Buffer length */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
int res; /* Ergebnis von write */ int res; /* Result from write() */
fd = open("/sys/class/gpio/unexport", O_WRONLY); fd = open("/sys/class/gpio/unexport", O_WRONLY);
if (fd < 0) if (fd < 0)
{ {
perror("Kann nicht auf unexport schreiben!\n"); perror("Could not unexport GPIO pin(open)!\n");
return(-1); return(-1);
} }
@ -675,7 +660,7 @@ int gpio_unexport(int pin)
if (res < 0) if (res < 0)
{ {
perror("Kann Pin nicht deaktivieren (write)!\n"); perror("Could not unexport GPIO pin(write)!\n");
return(-1); return(-1);
} }
@ -683,22 +668,22 @@ int gpio_unexport(int pin)
return(0); return(0);
} }
/* Datenrichtung GPIO-Pin festlegen /* Set GPIO pin mode (input/output)
* Schreiben Pinnummer nach /sys/class/gpioXX/direction * Write GPIO pin number to /sys/class/gpioXX/direction
* Richtung dir: 0 = Lesen, 1 = Schreiben * Direction: 0 = input, 1 = output
* Ergebnis: 0 = O.K., -1 = Fehler * Result: 0 = success, -1 = error
*/ */
int gpio_direction(int pin, int dir) int gpio_direction(int pin, int dir)
{ {
char path[MAXBUFFER]; /* Buffer fuer Pfad */ char path[MAXBUFFER]; /* Buffer for path */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
int res; /* Ergebnis von write */ int res; /* Result from write() */
snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/direction", pin); snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/direction", pin);
fd = open(path, O_WRONLY); fd = open(path, O_WRONLY);
if (fd < 0) if (fd < 0)
{ {
perror("Kann Datenrichtung nicht setzen (open)!\n"); perror("Could not set mode for GPIO pin(open)!\n");
return(-1); return(-1);
} }
@ -711,7 +696,7 @@ int gpio_direction(int pin, int dir)
if (res < 0) if (res < 0)
{ {
perror("Kann Datenrichtung nicht setzen (write)!\n"); perror("Could not set mode for GPIO pin(write)!\n");
return(-1); return(-1);
} }
@ -719,26 +704,26 @@ int gpio_direction(int pin, int dir)
return(0); return(0);
} }
/* vom GPIO-Pin lesen /* Read from GPIO pin
* Ergebnis: -1 = Fehler, 0/1 = Portstatus * Result: -1 = error, 0/1 = GPIO pin state
*/ */
int gpio_read(int pin) int gpio_read(int pin)
{ {
char path[MAXBUFFER]; /* Buffer fuer Pfad */ char path[MAXBUFFER]; /* Buffer for path */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
char result[MAXBUFFER] = {0}; /* Buffer fuer Ergebnis */ char result[MAXBUFFER] = {0}; /* Buffer for result */
snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/value", pin); snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/value", pin);
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
if (fd < 0) if (fd < 0)
{ {
perror("Kann vom GPIO nicht lesen (open)!\n"); perror("Could not read from GPIO(open)!\n");
return(-1); return(-1);
} }
if (read(fd, result, 3) < 0) if (read(fd, result, 3) < 0)
{ {
perror("Kann vom GPIO nicht lesen (read)!\n"); perror("Could not read from GPIO(read)!\n");
return(-1); return(-1);
} }
@ -746,21 +731,21 @@ int gpio_read(int pin)
return(atoi(result)); return(atoi(result));
} }
/* auf GPIO schreiben /* Write to GPIO pin
* Ergebnis: -1 = Fehler, 0 = O.K. * Result: -1 = error, 0 = success
*/ */
int gpio_write(int pin, int value) int gpio_write(int pin, int value)
{ {
char path[MAXBUFFER]; /* Buffer fuer Pfad */ char path[MAXBUFFER]; /* Buffer for path */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
int res; /* Ergebnis von write */ int res; /* Result from write()*/
snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/value", pin); snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/value", pin);
fd = open(path, O_WRONLY); fd = open(path, O_WRONLY);
if (fd < 0) if (fd < 0)
{ {
perror("Kann auf GPIO nicht schreiben (open)!\n"); perror("Could not write to GPIO(open)!\n");
return(-1); return(-1);
} }
@ -773,7 +758,7 @@ int gpio_write(int pin, int value)
if (res < 0) if (res < 0)
{ {
perror("Kann auf GPIO nicht schreiben (write)!\n"); perror("Could not write to GPIO(write)!\n");
return(-1); return(-1);
} }
@ -781,15 +766,14 @@ int gpio_write(int pin, int value)
return(0); return(0);
} }
/* GPIO-Pin auf Detektion einer Flanke setzen. /* Set GPIO pin edge detection
* Fuer die Flanke (edge) koennen folgende Parameter gesetzt werden: * 'r' (rising)
* 'r' (rising) - steigende Flanke, * 'f' (falling)
* 'f' (falling) - fallende Flanke, * 'b' (both)
* 'b' (both) - beide Flanken.
*/ */
int gpio_edge(unsigned int pin, char edge) int gpio_edge(unsigned int pin, char edge)
{ {
char path[MAXBUFFER]; /* Buffer fuer Pfad */ char path[MAXBUFFER]; /* Buffer for path */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/edge", pin); snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/edge", pin);
@ -797,7 +781,7 @@ int gpio_edge(unsigned int pin, char edge)
fd = open(path, O_WRONLY | O_NONBLOCK ); fd = open(path, O_WRONLY | O_NONBLOCK );
if (fd < 0) if (fd < 0)
{ {
perror("gpio_edge: Kann auf GPIO nicht schreiben (open)!\n"); perror("Could not set GPIO edge detection(open)!\n");
return(-1); return(-1);
} }
@ -816,46 +800,43 @@ int gpio_edge(unsigned int pin, char edge)
return 0; return 0;
} }
/* Warten auf Flanke am GPIO-Pin. /* Wait for edge on GPIO pin
* Eingabewerte: pin: GPIO-Pin * timeout in milliseconds
* timeout: Wartezeit in Millisekunden * Result: <0: error, 0: poll() Timeout,
* Der Pin muss voher eingerichtet werden (export, * 1: edge detected, GPIO pin reads "0"
* direction, edge) * 2: edge detected, GPIO pin reads "1"
* Rueckgabewerte: <0: Fehler, 0: poll() Timeout,
* 1: Flanke erkannt, Pin lieferte "0"
* 2: Flanke erkannt, Pin lieferte "1"
*/ */
int gpio_wait(unsigned int pin, int timeout) int gpio_wait(unsigned int pin, int timeout)
{ {
char path[MAXBUFFER]; /* Buffer fuer Pfad */ char path[MAXBUFFER]; /* Buffer for path */
int fd; /* Filedescriptor */ int fd; /* Filedescriptor */
struct pollfd polldat[1]; /* Variable fuer poll() */ struct pollfd polldat[1]; /* Variable for poll() */
char buf[MAXBUFFER]; /* Lesepuffer */ char buf[MAXBUFFER]; /* Read buffer */
int rc; /* Hilfsvariablen */ int rc; /* Result */
/* GPIO-Pin dauerhaft oeffnen */ /* Open GPIO pin */
snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/value", pin); snprintf(path, MAXBUFFER, "/sys/class/gpio/gpio%d/value", pin);
fd = open(path, O_RDONLY | O_NONBLOCK ); fd = open(path, O_RDONLY | O_NONBLOCK );
if (fd < 0) if (fd < 0)
{ {
perror("gpio_wait: Kann von GPIO nicht lesen (open)!\n"); perror("Could not wait for GPIO edge(open)!\n");
return(-1); return(-1);
} }
/* poll() vorbereiten */ /* prepare poll() */
memset((void*)buf, 0, sizeof(buf)); memset((void*)buf, 0, sizeof(buf));
memset((void*)polldat, 0, sizeof(polldat)); memset((void*)polldat, 0, sizeof(polldat));
polldat[0].fd = fd; polldat[0].fd = fd;
polldat[0].events = POLLPRI; polldat[0].events = POLLPRI;
/* eventuell anstehende Interrupts loeschen */ /* clear any existing detected edges before */
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
rc = read(fd, buf, MAXBUFFER - 1); rc = read(fd, buf, MAXBUFFER - 1);
rc = poll(polldat, 1, timeout); rc = poll(polldat, 1, timeout);
if (rc < 0) if (rc < 0)
{ /* poll() failed! */ { /* poll() failed! */
perror("gpio_wait: Poll-Aufruf ging schief!\n"); perror("Could not wait for GPIO edge(poll)!\n");
close(fd); close(fd);
return(-1); return(-1);
} }
@ -870,7 +851,7 @@ int gpio_wait(unsigned int pin, int timeout)
{ {
if (rc < 0) if (rc < 0)
{ /* read() failed! */ { /* read() failed! */
perror("gpio_wait: Kann von GPIO nicht lesen (read)!\n"); perror("Could not wait for GPIO edge(read)!\n");
close(fd); close(fd);
return(-2); return(-2);
} }

View File

@ -5,7 +5,6 @@
#include <string> #include <string>
#include "knx/platform.h" #include "knx/platform.h"
extern void delayMicroseconds (unsigned int howLong);
extern int gpio_direction(int pin, int dir); extern int gpio_direction(int pin, int dir);
extern int gpio_read(int pin); extern int gpio_read(int pin);
extern int gpio_write(int pin, int value); extern int gpio_write(int pin, int value);
@ -55,12 +54,6 @@ public:
void closeSpi() override; void closeSpi() override;
int readWriteSpi (uint8_t *data, size_t len) override; int readWriteSpi (uint8_t *data, size_t len) override;
//gpio
virtual void setupGpio(uint32_t dwPin, uint32_t dwMode) override;
virtual void closeGpio(uint32_t dwPin) override;
virtual void writeGpio(uint32_t dwPin, uint32_t dwVal) override;
virtual uint32_t readGpio(uint32_t dwPin) override;
//memory //memory
uint8_t* getEepromBuffer(uint16_t size) override; uint8_t* getEepromBuffer(uint16_t size) override;
void commitToEeprom() override; void commitToEeprom() override;