|
|
|
@ -12,10 +12,11 @@
@@ -12,10 +12,11 @@
|
|
|
|
|
// Pins
|
|
|
|
|
int _RO, _RE, _DE, _DI; |
|
|
|
|
|
|
|
|
|
const long _pulse_len = 1000; |
|
|
|
|
const long _break = _pulse_len * 20; |
|
|
|
|
const unsigned long _pulse_len = 1000; |
|
|
|
|
const unsigned long _break = _pulse_len * 20; |
|
|
|
|
|
|
|
|
|
unsigned long _last_flip = 0; // timestamp of last flip of line state
|
|
|
|
|
boolean _line = LOW; // current state of the transmission line
|
|
|
|
|
long _last_flip = 0; // timestamp since last flip of line state
|
|
|
|
|
boolean _start = false; // indicates whether a start bit shall be ignored
|
|
|
|
|
|
|
|
|
|
// Receive vars
|
|
|
|
@ -25,9 +26,9 @@ int _pos = 0; // character position within the buffer
@@ -25,9 +26,9 @@ int _pos = 0; // character position within the buffer
|
|
|
|
|
int _idx = 0; // bit position within the current character
|
|
|
|
|
|
|
|
|
|
// variables, that could be local, but are stored globally for speed optimization
|
|
|
|
|
long _diff = 0; // time difference between last flips
|
|
|
|
|
long _now = 0; // current time
|
|
|
|
|
long _count = 0; // helper for bit iteration
|
|
|
|
|
unsigned long _diff = 0; // time difference between last flips
|
|
|
|
|
unsigned long _now = 0; // current time
|
|
|
|
|
unsigned long _count = 0; // helper for bit iteration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined CONTROLLINO_MAXI |
|
|
|
@ -74,9 +75,9 @@ void interrupt485(){
@@ -74,9 +75,9 @@ void interrupt485(){
|
|
|
|
|
Serial.print(_line); |
|
|
|
|
#endif |
|
|
|
|
if (_idx == 8){ // full byte received
|
|
|
|
|
if (_recv_msg[_pos] == 0x00){ // received byte is string terminator
|
|
|
|
|
if (_pos == MSG_LEN || _recv_msg[_pos] == 0x00){ // received byte is string terminator
|
|
|
|
|
_avail = true; // notify about complete transmission
|
|
|
|
|
// TODO: prevent writing out of buffer boundaries!
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
_pos++; // advance to nect character of buffer
|
|
|
|
|
_idx=0; // start with first bit of that character
|
|
|
|
|