Permalink
Browse files

can_start now reading 10 bits

  • Loading branch information...
gioblu committed Apr 7, 2016
1 parent 6118b23 commit 6ceb2cb4928a1b80ac7087a5691984c9cf653f60
Showing with 12 additions and 6 deletions.
  1. +12 −6 PJON.cpp
@@ -169,16 +169,22 @@ void PJON::set_error(error e) {
/* Check if the channel is free for transmission:
If an entire byte received contains no 1s it means
that there is no active transmission */
If receiving 10 bits no 1s are detected
there is no active transmission */
boolean PJON::can_start() {
pinModeFast(_input_pin, INPUT);
this->send_bit(0, 2);
if(!this->read_byte())
return true;
return false;
for(uint8_t i = 0; i < 9; i++) {
if(digitalReadFast(_input_pin))
return false;
delayMicroseconds(BIT_WIDTH);
}
if(digitalReadFast(_input_pin))
return false;
return true;
}

0 comments on commit 6ceb2cb

Please sign in to comment.