Permalink
Browse files

SoftwareBitBang bit slope bugfix (important) no more pulldown resisto…

…r :)
  • Loading branch information...
gioblu committed Nov 21, 2016
1 parent 964a27a commit 120b2c72f1435519e7712adfd2c3f1eecc38557c
Showing with 6 additions and 2 deletions.
  1. +6 −2 strategies/SoftwareBitBang/SoftwareBitBang.h
@@ -133,7 +133,7 @@ class SoftwareBitBang {
uint16_t response = FAIL;
uint32_t time = micros();
/* Transmitter emits a bit SWBB_ACCEPTANCE / 4 long and tries
/* Transmitter emits a bit SWBB_BIT_WIDTH / 4 long and tries
to get a response cyclically for SWBB_TIMEOUT microseconds.
Receiver synchronizes to the falling edge of the last incoming
bit and transmits ACK or NAK */
@@ -144,6 +144,7 @@ class SoftwareBitBang {
pinModeFast(_output_pin, OUTPUT);
digitalWriteFast(_output_pin, HIGH);
delayMicroseconds(SWBB_BIT_WIDTH / 4);
digitalWriteFast(_output_pin, LOW); // Avoid 1 to 0 bit transition slope -\_
pullDownFast(_output_pin);
}
}
@@ -186,10 +187,12 @@ class SoftwareBitBang {
void send_response(uint8_t response) {
pullDownFast(_input_pin);
uint32_t time = micros();
/* Transmitter emits a bit SWBB_ACCEPTANCE / 4 long and tries
/* Transmitter emits a bit SWBB_BIT_WIDTH / 4 long and tries
to get a response cyclically for SWBB_TIMEOUT microseconds.
Receiver synchronizes to the falling edge of the last incoming
bit and transmits ACK or NAK */
while((uint32_t)(micros() - time) < (SWBB_BIT_WIDTH) && !digitalReadFast(_input_pin))
time = micros(); // Wait for the last high ending
while((uint32_t)(micros() - time) < (SWBB_BIT_WIDTH / 2.25) && digitalReadFast(_input_pin));
pinModeFast(_output_pin, OUTPUT);
send_byte(response);
@@ -203,6 +206,7 @@ class SoftwareBitBang {
pinModeFast(_output_pin, OUTPUT);
for(uint16_t b = 0; b < length; b++)
send_byte(string[b]);
digitalWriteFast(_output_pin, LOW); // Avoid 1 to 0 bit transition slope -\_
pullDownFast(_output_pin);
};

0 comments on commit 120b2c7

Please sign in to comment.