Stephan Richter
1 year ago
commit
10b96424cd
2 changed files with 57 additions and 0 deletions
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Library for Software Serial over RS485 connection |
||||
Created by Stepan Richter, November 2023 |
||||
*/ |
||||
|
||||
#include "Arduino.h" |
||||
#include "SoftRS485.h" |
||||
|
||||
SoftRS485 SoftRS485::instance; |
||||
|
||||
SoftRS485 SoftRS485::singleton(){ |
||||
return instance; |
||||
} |
||||
|
||||
void SoftRS485::isr(){ |
||||
instance.bam(); |
||||
} |
||||
|
||||
void SoftRS485::begin(int RO, int nRE, int DE, int DI){ |
||||
_RO = RO; |
||||
_RE = nRE; |
||||
_DE = DE; |
||||
_DI = DI; |
||||
Serial.begin(115200); |
||||
pinMode(_RE, OUTPUT); |
||||
pinMode(_DE, OUTPUT); |
||||
pinMode(_DI, OUTPUT); |
||||
pinMode(_RO, INPUT); |
||||
attachInterrupt(digitalPinToInterrupt(_RO),isr,CHANGE); |
||||
Serial.println("attached to interrupt!"); |
||||
} |
||||
|
||||
void SoftRS485::bam(){ |
||||
Serial.println("bam!"); |
||||
} |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Library for Software Serial over RS485 connection |
||||
Created by Stepan Richter, November 2023 |
||||
*/ |
||||
|
||||
#ifndef SoftRS485_h |
||||
#define SoftRS485_h |
||||
|
||||
#include "Arduino.h" |
||||
|
||||
class SoftRS485{ |
||||
public: |
||||
void begin(int RO, int nRE, int DE, int DI); |
||||
void bam(); |
||||
static SoftRS485 singleton(); |
||||
private: |
||||
static void isr(); |
||||
static SoftRS485 instance; |
||||
int _RO, _RE, _DE, _DI; |
||||
}; |
||||
|
||||
#endif |
Loading…
Reference in new issue