Skip to content

Commit

Permalink
can_start now reading 10 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
gioblu committed Apr 7, 2016
1 parent 6118b23 commit 6ceb2cb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions PJON.cpp
Expand Up @@ -169,16 +169,22 @@ void PJON::set_error(error e) {




/* Check if the channel is free for transmission: /* Check if the channel is free for transmission:
If an entire byte received contains no 1s it means If receiving 10 bits no 1s are detected
that there is no active transmission */ there is no active transmission */


boolean PJON::can_start() { boolean PJON::can_start() {
pinModeFast(_input_pin, INPUT); 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;
} }




Expand Down

0 comments on commit 6ceb2cb

Please sign in to comment.